wixpay

/**************************

* backend code - pay.jsw *

**************************/

 

import wixPayBackend from 'wix-pay-backend';

 

export function createMyPayment() {

return wixPayBackend.createPayment({

items: [ {

name: "Product Name",

price: 9.99

} ],

amount: 9.99

} );

}

 

/********************

* client-side code *

********************/

 

import {createMyPayment} from 'backend/pay';

import wixPay from 'wix-pay';

import wixWindow from 'wix-window';

 

export function myButton_click(event, $w) {

createMyPayment()

.then( (payment) => {

wixPay.startPayment(payment.id, {"showThankYouPage": false})

.then( (result) => {

if (result.status === "Successful") {

wixWindow.openLightbox("Success Box");

} else if (result.status === "Pending") {

wixWindow.openLightbox("Pending Box");

}

} );

} );

}