paypal-isomorphic-functions
Advanced tools
Comparing version 1.0.21 to 1.0.22
@@ -97,1 +97,18 @@ export declare const DEFAULT_PAYMENT_CREATE_PAYLOAD: { | ||
})[]; | ||
export declare const DEFAULT_REFERENCE_TRANSACTION_PAYLOAD: { | ||
intent: string; | ||
payer: { | ||
payment_method: string; | ||
funding_instruments: { | ||
billing: { | ||
billing_agreement_id: string; | ||
}; | ||
}[]; | ||
}; | ||
transactions: { | ||
amount: { | ||
currency: string; | ||
total: string; | ||
}; | ||
}[]; | ||
}; |
@@ -106,2 +106,23 @@ "use strict"; | ||
]; | ||
exports.DEFAULT_REFERENCE_TRANSACTION_PAYLOAD = { | ||
intent: "sale", | ||
payer: { | ||
payment_method: "PAYPAL", | ||
funding_instruments: [ | ||
{ | ||
billing: { | ||
billing_agreement_id: "B-50V812176H0783741" | ||
} | ||
} | ||
] | ||
}, | ||
transactions: [ | ||
{ | ||
amount: { | ||
currency: "USD", | ||
total: "1.00" | ||
} | ||
} | ||
] | ||
}; | ||
//# sourceMappingURL=constants.js.map |
@@ -5,1 +5,2 @@ import { IPayPalAccessToken } from "../../oauth/interfaces"; | ||
export declare function update(token: IPayPalAccessToken, id: string, data?: any, headers?: any): Promise<Response>; | ||
export declare function referenceTransaction(token: IPayPalAccessToken, billingAgreementId: string, data?: any, headers?: any): Promise<Response>; |
@@ -53,2 +53,19 @@ "use strict"; | ||
exports.update = update; | ||
async function referenceTransaction(token, billingAgreementId, data, headers) { | ||
const payload = data && Object.keys(data).length > 0 | ||
? data | ||
: constants_1.DEFAULT_REFERENCE_TRANSACTION_PAYLOAD; | ||
payload.transactions[0].funding_instruments[0].billing.billing_agreement_id = billingAgreementId; | ||
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.referenceTransaction = referenceTransaction; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "paypal-isomorphic-functions", | ||
"version": "1.0.21", | ||
"version": "1.0.22", | ||
"description": "Library of helpful paypal functions that can be run in a browser or server", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -106,1 +106,23 @@ export const DEFAULT_PAYMENT_CREATE_PAYLOAD = { | ||
]; | ||
export const DEFAULT_REFERENCE_TRANSACTION_PAYLOAD = { | ||
intent: "sale", | ||
payer: { | ||
payment_method: "PAYPAL", | ||
funding_instruments: [ | ||
{ | ||
billing: { | ||
billing_agreement_id: "B-50V812176H0783741" | ||
} | ||
} | ||
] | ||
}, | ||
transactions: [ | ||
{ | ||
amount: { | ||
currency: "USD", | ||
total: "1.00" | ||
} | ||
} | ||
] | ||
}; |
@@ -6,3 +6,4 @@ import { IPayPalAccessToken } from "../../oauth/interfaces"; | ||
DEFAULT_PAYMENT_CAPTURE_PAYLOAD, | ||
DEFAULT_PAYMENT_UPDATE_PAYLOAD | ||
DEFAULT_PAYMENT_UPDATE_PAYLOAD, | ||
DEFAULT_REFERENCE_TRANSACTION_PAYLOAD | ||
} from "../constants"; | ||
@@ -88,1 +89,29 @@ | ||
} | ||
export async function referenceTransaction( | ||
token: IPayPalAccessToken, | ||
billingAgreementId: string, | ||
data?: any, | ||
headers?: any | ||
) { | ||
const payload = | ||
data && Object.keys(data).length > 0 | ||
? data | ||
: DEFAULT_REFERENCE_TRANSACTION_PAYLOAD; | ||
payload.transactions[0].funding_instruments[0].billing.billing_agreement_id = billingAgreementId; | ||
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 | ||
); | ||
} |
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
422930
2150
44