【发布时间】:2014-08-22 13:06:06
【问题描述】:
根据官方文档,支付网关的主要预定义函数是capture() 和authorize(),它们应该在使用选定的支付方式下订单后执行。
我正在尝试设置的支付网关是请求 https POST 数据并返回 json 响应。基本上只有cc支付网关。
这个帖子数据应该放在模块内的什么位置?
在显示订单完成后如何使用网关 json 响应(所以我知道它执行正确)?
模块结构应该如何满足这项任务的最基本需求?
这是我的代码想要做的:
<?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