【问题标题】:Magento payment gateway documentationMagento 支付网关文档
【发布时间】:2014-08-22 13:06:06
【问题描述】:

根据官方文档,支付网关的主要预定义函数是capture()authorize(),它们应该在使用选定的支付方式下订单后执行。

我正在尝试设置的支付网关是请求 https POST 数据并返回 json 响应。基本上只有cc支付网关。

  1. 这个帖子数据应该放在模块内的什么位置?

  2. 在显示订单完成后如何使用网关 json 响应(所以我知道它执行正确)?

  3. 模块结构应该如何满足这项任务的最基本需求?

这是我的代码想要做的:

<?php

    class Mycompany_Pay_Model_Pay extends Mage_Payment_Model_Method_Abstract
    {
        protected $_code = 'mycompany_pay';

        protected $_isGateway               = true;
        protected $_canCapture              = true;
        protected $_canRefund               = true;
        protected $_canUseInternal          = true;

        protected $_allowCurrencyCode = array('EUR', 'HRK');

        protected $_minValue = 1;

        // taking predefined objects for further usage
        public function capture(Varien_Object $payment, $amount){
            $order = $payment->getOrder();
            //$order = Mage::getModel('sales/order')->load($orderId);
            $billingInfo = $order->getBillingAddress();
            $customer = Mage::getSingleton('customer/session')->getCustomer();

            $postfields = array('order_id'=>9999, // temp number for debugging 
                    'name'=>    $customer->getName(), 
                    'mail'=>    $customer->getEmail(), 
                    'address'=> $billingInfo->getStreet(1),
                    'zip'=>     $billingInfo->getPostcode(),
                    'city'=>    $billingInfo->getCity(),
                    'state'=>   $billingInfo->getRegion(),
                    'country'=> $billingInfo->getCountry(),
                    'amount'=>  $amount,
                    'currency'=>$order->getBaseCurrencyCode(),
                    'cc'=>      $payment->getCcNumber(),
                    'cvv'=>     $payment->getCcCid());

        curl_setopt($ch, CURLOPT_URL, 'https://mygatewayUrl');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_POST, 1);

        curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        $result = curl_exec($ch);
        print $result;
        }
    }

是否应该在捕获之外执行 curl 代码?每当我从我的 magento 测试站点测试订单时,我都会返回交易 ID,说订单已完成。没有实际证据表明此捕获甚至可以运行。 (我尝试向它添加日志/断点,什么也没做)。

另外一个问题:

在选择此付款方式时添加简单的 CC 表单供用户填写的最简单方法是什么(因此 CC 变量实际上并不像现在那样为空)?

非常感谢任何形式的帮助。

【问题讨论】:

  • 如果你有多个问题,你应该自己问他们。

标签: javascript php xml magento


【解决方案1】:

我认为本教程中解释了实现您想要的方法:

http://excellencemagentoblog.com/magento-create-custom-payment-method-api-based

我可以提取其中的一部分来回答你的问题,但我认为 Manish Prakash 给出的整个概述会丢失,它以非常清晰的方式涵盖了整个过程,看看。

【讨论】:

    猜你喜欢
    • 2013-12-07
    • 2015-05-24
    • 2011-09-08
    • 1970-01-01
    • 1970-01-01
    • 2017-10-02
    • 1970-01-01
    • 1970-01-01
    • 2013-09-29
    相关资源
    最近更新 更多