【问题标题】:Omnipay migs integrationOmnipay Migs 集成
【发布时间】: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。你能提供它的任何工作样本吗?
  • 这里没有人帮忙吗?

标签: php omnipay


【解决方案1】:
require_once 'vendor/autoload.php';

use \Omnipay\Omnipay as omnipay;

$gateway = Omnipay::create('Migs_ThreeParty');
$gateway->setMerchantId('MerchantId');
$gateway->setMerchantAccessCode('MerchantAccessCode');
$gateway->setSecureHash('SecureHash');

try {
    $response = $gateway->purchase(array(
        'amount' => '10.00', // amount should be greater than zero
        'currency' => 'AED',
        'transactionId' => 'refnodata', // replace this for your reference # such as invoice reference #
        'returnURL' => 'http://yourdomain.com/returnPage.php'))->send();

    if ($response->isRedirect()) {
        $url = $response->getRedirectUrl(); // do whatever with the return url
    } 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
    echo $e;
    exit('Sorry, there was an error processing your payment. Please try again later.');
}

【讨论】:

  • @Mohammad_Sharaf 您的解决方案工作正常,但在万事达卡的界面中,金额是 100 的倍数。您能帮我解决这个问题
  • 尝试'amount' => $amount * 100;因为 migs 接受整数数量。
【解决方案2】:

我也有同样的问题,returnURL 是关于什么的? 答案是 Migs_TwoParty 和 Migs_ThreeParty 方法之间的区别。

Migs_ThreeParty 将控制权传递给支付提供商,并在处理付款时将控制权传递回您的网站。文档是这样说的:

持卡人的互联网浏览器被重定向到 向支付服务器发出交易请求以处理交易。 处理完交易后,持卡人的互联网浏览器是 返回到您在交易中一起指定的网页 带有事务响应。事务响应处理 收据信息完成交易。

如果您想自己完成与网关的所有接口,您应该使用 Migs_TwoParty 方法。则不需要 returnURL。

干杯 穆雷

【讨论】:

  • 我同意。我发布的代码适用于需要提供 returnUrl 和 transactionId 的 2 方。在挣扎了很多小时后,我设法使代码按预期工作。谢谢:-)
  • @MohammadSharafAli 能不能和我们分享一下最终的代码结果...thnx
  • 我只实现过 MIGS_TwoParty,几年前我们搬到 Payway 时,该代码现已被替换。
猜你喜欢
  • 2014-10-01
  • 2015-03-19
  • 1970-01-01
  • 2018-06-17
  • 2014-03-28
  • 2016-07-14
  • 2014-01-12
  • 2023-04-08
  • 1970-01-01
相关资源
最近更新 更多