如何在我的 Joomla 网站上打印 eWAY PayNow 按钮响应
How to print eWAY PayNow button response on my Joomla site
我在我的 Joomla 网站上使用 eWAY PayNow 按钮。我需要在继续付款后捕获响应消息,并希望在我的 Joomla 网站上显示该消息。这是 eWAY PayNow 按钮脚本。如何捕获和查看响应消息???
我把这个放在 Joomla ChronoForms 里了。
<script src="https://secure.ewaypayments.com/scripts/eCrypt.js"
class="eway-paynow-button"
data-publicapikey="epk-CCEEEFDB-13FC-4094-BA0B-1F0B96B9D13C"
data-amount="0"
data-currency="AUD" data-resulturl="http://
www.mysite.com/responseMsg.php">
</script>
由于您使用的是 data-resulturl
参数,一旦交易完成,用户将被重定向到您指定的页面(在您的示例中是 http://
www.mysite.com/responseMsg.php
)。在此页面上,将向查询字符串添加一个 AccessCode - 这可用于获取交易结果。
因此您可以像使用任何查询变量一样在代码中使用 AccessCode:$_GET['AccessCode']
。
您可以使用eWAY's Transaction Query API获取交易结果。这样做的一个例子如下:
<?php
// eWAY API key & Password
$api_key = '60CF3Ce97nRS1Z1Wp5m9kMmzHHEh8Rkuj31QCtVxjPWGYA9FymyqsK0Enm1P6mHJf0THbR';
$api_password = 'API-P4ss';
$ch = curl_init();
// Note: using the Sandbox API endpoint
curl_setopt($ch, CURLOPT_URL, 'https://api.sandbox.ewaypayments.com/Transaction/'.$_GET['AccessCode']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $api_key . ":" . $api_password);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$output = curl_exec($ch);
curl_close($ch);
$result = json_decode($output);
if ($result->Transactions[0]->TransactionStatus) {
echo "Transaction successful";
} else {
echo "Transaction declined";
}
我在我的 Joomla 网站上使用 eWAY PayNow 按钮。我需要在继续付款后捕获响应消息,并希望在我的 Joomla 网站上显示该消息。这是 eWAY PayNow 按钮脚本。如何捕获和查看响应消息???
我把这个放在 Joomla ChronoForms 里了。
<script src="https://secure.ewaypayments.com/scripts/eCrypt.js"
class="eway-paynow-button"
data-publicapikey="epk-CCEEEFDB-13FC-4094-BA0B-1F0B96B9D13C"
data-amount="0"
data-currency="AUD" data-resulturl="http://
www.mysite.com/responseMsg.php">
</script>
由于您使用的是 data-resulturl
参数,一旦交易完成,用户将被重定向到您指定的页面(在您的示例中是 http://
www.mysite.com/responseMsg.php
)。在此页面上,将向查询字符串添加一个 AccessCode - 这可用于获取交易结果。
因此您可以像使用任何查询变量一样在代码中使用 AccessCode:$_GET['AccessCode']
。
您可以使用eWAY's Transaction Query API获取交易结果。这样做的一个例子如下:
<?php
// eWAY API key & Password
$api_key = '60CF3Ce97nRS1Z1Wp5m9kMmzHHEh8Rkuj31QCtVxjPWGYA9FymyqsK0Enm1P6mHJf0THbR';
$api_password = 'API-P4ss';
$ch = curl_init();
// Note: using the Sandbox API endpoint
curl_setopt($ch, CURLOPT_URL, 'https://api.sandbox.ewaypayments.com/Transaction/'.$_GET['AccessCode']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $api_key . ":" . $api_password);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$output = curl_exec($ch);
curl_close($ch);
$result = json_decode($output);
if ($result->Transactions[0]->TransactionStatus) {
echo "Transaction successful";
} else {
echo "Transaction declined";
}