Latest 1.0.1
Homepage https://github.com/SunlineTinyiOS/TPUnionPay
License MIT
Platforms ios 7.0
Frameworks Foundation, UIKit, CFNetwork, SystemConfiguration
Authors

CI Status
Version
License
Platform

Release Notes

1.0.0

基于SDK 3.3.6版本

1.0.1

更新时间:2017年5月21号
增加mode字段,当前视图控制器获取机制修改

Usage

var union=new UnionPay();
union.tn="111111";    //tn信息,服务端生成
union.mode="00";       //模式 "00" 正式环境 "01"
union.success=function(data){
    window.alert('支付成功');
}
union.error=function(data){
  alert('支付失败');
}
union.pay();

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

1.首先,在AppDelegate文件中引入头文件 TPUnionPay/UPPaymentControl.h。TPUnionPay
支付控件结果处理函数handlePaymentResult: completeBlock:需要在工程AppDelegate文件的application: openURL: options: 方法中进行调用。添加如下代码:

    //通联支付
[[UPPaymentControl defaultControl] handlePaymentResult:url completeBlock:^(NSString *code, NSDictionary *data) {

 //结果code为成功时,先校验签名,校验成功后做后续处理
 if() {

 [[NSNotificationCenter defaultCenter] postNotificationName:@"UnionPaySuccess" object:nil];

 //判断签名数据是否存在
 if(data == nil){
 //如果没有签名数据,建议商户app后台查询交易结果
 return;
 }

 //数据从NSDictionary转换为NSString
 NSData *signData = [NSJSONSerialization dataWithJSONObject:data
                                                    options:0
                                                      error:nil];
 NSString *sign = [[NSString alloc] initWithData:signData encoding:NSUTF8StringEncoding];

 //验签证书同后台验签证书
 //此处的verify,商户需送去商户后台做验签
 //            if([self verify:sign]) {
 //                //支付成功且验签成功,展示支付成功提示
 //            }
 //            else {
 //                //验签失败,交易结果数据被篡改,商户app后台查询交易结果
 //            }
 }
 else if() {
 //交易失败
 [[NSNotificationCenter defaultCenter] postNotificationName:@"UnionPayError" object:nil];
 }
 else if() {
 //交易取消
 [[NSNotificationCenter defaultCenter] postNotificationName:@"UnionPayError" object:nil];
 }
 }];

2.工程配置
2.1在工程info.plist设置中添加一个URL Types回调协议(在UPPayDemo工程中使用“UPPayDemo”作为协议),用于在支付完成后返回商户客户端。
TPUnionPay
2.2在Xcode7.0之后的版本中进行开发,需要在工程对应的plist文件中,添加LSApplicationQueriesSchemes Array并加入uppaysdk、uppaywallet、uppayx1、uppayx2、uppayx3五个item,具体设置可参考以下截图:
TPUnionPay

3.注册JS扩展
在tinyPlus.plist中注册JS扩展
TPUnionPay

Installation

TPUnionPay is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "TPUnionPay"

tips

官方帮助文档地址
https://open.unionpay.com/ajweb/product/detail?id=3

Author

kingdomrain, [email protected]

License

TPUnionPay is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "TPUnionPay",
    "version": "1.0.1",
    "summary": "u94f6u8054u652fu4ed8",
    "description": "tinyBuilderu5e73u53f0u5c01u88c5u7684u901au8054u652fu4ed8",
    "homepage": "https://github.com/SunlineTinyiOS/TPUnionPay",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "kingdomrain": "[email protected]"
    },
    "source": {
        "git": "https://github.com/SunlineTinyiOS/TPUnionPay.git"
    },
    "platforms": {
        "ios": "7.0"
    },
    "source_files": "TPUnionPay/Classes/**/*",
    "frameworks": [
        "Foundation",
        "UIKit",
        "CFNetwork",
        "SystemConfiguration"
    ],
    "libraries": [
        "z",
        "stdc++"
    ],
    "vendored_libraries": "TPUnionPay/Assets/libPaymentControl.a"
}

Pin It on Pinterest

Share This