1var express = require('express');
2var request = require('request');
3express().post('/my-server/create-order', function(req, res) {
4 request.post('https://api-m.sandbox.paypal.com/v2/checkout/orders', {
5 headers: {
6 "Content-Type": "application/json",
7 "Authorization": "Bearer ACCESS-TOKEN",
8 "PayPal-Partner-Attribution-Id": "BN-CODE",
9 "PayPal-Auth-Assertion": "PAYPAL-AUTH-ASSERTION"
10 },
11 body: {
12 "intent": "CAPTURE",
13 "purchase_units": [{
14 "amount": {
15 "currency_code": "USD",
16 "value": "100.00"
17 },
18 "payee": {
19 "email_address": "seller@example.com"
20 },
21 "payment_instruction": {
22 "disbursement_mode": "DELAYED",
23 "platform_fees": [{
24 "amount": {
25 "currency_code": "USD",
26 "value": "25.00"
27 }
28 }]
29 }
30 }],
31 },
32 json: true
33 }, function(err, response, body) {
34 if (err) {
35 console.error(err);
36 return res.sendStatus(500);
37 }
38 res.json({
39 id: body.id
40 });
41 });
42});