Last active
June 28, 2020 05:01
-
-
Save shanwixcode/40b03ee0a08b054e8be52c4ad8353b7f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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