Merge pull request #16616 from mozilla/FXA-8937

feat(payments-paypal): Create PayPalManager cancelBillingAgreement method
This commit is contained in:
Lisa Chan 2024-03-25 15:38:18 -04:00 коммит произвёл GitHub
Родитель 0df469e694 66cc0a9446
Коммит 9487944698
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 30 добавлений и 0 удалений

Просмотреть файл

@ -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