有人使用 Braintree 进行基于代币的交易吗?

发布于 2024-10-02 04:46:09 字数 1926 浏览 7 评论 0原文

我试图了解如何使用 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' => '[email protected]',
      '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());
  }


?>

i am trying to understand how to use braintree but their documents are becomeing hard to understand after all the errors that i am receiving.

what i am trying to do is submit customer billing information + credit card information to then receive a token so that i can store it in a db.

this is what i wrote and i am getting errors.

<?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' => '[email protected]',
      '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());
  }


?>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

允世 2024-10-09 04:46:09

只需删除行 'countryCodeAlpha2' =>; “US”并且您的代码将起作用。
另一件事是,结果没有您正在使用的事务对象,例如“$result->transaction->id”。

Just remove the line 'countryCodeAlpha2' => 'US' and your code will work.
One thing more the result does not have transaction object which you are using like '$result->transaction->id'.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文