Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions packages/ramps-controller/src/TransakService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1686,6 +1686,48 @@ describe('TransakService', () => {
await expect(promise).rejects.toThrow("failed with status '503'");
});

it('passes through errorCode from the API response when present', async () => {
const depositOrderId = `${STAGING_PROVIDER_PATH}/orders/order-abc-123`;
const orderWithErrorCode = {
...MOCK_DEPOSIT_ORDER,
status: 'FAILED',
errorCode: '4005',
};

nock(STAGING_ORDERS_BASE)
.get(`${STAGING_PROVIDER_PATH}/orders/order-abc-123`)
.query(true)
.reply(200, orderWithErrorCode);

const { service } = getService();

const promise = service.getOrder(depositOrderId, '0x1234');
await jest.runAllTimersAsync();
await flushPromises();
const result = await promise;

expect(result.errorCode).toBe('4005');
expect(result.status).toBe('FAILED');
});

it('returns undefined errorCode when not present in the API response', async () => {
const depositOrderId = `${STAGING_PROVIDER_PATH}/orders/order-abc-123`;

nock(STAGING_ORDERS_BASE)
.get(`${STAGING_PROVIDER_PATH}/orders/order-abc-123`)
.query(true)
.reply(200, MOCK_DEPOSIT_ORDER);

const { service } = getService();

const promise = service.getOrder(depositOrderId, '0x1234');
await jest.runAllTimersAsync();
await flushPromises();
const result = await promise;

expect(result.errorCode).toBeUndefined();
});

it('gracefully handles failure when fetching paymentDetails from Transak', async () => {
const depositOrderId = `${STAGING_PROVIDER_PATH}/orders/order-abc-123`;
const orderWithoutPaymentDetails = {
Expand Down
1 change: 1 addition & 0 deletions packages/ramps-controller/src/TransakService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ export type TransakDepositOrder = {
orderType: 'DEPOSIT';
exchangeRate?: number;
statusDescription?: string;
errorCode?: string;
paymentDetails: TransakOrderPaymentMethod[];
partnerFees?: number;
networkFees?: number;
Expand Down