-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
108ac9d
commit 2c70501
Showing
70 changed files
with
1,456 additions
and
1,832 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@hyperse-io/paypal-node-sdk": patch | ||
--- | ||
|
||
refactor codes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
{ | ||
"typescript.tsdk": "node_modules/typescript/lib", | ||
"typescript.enablePromptUseWorkspaceTsdk": true, | ||
"typescript.preferences.importModuleSpecifier": "relative", | ||
"editor.formatOnSave": true, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": "explicit" | ||
"source.fixAll": "explicit", | ||
"source.organizeImports": "never" | ||
}, | ||
"files.associations": { | ||
"*.css": "tailwindcss" | ||
}, | ||
// Disable vscode formatting for js,jsx,ts,tsx files | ||
// to allow dbaeumer.vscode-eslint to format them | ||
"[javascript]": { | ||
"editor.formatOnSave": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { OrdersAuthorizeRequest } from '@hyperse-io/paypal-node-sdk'; | ||
import { createClient } from 'samples/Common/payPalClient.js'; | ||
|
||
/** | ||
* This function can be used to perform authorization on the approved order. | ||
* An valid approved order id should be passed as an argument to this function. | ||
* | ||
* @param orderId | ||
* @param debug | ||
* @returns | ||
*/ | ||
export async function authorizeOrder(orderId, debug = false) { | ||
try { | ||
const request = new OrdersAuthorizeRequest(orderId); | ||
request.requestBody({}); | ||
const response = await createClient().execute(request); | ||
if (debug) { | ||
console.log('Status Code: ' + response.statusCode); | ||
console.log('Status: ' + response.result.status); | ||
console.log( | ||
'Authorization ID: ', | ||
response.result.purchase_units[0].payments.authorizations[0].id | ||
); | ||
console.log('Order ID: ' + response.result.id); | ||
console.log('Links: '); | ||
response.result.links.forEach((item) => { | ||
const rel = item.rel; | ||
const href = item.href; | ||
const method = item.method; | ||
const message = `\t${rel}: ${href}\tCall Type: ${method}`; | ||
console.log(message); | ||
}); | ||
console.log('Authorization Links:'); | ||
response.result.purchase_units[0].payments.authorizations[0].links.forEach( | ||
(item) => { | ||
const rel = item.rel; | ||
const href = item.href; | ||
const method = item.method; | ||
const message = `\t${rel}: ${href}\tCall Type: ${method}`; | ||
console.log(message); | ||
} | ||
); | ||
// To toggle print the whole body comment/uncomment the below line | ||
console.log(JSON.stringify(response.result, null, 4)); | ||
} | ||
return response; | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { AuthorizationsCaptureRequest } from '@hyperse-io/paypal-node-sdk'; | ||
import { createClient } from 'samples/Common/payPalClient.js'; | ||
|
||
/** | ||
* This function can be used to capture the payment on an authorized Order. | ||
* An Valid authorization Id should be passed as an argument to this method. | ||
* | ||
* @param authId | ||
* @param debug | ||
* @returns | ||
*/ | ||
export async function captureOrder(authId, debug = false) { | ||
try { | ||
const request = new AuthorizationsCaptureRequest(authId); | ||
request.requestBody({}); | ||
const response = await createClient().execute(request); | ||
if (debug) { | ||
console.log('Status Code: ' + response.statusCode); | ||
console.log('Status: ' + response.result.status); | ||
console.log('Capture ID: ' + response.result.id); | ||
console.log('Links:'); | ||
response.result.links.forEach((item) => { | ||
const rel = item.rel; | ||
const href = item.href; | ||
const method = item.method; | ||
const message = `\t${rel}: ${href}\tCall Type: ${method}`; | ||
console.log(message); | ||
}); | ||
// To toggle print the whole body comment/uncomment the below line | ||
console.log(JSON.stringify(response.result, null, 4)); | ||
} | ||
return response; | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
} |
Oops, something went wrong.