Skip to content
Merged
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fintoc",
"version": "1.13.0",
"version": "1.14.0",
"description": "The official Node client for the Fintoc API.",
"main": "build/main/index.js",
"typings": "build/main/index.d.ts",
Expand Down
3 changes: 3 additions & 0 deletions src/lib/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
TransfersManager,
AccountsManager as V2AccountsManager,
CheckoutSessionsManager as V2CheckoutSessionsManager,
PaymentIntentsManager as V2PaymentIntentsManager,
} from './managers/v2';
import { version } from './version';

Expand All @@ -37,6 +38,7 @@ class FintocV2 {
accountVerifications: AccountVerificationsManager;
customers: CustomersManager;
checkoutSessions: V2CheckoutSessionsManager;
paymentIntents: V2PaymentIntentsManager;

constructor(client: Client) {
this.accounts = new V2AccountsManager('/v2/accounts', client);
Expand All @@ -47,6 +49,7 @@ class FintocV2 {
this.accountVerifications = new AccountVerificationsManager('/v2/account_verifications', client);
this.customers = new CustomersManager('/v2/customers', client);
this.checkoutSessions = new V2CheckoutSessionsManager('/v2/checkout_sessions', client);
this.paymentIntents = new V2PaymentIntentsManager('/v2/payment_intents', client);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/lib/managers/v2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ export * from './accountVerificationsManager';
export * from './movementsManager';
export * from './customersManager';
export * from './checkoutSessionsManager';
export * from './paymentIntentsManager';
7 changes: 7 additions & 0 deletions src/lib/managers/v2/paymentIntentsManager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { ManagerMixin } from '../../mixins';
import { PaymentIntent } from '../../resources/v2/paymentIntent';

export class PaymentIntentsManager extends ManagerMixin<PaymentIntent> {
static resource = 'payment_intent';
static methods = ['list', 'get', 'create'];
}
1 change: 1 addition & 0 deletions src/lib/resources/v2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export * from './accountVerification';
export * from './checkoutSession';
export * from './movement';
export * from './customer';
export * from './paymentIntent';
4 changes: 4 additions & 0 deletions src/lib/resources/v2/paymentIntent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { ResourceMixin } from '../../mixins/resourceMixin';

export class PaymentIntent extends ResourceMixin<PaymentIntent> {
}
2 changes: 1 addition & 1 deletion src/lib/version.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const versionInfo = [1, 13, 0];
export const versionInfo = [1, 14, 0];

export const version = versionInfo.join('.');
39 changes: 39 additions & 0 deletions src/spec/integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1158,3 +1158,42 @@ test('fintoc.v2.checkoutSessions.expire()', async (t) => {
t.is(checkoutSession.method, 'post');
t.is(checkoutSession.url, `v2/checkout_sessions/${checkoutSessionId}/expire`);
});

test('fintoc.v2.paymentIntents.list()', async (t) => {
const ctx: any = t.context;
const paymentIntents = await ctx.fintoc.v2.paymentIntents.list();

let count = 0;
for await (const paymentIntent of paymentIntents) {
count += 1;
t.is(paymentIntent.method, 'get');
t.is(paymentIntent.url, 'v2/payment_intents');
}

t.true(count > 0);
});

test('fintoc.v2.paymentIntents.get()', async (t) => {
const ctx: any = t.context;
const paymentIntentId = 'payment_intent_id';
const paymentIntent = await ctx.fintoc.v2.paymentIntents.get(paymentIntentId);

t.is(paymentIntent.method, 'get');
t.is(paymentIntent.url, `v2/payment_intents/${paymentIntentId}`);
});

test('fintoc.v2.paymentIntents.create()', async (t) => {
const ctx: any = t.context;
const paymentIntentData = {
amount: 5000,
currency: 'CLP',
payment_method: 'payment_method_hashid',
};
const paymentIntent = await ctx.fintoc.v2.paymentIntents.create(paymentIntentData);

t.is(paymentIntent.method, 'post');
t.is(paymentIntent.url, 'v2/payment_intents');
t.is(paymentIntent.json.amount, paymentIntentData.amount);
t.is(paymentIntent.json.currency, paymentIntentData.currency);
t.is(paymentIntent.json.payment_method, paymentIntentData.payment_method);
});
Loading