This repository has been archived by the owner on May 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 452
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge in openid and config examples
- Loading branch information
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* Copyright 2015 PayPal */ | ||
"use strict"; | ||
var paypal = require('../../'); | ||
|
||
var first_config = { | ||
'mode': 'sandbox', | ||
'client_id': '<FIRST_CLIENT_ID>', | ||
'client_secret': '<FIRST_CLIENT_SECRET>' | ||
}; | ||
|
||
var second_config = { | ||
'mode': 'sandbox', | ||
'client_id': '<SECOND_CLIENT_ID>', | ||
'client_secret': '<SECOND_CLIENT_SECRET>' | ||
}; | ||
|
||
//This sets up client id and secret globally | ||
//to FIRST_CLIENT_ID and FIRST_CLIENT_SECRET | ||
paypal.configure(first_config); | ||
|
||
var create_payment_json = { | ||
"intent": "authorize", | ||
"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": "1.00", | ||
"currency": "USD", | ||
"quantity": 1 | ||
}] | ||
}, | ||
"amount": { | ||
"currency": "USD", | ||
"total": "1.00" | ||
}, | ||
"description": "This is the payment description." | ||
}] | ||
}; | ||
|
||
//Passing in the second_config here would override default settings | ||
//and use SECOND_CLIENT_ID and SECOND_CLIENT_SECRET for creating the payment | ||
//After buyer approves the payment via the HATEOS approval url, the second_config | ||
//would need to be passed in the payment.execute call as well, otherwise | ||
//a 404 with INVALID_RESOURCE_ID would get returned | ||
paypal.payment.create(create_payment_json, second_config, function (error, payment) { | ||
if (error) { | ||
throw error; | ||
} else { | ||
console.log("Create Payment Response"); | ||
console.log(payment); | ||
} | ||
}); |
File renamed without changes.