-
-
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'); |
You can use jquery, angular, or react or vanilla javascript (any framework really) to get the input value from your input field
Its pretty simple to implement but the implementation details are left to the developer since each developer will have a different way to get the value. What you can do is something similar to this:
Lets say you have an input on your page
<input type="text" id="my-input" />
Then with jQuery you can do something like this
var value = $("#my-input").value();
I did, i resolved this, the issue is when we get value from input this should be convert into parseJSON now working perfeclty, Thank You so much
can you please guid men how i customized safepay button or get input value on button click
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.
How i get amount value by input