Giter VIP home page Giter VIP logo

icpaysdk's Introduction

说明

  • 暂时支持支付宝/微信支付,如果需要其他支付方式可以【自定义支付对象】

ICPaySDK

CI Status Version License Platform

配置

  • 最新版本为 2.1.1
  • 使用Pod一键配置,也可以选择性的使用子模块
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'

target 'TargetName' do
pod 'ICPaySDK'

# pod 'ICPaySDK/ICWxPay'
# pod 'ICPaySDK/ICAliPay'

end

初始化SDK

// 使用微信支付需要
[[ICPayDesignManager shareInstance] registerWx:@"" universalLinks:@""];

设置支付回调

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    return [[ICPayDesignManager shareInstance] handleOpenURL:url sourceApplication:sourceApplication];

}

// NOTE: 9.0以后使用新API接口
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString*, id> *)options {
    return [[ICPayDesignManager shareInstance] handleOpenURL:url sourceApplication:nil];
}

// 微信支付通用链接
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
    return [[ICPayDesignManager shareInstance] handleOpenUniversalLink:userActivity];
}

实现支付

  • 支付宝(支付宝为例)
/*闭包方式*/
/*自定义数据模型 实现协议 <ICIAliModel>*/
AliModel *model = [[AliModel alloc] init];
model.orderString = orderString;
[[ICPayDesignManager shareInstance] payWithModel:model controller:nil completion:^(ICError *error) {
/*回调*/
}];

/*代理方式*/
[[ICPayDesignManager shareInstance] payWithModel:model controller:nil delegate:self];
/*回调*/
- (void)payManagerdidCompleteWithError:(ICError *)error {}

自定义支付对象

1. 新建类 继承ICBasePayEntry,实现父类方法, 可以参考 ICAliPayEntry/ICWxPayEntry


 支付统一规范
 */

- (void)payWithModel:(id)model
          controller:(nullable UIViewController *)controller
          completion:(nullable ICCompletion)completion;
/**
 处理支付
 */
- (BOOL)handleOpenURL:(NSURL *)url
    sourceApplication:(nullable NSString *)sourceApplication;

/**
 处理通用链接
 */
- (BOOL)handleOpenUniversalLink:(NSUserActivity *)userActivity;

2. 添加 支付对象
[[ICPayDesignManager shareInstance] addPayEntry:@"自定义的entry"];

3. 发起支付
[[ICPayDesignManager shareInstance] payWithEntryClass:<#(nonnull Class)#> data:<#(nonnull id)#> controller:<#(nonnull UIViewController *)#> completion:<#^(ICErrorStatusCode)completion#>]

Author

iCorki, [email protected] 发现问题或者bug 👏指正!

License

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

icpaysdk's People

Contributors

corkiios avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

icpaysdk's Issues

你好, 想请教一下framework

我这边需要将 微信支付和支付宝支付打成一个 framework.
但是我尝试后发现 支付宝SDK没法有引入, 想请教一下有什么好的办法吗

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.