Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@shanwixcode
Last active June 28, 2020 05:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shanwixcode/40b03ee0a08b054e8be52c4ad8353b7f to your computer and use it in GitHub Desktop.
Save shanwixcode/40b03ee0a08b054e8be52c4ad8353b7f to your computer and use it in GitHub Desktop.
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