Apple Pay 支付令牌示例
Apple Pay Payment Token Example
我如何才能以某种方式获取 Apple Pay 支付令牌 (as described here) 的示例,而无需使用 Apple 设备实际向 Apple 请求付款?
我正在创建一个端点,该端点将完全按照在请求 Apple 付款的设备上收到的 Apple Pay 支付令牌来接受。但是,它是一个二进制数据,因此必须将其解码为我假设的正常 json 对象。 json 对象的 format/structure 是什么?
从 Checkout.com 关于 Apple Pay 的文档 (here) 我假设解码后的 json 对象看起来像这样(尽管他们将其标记为 "example", 所以我不能确定):
{
"type": "applepay",
"token_data": {
"version": "EC_v1",
"data": "t7GeajLB9skXB...",
"signature": "MIAGCSqGSIb3DQEHAq...",
"header": {
"ephemeralPublicKey": "MFkwEwYHKoZIzj...",
"publicKeyHash": "tqYV+tmG9aMh+l/K6cicU...",
"transactionId": "3cee89679130a4b2617c..."
}
}
}
请注意,为简洁起见,以上字段中的数据已缩短。
Apple 向设备发送请求付款的具体内容是什么object/data?
如有任何帮助,我们将不胜感激!
我已经弄清楚 Apple 发送的支付令牌是什么。
Apple 发送了一个二进制数据 (PKPaymentToken
),可以将其解码为 json。 json 对象如下所示:
{
"data":"...",
"signature":"...",
"version":"..",
"header":{
"applicationData":"...",
"ephemeralPublicKey":"...",
"wrappedKey":"...",
"publicKeyHash":"...",
"transactionId":"..."
}
}
因此,使用支付令牌首先需要将二进制数据解码为 json,然后可以将其发送给商家(如 Checkout 或 Stripe)。需要注意的是,json 对象中的一些字段是加密的。它们可以未加密或加密使用。 Checkout, for instance, accepts the encrypted fields.
令牌
data: payment data dictionary, Base64 encoded as a string
header: header dictionary
signature: detached PKCS #7 signature, Base64 encoded as string
version: string
页眉
applicationData: SHA–256 hash, hex encoded as a string
ephemeralPublicKey: X.509 encoded key bytes, Base64 encoded as a string
wrappedKey: A Base64 encoded string
publicKeyHash: SHA–256 hash, Base64 encoded as a string
transactionId: A hexadecimal identifier, as a string
更多 information/detail 可以在 the Apple documentation 中找到。