0

このチュートリアルhttp://www.junaidbhura.com/how-to-make-a-custom-magento-payment-extension-for-an-external-の多くの助けを借りて、magento のカスタム支払いソリューションの統合に成功しました。ゲートウェイ/

支払いが成功したかどうかをウェブサイトに通知する最終段階にいます。

以下に PaymentController.php ファイルがありますが、これを支払いゲートウェイ通知にリンクする方法がわかりません。

支払いゲートウェイは、HTTP GET 要求を介してサーバーに通知を提供し、支払いが受け入れられたか拒否されたかを知らせます。これは以下です

http://www.websitedomain.co.uk/mygateway/payment/response?Operator=&SessionID=&Note=&Tariff=&Status=&Mobile=

コードを入力する必要がある支払いコントローラーのコードは以下のとおりです

class Myname_Mygateway_PaymentController extends Mage_Core_Controller_Front_Action {
// The redirect action is triggered when someone places an order
public function redirectAction() {
    $this->loadLayout();
    $block = $this->getLayout()->createBlock('Mage_Core_Block_Template','mygateway',array('template' => 'mygateway/redirect.phtml'));
    $this->getLayout()->getBlock('content')->append($block);
    $this->renderLayout();
}

// The response action is triggered when your gateway sends back a response after processing the customer's payment
public function responseAction() {
    if($this->getRequest()->isPost()) {

        /*
        /* Your gateway's code to make sure the reponse you
        /* just got is from the gatway and not from some weirdo.
        /* This generally has some checksum or other checks,
        /* and is provided by the gateway.
        /* For now, we assume that the gateway's response is valid
        */

        $validated = true;
        $orderId = ''; // Generally sent by gateway

        if($validated) {
            // Payment was successful, so update the order's state, send order email and move to the success page
            $order = Mage::getModel('sales/order');
            $order->loadByIncrementId($orderId);
            $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'Gateway has authorized the payment.');

            $order->sendNewOrderEmail();
            $order->setEmailSent(true);

            $order->save();

            Mage::getSingleton('checkout/session')->unsQuoteId();

            Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/success', array('_secure'=>true));
        }
        else {
            // There is a problem in the response we got
            $this->cancelAction();
            Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/failure', array('_secure'=>true));
        }
    }
    else
        Mage_Core_Controller_Varien_Action::_redirect('');
}

// The cancel action is triggered when an order is to be cancelled
public function cancelAction() {
    if (Mage::getSingleton('checkout/session')->getLastRealOrderId()) {
        $order = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
        if($order->getId()) {
            // Flag the order as 'cancelled' and save it
            $order->cancel()->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, 'Gateway has declined the payment.')->save();
        }
    }
}

}

4

1 に答える 1

0

支払いが $validated = true; 確認された場合、ここに独自の条件を入力する必要があります。

したがって、これが支払いゲートウェイからの応答である場合は、応答 http://www.websitedomain.co.uk/mygateway/payment/response?Operator=&SessionID=&Note=&Tariff=&Status=&Mobile=で変数を使用します

例えば

if ( $_GET('Status') == 'Paid' ){
$validated = true;
}

コードの情報については、支払いゲートウェイのドキュメントを読む必要があります。たとえば、Status 変数には、「支払い済み」、「保留中」、「期限切れ」、または「1」、「2」、「3」などの値を設定できます。ゲートウェイによって異なります。

于 2013-09-24T15:24:54.473 に答える