paypal-isomorphic-functions
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -26,1 +26,38 @@ export declare const DEFAULT_CREATE_BILLING_AGREEMENT_TOKEN_PAYLOAD: { | ||
}; | ||
export declare const DEFAULT_CREATE_PAYMENT_WITH_BILLING_AGREEMENT_PAYLOAD: { | ||
intent: string; | ||
payer: { | ||
payment_method: string; | ||
funding_instruments: { | ||
billing: { | ||
billing_agreement_id: string; | ||
}; | ||
}[]; | ||
}; | ||
transactions: { | ||
amount: { | ||
currency: string; | ||
total: string; | ||
}; | ||
description: string; | ||
custom: string; | ||
note_to_payee: string; | ||
invoice_number: string; | ||
item_list: { | ||
items: { | ||
sku: string; | ||
name: string; | ||
description: string; | ||
quantity: string; | ||
price: string; | ||
currency: string; | ||
tax: string; | ||
url: string; | ||
}[]; | ||
}; | ||
}[]; | ||
redirect_urls: { | ||
return_url: string; | ||
cancel_url: string; | ||
}; | ||
}; |
@@ -28,2 +28,45 @@ "use strict"; | ||
}; | ||
exports.DEFAULT_CREATE_PAYMENT_WITH_BILLING_AGREEMENT_PAYLOAD = { | ||
intent: "sale", | ||
payer: { | ||
payment_method: "PAYPAL", | ||
funding_instruments: [ | ||
{ | ||
billing: { | ||
billing_agreement_id: "B-50V812176H0783741" | ||
} | ||
} | ||
] | ||
}, | ||
transactions: [ | ||
{ | ||
amount: { | ||
currency: "USD", | ||
total: "1.00" | ||
}, | ||
description: "Payment transaction.", | ||
custom: "Payment custom field.", | ||
note_to_payee: "Note to payee field.", | ||
invoice_number: "GDAGDS5754YEK", | ||
item_list: { | ||
items: [ | ||
{ | ||
sku: "skuitemNo1", | ||
name: "ItemNo1", | ||
description: "The item description.", | ||
quantity: "1", | ||
price: "1.00", | ||
currency: "USD", | ||
tax: "0", | ||
url: "https://example.com/" | ||
} | ||
] | ||
} | ||
} | ||
], | ||
redirect_urls: { | ||
return_url: "https://example.com/return", | ||
cancel_url: "https://example.com/cancel" | ||
} | ||
}; | ||
//# sourceMappingURL=constants.js.map |
@@ -6,3 +6,5 @@ "use strict"; | ||
async function createBillingAgreementToken(token, data = {}) { | ||
const payload = Object.keys(data).length > 0 ? data : constants_1.DEFAULT_CREATE_BILLING_AGREEMENT_TOKEN_PAYLOAD; | ||
const payload = Object.keys(data).length > 0 | ||
? data | ||
: constants_1.DEFAULT_CREATE_BILLING_AGREEMENT_TOKEN_PAYLOAD; | ||
const options = { | ||
@@ -9,0 +11,0 @@ method: "POST", |
@@ -12,3 +12,3 @@ "use strict"; | ||
exports.CONFIG.set("PAYPAL_ENVIRONMENT", process.env.PAYPAL_ENVIRONMENT); | ||
exports.CONFIG.set('PAYPAL_REST_BEARER', btoa_1.default(`${process.env.PAYPAL_CLIENT_ID}:${process.env.PAYPAL_CLIENT_SECRET}`)); | ||
exports.CONFIG.set("PAYPAL_REST_BEARER", btoa_1.default(`${process.env.PAYPAL_CLIENT_ID}:${process.env.PAYPAL_CLIENT_SECRET}`)); | ||
} | ||
@@ -19,3 +19,3 @@ else { | ||
exports.CONFIG.set("PAYPAL_ENVIRONMENT", window.localStorage.getItem("PAYPAL_ENVIRONMENT")); | ||
exports.CONFIG.set('PAYPAL_REST_BEARER', window.btoa(`${window.localStorage.getItem("PAYPAL_CLIENT_ID")}:${window.localStorage.getItem("PAYPAL_CLIENT_SECRET")}`)); | ||
exports.CONFIG.set("PAYPAL_REST_BEARER", window.btoa(`${window.localStorage.getItem("PAYPAL_CLIENT_ID")}:${window.localStorage.getItem("PAYPAL_CLIENT_SECRET")}`)); | ||
} | ||
@@ -22,0 +22,0 @@ exports.CONFIG.set("PAYPAL_REST_HOSTNAME", exports.CONFIG.get("PAYPAL_ENVIRONMENT") === "productin" |
@@ -10,3 +10,3 @@ "use strict"; | ||
"Accept-Language": "en_US", | ||
Authorization: `Basic ${config_1.CONFIG.get('PAYPAL_REST_BEARER')}`, | ||
Authorization: `Basic ${config_1.CONFIG.get("PAYPAL_REST_BEARER")}`, | ||
"Content-Type": "application/x-www-form-urlencoded" | ||
@@ -13,0 +13,0 @@ }, |
{ | ||
"name": "paypal-isomorphic-functions", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Library of helpful paypal functions that can be run in a browser or server", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -26,1 +26,45 @@ export const DEFAULT_CREATE_BILLING_AGREEMENT_TOKEN_PAYLOAD = { | ||
}; | ||
export const DEFAULT_CREATE_PAYMENT_WITH_BILLING_AGREEMENT_PAYLOAD = { | ||
intent: "sale", | ||
payer: { | ||
payment_method: "PAYPAL", | ||
funding_instruments: [ | ||
{ | ||
billing: { | ||
billing_agreement_id: "B-50V812176H0783741" | ||
} | ||
} | ||
] | ||
}, | ||
transactions: [ | ||
{ | ||
amount: { | ||
currency: "USD", | ||
total: "1.00" | ||
}, | ||
description: "Payment transaction.", | ||
custom: "Payment custom field.", | ||
note_to_payee: "Note to payee field.", | ||
invoice_number: "GDAGDS5754YEK", | ||
item_list: { | ||
items: [ | ||
{ | ||
sku: "skuitemNo1", | ||
name: "ItemNo1", | ||
description: "The item description.", | ||
quantity: "1", | ||
price: "1.00", | ||
currency: "USD", | ||
tax: "0", | ||
url: "https://example.com/" | ||
} | ||
] | ||
} | ||
} | ||
], | ||
redirect_urls: { | ||
return_url: "https://example.com/return", | ||
cancel_url: "https://example.com/cancel" | ||
} | ||
}; |
@@ -9,3 +9,6 @@ import { DEFAULT_CREATE_BILLING_AGREEMENT_TOKEN_PAYLOAD } from "./constants"; | ||
) { | ||
const payload = Object.keys(data).length > 0 ? data : DEFAULT_CREATE_BILLING_AGREEMENT_TOKEN_PAYLOAD; | ||
const payload = | ||
Object.keys(data).length > 0 | ||
? data | ||
: DEFAULT_CREATE_BILLING_AGREEMENT_TOKEN_PAYLOAD; | ||
@@ -12,0 +15,0 @@ const options = { |
@@ -1,2 +0,2 @@ | ||
import btoa from 'btoa'; | ||
import btoa from "btoa"; | ||
@@ -10,3 +10,6 @@ export const CONFIG = new Map(); | ||
CONFIG.set("PAYPAL_ENVIRONMENT", process.env.PAYPAL_ENVIRONMENT); | ||
CONFIG.set('PAYPAL_REST_BEARER', btoa(`${process.env.PAYPAL_CLIENT_ID}:${process.env.PAYPAL_CLIENT_SECRET}`)); | ||
CONFIG.set( | ||
"PAYPAL_REST_BEARER", | ||
btoa(`${process.env.PAYPAL_CLIENT_ID}:${process.env.PAYPAL_CLIENT_SECRET}`) | ||
); | ||
} else { | ||
@@ -25,3 +28,10 @@ CONFIG.set( | ||
); | ||
CONFIG.set('PAYPAL_REST_BEARER', window.btoa(`${window.localStorage.getItem("PAYPAL_CLIENT_ID")}:${window.localStorage.getItem("PAYPAL_CLIENT_SECRET")}`)); | ||
CONFIG.set( | ||
"PAYPAL_REST_BEARER", | ||
window.btoa( | ||
`${window.localStorage.getItem( | ||
"PAYPAL_CLIENT_ID" | ||
)}:${window.localStorage.getItem("PAYPAL_CLIENT_SECRET")}` | ||
) | ||
); | ||
} | ||
@@ -35,3 +45,1 @@ | ||
); | ||
@@ -5,3 +5,2 @@ import { IPayPalAccessToken } from "./interfaces"; | ||
export async function createAccessToken() { | ||
const options = { | ||
@@ -12,3 +11,3 @@ method: "POST", | ||
"Accept-Language": "en_US", | ||
Authorization: `Basic ${CONFIG.get('PAYPAL_REST_BEARER')}`, | ||
Authorization: `Basic ${CONFIG.get("PAYPAL_REST_BEARER")}`, | ||
"Content-Type": "application/x-www-form-urlencoded" | ||
@@ -15,0 +14,0 @@ }, |
@@ -13,3 +13,3 @@ const path = require('path'); | ||
filename: 'paypal-isomorphic-functions.js', | ||
path: path.resolve(__dirname, 'dist'), | ||
path: path.resolve(__dirname, 'lib'), | ||
library: 'paypalFunctions', | ||
@@ -16,0 +16,0 @@ libraryTarget: 'umd' |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
341307
1121