Skip to content

Instantly share code, notes, and snippets.

@shanwixcode

shanwixcode/pagePayPal.rb

Last active Jun 28, 2020
Embed
What would you like to do?
import {getAccess, order} from 'backend/payPal.jsw';
import wixLocation from 'wix-location';
$w.onReady(function () {
});
export function checkout_click(event) {
getAccess()
.then( (tok) => {
if(tok.access_token) {
let token = tok.access_token;
let item = $w("#itemName").text;
let amount = Number($w("#price").text);
order(token, item, amount)
.then( (response) => {
if(response.id) {
let url = response.links[1].href;
wixLocation.to(`${url}`);
} else {
console.log(response);
}
});
} else {
console.log(tok);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment