最近为客户的一个在线商城做了一个易汇金在线支付的接口。跟大家分享一下。
1 首先可以模仿其他的接口,比如支付宝,财付通等的接口,构建模块功能文件和语言文件。
功能模块构建:
/includes/modules/payment/boc.php
Label文件构建:
/languages/zh_cn/payment/boc.php
功能模块boc.php中主要写好ecshop所需要的2个接口函数getcode和respond。
下面是主要的代码
public function builder($params)
{
$this->merchantId = $params['merchantId'];
$this->requestId = $params['requestId'];
$this->orderAmount = $params['orderAmount'];
$this->orderCurrency = $params['orderCurrency'];
$this->notifyUrl = $params['notifyUrl'];
$this->callbackUrl = $params['callbackUrl'];
$this->remark = $params['remark'];
$this->paymentModeCode = $params['paymentModeCode'];
//商品信息
if (!empty($params['product'])){
$postProduct = $params['product'];
$products = array();
foreach($postProduct as $val){
$product = new ProductDetail();
$product->setDescription($val['description'])
->setAmount($val['productAmount'])
->setName($val['productName'])
->setQuantity($val['quantity'])
->setReceiver($val['receiver']);
array_push($products,$product);
}
$this->productDetails = $products;
}
大家如果需要开发易汇金支付接口,可以跟我交流。QQ:804752009