Wix Payment API Issues

Good day sirs/mas, please I am trying to use WIX API to collect payment. I want this option to create a new order for logged in user and also ask for shipping details + shipping method as setup in my WIX settings. When I tried to test it, the payment went through. But no order was created and no shipping details requested. I want the payment API to work like physical product checkout works.

Here is my Backend code pls help:

/* Backend Code for WIX Pay (payment.jsw) [Backend]*/

import wixPay from ‘wix-pay-backend’ ;

export function createMyPayment ( quoteSummary , quotePrice ) {
let createPaymentParameter = {
amount : quotePrice ,
items : [{ name : quoteSummary , price : quotePrice }]
};
return wixPay . createPayment ( createPaymentParameter );
}

Can you share the rest of the code (i.e your frontend code)? After you create the payment you’ll need to call startPayment() from the frontend with the payment ID returned by createPayment.

Here is it Sir I have call the required startPayment(). Pls I also notice the image is not attached along with the input arrays added. It just says “:receipt:Image Uploaded: object” without quote. I am using this option because I can’t integrate the calculator to a WIX store product. A preview is shown at https://bit.ly/3RJoMm7

import { createMyPayment } from ‘backend/payment’;
import wixPay from ‘wix-pay’;
import wixData from ‘wix-data’;

//WIX PAY API💳
$w(“#paymentButton”).onClick(() => {
if ($w(“#uploader”).value.length > 0)
{
$w(‘#uploader’).startUpload()
.then((UploadFile)=>{
let imgurl=UploadFile.url;
let toInsert={
“image”:imgurl
};
wixData.insert(“SingleTransferUploads”,toInsert)
.then((results)=>{
$w(‘#msg’).text=“Image Submitted Successfully”;
$w(‘#msg’).expand();
})
. catch ((err)=>{
$w(‘#msg’).text=err,
$w(‘#msg’).expand();
})

})
} else {
$w(‘#msg’).text=“Please choose an image”;
$w(‘#msg’).expand();
}

createMyPayment(quoteSummary_Arr.join(" "), price)
.then((payment) => {
wixPay.startPayment(payment.id).then((result) => {

});
});
});
});

Can you console.log the result from startPayment? result.status might give you insight as to why the rest of the payment flow didn’t happen.

Debugging shows no error Sir

What’s the result.status say?

All I have here is shown below. No error at all.

I mean what does the result object say? Example

createMyPayment(quoteSummary_Arr.join(" "), price)
            .then((payment) => {

                            wixPay.startPayment(payment.id).then((result) => {
                    console.log(result); //do this
                });
            });

This is exactly what I did. Do i have to choose any custom view to see the error?

And createMyPayment() is returning? Might want to try on a live site then instead of Preview mode.

Am lost pls where will I see the result object outcome??? I have only use the normal wix developer console to see error before.

Now I use site Event logs from Wix Developer tools and no error shows. But a log says below when i cancelled the payment. I think the WIX API only works as guest checkout instead of creating order and allowing shipping options.

{“status”:“Cancelled”,“payment”:{“id”:“092ab47b-f877-4fa2-a01e-41fee6395bcb”,“amount”:43.09,"currenc…INFO

I have published the page. I don’t know if browser Developer tools can help you check from your end Sir. Pls check at https://bit.ly/3RJoMm7

Here below:

"jsonPayload":{"message":"{"status":"Cancelled","payment":{"id":"092ab47b-f877-4fa2-a01e-41fee6395bcb","amount":43.09,"currency":"GBP","items":[{"id":"c3c04f60-7c0d-4c8c-9e21-1e7a5303a296","name":"🕛 Order Summary 🧾Length: 500 mm 🧾Width: 491 mm Measurment: mm 🧾qty: 5 🧾Image Uploaded: [object Object]","quantity":1,"price":43.09,"description":"🕛 Order Summary 🧾Length: 500 mm 🧾Width: 491 mm Measurment: mm 🧾qty: 5 🧾Image Uploaded: [object Object]"}]},"userInfo":{"firstName":null,"lastName":null,"email":null,"phone":null,"country":null}}"
}
"receiveTimestamp":"2022-09-12T20:48:13.192Z"

Since the status is cancelled this would be why an order wouldn’t be getting created. You can refer to the docs here: https://www.wix.com/velo/reference/wix-pay/startpayment and full details on the order flow are here: https://www.wix.com/velo/reference/wix-pay/introduction#wix-pay_introduction_typical-payment-lifecycle

No sir. I choose to cancel when no error comes up. So I saw the report that payment was cancelled. I manually cancelled it myself just to see if any error will comeup. The cancel error I sent doesn’t have anything to do with the create order and allow shipping that we are debugging.

After going through https://www.wix.com/velo/reference/wix-pay/startpayment once again I only see transactionId and i can’t even find anything like create order or order number. I guess this feature only work for guest checkout.

Pls kindly help in adding option for creating order numbers for this and adding shipping details.

Sir pls I want to change the payment button to add to cart button. How can I connect a button to a product as reference and then use the value from my calculator as price??