# MMPayKit
**Repository Path**: mutouren_admin/MMPayKit
## Basic Information
- **Project Name**: MMPayKit
- **Description**: 淼迈支付
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2018-08-13
- **Last Updated**: 2020-12-19
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# MMPayKit
淼迈iOS第三方支付集成组件化
[](https://travis-ci.org/qulunping@gmail.com/MMPayKit)
[](https://cocoapods.org/pods/MMPayKit)
[](https://cocoapods.org/pods/MMPayKit)
[](https://cocoapods.org/pods/MMPayKit)
## Example
To run the example project, clone the repo, and run `pod install` from the Example directory first.
## Requirements
## Installation
MMPayKit is available through [CocoaPods](https://cocoapods.org). To install
it, simply add the following line to your Podfile:
```ruby
//添加源到你的Podfile里面
source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.com/aliyun/aliyun-specs.git'
```
```ruby
//复制以下代码引入pod
pod 'MMPayKit', :git => 'https://gitee.com/mutouren_admin/MMPayKit.git', branch:'master'
pod 'QUKit', :git => 'https://gitee.com/mutouren_admin/QUKit.git', branch:'master'
pod 'QUKit/QURefresh', :git => 'https://gitee.com/mutouren_admin/QUKit.git', branch:'master'
pod 'MMThirdPlatformKit', :git => 'https://gitee.com/mutouren_admin/MMThirdPlatformKit.git', branch:'master'
pod 'MMThirdPlatformKit/WXManager', :git => 'https://gitee.com/mutouren_admin/MMThirdPlatformKit.git', branch:'master'
pod 'MMThirdPlatformKit/AlipayManager', :git => 'https://gitee.com/mutouren_admin/MMThirdPlatformKit.git', branch:'master'
pod 'MiaoMaiKit', :git => 'https://gitee.com/mutouren_admin/MiaoMaiKit.git', branch:'master'
pod 'HMSegmentedControl'
```
#### 第三方平台配置
1、在AppDelegate的`didFinishLaunchingWithOptions`方法中进行平台的配置
```objc
// 自定义的第三方平台以插件的方式添加
MMThirdPlatformManager* configInstance = [MMThirdPlatformManager sharedInstance];
/**** 第三方平台注册 *****/
// 微信
[configInstance setPlaform:MMThirdPlatformTypeWechat
appID:kWXAppID
appKey:nil
appSecret:nil
redirectURL:nil
URLSchemes:nil];
// 支付宝
[configInstance setPlaform:MMThirdPlatformTypeAlipay
appID:nil
appKey:nil
appSecret:nil
redirectURL:nil
URLSchemes:kAlipayURLScheme];
// 执行配置
[configInstance thirdPlatConfigWithApplication:application
didFinishLaunchingWithOptions:launchOptions];
[MMPayAPIClient setDebugLogEnable:YES];
[MMPayAPIClient setupConfigIsProduction:NO];
```
2、在AppDelegate的`openURL`方法中配置URL回调
```objc
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [[MMThirdPlatformManager sharedInstance] thirdPlatCanOpenUrlWithApplication:application openURL:url sourceApplication:sourceApplication annotation:annotation];
}
```
3、功能调用
所有的SDK方法在MMPayVC+Custom.h文件中
具体调用的可以下载项目代码在MMViewController.m文件中查看。
#### SDK配置
项目已经添加了微信、支付宝的第三方SDK了,这些平台的依赖库已经配置好了,所以不需要再次配置即可使用。
#### URL Types 配置
这些配置使用到的key或者APPID部分需要自行完善,其中,**调用支付宝支付的 URL Schemes 代码调用和URL Types中的配置要保持一致**。
可以复制以下配置文件的内容,配置文件中只包含了微信、支付宝的配置,修改对应平台的配置,粘贴到info.plist文件中,更多平台的配置需要参考对应平台的文档说明
```ruby
CFBundleURLTypes
CFBundleTypeRole
Editor
CFBundleURLName
weixin
CFBundleURLSchemes
你的微信APPID
CFBundleTypeRole
Editor
CFBundleURLSchemes
alipayPlush
```
#### QueriesSchemes配置
APP调用第三方APP需要用到的,下面的配置文件配置了微信、支付宝这几个第三方APP的调用,其中微信的配置需要填写你的微信APPID,如需要更多的其他第三方APP调用,参考第三方平台的配置添加即可。
```ruby
LSApplicationQueriesSchemes
wechat
weixin
```
#### 拓展:网页调用原生支付
APP会监听startMMPayMethod方法,如果收到该方法,则开始调用支付功能。
1.网页发起执行startMMPayMethod方法,参数为json字符串:{"out_trade_no":商户订单号, "order_code":支付中心订单号, "shop_openid":"店铺openid" }
2.app收到startMMPayMethod方法并接收参数处理
3.app开始支付
4.支付完成,会回传给该方法json字符串:{"payMethodName":支付宝/微信, "payMoney":支付金额, "status":"支付状态:1成功/0失败" }
(额外)网页端需要做的工作是:
1.集成WebViewJavascriptBridge库,方便与app进行js交互
2.使用startMMPayMethod方法传值,并监听该方法收到的返回值。
## Author
284051099@qq.com
## License
MMPayKit is available under the MIT license. See the LICENSE file for more info.