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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "method-node",
"version": "1.1.11",
"version": "1.1.12",
"description": "Node.js library for the Method API",
"main": "dist/index.ts",
"module": "dist/index.mjs",
Expand Down
6 changes: 5 additions & 1 deletion src/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ import { AccountSubResources } from './resources/Account';
import { PaymentSubResources } from './resources/Payment';
import { EntitySubResources } from './resources/Entity';
import { SimulateAccountsSubResources } from './resources/Simulate/Accounts';
import { SimulateEntitiesSubResources } from './resources/Simulate/Entities';
import { SimulateCreditScoresInstance } from './resources/Simulate/Entities/CreditScores';

type TSubResources =
| AccountSubResources
| PaymentSubResources
| EntitySubResources
| SimulateAccountsSubResources;
| SimulateAccountsSubResources
| SimulateEntitiesSubResources
| SimulateCreditScoresInstance;

export interface IRequestConfig {
idempotency_key?: string;
Expand Down
40 changes: 40 additions & 0 deletions src/resources/Account/PaymentInstruments.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import Resource, { IResourceListOpts } from '../../resource';
import Configuration, { IResponse } from '../../configuration';
import type { IAccountPaymentInstrument, IPaymentInstrumentCreateOpts } from './types';

export default class AccountPaymentInstruments extends Resource {
constructor(config: Configuration) {
super(config.addPath('payment_instruments'));
}

/**
* Retrieves a Payment Instrument record for an Account.
*
* @param pmt_inst_id ID of the Payment Instrument
* @returns Returns an Account’s Payment Instrument object.
*/

async retrieve(pmt_inst_id: string) {
return super._getWithId<IResponse<IAccountPaymentInstrument>>(pmt_inst_id);
}

/**
* Retrieves a list of Payment Instrument objects for an account.
*
* @returns Returns a list of Payment Instrument objects.
*/

async list(opts?: IResourceListOpts) {
return super._list<IResponse<IAccountPaymentInstrument>>(opts);
}

/**
* Creates a new Payment Instrument request to retrieve the Account’s payment instruments.
*
* @returns Returns an Account’s Payment Instrument object.
*/

async create(data: IPaymentInstrumentCreateOpts) {
return super._create<IResponse<IAccountPaymentInstrument>, IPaymentInstrumentCreateOpts>(data);
}
};
3 changes: 3 additions & 0 deletions src/resources/Account/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import AccountBalances from './Balances';
import AccountSensitive from './Sensitive';
import AccountTransactions from './Transactions';
import AccountSubscriptions from './Subscriptions';
import AccountPaymentInstruments from './PaymentInstruments';
import AccountVerificationSession from './VerificationSessions';
import AccountProducts from './Products';
import type {
Expand All @@ -29,6 +30,7 @@ export class AccountSubResources {
transactions: AccountTransactions;
updates: AccountUpdates;
attributes: AccountAttributes;
paymentInstruments: AccountPaymentInstruments;
verificationSessions: AccountVerificationSession;

constructor(acc_id: string, config: Configuration) {
Expand All @@ -41,6 +43,7 @@ export class AccountSubResources {
this.transactions = new AccountTransactions(config.addPath(acc_id));
this.updates = new AccountUpdates(config.addPath(acc_id));
this.attributes = new AccountAttributes(config.addPath(acc_id));
this.paymentInstruments = new AccountPaymentInstruments(config.addPath(acc_id));
this.verificationSessions = new AccountVerificationSession(config.addPath(acc_id));
}
};
Expand Down
112 changes: 72 additions & 40 deletions src/resources/Account/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const AccountProducts = {
update: 'update',
attribute: 'attribute',
transactions: 'transactions',
payment_instrument: 'payment_instrument',
} as const;

export type TAccountProducts = keyof typeof AccountProducts;
Expand Down Expand Up @@ -67,11 +68,12 @@ export interface IAccountProductListResponse {
payoff?: IAccountProduct;
update?: IAccountProduct;
attribute?: IAccountProduct;
transactions?: IAccountProduct;
transaction?: IAccountProduct;
payment_instrument?: IAccountProduct;
};

export const AccountSubscriptionTypes = {
transactions: 'transactions',
transaction: 'transaction',
update: 'update',
update_snapshot: 'update.snapshot',
} as const;
Expand Down Expand Up @@ -384,7 +386,7 @@ export interface IAccountSubscription {
};

export interface IAccountSubscriptionsResponse {
transactions?: IAccountSubscription;
transaction?: IAccountSubscription;
update?: IAccountSubscription;
'update.snapshot'?: IAccountSubscription;
};
Expand Down Expand Up @@ -416,52 +418,32 @@ export interface IAccountUpdate {
updated_at: string;
};

export const AccountCurrencyTypes = {
USD: 'USD',
};

export type TAccountCurrencyTypes = keyof typeof AccountCurrencyTypes;

export const AccountTransactionStatuses = {
cleared: 'cleared',
auth: 'auth',
refund: 'refund',
unknown: 'unknown',
pending: 'pending',
posted: 'posted',
voided: 'voided',
} as const;

export type TAccountTransactionStatuses = keyof typeof AccountTransactionStatuses;

export interface IAccountTransactionMerchant {
name: string;
category_code: string;
city: string;
state: string;
country: string;
acquirer_bin: string;
acquirer_card_acceptor_id: string;
};

export interface IAccountTransactionNetworkData {
visa_merchant_id: string | null;
visa_merchant_name: string | null;
visa_store_id: string | null;
visa_store_name: string | null;
};

export interface IAccountTransaction {
id: string;
account_id: string;
merchant: IAccountTransactionMerchant;
network: string;
network_data: IAccountTransactionNetworkData | null;
descriptor: string;
amount: number;
currency: TAccountCurrencyTypes;
billing_amount: number;
billing_currency: TAccountCurrencyTypes;
auth_amount: number;
currency_code: string;
transaction_amount: number;
transaction_auth_amount: number;
transaction_currency_code: string;
merchant_category_code: string;
status: TAccountTransactionStatuses;
error: IResourceError | null;
created_at: string;
updated_at: string;
transacted_at: Date;
posted_at: Date | null;
voided_at: Date | null;
original_txn_id: string | null;
created_at: Date;
updated_at: Date;
};

export const AccountVerificationSessionStatuses = {
Expand All @@ -481,6 +463,7 @@ export const AccountVerificationSessionTypes = {
standard: 'standard',
instant: 'instant',
pre_auth: 'pre_auth',
network: 'network',
} as const;

export type TAccountVerificaionSessionTypes = keyof typeof AccountVerificationSessionTypes;
Expand Down Expand Up @@ -536,6 +519,14 @@ export interface IAccountVerificationSessionPreAuth extends IAccountVerification
pre_auth_check?: TAccountVerificationPassFail | null;
};

export interface IAccountVerificationSessionNetwork extends IAccountVerificationSessionInstant {
cvv?: string | null;
cvv_check?: TAccountVerificationPassFail | null;
billing_zip_code?: string | null;
billing_zip_code_check?: TAccountVerificationPassFail | null;
network_check?: TAccountVerificationPassFail | null;
};

export interface IAccountVerificationSessionCreateOpts {
type: TAccountVerificaionSessionTypes;
};
Expand Down Expand Up @@ -568,14 +559,19 @@ export interface IAccountVerificationSessionPreAuthUpdateOpts {
pre_auth: IAccountVerificationSessionPreAuth
};

export interface IAccountVerificationSessionNetworkUpdateOpts {
network: IAccountVerificationSessionNetwork;
};

export type IAccountVerificationSessionUpdateOpts =
| IAccountVerificationSessionMicroDepositsUpdateOpts
| IAccountVerificationSessionPlaidUpdateOpts
| IAccountVerificationSessionMXUpdateOpts
| IAccountVerificationSessionTellerUpdateOpts
| IAccountVerificationSessionStandardUpdateOpts
| IAccountVerificationSessionInstantUpdateOpts
| IAccountVerificationSessionPreAuthUpdateOpts;
| IAccountVerificationSessionPreAuthUpdateOpts
| IAccountVerificationSessionNetworkUpdateOpts;

export interface IAccountVerificationSession {
id: string;
Expand All @@ -592,6 +588,7 @@ export interface IAccountVerificationSession {
standard?: IAccountVerificationSessionStandard | null;
instant?: IAccountVerificationSessionInstant | null;
pre_auth?: IAccountVerificationSessionPreAuth | null;
network?: IAccountVerificationSessionNetwork | null;
three_ds?: IAccountVerificationSessionThreeDS | null;
issuer?: IAccountVerificationSessionIssuer | null;
created_at: string;
Expand Down Expand Up @@ -657,6 +654,40 @@ export interface IAccountAttributes {
updated_at: string;
}

export const PaymentInstrumentTypes = {
card: 'card',
network_token: 'network_token'
} as const;

export type TPaymentInstrumentTypes = keyof typeof PaymentInstrumentTypes;

export interface IPaymentInstrumentCreateOpts {
type: TPaymentInstrumentTypes;
}

export interface IPaymentInstrumentCard {
number: string;
exp_month: number;
exp_year: number;
}

export interface IPaymentInstrumentNetworkToken {
token: string;
}

export interface IAccountPaymentInstrument {
id: string;
account_id: string;
type: TPaymentInstrumentTypes;
network_token?: IPaymentInstrumentNetworkToken | null;
card?: IPaymentInstrumentCard | null;
chargeable: boolean;
status: TResourceStatus;
error: IResourceError | null;
created_at: Date;
updated_at: Date;
}

export interface IAccount {
id: string;
holder_id: string;
Expand All @@ -676,6 +707,7 @@ export interface IAccount {
transactions?: string | IAccountTransaction[] | null;
update?: string | IAccountUpdate | null;
attribute?: string | IAccountAttributes | null;
payment_instrument?: string | IAccountPaymentInstrument | null;
latest_verification_session?: string | IAccountVerificationSession | null;
error: IResourceError | null;
created_at: string;
Expand Down
35 changes: 35 additions & 0 deletions src/resources/Simulate/Entities/CreditScores.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import Resource from '../../../resource';
import Configuration, { IResponse } from '../../../configuration';
import type {
IEntityCreditScores,
IEntityCreditScoresType,
} from '../../Entity';

export class SimulateCreditScoresInstance extends Resource {
constructor(crs_id: string, config: Configuration) {
super(config.addPath(crs_id));
}

/**
* For Entities that have been successfully verified, you may simulate Credit Scores in the dev environment.
*
* @returns Returns the created Credit Score.
*/
async create(opts: { scores: IEntityCreditScoresType[] }) {
return super._create<IResponse<IEntityCreditScores>, { scores: IEntityCreditScoresType[] }>(opts);
}
}

export default interface SimulateCreditScores {
(crs_id: string): SimulateCreditScoresInstance;
}

export default class SimulateCreditScores extends Resource {
constructor(config: Configuration) {
super(config.addPath('credit_scores'));
}

protected _call(crs_id: string): SimulateCreditScoresInstance {
return new SimulateCreditScoresInstance(crs_id, this.config);
}
}
26 changes: 26 additions & 0 deletions src/resources/Simulate/Entities/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Resource from '../../../resource';
import Configuration from '../../../configuration';
import SimulateCreditScores from './CreditScores';

export class SimulateEntitiesSubResources {
creditScores: SimulateCreditScores;
constructor(entity_id: string, config: Configuration) {
this.creditScores = new SimulateCreditScores(config.addPath(entity_id));
}
}

export interface SimulateEntities {
(entity_id: string): SimulateEntitiesSubResources;
}

export class SimulateEntities extends Resource {
constructor(config: Configuration) {
super(config.addPath('entities'));
}

protected _call(entity_id: string): SimulateEntitiesSubResources {
return new SimulateEntitiesSubResources(entity_id, this.config);
}
}

export default SimulateEntities;
4 changes: 4 additions & 0 deletions src/resources/Simulate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,27 @@ import Resource from '../../resource';
import Configuration from '../../configuration';
import SimulatePayments from './Payments';
import SimulateAccounts from './Accounts';
import SimulateEntities from './Entities';
import SimulateEvents from './Events';

export interface Simulate {
payments: SimulatePayments;
accounts: SimulateAccounts;
entities: SimulateEntities;
events: SimulateEvents;
};

export class Simulate extends Resource {
payments: SimulatePayments;
accounts: SimulateAccounts;
entities: SimulateEntities;
events: SimulateEvents;
constructor(config: Configuration) {
const _config = config.addPath('simulate');
super(_config);
this.payments = new SimulatePayments(_config);
this.accounts = new SimulateAccounts(_config);
this.entities = new SimulateEntities(_config);
this.events = new SimulateEvents(_config);
}
};
Expand Down
Loading