paypal-isomorphic-functions
Advanced tools
Comparing version 1.0.12 to 1.0.13
@@ -54,1 +54,8 @@ export declare const DEFAULT_PAYMENT_CREATE_PAYLOAD: { | ||
}; | ||
export declare const DEFAULT_PAYMENT_CAPTURE_PAYLOAD: { | ||
amount: { | ||
value: string; | ||
currency_code: string; | ||
}; | ||
final_capture: boolean; | ||
}; |
@@ -69,2 +69,9 @@ "use strict"; | ||
}; | ||
exports.DEFAULT_PAYMENT_CAPTURE_PAYLOAD = { | ||
amount: { | ||
value: "1.99", | ||
currency_code: "USD" | ||
}, | ||
final_capture: true | ||
}; | ||
//# sourceMappingURL=constants.js.map |
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, data?: any, headers?: any): Promise<Response>; |
@@ -19,2 +19,16 @@ "use strict"; | ||
exports.create = create; | ||
async function capture(token, id, 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")}/v2/payments/authorizations/${id}/capture`, options); | ||
} | ||
exports.capture = capture; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "paypal-isomorphic-functions", | ||
"version": "1.0.12", | ||
"version": "1.0.13", | ||
"description": "Library of helpful paypal functions that can be run in a browser or server", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -67,1 +67,9 @@ export const DEFAULT_PAYMENT_CREATE_PAYLOAD = { | ||
}; | ||
export const DEFAULT_PAYMENT_CAPTURE_PAYLOAD = { | ||
amount: { | ||
value: "1.99", | ||
currency_code: "USD" | ||
}, | ||
final_capture: true | ||
}; |
import { IPayPalAccessToken } from "../oauth/interfaces"; | ||
import { CONFIG } from "../config"; | ||
import { DEFAULT_PAYMENT_CREATE_PAYLOAD } from "./constants"; | ||
import { | ||
DEFAULT_PAYMENT_CREATE_PAYLOAD, | ||
DEFAULT_PAYMENT_CAPTURE_PAYLOAD | ||
} from "./constants"; | ||
@@ -27,1 +30,27 @@ export async function create( | ||
} | ||
export async function capture( | ||
token: IPayPalAccessToken, | ||
id: string, | ||
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" | ||
)}/v2/payments/authorizations/${id}/capture`, | ||
options | ||
); | ||
} |
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
371807
1466
30