I am using pay api for collectiong payments.I need to add address field if a cusitomer want to buy something. There is no address field in that popup if customer putting there information.
Address fields are not supported as per the API https://www.wix.com/corvid/reference/wix-pay.html#PaymentUserInfo
Butt there should be an address field how I can ship my product If I dont have an address?
is there any alternate through which I can get address while payment process?
@alifraz456 I replied to your other post
As a workaround you can have the customer fill the address before sending them for payment to the Wix Pay window. If the transaction is successful, you can process their order using the address they had entered.
Wix Pay is a custom code solution for payments hence it collects information only about payments. You can collect the address before sending the user for the payment.
You can collect the shipping address on the checkout page then show a loader animation (preloader) while you make use of the wix pay api. Once the user is directed back to the page from the wix pay window, use code to get the payment status value from the Wix Pay’s response object.
If the payment is successful then you can fulfill the order using the shipping address the user has filled on your checkout page .
@shantanukumar847 I mean to say If I collect there address through wix input form then how I can I use that address in the payment information so the site owner will get one emaill or noticfication about the full order detail including address
@alifraz456 Like I said, you cannot send that address to the Wix Pay API. The API only supports these user information.
You could however code a custom email to be sent out to the site owner.
For example: I create my payment object on the checkout page by making the user fill out the following data:
1. First Name
2. Last Name
3. Street
4. City
5. State
6. Postal Code
7. Country
Now in order to create a payment object I need the Item name and price which I can get from the page using code so the final information i will send to the backend createPayment function will be the following:
1. Item Name (got using code)
2. Price (got using code)
3. User Email
4. First Name
5. Last Name
I send the above data to my backend file to get the payment id. In the meanwhile show a loading animation to the user.
//backend/pay.jsw
import wixPay from 'wix-pay-backend';
export function createMyPayment(item, price, fname, lname, email) {
return wixPay.createPayment({
items: [{
name: item,
price: price
}],
amount: price,
currency: "USD",
userInfo: {
firstName: fname,
lastName: lname,
email: email
}
});
}
Once the backend function sends me the response (payment.id) i use it to initiate the payment on the frontend:
wixPay.startPayment(payment.id, {"showThankYouPage": false})
.then( (result) => {
if (result.status === "Successful") {
//process order
} else {
//handle error
}
Now if the status is returned (from the Wix Pay window) as ‘Successful’ I can process the custom email and use the Shipping Data the customer has filled on the page along with the Item name to send a custom notification email to the site owner.
Take a look at this example to learn how to send custom coded emails using SendGrid.
I think I got you let me try It. Thanks for explaining !
@shantanukumar847 I think I got you let me try It. Thanks for explaining ! Also can we calculate shipping fee on that api?