【发布时间】:2016-10-07 10:52:12
【问题描述】:
有人知道如何将eway支付网关集成到普通的php网站吗?
我已经连接,但是当我在此链接中编写代码时显示错误:https://www.eway.com.au/developers/sdk/php
它显示了下面给出的错误: 错误:eWAY 库在连接到 Rapid 时遇到问题
<?php
require_once 'lib/eway-rapid-php-master/include_eway.php';
// eWAY Credentials
$apiKey = 'F9802AS8MHb/rAm6UyRbT2d5eHjOZWhff++jtFOtMU';
$apiPassword = 'V6E';
$apiEndpoint = 'Sandbox';
// Create the eWAY Client
$client = \Eway\Rapid::createClient($apiKey, $apiPassword, $apiEndpoint);
// Transaction details - these would usually come from the application
$transaction = [
'Customer' => [
'FirstName' => 'John',
'LastName' => 'Smith',
'Street1' => 'Level 5',
'Street2' => '369 Queen Street',
'City' => 'Sydney',
'State' => 'NSW',
'PostalCode' => '2000',
'Country' => 'au',
'Email' => 'demo@example.org',
],
// These should be set to your actual website (on HTTPS of course)
'RedirectUrl' => "http://$_SERVER[HTTP_HOST]" . dirname($_SERVER['REQUEST_URI']) . '/response.php',
'CancelUrl' => "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]",
'TransactionType' => \Eway\Rapid\Enum\TransactionType::PURCHASE,
'Payment' => [
'TotalAmount' => 1000,
]
];
// Submit data to eWAY to get a Shared Page URL
$response = $client->createTransaction(\Eway\Rapid\Enum\ApiMethod::RESPONSIVE_SHARED, $transaction);
// Check for any errors
if (!$response->getErrors()) {
$sharedURL = $response->SharedPaymentUrl;
} else {
foreach ($response->getErrors() as $error) {
echo "Error: ".\Eway\Rapid::getMessage($error)."<br>";
}
die();
}
echo '<a href="'.$sharedURL.'">Pay with our secure payment page</a>';
?>
我已经编写了如上所示的代码。
【问题讨论】:
-
这是一个很好的起点。eway.com.au/developers/sdk/php 但您需要检查您发送的 api 详细信息。我认为这是错误
-
api详细信息正确..
-
您似乎遇到了连接问题。您可以尝试按照this Gist 中的说明启用日志记录以获取根本错误 - documented here。
标签: php