-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtestPayPalAPI.js
More file actions
32 lines (29 loc) · 893 Bytes
/
testPayPalAPI.js
File metadata and controls
32 lines (29 loc) · 893 Bytes
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
'use strict';
var paypal = require('paypal-rest-sdk');
paypal.configure({
'mode': 'live',
'client_id': 'AS_XdXBWw77UyF_QkMtq53Dve9CueqCscfdqPH2Rk-ypPe1l3MhBMgZIUfCs9QoL3rR9FhtqVg5XDXVP',
'client_secret': 'ELBPMRDOYTKJ060PVEyTMQwBvH2HwQEFWwSziOKp9hYG48z8UXendg3Us_9rlm3ioUMT3Go79KKd2VWa',
});
var paymentId = "PAY-2NK20372P96057906K6KBDGI";
paypal.payment.get(paymentId, function(error, payment1) {
if (error) {
console.log(error);
throw error;
} else {
console.log("Paid");
console.log(JSON.stringify(payment1));
if (payment1.payer.payer_info) {
paypal.payment.execute(paymentId, {
payer_id: payment1.payer.payer_info.payer_id
}, function(error, payment) {
if (error) {
console.log(error);
} else {
console.log('success');
console.log(JSON.stringify(payment));
}
});
}
}
});