美文网首页
Ping++轻量聚合支付

Ping++轻量聚合支付

作者: 勇敢的_心_ | 来源:发表于2018-06-12 20:50 被阅读21次

Ping++免费聚合支付

支持的渠道包含:支付宝 APP 支付(alipay)、微信 APP 支付(wx)、银联 APP 支付(upacp)、招行一网通(cmb_wallet)、QQ 钱包支付(qpay)、Apple Pay(applepay_upacp)、百度钱包手机网页支付(bfb_wap)、易宝手机网页支付(yeepay_wap)、京东手机网页支付(jdpay_wap)

目前分为:免费试用版、收费版

准备

1.接入方法:

pod 'Pingpp', '~> 2.2.20'

2.若只接入微信、支付宝:

pod 'Pingpp/Alipay', '~> 2.2.20'
pod 'Pingpp/Wx', '~> 2.2.20'

3.依赖 Frameworks:

CFNetwork.framework
SystemConfiguration.framework
Security.framework
QuartzCore.framework
CoreTelephony.framework
libc++.tbd
libz.tbd
libsqlite3.0.tbd
libstdc++.tbd
CoreMotion.framework
CoreLocation.framework

4.Apple Pay 所需:

PassKit.framework

5.添加 Other Linker Flags:在 Build Settings 搜索 Other Linker Flags ,添加 -ObjC

使用 Ping++ 标准 SDK

轻量级聚合支付:支付调用此一方法即可;传参数正确的话应该可以调用支付宝、微信等支付。

#import <Pingpp.h>

[Pingpp createPayment:charge
           viewController:viewController
             appURLScheme:kUrlScheme
           withCompletion:^(NSString *result, PingppError *error) {
               if ([result isEqualToString:@"success"]) {
                   // 支付成功
               } else {
                   // 支付失败或取消
                   NSLog(@"Error: code=%lu msg=%@", error.code, [error getMsg]);
               }
}];

参数说明:

  • charge:json,一般由服务器返回给客户端;

  • kUrlScheme:支付宝/微信;添加 URL Schemes:在 Xcode 中,选择你的工程设置项,选中 TARGETS 一栏,在 Info 标签栏的 URL Types 添加 URL Schemes,如果使用微信(或微信 + 其他渠道),填入微信平台上注册的应用程序 id(为 wx 开头的字符串)。如果不使用微信,则可以自定义,建议起名稍复杂一些,尽量避免与其他程序冲突。允许英文字母和数字,首字母必须是英文字母,不允许特殊字符。

  • 测试的话kUrlScheme 可以设置为alisdkdemo,并在URL Types 添加 URL Schemes为alisdkdemo

注意

1.iOS 8 及以下

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation {
    BOOL canHandleURL = [Pingpp handleOpenURL:url withCompletion:nil];
    return canHandleURL;
}

2.iOS 9 及以上

- (BOOL)application:(UIApplication *)app
            openURL:(NSURL *)url
            options:(NSDictionary *)options {
    BOOL canHandleURL = [Pingpp handleOpenURL:url withCompletion:nil];
    return canHandleURL;
}

3.适配 iOS 9 及以上
在 Info.plist 里添加如下代码:

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>weixin</string>
    <string>wechat</string>
    <string>alipay</string>
    <string>alipays</string>
    <string>mqq</string>
    <string>uppaysdk</string>
    <string>uppaywallet</string>
    <string>uppayx1</string>
    <string>uppayx2</string>
    <string>uppayx3</string>
</array>

针对 iOS 9 及以上系统的限制 http 协议的访问,如果 App 需要访问 http://, 则需要在 Info.plist 添加如下代码:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

相关文章

网友评论

      本文标题:Ping++轻量聚合支付

      本文链接:https://www.haomeiwen.com/subject/btgreftx.html