paypal-isomorphic-functions
Advanced tools
Comparing version 1.0.18 to 1.0.19
import { IPayPalAccessToken } from "../../oauth"; | ||
export declare function capture(token: IPayPalAccessToken, id: string, data?: any, headers?: any): Promise<Response>; | ||
export declare function refund(token: IPayPalAccessToken, id: string, data: any, headers?: any): Promise<Response>; | ||
export declare function cancel(token: IPayPalAccessToken, id: string, headers?: any): Promise<Response>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const config_1 = require("../../config"); | ||
const constants_1 = require("../../payments/constants"); | ||
async function capture(token, id, data, headers) { | ||
const payload = data && Object.keys(data).length > 0 | ||
? data | ||
: constants_1.DEFAULT_PAYMENT_CAPTURE_PAYLOAD; | ||
const payload = data || {}; | ||
const options = { | ||
@@ -21,2 +18,28 @@ method: "POST", | ||
exports.capture = capture; | ||
async function refund(token, id, data, headers) { | ||
const payload = data || {}; | ||
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")}/v2/payments/captures/${id}/refund`, options); | ||
} | ||
exports.refund = refund; | ||
async function cancel(token, id, headers) { | ||
const options = { | ||
method: "POST", | ||
headers: { | ||
Authorization: `Bearer ${token.access_token}`, | ||
"Content-Type": "application/json", | ||
...headers | ||
} | ||
}; | ||
return await fetch(`${config_1.CONFIG.get("PAYPAL_REST_HOSTNAME")}/v2/payments/authorizations/${id}/void`, options); | ||
} | ||
exports.cancel = cancel; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "paypal-isomorphic-functions", | ||
"version": "1.0.18", | ||
"version": "1.0.19", | ||
"description": "Library of helpful paypal functions that can be run in a browser or server", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
import { CONFIG } from "../../config"; | ||
import { IPayPalAccessToken } from "../../oauth"; | ||
import { DEFAULT_PAYMENT_CAPTURE_PAYLOAD } from "../../payments/constants"; | ||
@@ -11,6 +10,3 @@ export async function capture( | ||
) { | ||
const payload = | ||
data && Object.keys(data).length > 0 | ||
? data | ||
: DEFAULT_PAYMENT_CAPTURE_PAYLOAD; | ||
const payload = data || {}; | ||
@@ -33,1 +29,45 @@ const options = { | ||
} | ||
export async function refund( | ||
token: IPayPalAccessToken, | ||
id: string, | ||
data: any, | ||
headers?: any | ||
) { | ||
const payload = data || {}; | ||
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")}/v2/payments/captures/${id}/refund`, | ||
options | ||
); | ||
} | ||
export async function cancel( | ||
token: IPayPalAccessToken, | ||
id: string, | ||
headers?: any | ||
) { | ||
const options = { | ||
method: "POST", | ||
headers: { | ||
Authorization: `Bearer ${token.access_token}`, | ||
"Content-Type": "application/json", | ||
...headers | ||
} | ||
}; | ||
return await fetch( | ||
`${CONFIG.get( | ||
"PAYPAL_REST_HOSTNAME" | ||
)}/v2/payments/authorizations/${id}/void`, | ||
options | ||
); | ||
} |
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
413559
2006
42