繁体   English   中英

Braintree与Paypal自定义集成

[英]braintree custom integration with paypal

我是Braintree付款网关的新手。 即时通讯使用自定义集成进行付款。我使用信用卡成功完成了付款。但是我有两个问题,我也想在表格中添加我选择的金额。

1)我想在表单中添加更多字段,例如客户名,地址,电话号码,电子邮件我不知道如何在托管字段中添加更多字段。

2)老实说,我不知道如何在braintree中配置贝宝。即使braintree说“默认情况下,沙箱中启用了PayPal”。 当我单击贝宝按钮时,它显示类似“抱歉,我们无法连接到贝宝。请在几分钟后重试。”

我在印度创建了我的沙盒帐户。也许Paypal不允许来自印度的Paypal付款。

    <?php 
require ('vendor/autoload.php');
$clientToken = Braintree_ClientToken::generate();
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Checkout</title>
  </head>
  <body>
    <form action="#" id="my-sample-form">
    <div id="paypal-container"></div>
      <label for="card-number">Card Number</label>
      <div id="card-number"></div>

      <label for="cvv">CVV</label>
      <div id="cvv"></div>

      <label for="expiration-date">Expiration Date</label>
      <div id="expiration-date"></div>

      <input type="submit" value="Pay" />
    </form>

    <script src="https://js.braintreegateway.com/v2/braintree.js"></script>
    <script>
      braintree.setup("<?php echo   $clientToken; ?>", "custom", {
        id: "my-sample-form",
        hostedFields: {
          number: {
            selector: "#card-number"
          },
          cvv: {
            selector: "#cvv"
          },
          expirationDate: {
            selector: "#expiration-date"
          }
        },
        paypal: {
      container: "paypal-container",
    },
    onPaymentMethodReceived: function (obj) {
      window.location.href = 'http://localhost/braintreecustom/payment.php?payment_method_nonce='+obj.nonce;
    },
    onError: function (){

        alert('wrong details');
    }
      });
    </script>
  </body>
</html>

这是payment.php的代码

<?php
require ('vendor/autoload.php');


  $nonce = $_GET["payment_method_nonce"];


  $result = Braintree_Transaction::sale([
    'amount' => '700.00', // Your amount goes here
    'paymentMethodNonce' => $nonce
  ]);

  ?>

全面披露:我在Braintree工作。 如果您还有其他疑问,请随时与支持小组联系

1)要添加其他字段,您需要做的就是将输入字段添加到表单中,并以与托管字段输入相同的方式对它们进行样式设置。 提交表单时,您可以将这些值捕获为普通表单输入。

<form action="#" id="my-sample-form">
  <div id="paypal-container"></div>
  <label for="card-number">Card Number</label>
  <div id="card-number"></div>

  <label for="cvv">CVV</label>
  <div id="cvv"></div>

  <label for="expiration-date">Expiration Date</label>
  <div id="expiration-date"></div>

  <label for="another-field">Another Field</label>
  <input type="text" id="another-field" name="another-field" />

  <input type="submit" value="Pay" />
</form>

这是服务器代码

<?php
require('vendor/autoload.php');

$nonce = $_GET["payment_method_nonce"];
$anotherField = $_GET["another-fild"];
// do something with fields

2)根据给定的信息,我不确定您的PayPal配置出了什么问题。 我建议联系Braintree支持,以便他们可以帮助您解决问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM