Skip to content

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

Open
@The-Lord-of-Owls

Description

@The-Lord-of-Owls

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions