I have following code in payments.jsw
export function paymentCreate(){
let create_payment_json={
"key1": "value2",
"key2": "value2
}
return paypal.payment.create(create_payment_json, function (error, payment) {
if (error) { throw error; } else {
for (let i = 0; i < payment.links.length; i++) {
if (payment.links[i].rel === 'approval_url') {
const uri = payment.links[i].href;
//console.log(uri);
return payment(uri);
}
}
}
});
}
and this in button click
export function button1_click(event) {
let s = paymentCreate()
.then((uri) =>{
console.log(uri);
});
}
All I see in console log is undefined.
If I console.log(uri) in paymentCreate function, it logs the value just fine. But I can’t receive it in button click.
Any help please?