如何使用Braintree托管字段

时间:2016-03-10 00:44:29

标签: php braintree

所以我在注册表单的顶部有以下代码,并且在表单的末尾是braintrees托管字段。我实际上在某些指南上发现了这段代码,但不记得在哪里,但基本上我不知道在我编写(**dont know what to do here**)的地方放置什么。

有人可以帮忙吗?

require_once 'braintree-php-3.9.0/lib/Braintree.php';

Braintree_Configuration::environment('production');
Braintree_Configuration::merchantId('#');
Braintree_Configuration::publicKey('#');
Braintree_Configuration::privateKey('#');
if(isset($_POST['submit'])){
    /* process transaction */
    $result = Braintree_Transaction::sale(array(
     'amount' => $amount,
     'creditCard' => array(
     'number' => '(**dont know what to do here**)',
     'expirationDate' => '(**dont know what to do here**)'
    )
  ));

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

$clientToken = Braintree_ClientToken::generate();

0 个答案:

没有答案