当我使用 Drop-in UI 创建的“payment_method_nonce”调用 Braintree::Transaction.sale 时,一切正常。但是,当我在 Drop-in UI 中添加一些自定义字段并调用相同的 API 后,我收到错误消息“美国运通卡的 CVV 必须为 4 位,其他卡类型的 CVV 必须为 3 位”。我很确定 CVV 应该是正确的......有人知道这个错误吗?
iOS客户端实现:
internal func tokenizeCreditCard(creditCard: CreditCard, completion: @escaping NerfireAPICompletionBlock) {
// For client authorization,
// get your tokenization key from the control panel
// or fetch a client token
let braintreeClient = BTAPIClient(authorization: <sandbox_token>)!
let cardClient = BTCardClient(apiClient: braintreeClient)
let card = BTCard(number: creditCard.number!, expirationMonth: creditCard.month!, expirationYear: creditCard.year!, cvv: creditCard.verificationValue!)
cardClient.tokenizeCard(card) { (tokenizedCard, error) in
if error != nil {
completion(nil, error as NSError?)
}else {
completion(tokenizedCard, nil)
}
}
}
Ruby服务器端:
result = Braintree::Transaction.sale(
:amount => "15.00",
:payment_method_nonce => nonce_from_the_client,
:options => {
:submit_for_settlement => true
}
)