Skip to content

Commit cbbfcc6

Browse files
authored
Merge pull request #345 from internxt/feature/pass-the-user-address-when-creating-an-invoice
[PB-5313]: feat/add user IP address as param when creating invoices
2 parents b529f49 + 6192ffd commit cbbfcc6

4 files changed

Lines changed: 37 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@internxt/sdk",
33
"author": "Internxt <hello@internxt.com>",
4-
"version": "1.11.16",
4+
"version": "1.11.17",
55
"description": "An sdk for interacting with Internxt's services",
66
"repository": {
77
"type": "git",

src/payments/checkout.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ export class Checkout {
130130
token,
131131
currency,
132132
captchaToken,
133+
userAddress,
133134
promoCodeId,
134135
}: CreatePaymentIntentPayload): Promise<PaymentIntent> {
135136
return this.client.post(
@@ -140,6 +141,7 @@ export class Checkout {
140141
token,
141142
currency,
142143
captchaToken,
144+
userAddress,
143145
promoCodeId,
144146
},
145147
this.authHeaders(),

src/payments/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export interface CreatePaymentIntentPayload {
2727
token: string;
2828
currency: string;
2929
captchaToken: string;
30+
userAddress: string;
3031
promoCodeId?: string;
3132
}
3233

test/payments/checkout.test.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { HttpClient } from '../../src/shared/http/client';
33
import { Checkout } from '../../src/payments';
44
import { ApiSecurity, AppDetails } from '../../src/shared';
55
import { basicHeaders, headersWithToken } from '../../src/shared/headers';
6-
import { CreateCustomerPayload, CryptoCurrency } from '../../src/payments/types';
6+
import { CreateCustomerPayload, CreatePaymentIntentPayload, CryptoCurrency } from '../../src/payments/types';
77

88
const httpClient = HttpClient.create('');
99

@@ -47,6 +47,38 @@ describe('Checkout service tests', () => {
4747
});
4848
});
4949

50+
describe('Create payment intent', () => {
51+
it('should call with right params & return data', async () => {
52+
// Arrange
53+
const userPayload: CreatePaymentIntentPayload = {
54+
customerId: 'customer-id',
55+
priceId: 'price-id',
56+
token: 'user-token',
57+
currency: 'eur',
58+
captchaToken: 'captcha-token',
59+
userAddress: '1.1.1.1',
60+
promoCodeId: 'promo-code',
61+
};
62+
const mockedResponse = {
63+
id: 'invoice-id',
64+
type: 'fiat',
65+
clientSecret: 'client-secret',
66+
invoiceStatus: 'paid',
67+
};
68+
69+
const callStub = sinon.stub(httpClient, 'post').resolves([mockedResponse]);
70+
71+
const { client, headers } = clientAndHeadersWithAuthToken({});
72+
73+
// Act
74+
const body = await client.createPaymentIntent(userPayload);
75+
76+
// Assert
77+
expect(callStub.firstCall.args).toEqual(['/checkout/payment-intent', userPayload, headers]);
78+
expect(body).toStrictEqual([mockedResponse]);
79+
});
80+
});
81+
5082
describe('Fetch available crypto currencies', () => {
5183
it('should call with right params & return data', async () => {
5284
// Arrange

0 commit comments

Comments
 (0)