paypal-isomorphic-functions
Advanced tools
Comparing version 1.0.14 to 1.0.15
@@ -61,1 +61,37 @@ export declare const DEFAULT_PAYMENT_CREATE_PAYLOAD: { | ||
}; | ||
export declare const DEFAULT_PAYMENT_UPDATE_PAYLOAD: ({ | ||
op: string; | ||
path: string; | ||
value: { | ||
total: string; | ||
currency: string; | ||
details: { | ||
subtotal: string; | ||
tax: string; | ||
shipping: string; | ||
handling_fee: string; | ||
shipping_discount: string; | ||
insurance: string; | ||
}; | ||
recipient_name?: undefined; | ||
line1?: undefined; | ||
city?: undefined; | ||
postal_code?: undefined; | ||
country_code?: undefined; | ||
state?: undefined; | ||
}; | ||
} | { | ||
op: string; | ||
path: string; | ||
value: { | ||
recipient_name: string; | ||
line1: string; | ||
city: string; | ||
postal_code: string; | ||
country_code: string; | ||
state: string; | ||
total?: undefined; | ||
currency?: undefined; | ||
details?: undefined; | ||
}; | ||
})[]; |
@@ -76,2 +76,32 @@ "use strict"; | ||
}; | ||
exports.DEFAULT_PAYMENT_UPDATE_PAYLOAD = [ | ||
{ | ||
op: "replace", | ||
path: "/transactions/0/amount", | ||
value: { | ||
total: "35.11", | ||
currency: "USD", | ||
details: { | ||
subtotal: "30.00", | ||
tax: "0.07", | ||
shipping: "5.03", | ||
handling_fee: "1.00", | ||
shipping_discount: "-1.00", | ||
insurance: "0.01" | ||
} | ||
} | ||
}, | ||
{ | ||
op: "add", | ||
path: "/transactions/0/item_list/shipping_address", | ||
value: { | ||
recipient_name: "Anna Gruneberg", | ||
line1: "101 main st", | ||
city: "Beverly Hills", | ||
postal_code: "90210", | ||
country_code: "US", | ||
state: "CA" | ||
} | ||
} | ||
]; | ||
//# sourceMappingURL=constants.js.map |
@@ -1,3 +0,2 @@ | ||
import { IPayPalAccessToken } from "../oauth/interfaces"; | ||
export declare function create(token: IPayPalAccessToken, data?: any, headers?: any): Promise<Response>; | ||
export declare function capture(token: IPayPalAccessToken, id: string, version?: string, data?: any, headers?: any): Promise<Response>; | ||
import * as v1 from "./v1"; | ||
export { v1 }; |
"use strict"; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const config_1 = require("../config"); | ||
const constants_1 = require("./constants"); | ||
async function create(token, data, headers) { | ||
const payload = Object.keys(data).length > 0 ? data : constants_1.DEFAULT_PAYMENT_CREATE_PAYLOAD; | ||
const options = { | ||
method: "POST", | ||
headers: { | ||
Authorization: `Bearer ${token.access_token}`, | ||
"Content-Type": "application/json", | ||
...headers | ||
}, | ||
body: JSON.stringify(payload) | ||
}; | ||
return await fetch(`${config_1.CONFIG.get("PAYPAL_REST_HOSTNAME")}/v1/payments/payment`, options); | ||
} | ||
exports.create = create; | ||
async function capture(token, id, version = "v1", data, headers) { | ||
const payload = Object.keys(data).length > 0 ? data : constants_1.DEFAULT_PAYMENT_CAPTURE_PAYLOAD; | ||
const options = { | ||
method: "POST", | ||
headers: { | ||
Authorization: `Bearer ${token.access_token}`, | ||
"Content-Type": "application/json", | ||
...headers | ||
}, | ||
body: JSON.stringify(payload) | ||
}; | ||
return await fetch(`${config_1.CONFIG.get("PAYPAL_REST_HOSTNAME")}/${version}/payments/authorizations/${id}/capture`, options); | ||
} | ||
exports.capture = capture; | ||
const v1 = __importStar(require("./v1")); | ||
exports.v1 = v1; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "paypal-isomorphic-functions", | ||
"version": "1.0.14", | ||
"version": "1.0.15", | ||
"description": "Library of helpful paypal functions that can be run in a browser or server", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -75,1 +75,32 @@ export const DEFAULT_PAYMENT_CREATE_PAYLOAD = { | ||
}; | ||
export const DEFAULT_PAYMENT_UPDATE_PAYLOAD = [ | ||
{ | ||
op: "replace", | ||
path: "/transactions/0/amount", | ||
value: { | ||
total: "35.11", | ||
currency: "USD", | ||
details: { | ||
subtotal: "30.00", | ||
tax: "0.07", | ||
shipping: "5.03", | ||
handling_fee: "1.00", | ||
shipping_discount: "-1.00", | ||
insurance: "0.01" | ||
} | ||
} | ||
}, | ||
{ | ||
op: "add", | ||
path: "/transactions/0/item_list/shipping_address", | ||
value: { | ||
recipient_name: "Anna Gruneberg", | ||
line1: "101 main st", | ||
city: "Beverly Hills", | ||
postal_code: "90210", | ||
country_code: "US", | ||
state: "CA" | ||
} | ||
} | ||
]; |
@@ -1,56 +0,3 @@ | ||
import { IPayPalAccessToken } from "../oauth/interfaces"; | ||
import { CONFIG } from "../config"; | ||
import { | ||
DEFAULT_PAYMENT_CREATE_PAYLOAD, | ||
DEFAULT_PAYMENT_CAPTURE_PAYLOAD | ||
} from "./constants"; | ||
import * as v1 from "./v1"; | ||
export async function create( | ||
token: IPayPalAccessToken, | ||
data?: any, | ||
headers?: any | ||
) { | ||
const payload = | ||
Object.keys(data).length > 0 ? data : DEFAULT_PAYMENT_CREATE_PAYLOAD; | ||
const options = { | ||
method: "POST", | ||
headers: { | ||
Authorization: `Bearer ${token.access_token}`, | ||
"Content-Type": "application/json", | ||
...headers | ||
}, | ||
body: JSON.stringify(payload) | ||
}; | ||
return await fetch( | ||
`${CONFIG.get("PAYPAL_REST_HOSTNAME")}/v1/payments/payment`, | ||
options | ||
); | ||
} | ||
export async function capture( | ||
token: IPayPalAccessToken, | ||
id: string, | ||
version = "v1", | ||
data?: any, | ||
headers?: any | ||
) { | ||
const payload = | ||
Object.keys(data).length > 0 ? data : DEFAULT_PAYMENT_CAPTURE_PAYLOAD; | ||
const options = { | ||
method: "POST", | ||
headers: { | ||
Authorization: `Bearer ${token.access_token}`, | ||
"Content-Type": "application/json", | ||
...headers | ||
}, | ||
body: JSON.stringify(payload) | ||
}; | ||
return await fetch( | ||
`${CONFIG.get( | ||
"PAYPAL_REST_HOSTNAME" | ||
)}/${version}/payments/authorizations/${id}/capture`, | ||
options | ||
); | ||
} | ||
export { v1 }; |
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 too big to display
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
382699
64
1631
32