问题描述
我正在尝试用 PHP 在我的电子商务中实现 Braintree。
在控制面板中有这 2 个不同的代码,但我不明白如何将它们连接在一起。
- 这是javascript中插入信用卡的部分
<link rel="stylesheet" href="paypal.css">
<!-- partial:index.partial.html -->
<script src="https://js.braintreegateway.com/web/dropin/1.25.0/js/dropin.js"></script>
<div id="dropin-container"></div>
<button id="submit-button" class="button button--small button--green">Acquista</button>
<!-- partial -->
<script src="paypal.js"></script>
- 这是应该从 Braintree 获得答案的 PHP 部分。
<?PHP
use Braintree\Gateway as Gateway;
use Braintree\Transaction as Transaction;
require_once 'braintree/lib/Braintree.PHP';
$gateway = new Braintree\Gateway([
'environment' => 'sandBox','merchantId' => 'xxxxx','publicKey' => 'xxxxx','privateKey' => 'xxxxxx'
]);
// pass $clientToken to your front-end
$clientToken = $gateway->clientToken()->generate([
"customerId" => $aCustomerId
]);
echo($clientToken = $gateway->clientToken()->generate());
$nonceFromTheClient = $_POST["payment_method_nonce"];
echo "<br><br>: " . $nonceFromTheClient . "<br><br>";
$result = $gateway->transaction()->sale([
'amount' => '10.00','paymentMethodNonce' => $nonceFromTheClient,'deviceData' => $deviceDataFromTheClient,'options' => [
'submitForSettlement' => True
]
]);
echo "<pre>";
echo $result;
echo "</pre>";
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)