braintree使用测试信用卡进行3D安全交易

时间:2018-06-09 18:44:35

标签: php braintree braintree-sandbox

我正在尝试在braintree沙箱中实施3D安全支付,但是收到此错误并且无法弄清楚代码有什么问题。

是否可以使用测试信用卡进行3D安全交易。

如果响应有错误,如何显示错误

查找回复:

{"paymentMethod":{"type":"CreditCard","nonce":"5b721a96-8db5-07ba-55b1-d6546239d2b9","description":"ending in 11","isLocked":false,"securityQuestions":["cvv"],"details":{"cardType":"MasterCard","lastTwo":"11","lastFour":"0011"},"threeDSecureInfo":{"liabilityShifted":false,"liabilityShiftPossible":false,"status":"authentication_unavailable","enrolled":"U"},"consumed":false,"default":false,"hasSubscription":false,"binData":{"prepaid":"Unknown","healthcare":"Unknown","debit":"Unknown","durbinRegulated":"Unknown","commercial":"Unknown","payroll":"Unknown","issuingBank":"Unknown","countryOfIssuance":"Unknown","productId":"Unknown"}},"threeDSecureInfo":{"liabilityShifted":false,"liabilityShiftPossible":false},"lookup":{"acsUrl":null,"md":"tf6v87wpjpwtdydgbm","termUrl":"https://api.sandbox.braintreegateway.com:443/merchants/jd8k25qkwvyhngp2/client_api/v1/payment_methods/5b721a96-8db5-07ba-55b1-d6546239d2b9/three_d_secure/authenticate?authorization_fingerprint=15ed71ef406740a812f5e8ccca7302f2ffebd7ded88685faaadd287ef2b118e1%7Ccreated_at%3D2018-06-09T18%3A03%3A23.177132032%2B0000%26customer_id%3Dcustomer_4%26merchant_id%3Djd8k25qkwvyhngp2%26public_key%3Dzm5kmgjkx2hbyn3r\u0026authorization_fingerprint_64=MTVlZDcxZWY0MDY3NDBhODEyZjVlOGNjY2E3MzAyZjJmZmViZDdkZWQ4ODY4NWZhYWFkZDI4N2VmMmIxMThlMXxjcmVhdGVkX2F0PTIwMTgtMDYtMDlUMTg6MDM6MjMuMTc3MTMyMDMyKzAwMDAmY3VzdG9tZXJfaWQ9Y3VzdG9tZXJfNCZtZXJjaGFudF9pZD1qZDhrMjVxa3d2eWhuZ3AyJnB1YmxpY19rZXk9em01a21namt4MmhieW4zcg%3D%3D","pareq":null}}

我的代码:

<script src="{{ URL::asset('theme/js/jquery.min.js') }}"></script>    
<script src="https://js.braintreegateway.com/web/3.34.0/js/client.min.js"></script>    
<!-- Load the 3D Secure component. -->
<script src="https://js.braintreegateway.com/web/3.34.0/js/three-d-secure.min.js"></script>    
<script type="text/javascript">
        function showCardDetail(id){
    $('#card-detail').hide();
    if(id==3){
      $('#card-detail').show();
          }
     }
       $("#paymentForm").submit(function(e) {
         var paymentMethod = $("input[name='payment_method']:checked").val();
         if(paymentMethod==3){
           var holderName = $('#holderName').val();
        var holderCreditCardNumber = $('#holderCreditCardNumber').val();
        var customer_credit_card_expiration_date = $('#customer_credit_card_expiration_date').val();
        var customer_credit_card_cvv = $('#customer_credit_card_cvv').val();
         $.get( "{{ route('ajaxGenerateNonce')}}",{ 
        holderName:holderName, 
        holderCreditCardNumber:holderCreditCardNumber, 
customer_credit_card_expiration_date:customer_credit_card_expiration_date, 
        customer_credit_card_cvv:customer_credit_card_cvv}, function(data) {

        console.log(data.clientToken);
        console.log(data.nonce);
        braintree.client.create({
          // Use the generated client token to instantiate the Braintree client.
          authorization: data.clientToken
        }, function (clientErr, clientInstance) {
          if (clientErr) {
            return;
          }
          braintree.threeDSecure.create({
            client: clientInstance
          }, function (threeDSecureErr, threeDSecureInstance) {
            if (threeDSecureErr) {
              return;
            }
            verifyCard(threeDSecureInstance,data );
          });
        });         
      });
        e.preventDefault();
      }  
    })
function verifyCard(threeDSecure, data){
var my3DSContainer = document.createElement('div');  
        threeDSecure.verifyCard({amount: '500.00',nonce: data.nonce,
          addFrame: function (err, iframe) {
            my3DSContainer.appendChild(iframe);
            document.body.appendChild(my3DSContainer);
          },
          removeFrame: function () {
            // Remove UI that you added in addFrame.
            document.body.removeChild(my3DSContainer);
          }
        }, function (err, response) {
            console.log(response);
              // Send response.nonce to use in your transaction
        });
    }
    </script>

1 个答案:

答案 0 :(得分:2)

根据您提供的查找响应,您看起来并不像使用3D安全专用测试卡。我建议使用此Cardinal Consumer Authentication Test Cases Guide在沙盒环境中测试3D Secure。

要在出现错误时显示错误,我建议将它们记录到您的控制台。目前,如果在任何级别发生错误,您都可以将代码设置为返回。您可以更新它以使用以下内容记录错误:

if (clientErr) {
  console.error(clientErr);
  return;
}

您可以针对包含的每个错误实例执行此操作,例如threeDSecureErr。如果您仍然遇到问题,请随时通过support@braintreepayments.com与支持小组联系。