@@ -3,7 +3,7 @@ import { HttpClient } from '../../src/shared/http/client';
33import { Checkout } from '../../src/payments' ;
44import { ApiSecurity , AppDetails } from '../../src/shared' ;
55import { basicHeaders , headersWithToken } from '../../src/shared/headers' ;
6- import { CreateCustomerPayload , CryptoCurrency } from '../../src/payments/types' ;
6+ import { CreateCustomerPayload , CreatePaymentIntentPayload , CryptoCurrency } from '../../src/payments/types' ;
77
88const 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