Open
Description
Trying to setup my backend to use this properly and had to use ChatGPT to try and get a decent understanding of how things flow and piece together something that kinda works.
Its rather difficult to work with the docs as it doesn't specify where things are included from. Some of the examples in the docs also don't seem to function as they should either.
Requesting examples on how to make these routes
POST /create-payment
GET /success
POST /refund
POST /webhook
I've already gotten my frontend working as intended with these routes and from my understanding I've already correctly managed to piece together the client. I'm going to include it here just to be sure given the issues currently with trying to understand the docs
'use strict';
const { Client, Environment, LogLevel } = require( '@paypal/paypal-server-sdk' )
const { PAYPAL_CLIENT_ID, PAYPAL_CLIENT_SECRET } = process.env
// PayPal SDK client
const client = new Client( {
clientCredentialsAuthCredentials: {
oAuthClientId: PAYPAL_CLIENT_ID,
oAuthClientSecret: PAYPAL_CLIENT_SECRET
},
timeoute: 0,
environment: Environment.Sandbox,
logging: {
logLevel: LogLevel.Info,
logRequest: {
logBody: true
},
logResponse: {
logHeaders: true
}
}
} )
// Promo code handling
const promoCodes = {
'DISCOUNT10': 0.9,
'DISCOUNT20': 0.8
}
module.exports = {
promoCodes: promoCodes,
client: client
}
Metadata
Metadata
Assignees
Labels
No labels