帮酷LOGO
0 0 评论
  • 显示原文与译文双语对照的内容
文章标签:支付处理  Union  Omnipay  PROC  Drive  支付  PHP  
framework agnostic, multi-gateway payment processing library for PHP 5.3+

  • 源代码名称:omnipay-unionpay
  • 源代码网址:http://www.github.com/lokielse/omnipay-unionpay
  • omnipay-unionpay源代码文档
  • omnipay-unionpay源代码下载
  • Git URL:
    git://www.github.com/lokielse/omnipay-unionpay.git
  • Git Clone代码到本地:
    git clone http://www.github.com/lokielse/omnipay-unionpay
  • Subversion代码到本地:
    $ svn co --depth empty http://www.github.com/lokielse/omnipay-unionpay
    Checked out revision 1.
    $ cd repo
    $ svn up trunk
    
  • Omnipay: 银联

    Build StatusLatest Stable VersionTotal Downloads

    用于 Omnipay PHP支付处理库的驱动程序

    Omnipay 是一个框架,多网关支付处理库,用于 PHP 5.3 +。 这里软件包实现对Omnipay的银联支持。

    安装

    Omnipay是通过 Composer 设备安装的。 要安装,只需将它的添加到 composer.json file:

    {
     "require": {
     "lokielse/omnipay-unionpay": "^0.4" }
    }

    运行 Composer 来更新你的依赖关系:

    
    $ curl -s http://getcomposer.org/installer | php
    
    
    $ php composer.phar update
    
    
    
    

    基本用法

    这里软件包提供了以下网关:

    用法

    沙箱参数可以在以下位置找到: 银联开发人员中心产品

    准备

    如何获取 PrivateKeyPublicKeyCert ID:

    
    0. Prepare cert.pfx and its password, verify_sign_acp.cer
    
    
    
    1. Get Private Key
    
    
    $ openssl pkcs12 -in cert.pfx -nocerts -nodes | openssl rsa -out private_key.pem
    
    
    
    2. Public key is verify_sign_acp.cer
    
    
    
    3. Get Cert ID
    
    
    $ openssl pkcs12 -in cert.pfx -clcerts -nokeys | openssl x509 -serial -noout//result hex eg: XXXXXXXXXX
    
    
    $ visit https://lokielse.github.io/hex2dec//Convert hex to decimal online
    
    
    
    

    $gateway=Omnipay::create('UnionPay_Express');$gateway->setMerId($config['merId']);$gateway->setCertId($config['certId']);$gateway->setPrivateKey($config['privateKey']); // path or content$gateway->setReturnUrl($config['returnUrl']);$gateway->setNotifyUrl($config['notifyUrl']);$order= ['orderId'=>date('YmdHis'), //Your order ID'txnTime'=>date('YmdHis'), //Should be format 'YmdHis''orderDesc'=>'My order title', //Order Title'txnAmt'=>'100', //Order Total Fee];//For PC/Wap$response=$gateway->purchase($order)->send();$response->getRedirectHtml();//For APP$response=$gateway->createOrder($order)->send();$response->getTradeNo();

    返回/通知

    $gateway=Omnipay::create('UnionPay_Express');$gateway->setMerId($config['merId']);$gateway->setPublicKey($config['publicKey']); // path or content$response=$gateway->completePurchase(['request_params'=>$_REQUEST])->send();if ($response->isPaid()) {//pay success}else{//pay fail}

    查询订单状态

    $response=$gateway->query(['orderId'=>'20150815121214', //Your site trade no, not union tn.'txnTime'=>'20150815121214', //Order trade time'txnAmt'=>'200', //Order total fee])->send();var_dump($response->isSuccessful());var_dump($response->getData());

    使用撤销

    $response=$gateway->consumeUndo(['orderId'=>'20150815121214', //Your site trade no, not union tn.'txnTime'=>date('YmdHis'), //Regenerate a new time'txnAmt'=>'200', //Order total fee'queryId'=>'xxxxxxxxx', //Order total fee])->send();var_dump($response->isSuccessful());var_dump($response->getData());

    退款

    $response=$gateway->refund(['orderId'=>'20150815121214', //Your site trade no, not union tn.'txnTime'=>'20150815121214', //Order trade time'txnAmt'=>'200', //Order total fee])->send();var_dump($response->isSuccessful());var_dump($response->getData());

    文件传输

    $response=$gateway->fileTransfer(['txnTime'=>'20150815121214', //Order trade time'settleDate'=>'0119', //Settle Date'fileType'=>'00', //File Type])->send();var_dump($response->isSuccessful());var_dump($response->getData());

    有关一般使用说明,请参见主 Omnipay 存储库。

    相关

    支持

    如果你对Omnipay有一般问题,我们建议在堆栈溢出模式下发布。 一定要添加 omnipay标签,以便能很容易地找到它。

    如果你想及时了解发布 anouncements,请讨论项目的想法,或者询问更多的问题,还有一个邮件列表,你可以订阅它。

    如果你认为已经找到了一个 Bug,请使用 GitHub问题跟踪程序报告它,或者更好的时候,库并提交请求请求。



    文章标签:PHP  PROC  Drive  支付  支付处理  Union  Omnipay  

    Copyright © 2011 HelpLib All rights reserved.    知识分享协议 京ICP备05059198号-3  |  如果智培  |  酷兔英语