Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 有人使用braintree进行基于令牌的交易吗?_Php_Token_Braintree - Fatal编程技术网

Php 有人使用braintree进行基于令牌的交易吗?

Php 有人使用braintree进行基于令牌的交易吗?,php,token,braintree,Php,Token,Braintree,我试图理解如何使用braintree,但在我收到所有错误后,他们的文档变得很难理解 我试图做的是提交客户账单信息+信用卡信息,然后接收令牌,以便将其存储在数据库中 这是我写的,我得到了错误 <?php include_once("lib/Braintree.php"); //braintree library include_once("config.php"); //the Braintree_Configurations $result = Braintree_Cus

我试图理解如何使用braintree,但在我收到所有错误后,他们的文档变得很难理解

我试图做的是提交客户账单信息+信用卡信息,然后接收令牌,以便将其存储在数据库中

这是我写的,我得到了错误

<?php
  include_once("lib/Braintree.php"); //braintree library
  include_once("config.php"); //the Braintree_Configurations



  $result = Braintree_Customer::create(array(
      'firstName' => 'Mike',
      'lastName' => 'Jones',
      'company' => 'Jones Co.',
      'email' => 'mike.jones@example.com',
      'phone' => '419.555.1234',
      'fax' => '419.555.1235',
      'website' => 'http://example.com',
      'creditCard' => array(
          'number' => '5105105105105100',
          'expirationDate' => '05/12',
          'cvv' => '123',
          'cardholderName' => 'Mike Jones',
          'billingAddress' => array(
              'firstName' => 'Drew',
              'lastName' => 'Smith',
              'company' => 'Smith Co.',
              'streetAddress' => '1 E Main St',
              'extendedAddress' => 'Suite 101',
              'locality' => 'Chicago',
              'region' => 'IL',
              'postalCode' => '60622',
              'countryCodeAlpha2' => 'US'
          )
      )
  ));






  if ($result->success) {
      print_r("success!: " . $result->transaction->id);
  } else if ($result->transaction) {
      print_r("Error processing transaction:");
      print_r("\n  message: " . $result->message);
      print_r("\n  code: " . $result->transaction->processorResponseCode);
      print_r("\n  text: " . $result->transaction->processorResponseText);
  } else {
      print_r("Message: " . $result->message);
      print_r("\nValidation errors: \n");
      print_r($result->errors->deepAll());
  }


?>

只需删除“countryCodeAlpha2”=>“US”一行,您的代码就可以工作了。 还有一件事,结果没有您正在使用的事务对象,如“$result->transaction->id”