Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 1.1.0 #17

Merged
merged 11 commits into from
Dec 14, 2021
58 changes: 50 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
</p>

<p align="center">
<a href="https://pypi.org/project/fintoc" target="_blank">
<img src="https://img.shields.io/npm/v/fintoc?label=version&logo=nodedotjs&logoColor=%23fff&color=306998" alt="PyPI - Version">
<a href="https://www.npmjs.com/package/fintoc" target="_blank">
<img src="https://img.shields.io/npm/v/fintoc?label=version&logo=nodedotjs&logoColor=%23fff&color=306998" alt="NPM - Version">
</a>

<a href="https://github.com/fintoc-com/fintoc-node/actions?query=workflow%3Atests" target="_blank">
Expand Down Expand Up @@ -210,7 +210,7 @@ import { Fintoc } from 'fintoc';
const fintocClient = new Fintoc('your_api_key');
```

This gives us access to a bunch of operations already. The object created using this _snippet_ contains two [managers](#managers): `links` and `webhookEndpoints`.
This gives us access to a bunch of operations already. The object created using this _snippet_ contains three [managers](#managers): `links`, `paymentIntents` and `webhookEndpoints`.

#### The `webhookEndpoints` manager

Expand Down Expand Up @@ -264,6 +264,45 @@ const webhookEndpoint = await fintocClient.webhookEndpoints.get('we_8anqVLlBC8RO
console.log(webhookEndpoint.id); // we_8anqVLlBC8ROodem
```

#### The `paymentIntents` manager

Available methods: `all`, `get`, `create`.

Payment intents allow you to start a payment using Fintoc! Start by creating a new payment intent:

```javascript
const paymentIntent = await fintocClient.paymentIntents.create({
currency: 'CLP',
amount: 5990,
recipient_account: {
holder_id: '111111111',
number: '123123123',
type: 'checking_account',
institution_id: 'cl_banco_de_chile',
},
});

console.log(paymentIntent.id); // pi_BO381oEATXonG6bj
console.log(paymentIntent.widget_token); // pi_BO381oEATXonG6bj_sec_a4xK32BanKWYn
```

Notice that the success of this payment intent will be notified through a Webhook. Now, let's list every payment intent we have:

```javascript
for await (const paymentIntent of await fintocClient.paymentIntents.all()) {
console.log(paymentIntent.id);
}
```

If you see a payment intent you want to use, just use the `get` method!

```javascript
const paymentIntent = fintocClient.paymentIntents.get('pi_BO381oEATXonG6bj')

console.log(paymentIntent.id) // pi_BO381oEATXonG6bj
console.log(paymentIntent.status) // succeeded
```

#### The `links` manager

Available methods: `all`, `get`, `update`, `delete`.
Expand Down Expand Up @@ -339,23 +378,26 @@ Available methods: `all`, `get`, `create`.
Refresh intents allow you to control how an account gets refreshed on Fintoc! Once you have a Link, you can use the `refreshIntents` manager to create a new refresh intent:

```javascript
const refreshIntent = await link.refreshIntents.create()
console.log(refreshIntent.id) // ri_5A94DVCJ7xNM3MEo
const refreshIntent = await link.refreshIntents.create();

console.log(refreshIntent.id); // ri_5A94DVCJ7xNM3MEo
```

Notice that the success of this refresh intent will be notified through a Webhook. Now, let's list every refresh intent we have:

```javascript
for await (const refreshIntent of await link.refreshIntents.all()) {
console.log(refreshIntent.id)
console.log(refreshIntent.id);
}
```

If you see a refresh intent you want to use, just use the `get` method!

```javascript
const refreshIntent = await link.refreshIntents.get('ri_5A94DVCJ7xNM3MEo')
console.log(refreshIntent.id) // ri_5A94DVCJ7xNM3MEo
const refreshIntent = await link.refreshIntents.get('ri_5A94DVCJ7xNM3MEo');

console.log(refreshIntent.id); // ri_5A94DVCJ7xNM3MEo
console.log(refreshIntent.status); // succeeded
```

#### The `accounts` manager
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"name": "fintoc",
"version": "1.0.0",
"version": "1.1.0",
"description": "The official Node client for the Fintoc API.",
"main": "build/main/index.js",
"typings": "build/main/index.d.ts",
"module": "build/module/index.js",
"homepage": "https://fintoc.com",
"repository": "https://github.com/fintoc-com/fintoc-node",
"bugs": "https://github.com/fintoc-com/fintoc-node/issues",
"license": "BSD-3-Clause",
"author": "Daniel Leal <[email protected]>",
"maintainers": [
Expand Down
4 changes: 3 additions & 1 deletion src/lib/core.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { Client } from './client';
import { API_BASE_URL, API_VERSION } from './constants';
import { LinksManager, WebhookEndpointsManager } from './managers';
import { LinksManager, PaymentIntentsManager, WebhookEndpointsManager } from './managers';
import { version } from './version';

export class Fintoc {
#client: Client;

links: LinksManager;
paymentIntents: PaymentIntentsManager;
webhookEndpoints: WebhookEndpointsManager;

constructor(apiKey: string) {
Expand All @@ -16,6 +17,7 @@ export class Fintoc {
apiKey,
});
this.links = new LinksManager('/links', this.#client);
this.paymentIntents = new PaymentIntentsManager('/payment_intents', this.#client);
this.webhookEndpoints = new WebhookEndpointsManager('/webhook_endpoints', this.#client);
}
}
1 change: 1 addition & 0 deletions src/lib/managers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export * from './accountsManager';
export * from './invoicesManager';
export * from './linksManager';
export * from './movementsManager';
export * from './paymentIntentsManager';
export * from './refreshIntentsManager';
export * from './subscriptionsManager';
export * from './taxReturnsManager';
Expand Down
7 changes: 7 additions & 0 deletions src/lib/managers/paymentIntentsManager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { ManagerMixin } from '../mixins';
import { PaymentIntent } from '../resources/paymentIntent';

export class PaymentIntentsManager extends ManagerMixin<PaymentIntent> {
static resource = 'payment_intent';
static methods = ['all', 'get', 'create'];
}
4 changes: 2 additions & 2 deletions src/lib/resources/movement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ResourceMixin } from '../mixins/resourceMixin';

export class Movement extends ResourceMixin<Movement> {
static mappings = {
recipient_account: 'transferAccount',
sernder_account: 'transferAccount',
recipient_account: 'transfer_account',
sernder_account: 'transfer_account',
}
}
8 changes: 8 additions & 0 deletions src/lib/resources/paymentIntent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ResourceMixin } from '../mixins/resourceMixin';

export class PaymentIntent extends ResourceMixin<PaymentIntent> {
static mappings = {
recipient_account: 'transfer_account',
sernder_account: 'transfer_account',
}
}
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, 0, 0];
export const versionInfo = [1, 1, 0];

export const version = versionInfo.join('.');