Skip to content

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

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

Open
The-Lord-of-Owls opened this issue Dec 24, 2024 · 1 comment

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
}
@DPoplin
Copy link
Contributor

DPoplin commented Apr 25, 2025

Hey @The-Lord-of-Owls apologies for the very late response here. Our developer documentation should have what you need as far as examples go. Webhooks and other APIs besides Orders, Payments, and Vault are not yet available, but are being evaluated for addition in a future version.

Here are some of the specific pages that should assist you:

Additionally, I would recommend enabling Show Complete File in the options for the interactive code section to ensure you can see your imports and other pertinent information:

Image

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

2 participants