我的(沙盒)结帐时有以下代码: (为简洁起见,我省略了初始变量声明)
require_once("braintree/braintree_init.php");
$nonceFromTheClient = 'fake-gateway-rejected-fraud-nonce';
$result = Braintree_Customer::create([
'id' => $userId,
'firstName' => $firstName,
'lastName' => $lastName,
'email' => $email,
'paymentMethodNonce' => $nonceFromTheClient,
'creditCard' => [
'billingAddress' => [
'streetAddress' => $billingAddress,
'locality' => $billingCity,
'region' => $billingState,
'postalCode' => $billingZip
]
]
]);
if ($result->success) {
echo "create: success";
$token = $result->customer->paymentMethods[0]->token;
} else {
echo "create: fail";
foreach($result->errors->deepAll() AS $error) {
echo($error->code . ": " . $error->message . "\n");
}
$verification = $result->creditCardVerification;
echo $verification->status;
echo $verification->processorResponseCode;
echo $verification->processorResponseText;
echo $verification->gatewayRejectionReason;
$verificationError = "There was a problem processing your credit card; please double check your payment information and try again.";
return false;
}
$result = Braintree_Subscription::create([
'paymentMethodToken' => $token,
'planId' => $subId
]);
if ($result->success) {
$subscriptionId = $result->subscription->id;
header("Location: transaction.php?i=".$subscriptionId."");
} else {
foreach($result->errors->deepAll() AS $error) {
echo($error->code . ": " . $error->message . "\n");
}
}
我正在尝试让卡验证失败。我已在控制面板中为所有卡启用了验证。当我使用提供的$ nonceFromTheClient ='fake-gateway-rejected-fraud-nonce'时,客户创建仍然成功。
如果我使用不成功的信用卡验证列表中的卡号4000111111111115,它仍然是成功的,但我承认我不清楚卡号应该使用什么nonce。
如果我使用'fake-processor-decline-visa-nonce',它会失败(如预期的那样)。
所以我不确定为什么卡片验证在前两次尝试中仍然成功?
答案 0 :(得分:0)
完全披露:我在Braintree工作。如果您有任何其他问题,请随时联系我们的support team。
Credit cards are not verified by default在我们的网关中被保存时。您必须将verifyCard
选项设置为true
才能验证该卡。
$result = Braintree_Customer::create([
'firstName' => 'Fred',
'lastName' => 'Jones',
'creditCard' => [
'paymentMethodNonce' => nonceFromTheClient,
'options' => [
'verifyCard' => true
]
]
]);
The testing section我们的文档进一步详细说明了我们的假测试符号的使用。