payresobj value is found good in the "function(instance, error, result)" scope,
Want to pass the same variable payresobj to "function(stage, expired)" , it is currently returning "undefined" , How can i pass the variable in that "function(stage, expired)" callback function to use it in the case switch scenarios.. Please Advice!
function checkout_card() {
paysafe.checkout.setup("************************************", {
amount: amt,
currency: "USD",
locale: "en_US",
customer: {
firstName: fname,
lastName: lname,
email: uemail,
phone: "",
},
payout: false,
payoutConfig: {
maximumAmount: 999999
},
merchantRefNum: merchrefno,
canEditAmount: false,
environment: "TEST",
singleUseCustomerToken: singletoken,
displayPaymentMethods: ["card"],
billingAddress: {
street: staddress,
city: bcity,
zip: bzip,
country: bcountry,
state: bstate
},
simulator: "EXTERNAL",
paymentMethodDetails: {
card: {
accountId: "********"
}
},
},
function(instance, error, result) {
//console.log(error);
if (error) {
console.log(error);
}
if (result && result.paymentHandleToken) {
payresobj = result
return payresobj;
} else {
//alert(error.message);
}
},
function(stage, expired) {
console.log(stage);
//console.log(instance)
console.log(payresobj);
switch (stage) {
case "PAYMENT_HANDLE_NOT_CREATED": // Handle the scenario
break;
case "PAYMENT_HANDLE_CREATED": // Handle the scenario
case "PAYMENT_HANDLE_REDIRECT": // Handle the scenario
console.log("PAYMENT_HANDLE_REDIRECT");
break;
default: // Handle the scenario
console.log("DEFAULT");
}
});
}