中国银联开放平台在线网关支付(银行卡/云闪付)易支付插件

中国银联开放平台在线网关支付(银行卡/云闪付)易支付插件
1.银联开放平台在线网关支付文档: 直达
2.网关产品开发包SDK下载:直达
3.易支付系统根目录进入plugin文件夹新建目录myunion
复制开发包sdk文件夹到myunion目录 复制相关证书文件到myunion/certs目录 最终文件夹目录内容如下图
文件夹目录内容
4.新建文件myunion_plugin.php


<?php
class myunion_plugin
{
    static public $info = [
        'name' => 'myunion', 
        'showname' => '银联开放平台支付', 
        'author' => '银联开放平台', 
        'link' => 'http://www.95516.com/', 
        'types' => ['bank'],
        'inputs' => [ 
            'appid' => [
                'name' => '商户号',
                'type' => 'input',
                'note' => '777290058110048',
            ],
            'appkey' => [
                'name' => '商户密钥',
                'type' => 'input',
                'note' => '',
            ],
            'appurl' => [
                'name' => '自定义网关URL',
                'type' => 'input',
                'note' => '默认测试网关,https://gateway.test.95516.com/gateway/api/frontTransReq.do',
            ],
            'appswitch' => [
                'name' => '支付跳转模式',
                'type' => 'select',
                'options' => [0=>'直接跳转接口'],
            ],

        ],
        'select' => null,
        'note' => '', 
        'bindwxmp' => false, 
        'bindwxa' => false
    ];

    static public function submit()
    {
        //固定跳转到 /pay/bank
        global $siteurl, $channel, $order, $sitename;

        if ($order['typename'] == 'alipay') {
            return ['type' => 'jump', 'url' => '/pay/bank/' . TRADE_NO . '/'];
        } elseif ($order['typename'] == 'wxpay') {
            if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false) {
                return ['type' => 'jump', 'url' => '/pay/bank/' . TRADE_NO . '/?d=1'];
            } elseif (checkmobile() == true) {
                return ['type' => 'jump', 'url' => '/pay/bank/' . TRADE_NO . '/'];
            } else {
                return ['type' => 'jump', 'url' => '/pay/bank/' . TRADE_NO . '/'];
            }
        } elseif ($order['typename'] == 'qqpay') {
            return ['type' => 'jump', 'url' => '/pay/bank/' . TRADE_NO . '/'];
        } elseif ($order['typename'] == 'jdpay') {
            return ['type' => 'jump', 'url' => '/pay/jbank/' . TRADE_NO . '/'];
        } elseif ($order['typename'] == 'bank') {
            return ['type' => 'jump', 'url' => '/pay/bank/' . TRADE_NO . '/'];
        }
    }

    static public function bank()
    {
        global $siteurl,$channel, $order, $ordername, $conf, $clientip;
        header ( 'Content-type:text/html;charset=utf-8' );
        include_once dirname(__FILE__) . '/sdk/acp_service.php';

        $params = array(
            'version' => com\unionpay\acp\sdk\SDKConfig::getSDKConfig()->version,                
            'encoding' => 'utf-8',				 
            'txnType' => '01',				     
            'txnSubType' => '01',				 
            'bizType' => '000201',				  
            'frontUrl' =>  $siteurl.'pay/return/'.TRADE_NO.'/',  /
            'backUrl' => $conf['localurl'].'pay/notify/'.TRADE_NO.'/',	 
            'signMethod' => com\unionpay\acp\sdk\SDKConfig::getSDKConfig()->signMethod,	              
            'channelType' => '08',	              
            'accessType' => '0',		         
            'currencyCode' => '156',	          
            'merId' => $channel['appid'],		
            'orderId' => TRADE_NO,	
            'txnTime' => date('YmdHis'),	
            'txnAmt' => strval($order['realmoney']*100),	
            'payTimeout' => date('YmdHis', strtotime('+15 minutes')),
            'riskRateInfo' =>'{commodityName='.$ordername.'}',
        );
        com\unionpay\acp\sdk\AcpService::sign ( $params );
        $uri = $channel['appurl'];
        $html_form = com\unionpay\acp\sdk\AcpService::createAutoFormHtml( $params, $uri );
        echo $html_form;
    }


    //异步回调
    static public function notify()
    {
        global $channel, $order;

        include_once dirname(__FILE__) . '/sdk/acp_service.php';

        $logger = com\unionpay\acp\sdk\LogUtil::getLogger();
        $logger->LogInfo("receive back notify: " . com\unionpay\acp\sdk\createLinkString ( $_POST, false, true ));

        try {

            $result = com\unionpay\acp\sdk\AcpService::validate($_POST);
            if(!$result){
                return ['type' => 'html', 'data' => 'failure'];
            }
            processNotify($order);
            return ['type' => 'html', 'data' => 'success'];
        } catch (Exception $e) {
            return ['type' => 'html', 'data' => $e->getMessage()];
        }
    }

    //支付成功页面
    static public function ok()
    {
        return ['type' => 'page', 'page' => 'ok'];
    }

    //支付返回页面
    static public function return()
    {
        return ['type' => 'page', 'page' => 'return'];
    }

}

5.配置好参数后 点击支付测试
点击支付测试
6.跳转到银联支付页面
银联支付页面
7支付页面支持云闪付扫码 手机端支付页面
手机端支付

  • 7
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值