зеркало из https://github.com/mozilla/fxa.git
Merge pull request #16616 from mozilla/FXA-8937
feat(payments-paypal): Create PayPalManager cancelBillingAgreement method
This commit is contained in:
Коммит
9487944698
|
@ -62,6 +62,29 @@ describe('PaypalManager', () => {
|
|||
}
|
||||
});
|
||||
|
||||
describe('cancelBillingAgreement', () => {
|
||||
it('cancels a billing agreement', async () => {
|
||||
const billingAgreementId = faker.string.sample();
|
||||
|
||||
paypalClient.baUpdate = jest
|
||||
.fn()
|
||||
.mockResolvedValueOnce(NVPBAUpdateTransactionResponseFactory());
|
||||
|
||||
const result = await paypalManager.cancelBillingAgreement(
|
||||
billingAgreementId
|
||||
);
|
||||
expect(result).toBeUndefined();
|
||||
expect(paypalClient.baUpdate).toBeCalledWith({
|
||||
billingAgreementId,
|
||||
cancel: true,
|
||||
});
|
||||
});
|
||||
|
||||
it('throws an error', async () => {
|
||||
expect(paypalManager.cancelBillingAgreement).rejects.toThrowError();
|
||||
});
|
||||
});
|
||||
|
||||
describe('getBillingAgreement', () => {
|
||||
it('returns agreement details (active status)', async () => {
|
||||
const billingAgreementId = faker.string.sample();
|
||||
|
|
|
@ -23,6 +23,13 @@ export class PayPalManager {
|
|||
private paypalCustomerManager: PaypalCustomerManager
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Cancels a billing agreement.
|
||||
*/
|
||||
async cancelBillingAgreement(billingAgreementId: string): Promise<void> {
|
||||
await this.client.baUpdate({ billingAgreementId, cancel: true });
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Billing Agreement details by calling the update Billing Agreement API.
|
||||
* Parses the API call response for country code and billing agreement status
|
||||
|
|
Загрузка…
Ссылка в новой задаче