feat(payments-stripe): add cancelSubscription to stripe manager

Because:

* We want to be able to cancel subscriptions from non-stripe lib

This commit:

* Adds a stripe manager method to do so

Closes FXA-9027
This commit is contained in:
Julian Poyourow 2024-04-10 09:26:58 -07:00
Родитель 0e40f47469
Коммит f619c142fb
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: EA0570ABC73D47D3
2 изменённых файлов: 16 добавлений и 0 удалений

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

@ -122,6 +122,18 @@ describe('StripeManager', () => {
});
});
describe('cancelSubscription', () => {
it('calls stripeclient', async () => {
const mockSubscription = StripeSubscriptionFactory();
mockClient.subscriptionsCancel = jest
.fn()
.mockResolvedValueOnce(undefined);
await manager.cancelSubscription(mockSubscription.id);
});
});
describe('isCustomerStripeTaxEligible', () => {
it('should return true for a taxable customer', async () => {
const mockCustomer = StripeCustomerFactory({

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

@ -70,6 +70,10 @@ export class StripeManager {
});
}
async cancelSubscription(subscriptionId: string) {
return this.client.subscriptionsCancel(subscriptionId);
}
/**
* Check if customer's automatic tax status indicates that they're eligible for automatic tax.
* Creating a subscription with automatic_tax enabled requires a customer with an address