首页 > 分享 > iOS

iOS

资料

支付宝 //文档idk都包含了安卓、iOS版

银 联

银联官网资料

Demo

Demo给了一个订单号,做测试使用,若出现支付失败什么的,可能是已经被别人给支付了,或者是服务器订单过期了 ~

一、支付宝

1.1 请阅读支付宝文档和Demo

1.2 导入对应的库

将支付宝Demo中得这些东西全拷贝过来

1

2

3

4

5

localhost:alipay mac$ ls

APAuthV2Info.h        Order.h            libssl.a

APAuthV2Info.m        Order.m            openssl

AlipaySDK.bundle    Util

AlipaySDK.framework    libcrypto.a

导入系统库

1

SystemConfiguration.framework

设置一下search paths

1

build setting ->搜索search path,然后你懂的

完成后,编译一下,看有没有错,有错没错,还是下一步吧。

1.3 对接

支付宝对节前,你还是需要从服务器拿到一下一堆东西

支付宝接口文档中写了3p参数列表,--! 总结下我用的到,或者说是Demo中提到的,别的就超出范围了

1

2

3

4

5

合作者身份ID     alipayPartner = @ "2088一串数字" ;

接口名称             alipaySeller = @ "tianticar@126.com" ;

签名                aliPayPrivateKey = @ "很长很长的私钥" ;

服务器异步通知页面路径  alipayNotifServerURL = @ "一个网址" ; 

其他一些参数(与购买产品相关,设计到业务了,客户端/服务器谁提供均可)直接贴order代码了,具体看我的Demo示例.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

Order *order = [[Order alloc] init];

                     order.partner = alipayPartner ;

                     order.seller = alipaySeller;

                     order.tradeNO = tn; 

                     order.productName = [NSString stringWithFormat:@ "汽车服务充值-%@" ,@ "支付" ]; 

                     order.productDescription = [NSString stringWithFormat:@ "%@:支付宝移动支付充值" ,@ "xxxx" ]; 

                     order.amount = _txtCNY.text; 

                     order.notifyURL =  alipayNotifServerURL; 

                     order.service = @ "mobile.securitypay.pay" ;

                     order.paymentType = @ "1" ;

                     order.inputCharset = @ "utf-8" ;

                     order.itBPay = @ "30m" ;

                     order.showUrl = @ "m.alipay.com" ;

                     NSString *appScheme = URLScheme;

调用支付宝

1

2

3

4

5

6

7

8

9

10

11

12

[[AlipaySDK defaultService] payOrder:orderString fromScheme:appScheme callback:^(NSDictionary *resultDic) {

                             NSLog(@ "reslut = %@" ,resultDic);

                             if  ([resultDic[@ "resultStatus" ] intValue]==9000) {

                                 NSLog(@ "支付成功" );

                             }

                             else {

                                 NSString *resultMes = resultDic[@ "memo" ];

                                 resultMes = (resultMes.length<=0?@ "支付失败" :resultMes);

                                 NSLog(@ "%@" ,resultMes);

                             }

     }];

你可能会发现回调不行->设置回调shema

1

2

3

4

5

6

7

8

9

10

11

12

13

14

  NSString *appScheme = URLScheme;

  在APPDelegate -

   - (BOOL)application:(UIApplication *)application

             openURL:(NSURL *)url

   sourceApplication:(NSString *)sourceApplication

          annotation:(id)annotation {

     [[AlipaySDK defaultService] processOrderWithPaymentResult:url standbyCallback:^(NSDictionary *resultDic) {

         NSLog(@ "result = %@" ,resultDic);

     }];

     return  YES;

}

二、银联

2.1 请去看银联文档和demo

2.2 导入对应的库

SDK说明

SDK分为以下两个版本:

①    支持纯无卡交易静态库,以下简称UPPayPlugin,包含文件:

1

2

3

UPPayPlugin.h

UPPayPluginDelegate.h

libUPPayPlugin.a

②    支持纯无卡交易和VIPOS音频口支付静态库,以下简称UPPayPluginPro,包含文件:

1

2

3

UPPayPluginPro.h

UPPayPluginDelegate.h

