【发布时间】:2016-01-20 10:43:08
【问题描述】:
我是 Braintree 的新手。我正在使用 Braintree 透明重定向(php SDK)方法进行付款。在这种方法中,我可以使用信用卡成功付款。现在我想在透明重定向中添加贝宝付款。我可以显示如果有人想看我的代码。任何帮助将不胜感激。抱歉英语不好。
<?php
require ('vendor/autoload.php');
require ('settings.php');
$settings['redirectUrl'] .= $_SERVER['SCRIPT_NAME'];
/*
* replace the following with the configuration code from the Braintree Control Panel, which
* will contain your unique API keys
*/
Braintree_Configuration::environment($settings['environment']);
Braintree_Configuration::merchantId($settings['merchantId']);
Braintree_Configuration::publicKey($settings['publicKey']);
Braintree_Configuration::privateKey($settings['privateKey']);
$status = '';
if(isset($_GET['http_status']) && $_GET['http_status'] == '200') {
try {
$result = Braintree_TransparentRedirect::confirm($_SERVER['QUERY_STRING']);
if ($result->success) {
$status = 'Your transaction was processed successfully.';
} else {
$status = $result->message;
}
} catch (Braintree_Exception_NotFound $e) {
$status = 'Due to security reasons, the reload button has been disabled on this page.';
}
}
$tr_data = Braintree_TransparentRedirect::transactionData([
'transaction' => [
'type' => Braintree_Transaction::SALE,
'options' => [
'submitForSettlement' => true
]
],
'redirectUrl' => $settings['redirectUrl']
]);
?>
<body>
<div id="wrap">
<?php if ($status):?>
<div class="status"><?= $status?></div>
<?php endif;?>
<form method="post" action="<?= Braintree_TransparentRedirect::url()?>" autocomplete="off">
<label>Amount: <input type="text" name="transaction[amount]" /></label>
<label>First Name: <input type="text" name="transaction[customer][first_name]"></label>
<label>Last Name: <input type="text" name="transaction[customer][last_name]"></label>
<label>Email: <input type="text" name="transaction[customer][email]"></label>
<label>Phone No.: <input type="text" name="transaction[customer][phone]"></label>
<label>Card Number: <input type="text" name="transaction[credit_card][number]"></label>
<label>CVV: <input type="text" name="transaction[credit_card][cvv]" class="short"></label>
<label>Expiration Date (MM/YYYY): <input type="text" name="transaction[credit_card][expiration_date]" class="short"></label>
<p>----------------------------------------Billing Address------------------------------------</p>
<label>Billing First Name: <input type="text" name="transaction[billing][first_name]"></label>
<label>Billing Last Name: <input type="text" name="transaction[billing][last_name]"></label>
<label>Billing Street Address: <input type="text" name="transaction[billing][street_address]"></label>
<label>Postal Code: <input type="text" name="transaction[billing][postal_code]"></label>
<input type="submit" value="submit payment">
<input type="hidden" name="tr_data" value="<?=$tr_data?>">
</form>
</div>
</body>
【问题讨论】:
-
发布您的代码可能会有用
-
是的,除了排除/屏蔽您的许可证/敏感数据之外,您应该始终发布一些代码示例。
-
@sudhAnsu63 现在你可以看看我的代码了。