forked from tjmehta/rest-api-sdk-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_with_paypal_security_test.js
52 lines (48 loc) · 1.23 KB
/
create_with_paypal_security_test.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* Copyright 2016 PayPal */
"use strict";
var paypal = require('../../');
paypal.configure({
'mode': 'security-test-sandbox',
'client_id': '<CLIENT_ID>',
'client_secret': '<CLIENT_SECRET>'
});
var create_payment_json = {
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
"redirect_urls": {
"return_url": "http://return.url",
"cancel_url": "http://cancel.url"
},
"transactions": [{
"item_list": {
"items": [{
"name": "item",
"sku": "item",
"price": "0.03",
"currency": "USD",
"quantity": 1
}]
},
"amount": {
"currency": "USD",
"total": "0.07",
"details": {
"subtotal": "0.03",
"tax": "0.01",
"shipping": "0.02",
"handling_fee": "0.01"
}
},
"description": "This is the payment description."
}]
};
paypal.payment.create(create_payment_json, function (error, payment) {
if (error) {
throw error;
} else {
console.log("Create Payment Response");
console.log(JSON.stringify(payment, null, 2));
}
});