Skip to content

Commit 3d333d5

Browse files
jshawlgregjopa
andauthored
add JSDoc links to REST APIs (#28)
* add JSDoc links to REST APIs Co-authored-by: Greg Jopa <[email protected]>
1 parent 0806635 commit 3d333d5

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

advanced-integration/paypal-api.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import fetch from "node-fetch";
44
const { CLIENT_ID, APP_SECRET } = process.env;
55
const base = "https://api-m.sandbox.paypal.com";
66

7-
// call the create order method
7+
/**
8+
* Create an order
9+
* @see https://developer.paypal.com/docs/api/orders/v2/#orders_create
10+
*/
811
export async function createOrder() {
912
const purchaseAmount = "100.00"; // TODO: pull prices from a database
1013
const accessToken = await generateAccessToken();
@@ -31,7 +34,10 @@ export async function createOrder() {
3134
return handleResponse(response);
3235
}
3336

34-
// capture payment for an order
37+
/**
38+
* Capture payment for an order
39+
* @see https://developer.paypal.com/docs/api/orders/v2/#orders_capture
40+
*/
3541
export async function capturePayment(orderId) {
3642
const accessToken = await generateAccessToken();
3743
const url = `${base}/v2/checkout/orders/${orderId}/capture`;
@@ -46,7 +52,10 @@ export async function capturePayment(orderId) {
4652
return handleResponse(response);
4753
}
4854

49-
// generate access token
55+
/**
56+
* Generate an OAuth 2.0 access token
57+
* @see https://developer.paypal.com/api/rest/authentication/
58+
*/
5059
export async function generateAccessToken() {
5160
const auth = Buffer.from(CLIENT_ID + ":" + APP_SECRET).toString("base64");
5261
const response = await fetch(`${base}/v1/oauth2/token`, {
@@ -60,7 +69,10 @@ export async function generateAccessToken() {
6069
return jsonData.access_token;
6170
}
6271

63-
// generate client token
72+
/**
73+
* Generate a client token
74+
* @see https://developer.paypal.com/docs/checkout/advanced/integrate/#link-sampleclienttokenrequest
75+
*/
6476
export async function generateClientToken() {
6577
const accessToken = await generateAccessToken();
6678
const response = await fetch(`${base}/v1/identity/generate-token`, {

standard-integration/paypal-api.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import fetch from "node-fetch";
33
const { CLIENT_ID, APP_SECRET } = process.env;
44
const base = "https://api-m.sandbox.paypal.com";
55

6+
/**
7+
* Create an order
8+
* @see https://developer.paypal.com/docs/api/orders/v2/#orders_create
9+
*/
610
export async function createOrder() {
711
const accessToken = await generateAccessToken();
812
const url = `${base}/v2/checkout/orders`;
@@ -28,6 +32,10 @@ export async function createOrder() {
2832
return handleResponse(response);
2933
}
3034

35+
/**
36+
* Capture payment for an order
37+
* @see https://developer.paypal.com/docs/api/orders/v2/#orders_capture
38+
*/
3139
export async function capturePayment(orderId) {
3240
const accessToken = await generateAccessToken();
3341
const url = `${base}/v2/checkout/orders/${orderId}/capture`;
@@ -42,6 +50,10 @@ export async function capturePayment(orderId) {
4250
return handleResponse(response);
4351
}
4452

53+
/**
54+
* Generate an OAuth 2.0 access token
55+
* @see https://developer.paypal.com/api/rest/authentication/
56+
*/
4557
export async function generateAccessToken() {
4658
const auth = Buffer.from(CLIENT_ID + ":" + APP_SECRET).toString("base64");
4759
const response = await fetch(`${base}/v1/oauth2/token`, {

0 commit comments

Comments
 (0)