-
-
Save ziyadparekh/e55a196ad343850b65be8f9e00308078 to your computer and use it in GitHub Desktop.
safepay.Button.render({ | |
env: 'sandbox', | |
amount: 6800.57, | |
client: { | |
"sandbox": "sec_4f84abd2-0bae-4476-be6b-22c8c9e35133" | |
"production": "<YOUR_CLIENT_KEY>" | |
}, | |
payment: function (data, actions) { | |
return actions.payment.create({ | |
transaction: { | |
amount: 6800.57, | |
currency: 'PKR' | |
} | |
}) | |
}, | |
onCancel: function (data, actions) { | |
console.log(data) | |
console.log(actions) | |
}, | |
onCheckout: function(data, actions) { | |
console.log(data) | |
console.log("You completed the payment!"); | |
} | |
}, '#container'); |
function dopayment(amount){
$('#safepay-button-container').html('');
safepay.Button.render({
// Choose between "production" or "sandbox"
env: 'sandbox',
// The amount you wish you charge
amount: amount,
// The currency of the purchase
currency: "PKR",
// Your API Keys
client: {
"sandbox": "sec_8cac76dd-3cfb-403d-a2fb-beee3f3eb98e"
// "production": "e154d770af7bc7999e1baf56dae8cfea123be4abedaca07269b168dc6385da23"
},
payment: function (data, actions) {
return actions.payment.create({
transaction: {
amount: amount,
currency: 'PKR'
}
})
},
onCheckout: function(data, actions) {
console.log(data)
console.log("You completed the payment!");
}
}, '#safepay-button-container');
}
Call thw function on click event and pass amount
How can i use this code in angular typescript? It gives me error "cannot find name safepay"
Hey you can check out this link for angular integration.
https://gist.github.com/ziyadparekh/62f04992b544566a9dc01181bf21b3e1
I don’t think we have typescript bindings at the moment though
Ok thanks. Got it.
can you please guid men how i customized safepay button or get input value on button click