Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation is not straight forward to use. Usage examples would help alot. #14

Open
The-Lord-of-Owls opened this issue Dec 24, 2024 · 0 comments

Comments

@The-Lord-of-Owls
Copy link

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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant