42-cent-base

中文文档
1.0.1发布于 2019/07/22MITCommonJS近 30 天下载 3393

structural interface for 42-cent adaptors

原始使用文档
文档目录3 节
  1. Semantic Versioning
  2. BaseGateway API
  3. basegateway#voidTransaction(transactionId[, options])

42-cent-base

Greenkeeper badge

Node.js API abstraction for payment gateways.

Used by supported gateways listed in 42-cent.

Semantic Versioning

It is important to note that the BaseGateway API will follow the semantic versioning rules so that:

  • Any change on already defined property will define a new API and therefore will result on a different first digit of the BaseGateway version
  • New supported parameters/methods will define a new functionality and therefore will result in a different second digit of the BaseGateway version
  • Bug fixes/patches should not impact gateways implementation and will result in a different third digit of the BaseGateway version

BaseGateway API


basegateway(options)


basegateway#submitTransaction(order, creditCard, prospect[, other])

Authorize and capture a transaction.

parameters

order (object)

  • 'amount' (string): The amount of the transaction.

'creditCard' (object)

  • 'creditCardNumber' (string): The credit card (PAN) number.
  • 'expirationMonth' (string): The month of credit card expiration date.
  • 'expirationYear' (string): The year of credit card expiration date (2 or 4 digits).
  • 'cvv' (string): The credit card security code (3 or 4 digits).

prospect (object)

  • 'customerFirstName' (string): First name of the customer (also used for the billing).
  • 'customerLastName' (string): Last name of the customer (also used for the billing).
  • 'customerEmail' (string): Email of the customer.
  • 'billingAddress' (string): Billing address.
  • 'billingCity' (string): Billing City
  • 'billingState' (string): Billing State
  • 'billingZip' (string): Billing Zip
  • 'billingCountry' (string): Billing Country
  • 'shippingFirstName' (string):
  • 'shippingLastName' (string):
  • 'shippingAddress' (string):
  • 'shippingCity' (string):
  • 'shippingState' (string):
  • 'shippingZip' (string):
  • 'shippingCountry' (string):

other (object)

Other fields specific to a gateway SDK implementation.
Refer to specific SDK for more details.

return value

Returns a Promise with the following object as a result:

  • 'transactionId' (string): A unique identifier of the transaction.
  • 'authCode' (string): Authorization code from the banking institution.
  • '_original': The original response from the gateway.

If the promise gets rejected because of the gateway, the reason will be an object instance of GatewayError holding the following attributes:

  • 'message' (string): The error message from the gateway.
  • '_original': The original response from the specific sdk implementation.

Otherwise it will be an instance of Error.


basegateway#authorizeTransaction(order, creditCard, prospect[, other])

Auhtorize a transaction.

parameters

See basegateway#submitTransaction().


basegateway#getSettledBatchList(from, to)

get a batch list of settled transaction within the window of time

parameters

from (Date): Lower limit.

to (Date, default: Date.now()): Upper limit.

return value

Returns a Promise with the following object as a result:

  • 'batchList' (Array): An array of batch where a batch will have the following fields.
    • 'batchId': The id the batch is referenced by in the gateway internal system.
    • 'settlementDate' (string): A string for the settlement date time (UTC).
    • 'chargeAmount' (string): The total amount from the charged transactions during the window of time.
    • 'chargeCount' (string): The total count of charged transactions during the window of time.
    • 'refundAmount' (string): The total amount from the refunded transactions during the window of time.
    • 'refundCount' (string): The total count of refund transactions during the window of time.
    • 'voidCount' (string): The total count of voided transactions during the window of time.
    • 'declineCount' (string): The total count of voided transactions during the window of time.
    • 'errorCount' (string): The total count of voided transactions during the window of time.

basegateway#refundTransaction(transactionId, options)

Refund (or credit) a settled transaction.

parameters

transactionId (string): The id referencing the transaction to refund at the gateway.

options (object): Set of optional fields.

  • 'amount': The amount to be refunded (useful for partial refund).

return value

Returns a Promise with the following object as a result:

  • '_original': The original response from the gateway.

If the promise gets rejected because of the gateway, the reason will be an object instance of GatewayError holding the following attributes:

  • 'message' (string): The error message from the gateway.
  • '_original': The original response from the specific sdk implementation.

Otherwise it will be an instance of Error.


basegateway#voidTransaction(transactionId[, options])

Void a non-settled transaction.

parameters

transactionId (string): The id referencing the transaction to void at the gateway.

options (object): Set of optional fields.

return value

Returns a Promise with the following object as a result:

  • '_original': The original response from the gateway.

If the promise gets rejected because of the gateway, the reason will be an object instance of GatewayError holding the following attributes:

  • 'message' (string): The error message from the gateway.
  • '_original': The original response from the specific sdk implementation.

Otherwise it will be an instance of Error.


basegateway#createSubscription(creditCard, prospect, subscriptionPlan[, other])

Create a recurring payment.

parameters

creditCard: CreditCard | Object, the credit card associated to the payment

prospect: Prospect | Object, the prospect/customer linked to the subscription

subscriptionPlan: SubscriptionPlan | Object, a subscription plan Note that the tuple [periodUnit , periodLength] must result in a period supported by the gateway implementation otherwise periodUnit should take priority

other: Object, a set of options to be used by specific implementations

return value

Returns a Promise with the following object as a result:

  • 'subscriptionId': An id referencing to the subscription at the gateway.
  • '_original': The original response from the gateway.

basegateway#createCustomerProfile(payment, billing, shipping, other)

Create a customer profile in the gateway, useful to charge a customer without having to provide his payment method information again.

parameters

payment: CreditCard | Object, payment info to associate with the customer

billing: Object, billing info to associate with the customer

shipping: Object, shipping info to associate with the customer

other: Object, optional info related to a specific gateway implementation

return value

Returns a Promise with the following object as a result:

  • 'profileId': A reference id to the customer profile.
  • '_original': The original response from the payment gateway.

basegateway#getCustomerProfile(profileId)

Get a previously saved customer profile.

parameters

profileId (string): The id referencing to the customer profile in the gateway.

return value

Returns a Promise with the following object as a result:

if resolved the promise will have the same field than a Prospect instance plus a field payment holding a CreditCard


basegateway#chargeCustomer(order, prospect[, other])

Submit a transaction (authorization and capture) using a customer profile.

parameters

order: Object, order information

prospect: Prospect, the prospect profile to charge, note that the prospect must have the field profileId set

other: Object, optional info related to a specific gateway implementation

return value

See basegateway#submitTransaction().

版本与发布记录

42-cent-base 共发布 14 个版本,首次发布于 2014/09/17;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.1latest2019/07/227 年前
1.0.02015/06/0511 年前
0.9.02014/12/0111 年前
0.8.02014/11/2511 年前
0.7.02014/11/2111 年前
0.6.12014/11/2111 年前

关于 42-cent-base 的常见问题

42-cent-base 是什么?

structural interface for 42-cent adaptors

如何安装 42-cent-base?

在项目目录运行 npm install 42-cent-base,或使用 pnpm add / yarn add / bun add。

42-cent-base 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/42-cent-base 是否存在。

42-cent-base 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

42-cent-base 可以商用吗?

42-cent-base 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

42-cent-base 的下载量有多少?

根据 npm 官方下载统计,42-cent-base 在 2026/10/04 – 2026/11/02 这 30 天内被下载 3,393 次,日均约 113 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

42-cent-base 还在维护吗?

最新版本 1.0.1 发布于 2019/07/22(7 年前);至今共发布 14 个版本,其中过去 12 个月发布了 0 个;首次发布于 2014/09/17。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。