Apple Pay(Optional)

Apple Pay 采用两步调用:

  1. 先创建订单并获取 applePayParams
  2. 用户完成 Apple Pay 授权后,再提交 token 完成支付

创建 Apple Pay 订单

Endpoint
POST {BASE_URL}/api/v2.0/payments/apple-pay/preOrder

创建 Apple Pay 订单,并返回客户端拉起 Apple Pay 所需的支付参数。

Request Body
paymentRequestIdstringREQUIRED

商户的订单ID

merchantIdentifierstring

Apple Pay 商户标识 (Optional)

orderobjectREQUIRED

订单信息

隐藏子字段
order.orderAmountobjectREQUIRED

订单金额

隐藏子字段
order.orderAmount.valuestringREQUIRED

订单金额值,单位为货币最小单位,例如传入100表示1.00CAD

order.orderAmount.currencystringREQUIRED

订单币种,允许值:CAD

order.descriptionstringREQUIRED

订单描述 <= 128 characters

order.notifyUrlstring

支付通知URL (Optional)

Apple Pay PreOrder Request Body
{
  "paymentRequestId": "string",
  "merchantIdentifier": "merchant.com.example.applepay",
  "order": {
    "orderAmount": {
      "value": "1",
      "currency": "CAD"
    },
    "description": "Apple Pay 测试订单",
    "notifyUrl": "https://www.example.com/notify"
  }
}

Response (200 OK)
paymentRequestIdstring

商户的订单ID

paymentIdstring

AlphaPay平台订单ID

paymentCreateTimestring <date-time>

订单创建时间

paymentExpireTimestring <date-time>

订单超时时间

applePayParamsobject

客户端拉起 Apple Pay 所需的支付参数

隐藏子字段
applePayParams.orderIdstring

AlphaPay平台订单ID

applePayParams.merchantIdentifierstring

Apple Pay 商户标识

applePayParams.countryCodestring

国家代码

applePayParams.currencyCodestring

币种代码

applePayParams.labelstring

商户展示名称

applePayParams.amountstring

十进制格式的支付金额

applePayParams.supportedNetworksarray[string]

支持的卡组织

applePayParams.merchantCapabilitiesarray[string]

Apple Pay 商户能力

resultobject

业务结果

隐藏子字段
result.resultCodestring

业务结果码,通常为 PAYMENT_IN_PROCESS

result.resultMessagestring

业务结果消息

result.resultStatusstring

业务结果状态

  • U:订单已创建,等待 Apple Pay 授权
  • F:接口调用失败
Apple Pay PreOrder Response
{
  "paymentRequestId": "string",
  "paymentId": "string",
  "paymentCreateTime": "2019-08-24T14:15:22Z",
  "paymentExpireTime": "2019-08-24T14:45:22Z",
  "applePayParams": {
    "orderId": "string",
    "merchantIdentifier": "merchant.com.example.applepay",
    "countryCode": "CA",
    "currencyCode": "CAD",
    "label": "Demo Merchant",
    "amount": "0.01",
    "supportedNetworks": ["visa", "masterCard", "amex"],
    "merchantCapabilities": ["supports3DS", "supportsCredit", "supportsDebit"]
  },
  "result": {
    "resultCode": "PAYMENT_IN_PROCESS",
    "resultMessage": "string",
    "resultStatus": "U"
  }
}

提交 Apple Pay Token

Endpoint
POST {BASE_URL}/api/v2.0/payments/apple-pay/pay

用户完成 Apple Pay 授权后,提交 Apple Pay token 发起支付。

Request Body
paymentIdstringREQUIRED

AlphaPay平台订单ID

customerIdstring

用户ID (Optional)

tokenobjectREQUIRED

Apple Pay 支付 token

隐藏子字段
token.transactionIdentifierstring

Apple Pay 交易标识 (Optional)

token.paymentMethodobject

Apple Pay 支付方式 (Optional)

隐藏子字段
token.paymentMethod.displayNamestring

展示名称 (Optional)

token.paymentMethod.networkstring

卡组织 (Optional)

token.paymentMethod.typestring

卡类型 (Optional)

token.paymentDataobjectREQUIRED

Apple Pay 加密载荷

隐藏子字段
token.paymentData.versionstringREQUIRED

Apple Pay 载荷版本

token.paymentData.datastringREQUIRED

加密载荷数据

token.paymentData.signaturestringREQUIRED

Apple Pay 签名

token.paymentData.headerobjectREQUIRED

Apple Pay 载荷头信息

隐藏子字段
token.paymentData.header.publicKeyHashstringREQUIRED

公钥哈希

token.paymentData.header.ephemeralPublicKeystringREQUIRED

临时公钥

token.paymentData.header.transactionIdstring

交易ID (Optional)

Apple Pay Pay Request Body
{
  "paymentId": "string",
  "customerId": "string",
  "token": {
    "transactionIdentifier": "string",
    "paymentMethod": {
      "displayName": "Visa 1234",
      "network": "Visa",
      "type": "debit"
    },
    "paymentData": {
      "version": "EC_v1",
      "data": "string",
      "signature": "string",
      "header": {
        "publicKeyHash": "string",
        "ephemeralPublicKey": "string",
        "transactionId": "string"
      }
    }
  }
}

Response (200 OK)
paymentRequestIdstring

商户的订单ID

paymentIdstring

AlphaPay平台订单ID

paymentStatusstring

支付状态,允许值:SUCCESS FAILED PARTIAL_REFUND FULL_REFUND

paymentTimestring <date-time>

支付完成时间

transactionIdstring

渠道交易号

resultobject

业务结果

隐藏子字段
result.resultCodestring

业务结果码

result.resultMessagestring

业务结果消息

result.resultStatusstring

业务结果状态

  • S:支付成功
  • F:支付失败
Apple Pay Pay Response
{
  "paymentRequestId": "string",
  "paymentId": "string",
  "paymentStatus": "SUCCESS",
  "paymentTime": "2019-08-24T14:16:22Z",
  "transactionId": "string",
  "result": {
    "resultCode": "SUCCESS",
    "resultMessage": "string",
    "resultStatus": "S"
  }
}