PayPalトランザクションがユーザーによってキャンセルされたときの順序として保存する

magento.stackexchange https://magento.stackexchange.com/questions/100324

質問

PayPal規格で支払いがキャンセルされたときの任意の状態の下の順序の節約方法。

役に立ちましたか?

解決

これで数時間過ごした後、私は最初にMagento 1.9がPayPal規格と一緒にPayPal Expressを含むことを知っていました。したがって、このクリアをすると、SQLの変更とブロックの書き換え(https://www.cadence-labs.com/2015/06/magento-1-9- gathable-voth-eNable-voth-eNable-voth-paypal-jable-voth-paypal-both-paypal-paypal-内容 - standard-and-paypal-express-checkout / "rel=" nofollow ">いくつかの外部ソース)。 PayPalキャンセルアクションの上書きが必要な点に戻ってくる。これはObserver sales_order_payment_cancelによって取得でき、以下のコードの残りの部分も他のプロセスも説明します。これが誰かに役立つべきべきことを願っています。

ローカル/ stackOverflow / paypalstandard / etc / config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Stackoverflow_Paypalstandard>
            <version>0.1.0</version>
        </Stackoverflow_Paypalstandard>
    </modules>
    <global>
        <models>
            <custom_paypalstandard>
                <class>Stackoverflow_Paypalstandard_Model</class>
            </custom_paypalstandard>
        </models>
        <blocks>
            <custom_paypalstandard>
                <class>Stackoverflow_Paypalstandard_Block</class>
            </custom_paypalstandard>
            <paypal>
                <rewrite>
                    <standard_redirect>Stackoverflow_Paypalstandard_Block_Standard_Redirect</standard_redirect>
                    <adminhtml_system_config_fieldset_location>Stackoverflow_Paypalstandard_Block_Adminhtml_System_Config_Fieldset_Location</adminhtml_system_config_fieldset_location>
                </rewrite>
            </paypal>
        </blocks>
        <events>
            <sales_order_payment_cancel>
                <observers>
                    <after_placing_order>
                        <class>custom_paypalstandard/observer</class>
                        <method>implementOrderStatus</method>
                    </after_placing_order>
                </observers>
            </sales_order_payment_cancel>
        </events>
    </global>
</config>
.

ローカル/スタックオーバーフロー/ PayPalStandard / Block / AdminHTML / System / Config / Fieldset / Location.Php

これはPayPal Expressを無効にするためのオーバーライドの一部です - これについては いくつかの リンク。

ローカル/スタックオーバーフロー/ PayPalStandard / Block / Standard / Redirect.php

class Stackoverflow_Paypalstandard_Block_Standard_Redirect extends Mage_Paypal_Block_Standard_Redirect
{
    public function _toHtml()
    {
        $standard = Mage::getModel('paypal/standard');

        $form = new Varien_Data_Form();
        $form->setAction($standard->getConfig()->getPaypalUrl())
            ->setId('paypal_standard_checkout')
            ->setName('paypal_standard_checkout')
            ->setMethod('POST')
            ->setUseContainer(true);
        foreach ($standard->getStandardCheckoutFormFields() as $field=>$value) {
            $form->addField($field, 'hidden', array('name'=>$field, 'value'=>$value));
        }
        $idSuffix = Mage::helper('core')->uniqHash();
        $submitButton = new Varien_Data_Form_Element_Submit(array(
            'value'    => $this->__('Click here if you are not redirected within 10 seconds...'),
        ));
        $id = "submit_to_paypal_button_{$idSuffix}";
        $submitButton->setId($id);
        $form->addElement($submitButton);
        $html = '<html><body>';
        $html.= $this->__('You will be redirected to the PayPal website in a few seconds.');
        $html.= $form->toHtml();
        $html.= '<script type="text/javascript">document.getElementById("paypal_standard_checkout").submit();</script>';
        $html.= '</body></html>';

        return $html;
    }
}
.


ローカル/スタックオーバーフロー/ PayPalstandard / Model / Observer.php


class Stackoverflow_Paypalstandard_Model_Observer
{

 public function implementOrderStatus($observer)
    {
        $payment = $observer->getEvent()->getPayment();
        $order = $payment->getOrder();
        $order->setActionFlag(Mage_Sales_Model_Order::ACTION_FLAG_CANCEL, false);
        $orderIds = Mage::getSingleton('adminhtml/session')->getNonCancelledOrders();
        if (!$orderIds) {
            $orderIds = array($order->getId());
        } else {
            $orderIds[] = $order->getId();
        }
        Mage::getSingleton('adminhtml/session')->setNonCancelledOrders($orderIds);
    }
}
.

etc / modules / stackoverflow_paypalstandard.xml


<config>
    <modules>
        <Stackoverflow_Paypalstandard>
            <active>true</active>
            <codePool>local</codePool>
        </Stackoverflow_Paypalstandard>
    </modules>
</config>
.
ライセンス: CC-BY-SA帰属
所属していません magento.stackexchange
scroll top