Omnipay 迁移集成

Omnipay migs integration

您好,我在我的项目中使用 omnipay github 库和 migs 集成。示例代码似乎不起作用。谁能帮我解决这个问题?

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”是否如示例所示linkhttp://integrate-payment-gateway.blogspot.in/2012/01/migs-payment-gateway-integration-php.html

以上代码请求 redirectUrl 和 transactionId。在哪里指定?

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.');
}

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

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

The cardholder's Internet browser is redirected to take the Transaction Request to the Payment Server to process the transaction. After processing the transaction, the cardholder's Internet browser is returned to a web page that you nominate in the transaction together with a Transaction Response. The Transaction Response processing of the receipt information completes the transaction.

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

干杯 默里