Skip to content

Commit

Permalink
Update save-payment-method/server/server.js
Browse files Browse the repository at this point in the history
Co-authored-by: Greg Jopa <[email protected]>
  • Loading branch information
jshawl and gregjopa authored Nov 2, 2023
1 parent d581019 commit dcffe7f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion save-payment-method/server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@ app.use(express.json());
* Generate an OAuth 2.0 access token for authenticating with PayPal REST APIs.
* @see https://developer.paypal.com/api/rest/authentication/
*/
const authenticate = async (targetCustomerId) => {
const authenticate = async (bodyParams) => {
const params = {
grant_type: "client_credentials",
response_type: "id_token",
...bodyParams
};

// pass the url encoded value as the body of the post call
const urlEncodedParams = new URLSearchParams(params).toString();
try {
if (!PAYPAL_CLIENT_ID || !PAYPAL_CLIENT_SECRET) {
throw new Error("MISSING_API_CREDENTIALS");
Expand Down

0 comments on commit dcffe7f

Please sign in to comment.