forked from stephenjude/paystack-payout-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
36 lines (34 loc) · 1.3 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function payWithPaystack() {
var handler = PaystackPop.setup({
key: 'your_public_key', //put your public key here
email: '[email protected]', //put your customer's email here
amount: 370000, //amount the customer is supposed to pay
metadata: {
custom_fields: [
{
display_name: "Mobile Number",
variable_name: "mobile_number",
value: "+2348012345678" //customer's mobile number
}
]
},
callback: function (response) {
//after the transaction have been completed
//make post call to the server with to verify payment
//using transaction reference as post data
$.post("verify.php", {reference:response.reference}, function(status){
if(status == "success")
//successful transaction
alert('Transaction was successful');
else
//transaction failed
alert(response);
});
},
onClose: function () {
//when the user close the payment modal
alert('Transaction cancelled');
}
});
handler.openIframe(); //open the paystack's payment modal
}