42-cent-base 中文文档教程

发布于 5年前 浏览 31 项目主页 更新于 3年前

42-cent-base

Greenkeeper 徽章< /a>

支付网关的 Node.js API 抽象。

42-cent 中列出的受支持网关使用。

Semantic Versioning

请务必注意,BaseGateway API 将遵循语义版本控制规则,以便:

  • 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])

授权和捕获交易。

parameters

订单 (对象)

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

'creditCard' (对象)

  • '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).

前景 ( 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)

特定于网关 SDK 实现的其他字段。
有关更多详细信息,请参阅特定的 SDK。

return value

结果返回具有以下对象的 Promise

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

如果 promise 由于网关而被拒绝,原因将是 GatewayError 的 object 实例,其中包含以下属性:

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

否则它将是 Error 的实例。


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

授权交易。

parameters

请参阅 basegateway#submitTransaction()


basegateway#getSettledBatchList(from, to)

获取from(Date)时间窗口内的结算交易批次列表

parameters

:下限。

(日期,默认值:Date.now():上限。

return value

结果返回具有以下对象的 Promise

  • '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)

退款(或贷记)已结算交易。

parameters

transactionId (string):在网关处引用要退款的交易的 ID。

options (object):可选字段集。

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

return value

结果返回具有以下对象的 Promise

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

如果 promise 由于网关而被拒绝,原因将是 GatewayError 的 object 实例,其中包含以下属性:

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

否则它将是 Error 的实例。


basegateway#voidTransaction(transactionId[, options])

作废未结算的交易。

parameters

transactionId (字符串):引用要在网关处作废的事务的 ID。

options (object):可选字段集。

return value

结果返回具有以下对象的 Promise

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

如果 promise 由于网关而被拒绝,原因将是 GatewayError 的 object 实例,其中包含以下属性:

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

否则它将是 Error 的实例。


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

创建定期付款。

parameters

信用卡:信用卡 | 关联的信用卡

对象,与支付前景 :Prospect | 对象,链接到订阅

subscriptionPlan 的潜在客户/客户:SubscriptionPlan | 对象,订阅计划 请注意,元组 [periodUnit , periodLength] 必须导致网关实现支持的周期,否则 periodUnit 应优先

other: 对象,一组由特定实现使用的选项

return value

返回一个 Promise 结果为以下对象:

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

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

在网关中创建客户配置文件,用于向客户收费而无需再次提供其付款方式信息。

parameters

付款方式:信用卡 | 对象,与客户关联的付款信息

账单:对象,与客户关联的账单信息

运费:对象,与客户关联的运费信息

其他< /strong>:对象,与特定网关实现相关的可选信息

return value

返回一个 Promise,结果是以下对象:

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

basegateway#getCustomerProfile(profileId)

获取以前保存的客户资料.

parameters

profileId (string):引用网关中客户资料的 ID。

return value

结果返回具有以下对象的 Promise

如果已解决,promise 将具有与 Prospect 实例相同的字段加上一个字段 payment 持有 CreditCard


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

使用客户资料提交交易(授权和获取)。

parameters

order: Object,订单信息

prospect: Prospect,要收费的前景profile,注意,prospect必须设置字段profileId

other: Object ,与特定网关实现相关的可选信息

return value

参见 basegateway#submitTransaction()

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 <b>basegateway#submitTransaction()</b>.


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 <b>basegateway#submitTransaction()</b>.

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文