iOS 支付功能

Ping++,它集成所有支付功能于一身:

支付流程:

ping++,支持支付宝支付,微信支付,银联支付,百度钱包支付,applepay

(1)根据呢需要介入的支付方式去对应的支付平台申请账号和参数

(2)(恨不得直接上代码了),传说中的7行代码搞定支付


iOS <wbr> <wbr>支付功能

Ping++有着前所未有的简单,号称7行代码搞定支付

 

NSDictionary* dict = @{    @"channel" : channel, // 渠道 alipay, wx, upacp, bfb

@"amount"  : amount  // 金额};

NSData* data = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:nil];

NSString *bodyData = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

[postRequest setHTTPBody:[NSData dataWithBytes:[bodyData UTF8String] length:strlen([bodyData UTF8String])]];

[postRequest setHTTPMethod:@"POST"];

NSOperationQueue *queue = [[NSOperationQueue alloc] init];

[NSURLConnection sendAsynchronousRequest:postRequest queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {

NSHTTPURLResponse* httpResponse = (NSHTTPURLResponse*)response;

NSString* charge = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];    // ...

[Pingpp createPayment:charge viewController:viewController appURLScheme:kUrlScheme withCompletion:^(NSString *result, PingppError *error) {   

 if ([result isEqualToString:@"success"]) {        // ...

} else {      

  NSLog(@"PingppError: code=%lu msg=%@", error.code, [error getMsg]);

}

}];

}];

//AppDelegate添加这行代码适用于监听支付结果的

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {

[Pingpp handleOpenURL:url withCompletion:^(NSString *result, PingppError *error) {       if ([result isEqualToString:@"success"]) {            // ...

} else {            NSLog(@"PingppError: code=%lu msg=%@", error.code, [error getMsg]);

}

}];    return  YES;

}

综上所述,你可以跟你的个人需求来选择接入支付方式

第三方支付,终究还是第三方,第三方站着公司和开发者的角度上考虑问题,减少开发难度和成本,不必要如此担心。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值