首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Omnipay migs集成

Omnipay migs集成
EN

Stack Overflow用户
提问于 2016-01-05 13:21:23
回答 2查看 1K关注 0票数 1

你好,我在我的项目中使用带有migs集成的万能github。示例代码似乎不起作用。有人能帮我吗?

代码语言:javascript
复制
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。在哪里指定呢?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-01-10 13:34:29

代码语言:javascript
复制
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.');
}
票数 1
EN

Stack Overflow用户

发布于 2016-08-15 23:22:23

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

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

持卡人的Internet浏览器被重定向,以便将事务请求接收到支付服务器以处理事务。处理事务后,持卡人的Internet浏览器将返回到您在交易中指定的网页以及事务响应。接收信息的事务响应处理完成事务。

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

穆雷干杯

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34612747

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档