libUPPayPluginPro.a

大概这两个库就是上述那样(嗯,装懂了),具体问商务/后者后台,我们只需要知道

②需要将.m改成.mm (应该是用c++封装的音频...??)

添加SDK包

a)    根据商户选择的SDK版本,将sdk/inc目录和sdk/libs目录下对应版本的三个文件添加到UPPayDemo工程中;

b)    如果你选择的是UPPayPlugin版本,添加QuartzCore.framework、Security.framework到工程中;

c)    如果你选择的是UPPayPluginPro版本,添加QuartzCore.framework、AudioToolbox.framework, CoreAudio.framework、 MediaPlayer.framework, AVFoundation.framework和Security.framework到工程中;

d)    在工程的Build Settings中找到Other Linker Flags中添加-ObjC宏;

导入到工程,让服务器准备一下交易流水号信息 (什么他们不懂,让他们去看文档 银 联),休息一下,喝杯什么好了

2.3 对接

咱们的服务器也是挺给力的,一盏茶的功夫,就将交易流水号信息 给准备好了,嗯不错,速度对接一下。

1

2

3

4

  + (BOOL)startPay:(NSString*)tn 

mode:(NSString*)mode 

viewController:(UIViewController*)viewController 

delegate:(id)delegate;

-------------参数说明(必填)-------------------

1

2

3

4

tn                 NSString*                   交易流水号信息,银联后台生成,通过商户后台返回到客户端并传入支付控件; 

mode            NSString*                 接入模式设定,两个值:@ "00" :代表接入生产环境(正式版本需要);@ "01" :代表接入开发测试环境(测试版本需要);

viewController    UIViewController*          商户应用程序调用银联手机支付的当前UIViewController;

delegate        id     实现UPPayPluginDelegate方法的UIViewController;

嗯,这些都是文档中的,请仔细看看[上线的时候一定药修改mode模式]。

mode在测试环境下可以银联给的测试号 tn=@"01" 测试环境

测试使用卡号、手机号信息(此类信息仅供测试,不会发生正式交易)招商银行预付费卡:

卡号:6226 4401 2345 6785

密码:111101

[这个居然无效]

再来一个:

银行卡号:6216261000000000018

身份证号:341126197709218366

手 机 号 :13552535506

验 证 码 :123456 【要点击获取验证码,不然提交会报错】

viewcontroller需要干这些事情

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

*引入头文件   #import "UPPayPluginPro.h"

*调用接口

         [UPPayPluginPro startPay:tn mode:self.tnMode viewController:self delegate:self];

*实现对应代理方法

         #pragma mark UPPayPluginResult

         - (void)UPPayPluginResult:(NSString *)result

         {

             NSString* msg = [NSString stringWithFormat:@ "%@" , result];

             NSLog(@ "msg%@" ,msg);

             if  ([result isEqualToString:@ "msgcancel" ]) {

                 NSLog(@ "取消银联支付..." );

             }

             else  if ([result containsString:@ "success" ]){

                 NSLog(@ "支付成功" );

             }

       }

微信支付

微信支付工作之前的流程

微信支付文档

微信sdk

总体来说微信支付需要审核的比较麻烦,我也没有去弄一个号亲自测试一下,按照文档demo去走一般不会出什么问题。

小记

可能遇到银联c++编译问题,把对应的viewcontroller切换成.mm,编译看看。若有CreateRSADataSigner arm64的,请将支付宝给的DataSigner改成.mm即可。

其他可以参照demo

相关知识

花卉识别ios版下载
区块链原生工程师(iOS、Android)(长沙)
花集网ios版下载
梦想花店模拟器ios版推荐
花帮主ios版下载
苹果ios付费游戏免费下载iphone账号id花夏数娱
苹果发布 iOS 18.1 RC版,正式版下周推送,还存在两个离谱Bug
ios一个app调起另一个app
唯美禅意游戏《花》今日登陆IOS平台
花百科iOS版app下载

网址: iOS https://m.huajiangbk.com/newsview849429.html

所属分类:花卉
上一篇: android 支付模块封装,A
下一篇: thinkdai/payment