【发布时间】:2016-04-09 08:10:18
【问题描述】:
您好,我在我的项目中使用了带有 migs 集成的 omnipay github lib。示例代码似乎不起作用。谁能帮我解决这个问题?
require_once 'vendor/autoload.php';
use \Omnipay\Omnipay as omnipay;
$gateway = Omnipay::create('Migs_ThreeParty');
$gateway->setMerchantId('foo');
$gateway->setMerchantAccessCode('foo');
$gateway->setSecureHash('foo');
try {
$response = $gateway->purchase(array('amount' => '0.00', 'currency' => 'AED', 'returnURL' => 'www.google.com.pk'))->send();
if ($response->isRedirect()) {
// redirect to offsite payment gateway
$response->redirect();
//$url = $response->getRedirectUrl();
//$data = $response->getRedirectData();
} else {
// payment failed: display message to customer
echo $response->getMessage();
}
} catch (\Exception $e) {
// internal error, log exception and display a generic message to the customer
exit('Sorry, there was an error processing your payment. Please try again later.');
}
"$gateway->setSecureHash" == "$SECURE_SECRET" 是否如示例链接http://integrate-payment-gateway.blogspot.in/2012/01/migs-payment-gateway-integration-php.html 中所示
上面的代码要求redirectUrl和transactionId。在哪里指定?
【问题讨论】:
-
“示例代码似乎不起作用”是什么意思?有错误信息吗?
-
是的 php 给出了致命错误,并且消息说要提供 returnURL。如何在上面的示例中提供它?此外,它还要求提供 transactionId。我不知道在哪里可以找到并提供。是的,示例代码取自 github。
-
我不会使用 $response->redirect() 方法。你如何进行重定向取决于你使用的框架——他们中的一些人更喜欢你创建一个重定向对象并从你的控制器中返回它,而另一些人则以非常不同的方式实现它。我要做的是使用 $response->getRedirectUrl() 获取重定向 URL,并使用框架的常用方法重定向到该 URL。
-
我问过的问题是代码没有执行,因为它要求提供returnURL和transactionId。你能提供它的任何工作样本吗?
-
这里没有人帮忙吗?