├── .gitignore ├── README.md ├── index.ios.js ├── ios ├── Channels │ └── Wx │ │ ├── WXApi.h │ │ ├── WXApiObject.h │ │ └── libpingpp+wx.a ├── Pingpp.bundle │ ├── Info.plist │ ├── PingppTestPaymentSummaryViewController.nib │ ├── en.lproj │ │ └── Localizable.strings │ └── zh-Hans.lproj │ │ └── Localizable.strings ├── Pingpp.h ├── RCTPingPP.xcodeproj │ ├── project.pbxproj │ └── xcuserdata │ │ └── yorkieliu.xcuserdatad │ │ └── xcschemes │ │ ├── RCTPingPP.xcscheme │ │ └── xcschememanagement.plist ├── RCTPingPP │ ├── RCTPingPP.h │ └── RCTPingPP.m └── libpingpp.a ├── package.json └── 来读我吧.md /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.DS_Store 3 | node_modules 4 | 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # React-Native Pingpp 3 | 4 | A React-Native(RN) binding library for [Pingxx.com]'s iOS and Android(TODO). For more details upstream documentation, take a look at the following links: 5 | 6 | - iOS: [PingPlusPlus/pingpp-ios](https://github.com/PingPlusPlus/pingpp-ios) 7 | - Android: [PingPlusPlus/pingpp-android](https://github.com/PingPlusPlus/pingpp-android) Not worked currently. 8 | 9 | 中文文档请点击[此处](来读我吧.md) 10 | 11 | ## Install 12 | 13 | ```sh 14 | $ npm install react-native-pingpp --save 15 | ``` 16 | 17 | ## Working in iOS 18 | 19 | 1. So the first place is [there](https://github.com/PingPlusPlus/pingpp-ios#手动导入), those steps will be required at upstream library [PingPlusPlus/pingpp-ios](https://github.com/PingPlusPlus/pingpp-ios). 20 | 21 | 2. Added the URL handled code to your application delegate like the below: 22 | 23 | ``` 24 | // for iOS 8 25 | - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { 26 | return [Pingpp handleOpenURL:url withCompletion:nil]; 27 | } 28 | 29 | // for iOS 9 30 | - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options { 31 | return [Pingpp handleOpenURL:url withCompletion:nil]; 32 | } 33 | ``` 34 | 35 | 3. Require `react-native-pingpp` to play around as below: 36 | 37 | ```js 38 | const { createPayment } = require('react-native-pingpp'); 39 | 40 | // anyway, you will be able to request and get back the charge object 41 | var result = await createPayment(charge, schema); 42 | // now will redirect to corresponding application, and get back. 43 | ``` 44 | 45 | ## Q & A 46 | 47 | - Why not found the libWechat.a which is able to find at PingPlusPlus/pingpp-ios? 48 | 49 | > Because react-native use static library to build, so that we require user to link that by yourself. Or you could directly use another WeFlex's RN library [react-native-wechat](https://github.com/weflex/react-native-wechat). 50 | 51 | - Why not working on Android? 52 | 53 | > That's just because I have no time to work on that platform, come soon later, Or Github pull request is also welcome :-) 54 | 55 | ## License 56 | 57 | GPLv2 @ WeFlex, Inc. 58 | -------------------------------------------------------------------------------- /index.ios.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const { 4 | setDebugMode, 5 | handleOpenURLInIOS8, 6 | handleOpenURLInIOS9, 7 | createPayment, 8 | } = require('react-native').NativeModules.PingPP; 9 | 10 | class PingPlusPlus { 11 | 12 | /** 13 | * 设置为debug模式 14 | * @method setDebugMode 15 | * @static 16 | * @param {Boolean} enabled 17 | */ 18 | static setDebugMode(enabled) { 19 | setDebugMode(enabled); 20 | return true; 21 | } 22 | 23 | /** 24 | * 在appDelegate中调用,iOS8及以下版本使用 25 | * @method handleOpenURLInIOS8 26 | * @static 27 | * @param {String} url 28 | * @param {Function} callback 29 | */ 30 | static handleOpenURLInIOS8(url, callback) { 31 | return handleOpenURLInIOS8(url, callback); 32 | } 33 | 34 | /** 35 | * 在appDelegate中调用,iOS9及以上版本使用 36 | * @method handleOpenURLInIOS9 37 | * @static 38 | * @param {String} url 39 | * @param {String} source 40 | * @param {Function} callback 41 | */ 42 | static handleOpenURLInIOS9(url, source, callback) { 43 | return handleOpenURLInIOS9(url, source, callback); 44 | } 45 | 46 | /** 47 | * 创建支付对象 48 | * @method createPayment 49 | * @static 50 | * @param {Object} charge 51 | * @param {String} schema 52 | * @param {Function} callback 53 | */ 54 | static createPayment(charge, schema, callback) { 55 | if (typeof callback === 'function') { 56 | createPayment(charge, schema, callback); 57 | } else { 58 | return new Promise( 59 | (resolve, reject) => createPayment(charge, schema, resolve)); 60 | } 61 | } 62 | 63 | } 64 | 65 | module.exports = PingPlusPlus; 66 | -------------------------------------------------------------------------------- /ios/Channels/Wx/WXApi.h: -------------------------------------------------------------------------------- 1 | // 2 | // WXApi.h 3 | // 所有Api接口 4 | // 5 | // Created by Wechat on 12-2-28. 6 | // Copyright (c) 2012年 Tencent. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "WXApiObject.h" 11 | 12 | 13 | #pragma mark - WXApiDelegate 14 | /*! @brief 接收并处理来自微信终端程序的事件消息 15 | * 16 | * 接收并处理来自微信终端程序的事件消息,期间微信界面会切换到第三方应用程序。 17 | * WXApiDelegate 会在handleOpenURL:delegate:中使用并触发。 18 | */ 19 | @protocol WXApiDelegate 20 | @optional 21 | 22 | /*! @brief 收到一个来自微信的请求,第三方应用程序处理完后调用sendResp向微信发送结果 23 | * 24 | * 收到一个来自微信的请求,异步处理完成后必须调用sendResp发送处理结果给微信。 25 | * 可能收到的请求有GetMessageFromWXReq、ShowMessageFromWXReq等。 26 | * @param req 具体请求内容,是自动释放的 27 | */ 28 | -(void) onReq:(BaseReq*)req; 29 | 30 | 31 | 32 | /*! @brief 发送一个sendReq后,收到微信的回应 33 | * 34 | * 收到一个来自微信的处理结果。调用一次sendReq后会收到onResp。 35 | * 可能收到的处理结果有SendMessageToWXResp、SendAuthResp等。 36 | * @param resp具体的回应内容,是自动释放的 37 | */ 38 | -(void) onResp:(BaseResp*)resp; 39 | 40 | @end 41 | 42 | 43 | 44 | #pragma mark - WXApi 45 | 46 | /*! @brief 微信Api接口函数类 47 | * 48 | * 该类封装了微信终端SDK的所有接口 49 | */ 50 | @interface WXApi : NSObject 51 | 52 | /*! @brief WXApi的成员函数,向微信终端程序注册第三方应用。 53 | * 54 | * 需要在每次启动第三方应用程序时调用。第一次调用后,会在微信的可用应用列表中出现。 55 | * iOS7及以上系统需要调起一次微信才会出现在微信的可用应用列表中。 56 | * @attention 请保证在主线程中调用此函数 57 | * @param appid 微信开发者ID 58 | * @return 成功返回YES,失败返回NO。 59 | */ 60 | +(BOOL) registerApp:(NSString *)appid; 61 | 62 | 63 | 64 | /*! @brief WXApi的成员函数,向微信终端程序注册第三方应用。 65 | * 66 | * 需要在每次启动第三方应用程序时调用。第一次调用后,会在微信的可用应用列表中出现。 67 | * @see registerApp 68 | * @param appid 微信开发者ID 69 | * @param appdesc 应用附加信息,长度不超过1024字节 70 | * @return 成功返回YES,失败返回NO。 71 | */ 72 | +(BOOL) registerApp:(NSString *)appid withDescription:(NSString *)appdesc; 73 | 74 | 75 | 76 | /*! @brief 处理微信通过URL启动App时传递的数据 77 | * 78 | * 需要在 application:openURL:sourceApplication:annotation:或者application:handleOpenURL中调用。 79 | * @param url 微信启动第三方应用时传递过来的URL 80 | * @param delegate WXApiDelegate对象,用来接收微信触发的消息。 81 | * @return 成功返回YES,失败返回NO。 82 | */ 83 | +(BOOL) handleOpenURL:(NSURL *) url delegate:(id) delegate; 84 | 85 | 86 | 87 | /*! @brief 检查微信是否已被用户安装 88 | * 89 | * @return 微信已安装返回YES,未安装返回NO。 90 | */ 91 | +(BOOL) isWXAppInstalled; 92 | 93 | 94 | 95 | /*! @brief 判断当前微信的版本是否支持OpenApi 96 | * 97 | * @return 支持返回YES,不支持返回NO。 98 | */ 99 | +(BOOL) isWXAppSupportApi; 100 | 101 | 102 | 103 | /*! @brief 获取微信的itunes安装地址 104 | * 105 | * @return 微信的安装地址字符串。 106 | */ 107 | +(NSString *) getWXAppInstallUrl; 108 | 109 | 110 | 111 | /*! @brief 获取当前微信SDK的版本号 112 | * 113 | * @return 返回当前微信SDK的版本号 114 | */ 115 | +(NSString *) getApiVersion; 116 | 117 | 118 | 119 | /*! @brief 打开微信 120 | * 121 | * @return 成功返回YES,失败返回NO。 122 | */ 123 | +(BOOL) openWXApp; 124 | 125 | 126 | 127 | /*! @brief 发送请求到微信,等待微信返回onResp 128 | * 129 | * 函数调用后,会切换到微信的界面。第三方应用程序等待微信返回onResp。微信在异步处理完成后一定会调用onResp。支持以下类型 130 | * SendAuthReq、SendMessageToWXReq、PayReq等。 131 | * @param req 具体的发送请求,在调用函数后,请自己释放。 132 | * @return 成功返回YES,失败返回NO。 133 | */ 134 | +(BOOL) sendReq:(BaseReq*)req; 135 | 136 | /*! @brief 发送Auth请求到微信,支持用户没安装微信,等待微信返回onResp 137 | * 138 | * 函数调用后,会切换到微信的界面。第三方应用程序等待微信返回onResp。微信在异步处理完成后一定会调用onResp。支持SendAuthReq类型。 139 | * @param req 具体的发送请求,在调用函数后,请自己释放。 140 | * @param viewController 当前界面对象。 141 | * @param delegate WXApiDelegate对象,用来接收微信触发的消息。 142 | * @return 成功返回YES,失败返回NO。 143 | */ 144 | +(BOOL) sendAuthReq:(SendAuthReq*) req viewController : (UIViewController*) viewController delegate:(id) delegate; 145 | 146 | 147 | /*! @brief 收到微信onReq的请求,发送对应的应答给微信,并切换到微信界面 148 | * 149 | * 函数调用后,会切换到微信的界面。第三方应用程序收到微信onReq的请求,异步处理该请求,完成后必须调用该函数。可能发送的相应有 150 | * GetMessageFromWXResp、ShowMessageFromWXResp等。 151 | * @param resp 具体的应答内容,调用函数后,请自己释放 152 | * @return 成功返回YES,失败返回NO。 153 | */ 154 | +(BOOL) sendResp:(BaseResp*)resp; 155 | 156 | 157 | @end 158 | -------------------------------------------------------------------------------- /ios/Channels/Wx/WXApiObject.h: -------------------------------------------------------------------------------- 1 | // 2 | // MMApiObject.h 3 | // Api对象,包含所有接口和对象数据定义 4 | // 5 | // Created by Wechat on 12-2-28. 6 | // Copyright (c) 2012年 Tencent. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /*! @brief 错误码 12 | * 13 | */ 14 | enum WXErrCode { 15 | WXSuccess = 0, /**< 成功 */ 16 | WXErrCodeCommon = -1, /**< 普通错误类型 */ 17 | WXErrCodeUserCancel = -2, /**< 用户点击取消并返回 */ 18 | WXErrCodeSentFail = -3, /**< 发送失败 */ 19 | WXErrCodeAuthDeny = -4, /**< 授权失败 */ 20 | WXErrCodeUnsupport = -5, /**< 微信不支持 */ 21 | }; 22 | 23 | 24 | 25 | /*! @brief 请求发送场景 26 | * 27 | */ 28 | enum WXScene { 29 | WXSceneSession = 0, /**< 聊天界面 */ 30 | WXSceneTimeline = 1, /**< 朋友圈 */ 31 | WXSceneFavorite = 2, /**< 收藏 */ 32 | }; 33 | 34 | 35 | 36 | enum WXAPISupport { 37 | WXAPISupportSession = 0, 38 | }; 39 | 40 | 41 | 42 | /*! @brief 跳转profile类型 43 | * 44 | */ 45 | enum WXBizProfileType{ 46 | WXBizProfileType_Normal = 0, //**< 普通公众号 */ 47 | WXBizProfileType_Device = 1, //**< 硬件公众号 */ 48 | }; 49 | 50 | 51 | 52 | /*! @brief 跳转mp网页类型 53 | * 54 | */ 55 | enum WXMPWebviewType { 56 | WXMPWebviewType_Ad = 0, /**< 广告网页 **/ 57 | }; 58 | 59 | #pragma mark - BaseReq 60 | /*! @brief 该类为微信终端SDK所有请求类的基类 61 | * 62 | */ 63 | @interface BaseReq : NSObject 64 | 65 | /** 请求类型 */ 66 | @property (nonatomic, assign) int type; 67 | /** 由用户微信号和AppID组成的唯一标识,发送请求时第三方程序必须填写,用于校验微信用户是否换号登录*/ 68 | @property (nonatomic, retain) NSString* openID; 69 | 70 | @end 71 | 72 | 73 | 74 | #pragma mark - BaseResp 75 | /*! @brief 该类为微信终端SDK所有响应类的基类 76 | * 77 | */ 78 | @interface BaseResp : NSObject 79 | /** 错误码 */ 80 | @property (nonatomic, assign) int errCode; 81 | /** 错误提示字符串 */ 82 | @property (nonatomic, retain) NSString *errStr; 83 | /** 响应类型 */ 84 | @property (nonatomic, assign) int type; 85 | 86 | @end 87 | 88 | 89 | 90 | #pragma mark - WXMediaMessage 91 | @class WXMediaMessage; 92 | 93 | /*! @brief 第三方向微信终端发起支付的消息结构体 94 | * 95 | * 第三方向微信终端发起支付的消息结构体,微信终端处理后会向第三方返回处理结果 96 | * @see PayResp 97 | */ 98 | @interface PayReq : BaseReq 99 | 100 | /** 商家向财付通申请的商家id */ 101 | @property (nonatomic, retain) NSString *partnerId; 102 | /** 预支付订单 */ 103 | @property (nonatomic, retain) NSString *prepayId; 104 | /** 随机串,防重发 */ 105 | @property (nonatomic, retain) NSString *nonceStr; 106 | /** 时间戳,防重发 */ 107 | @property (nonatomic, assign) UInt32 timeStamp; 108 | /** 商家根据财付通文档填写的数据和签名 */ 109 | @property (nonatomic, retain) NSString *package; 110 | /** 商家根据微信开放平台文档对数据做的签名 */ 111 | @property (nonatomic, retain) NSString *sign; 112 | 113 | @end 114 | 115 | 116 | 117 | #pragma mark - PayResp 118 | /*! @brief 微信终端返回给第三方的关于支付结果的结构体 119 | * 120 | * 微信终端返回给第三方的关于支付结果的结构体 121 | */ 122 | @interface PayResp : BaseResp 123 | 124 | /** 财付通返回给商家的信息 */ 125 | @property (nonatomic, retain) NSString *returnKey; 126 | 127 | @end 128 | 129 | 130 | 131 | #pragma mark - SendAuthReq 132 | /*! @brief 第三方程序向微信终端请求认证的消息结构 133 | * 134 | * 第三方程序要向微信申请认证,并请求某些权限,需要调用WXApi的sendReq成员函数, 135 | * 向微信终端发送一个SendAuthReq消息结构。微信终端处理完后会向第三方程序发送一个处理结果。 136 | * @see SendAuthResp 137 | */ 138 | @interface SendAuthReq : BaseReq 139 | /** 第三方程序要向微信申请认证,并请求某些权限,需要调用WXApi的sendReq成员函数,向微信终端发送一个SendAuthReq消息结构。微信终端处理完后会向第三方程序发送一个处理结果。 140 | * @see SendAuthResp 141 | * @note scope字符串长度不能超过1K 142 | */ 143 | @property (nonatomic, retain) NSString* scope; 144 | /** 第三方程序本身用来标识其请求的唯一性,最后跳转回第三方程序时,由微信终端回传。 145 | * @note state字符串长度不能超过1K 146 | */ 147 | @property (nonatomic, retain) NSString* state; 148 | @end 149 | 150 | 151 | 152 | #pragma mark - SendAuthResp 153 | /*! @brief 微信处理完第三方程序的认证和权限申请后向第三方程序回送的处理结果。 154 | * 155 | * 第三方程序要向微信申请认证,并请求某些权限,需要调用WXApi的sendReq成员函数,向微信终端发送一个SendAuthReq消息结构。 156 | * 微信终端处理完后会向第三方程序发送一个SendAuthResp。 157 | * @see onResp 158 | */ 159 | @interface SendAuthResp : BaseResp 160 | @property (nonatomic, retain) NSString* code; 161 | /** 第三方程序发送时用来标识其请求的唯一性的标志,由第三方程序调用sendReq时传入,由微信终端回传 162 | * @note state字符串长度不能超过1K 163 | */ 164 | @property (nonatomic, retain) NSString* state; 165 | @property (nonatomic, retain) NSString* lang; 166 | @property (nonatomic, retain) NSString* country; 167 | @end 168 | 169 | 170 | 171 | #pragma mark - SendMessageToWXReq 172 | /*! @brief 第三方程序发送消息至微信终端程序的消息结构体 173 | * 174 | * 第三方程序向微信发送信息需要传入SendMessageToWXReq结构体,信息类型包括文本消息和多媒体消息, 175 | * 分别对应于text和message成员。调用该方法后,微信处理完信息会向第三方程序发送一个处理结果。 176 | * @see SendMessageToWXResp 177 | */ 178 | @interface SendMessageToWXReq : BaseReq 179 | /** 发送消息的文本内容 180 | * @note 文本长度必须大于0且小于10K 181 | */ 182 | @property (nonatomic, retain) NSString* text; 183 | /** 发送消息的多媒体内容 184 | * @see WXMediaMessage 185 | */ 186 | @property (nonatomic, retain) WXMediaMessage* message; 187 | /** 发送消息的类型,包括文本消息和多媒体消息两种,两者只能选择其一,不能同时发送文本和多媒体消息 */ 188 | @property (nonatomic, assign) BOOL bText; 189 | /** 发送的目标场景,可以选择发送到会话(WXSceneSession)或者朋友圈(WXSceneTimeline)。 默认发送到会话。 190 | * @see WXScene 191 | */ 192 | @property (nonatomic, assign) int scene; 193 | 194 | @end 195 | 196 | 197 | 198 | #pragma mark - SendMessageToWXResp 199 | /*! @brief 微信终端向第三方程序返回的SendMessageToWXReq处理结果。 200 | * 201 | * 第三方程序向微信终端发送SendMessageToWXReq后,微信发送回来的处理结果,该结果用SendMessageToWXResp表示。 202 | */ 203 | @interface SendMessageToWXResp : BaseResp 204 | @property(nonatomic, retain) NSString* lang; 205 | @property(nonatomic, retain) NSString* country; 206 | @end 207 | 208 | 209 | 210 | #pragma mark - GetMessageFromWXReq 211 | /*! @brief 微信终端向第三方程序请求提供内容的消息结构体。 212 | * 213 | * 微信终端向第三方程序请求提供内容,微信终端会向第三方程序发送GetMessageFromWXReq消息结构体, 214 | * 需要第三方程序调用sendResp返回一个GetMessageFromWXResp消息结构体。 215 | */ 216 | @interface GetMessageFromWXReq : BaseReq 217 | @property (nonatomic, retain) NSString* lang; 218 | @property (nonatomic, retain) NSString* country; 219 | @end 220 | 221 | 222 | 223 | #pragma mark - GetMessageFromWXResp 224 | /*! @brief 微信终端向第三方程序请求提供内容,第三方程序向微信终端返回的消息结构体。 225 | * 226 | * 微信终端向第三方程序请求提供内容,第三方程序调用sendResp向微信终端返回一个GetMessageFromWXResp消息结构体。 227 | */ 228 | @interface GetMessageFromWXResp : BaseResp 229 | /** 向微信终端提供的文本内容 230 | @note 文本长度必须大于0且小于10K 231 | */ 232 | @property (nonatomic, retain) NSString* text; 233 | /** 向微信终端提供的多媒体内容。 234 | * @see WXMediaMessage 235 | */ 236 | @property (nonatomic, retain) WXMediaMessage* message; 237 | /** 向微信终端提供内容的消息类型,包括文本消息和多媒体消息两种,两者只能选择其一,不能同时发送文本和多媒体消息 */ 238 | @property (nonatomic, assign) BOOL bText; 239 | @end 240 | 241 | 242 | 243 | #pragma mark - ShowMessageFromWXReq 244 | /*! @brief 微信通知第三方程序,要求第三方程序显示的消息结构体。 245 | * 246 | * 微信需要通知第三方程序显示或处理某些内容时,会向第三方程序发送ShowMessageFromWXReq消息结构体。 247 | * 第三方程序处理完内容后调用sendResp向微信终端发送ShowMessageFromWXResp。 248 | */ 249 | @interface ShowMessageFromWXReq : BaseReq 250 | /** 微信终端向第三方程序发送的要求第三方程序处理的多媒体内容 251 | * @see WXMediaMessage 252 | */ 253 | @property (nonatomic, retain) WXMediaMessage* message; 254 | @property (nonatomic, retain) NSString* lang; 255 | @property (nonatomic, retain) NSString* country; 256 | @end 257 | 258 | 259 | 260 | #pragma mark - ShowMessageFromWXResp 261 | /*! @brief 微信通知第三方程序,要求第三方程序显示或处理某些消息,第三方程序处理完后向微信终端发送的处理结果。 262 | * 263 | * 微信需要通知第三方程序显示或处理某些内容时,会向第三方程序发送ShowMessageFromWXReq消息结构体。 264 | * 第三方程序处理完内容后调用sendResp向微信终端发送ShowMessageFromWXResp。 265 | */ 266 | @interface ShowMessageFromWXResp : BaseResp 267 | @end 268 | 269 | 270 | 271 | #pragma mark - LaunchFromWXReq 272 | /*! @brief 微信终端打开第三方程序携带的消息结构体 273 | * 274 | * 微信向第三方发送的结构体,第三方不需要返回 275 | */ 276 | @interface LaunchFromWXReq : BaseReq 277 | @property (nonatomic, retain) WXMediaMessage* message; 278 | @property (nonatomic, retain) NSString* lang; 279 | @property (nonatomic, retain) NSString* country; 280 | @end 281 | 282 | #pragma mark - JumpToBizProfileReq 283 | /* ! @brief 第三方通知微信,打开指定微信号profile页面 284 | * 285 | * 第三方通知微信,打开指定微信号profile页面 286 | */ 287 | @interface JumpToBizProfileReq : BaseReq 288 | /** 跳转到该公众号的profile 289 | * @attention 长度不能超过512字节 290 | */ 291 | @property (nonatomic, retain) NSString* username; 292 | /** 如果用户加了该公众号为好友,extMsg会上传到服务器 293 | * @attention 长度不能超过1024字节 294 | */ 295 | @property (nonatomic, retain) NSString* extMsg; 296 | /** 297 | * 跳转的公众号类型 298 | * @see WXBizProfileType 299 | */ 300 | @property (nonatomic, assign) int profileType; 301 | @end 302 | 303 | 304 | 305 | #pragma mark - JumpToBizWebviewReq 306 | /* ! @brief 第三方通知微信,打开指定usrname的profile网页版 307 | * 308 | */ 309 | @interface JumpToBizWebviewReq : BaseReq 310 | /** 跳转的网页类型,目前只支持广告页 311 | * @see WXMPWebviewType 312 | */ 313 | @property(nonatomic, assign) int webType; 314 | /** 跳转到该公众号的profile网页版 315 | * @attention 长度不能超过512字节 316 | */ 317 | @property(nonatomic, retain) NSString* tousrname; 318 | /** 如果用户加了该公众号为好友,extMsg会上传到服务器 319 | * @attention 长度不能超过1024字节 320 | */ 321 | @property(nonatomic, retain) NSString* extMsg; 322 | 323 | @end 324 | 325 | #pragma mark - WXCardItem 326 | 327 | @interface WXCardItem : NSObject 328 | /** 卡id 329 | * @attention 长度不能超过1024字节 330 | */ 331 | @property (nonatomic,retain) NSString* cardId; 332 | /** ext信息 333 | * @attention 长度不能超过2024字节 334 | */ 335 | @property (nonatomic,retain) NSString* extMsg; 336 | /** 337 | * @attention 卡的状态,req不需要填。resp:0为未添加,1为已添加。 338 | */ 339 | @property (nonatomic,assign) UInt32 cardState; 340 | @end; 341 | 342 | #pragma mark - AddCardToWXCardPackageReq 343 | /* ! @brief 请求添加卡券至微信卡包 344 | * 345 | */ 346 | 347 | @interface AddCardToWXCardPackageReq : BaseReq 348 | /** 卡列表 349 | * @attention 个数不能超过40个 类型WXCardItem 350 | */ 351 | @property (nonatomic,retain) NSArray* cardAry; 352 | 353 | @end 354 | 355 | 356 | #pragma mark - AddCardToWXCardPackageResp 357 | /** ! @brief 微信返回第三方添加卡券结果 358 | * 359 | */ 360 | 361 | @interface AddCardToWXCardPackageResp : BaseResp 362 | /** 卡列表 363 | * @attention 个数不能超过40个 类型WXCardItem 364 | */ 365 | @property (nonatomic,retain) NSArray* cardAry; 366 | @end 367 | 368 | 369 | #pragma mark - WXMediaMessage 370 | 371 | /*! @brief 多媒体消息结构体 372 | * 373 | * 用于微信终端和第三方程序之间传递消息的多媒体消息内容 374 | */ 375 | @interface WXMediaMessage : NSObject 376 | 377 | +(WXMediaMessage *) message; 378 | 379 | /** 标题 380 | * @note 长度不能超过512字节 381 | */ 382 | @property (nonatomic, retain) NSString *title; 383 | /** 描述内容 384 | * @note 长度不能超过1K 385 | */ 386 | @property (nonatomic, retain) NSString *description; 387 | /** 缩略图数据 388 | * @note 大小不能超过32K 389 | */ 390 | @property (nonatomic, retain) NSData *thumbData; 391 | /** 392 | * @note 长度不能超过64字节 393 | */ 394 | @property (nonatomic, retain) NSString *mediaTagName; 395 | /** 396 | * 397 | */ 398 | @property (nonatomic, retain) NSString *messageExt; 399 | @property (nonatomic, retain) NSString *messageAction; 400 | /** 401 | * 多媒体数据对象,可以为WXImageObject,WXMusicObject,WXVideoObject,WXWebpageObject等。 402 | */ 403 | @property (nonatomic, retain) id mediaObject; 404 | 405 | /*! @brief 设置消息缩略图的方法 406 | * 407 | * @param image 缩略图 408 | * @note 大小不能超过32K 409 | */ 410 | - (void) setThumbImage:(UIImage *)image; 411 | 412 | @end 413 | 414 | 415 | 416 | #pragma mark - WXImageObject 417 | /*! @brief 多媒体消息中包含的图片数据对象 418 | * 419 | * 微信终端和第三方程序之间传递消息中包含的图片数据对象。 420 | * @note imageData和imageUrl成员不能同时为空 421 | * @see WXMediaMessage 422 | */ 423 | @interface WXImageObject : NSObject 424 | /*! @brief 返回一个WXImageObject对象 425 | * 426 | * @note 返回的WXImageObject对象是自动释放的 427 | */ 428 | +(WXImageObject *) object; 429 | 430 | /** 图片真实数据内容 431 | * @note 大小不能超过10M 432 | */ 433 | @property (nonatomic, retain) NSData *imageData; 434 | /** 图片url 435 | * @note 长度不能超过10K 436 | */ 437 | @property (nonatomic, retain) NSString *imageUrl; 438 | 439 | @end 440 | 441 | 442 | #pragma mark - WXMusicObject 443 | /*! @brief 多媒体消息中包含的音乐数据对象 444 | * 445 | * 微信终端和第三方程序之间传递消息中包含的音乐数据对象。 446 | * @note musicUrl和musicLowBandUrl成员不能同时为空。 447 | * @see WXMediaMessage 448 | */ 449 | @interface WXMusicObject : NSObject 450 | /*! @brief 返回一个WXMusicObject对象 451 | * 452 | * @note 返回的WXMusicObject对象是自动释放的 453 | */ 454 | +(WXMusicObject *) object; 455 | 456 | /** 音乐网页的url地址 457 | * @note 长度不能超过10K 458 | */ 459 | @property (nonatomic, retain) NSString *musicUrl; 460 | /** 音乐lowband网页的url地址 461 | * @note 长度不能超过10K 462 | */ 463 | @property (nonatomic, retain) NSString *musicLowBandUrl; 464 | /** 音乐数据url地址 465 | * @note 长度不能超过10K 466 | */ 467 | @property (nonatomic, retain) NSString *musicDataUrl; 468 | 469 | /**音乐lowband数据url地址 470 | * @note 长度不能超过10K 471 | */ 472 | @property (nonatomic, retain) NSString *musicLowBandDataUrl; 473 | 474 | @end 475 | 476 | 477 | 478 | #pragma mark - WXVideoObject 479 | /*! @brief 多媒体消息中包含的视频数据对象 480 | * 481 | * 微信终端和第三方程序之间传递消息中包含的视频数据对象。 482 | * @note videoUrl和videoLowBandUrl不能同时为空。 483 | * @see WXMediaMessage 484 | */ 485 | @interface WXVideoObject : NSObject 486 | /*! @brief 返回一个WXVideoObject对象 487 | * 488 | * @note 返回的WXVideoObject对象是自动释放的 489 | */ 490 | +(WXVideoObject *) object; 491 | 492 | /** 视频网页的url地址 493 | * @note 长度不能超过10K 494 | */ 495 | @property (nonatomic, retain) NSString *videoUrl; 496 | /** 视频lowband网页的url地址 497 | * @note 长度不能超过10K 498 | */ 499 | @property (nonatomic, retain) NSString *videoLowBandUrl; 500 | 501 | @end 502 | 503 | 504 | 505 | #pragma mark - WXWebpageObject 506 | /*! @brief 多媒体消息中包含的网页数据对象 507 | * 508 | * 微信终端和第三方程序之间传递消息中包含的网页数据对象。 509 | * @see WXMediaMessage 510 | */ 511 | @interface WXWebpageObject : NSObject 512 | /*! @brief 返回一个WXWebpageObject对象 513 | * 514 | * @note 返回的WXWebpageObject对象是自动释放的 515 | */ 516 | +(WXWebpageObject *) object; 517 | 518 | /** 网页的url地址 519 | * @note 不能为空且长度不能超过10K 520 | */ 521 | @property (nonatomic, retain) NSString *webpageUrl; 522 | 523 | @end 524 | 525 | 526 | 527 | #pragma mark - WXAppExtendObject 528 | /*! @brief 多媒体消息中包含的App扩展数据对象 529 | * 530 | * 第三方程序向微信终端发送包含WXAppExtendObject的多媒体消息, 531 | * 微信需要处理该消息时,会调用该第三方程序来处理多媒体消息内容。 532 | * @note url,extInfo和fileData不能同时为空 533 | * @see WXMediaMessage 534 | */ 535 | @interface WXAppExtendObject : NSObject 536 | /*! @brief 返回一个WXAppExtendObject对象 537 | * 538 | * @note 返回的WXAppExtendObject对象是自动释放的 539 | */ 540 | +(WXAppExtendObject *) object; 541 | 542 | /** 若第三方程序不存在,微信终端会打开该url所指的App下载地址 543 | * @note 长度不能超过10K 544 | */ 545 | @property (nonatomic, retain) NSString *url; 546 | /** 第三方程序自定义简单数据,微信终端会回传给第三方程序处理 547 | * @note 长度不能超过2K 548 | */ 549 | @property (nonatomic, retain) NSString *extInfo; 550 | /** App文件数据,该数据发送给微信好友,微信好友需要点击后下载数据,微信终端会回传给第三方程序处理 551 | * @note 大小不能超过10M 552 | */ 553 | @property (nonatomic, retain) NSData *fileData; 554 | 555 | @end 556 | 557 | 558 | 559 | #pragma mark - WXEmoticonObject 560 | /*! @brief 多媒体消息中包含的表情数据对象 561 | * 562 | * 微信终端和第三方程序之间传递消息中包含的表情数据对象。 563 | * @see WXMediaMessage 564 | */ 565 | @interface WXEmoticonObject : NSObject 566 | 567 | /*! @brief 返回一个WXEmoticonObject对象 568 | * 569 | * @note 返回的WXEmoticonObject对象是自动释放的 570 | */ 571 | +(WXEmoticonObject *) object; 572 | 573 | /** 表情真实数据内容 574 | * @note 大小不能超过10M 575 | */ 576 | @property (nonatomic, retain) NSData *emoticonData; 577 | 578 | @end 579 | 580 | 581 | 582 | #pragma mark - WXFileObject 583 | /*! @brief 多媒体消息中包含的文件数据对象 584 | * 585 | * @see WXMediaMessage 586 | */ 587 | @interface WXFileObject : NSObject 588 | 589 | /*! @brief 返回一个WXFileObject对象 590 | * 591 | * @note 返回的WXFileObject对象是自动释放的 592 | */ 593 | +(WXFileObject *) object; 594 | 595 | /** 文件后缀名 596 | * @note 长度不超过64字节 597 | */ 598 | @property (nonatomic, retain) NSString *fileExtension; 599 | 600 | /** 文件真实数据内容 601 | * @note 大小不能超过10M 602 | */ 603 | @property (nonatomic, retain) NSData *fileData; 604 | 605 | @end 606 | -------------------------------------------------------------------------------- /ios/Channels/Wx/libpingpp+wx.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weflex/react-native-pingpp/4b480c08e17baaa291a2a6023d724cfab8435c64/ios/Channels/Wx/libpingpp+wx.a -------------------------------------------------------------------------------- /ios/Pingpp.bundle/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weflex/react-native-pingpp/4b480c08e17baaa291a2a6023d724cfab8435c64/ios/Pingpp.bundle/Info.plist -------------------------------------------------------------------------------- /ios/Pingpp.bundle/PingppTestPaymentSummaryViewController.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weflex/react-native-pingpp/4b480c08e17baaa291a2a6023d724cfab8435c64/ios/Pingpp.bundle/PingppTestPaymentSummaryViewController.nib -------------------------------------------------------------------------------- /ios/Pingpp.bundle/en.lproj/Localizable.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weflex/react-native-pingpp/4b480c08e17baaa291a2a6023d724cfab8435c64/ios/Pingpp.bundle/en.lproj/Localizable.strings -------------------------------------------------------------------------------- /ios/Pingpp.bundle/zh-Hans.lproj/Localizable.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weflex/react-native-pingpp/4b480c08e17baaa291a2a6023d724cfab8435c64/ios/Pingpp.bundle/zh-Hans.lproj/Localizable.strings -------------------------------------------------------------------------------- /ios/Pingpp.h: -------------------------------------------------------------------------------- 1 | // 2 | // Pingpp.h 3 | // Pingpp 4 | // 5 | // Created by afon on 14/11/20. 6 | // 7 | #ifndef Pingpp_Pingpp_h 8 | #define Pingpp_Pingpp_h 9 | 10 | #import 11 | #import 12 | 13 | typedef NS_ENUM(NSUInteger, PingppErrorOption) 14 | { 15 | PingppErrInvalidCharge, 16 | PingppErrInvalidCredential, 17 | PingppErrInvalidChannel, 18 | PingppErrWxNotInstalled, 19 | PingppErrWxAppNotSupported, 20 | PingppErrCancelled, 21 | PingppErrViewControllerIsNil, 22 | PingppErrTestmodeNotifyFailed, 23 | PingppErrChannelReturnFail, 24 | PingppErrConnectionError, 25 | PingppErrUnknownError 26 | }; 27 | 28 | @interface PingppError : NSObject 29 | 30 | @property(readonly, assign) PingppErrorOption code; 31 | 32 | - (NSString *)getMsg; 33 | 34 | @end 35 | 36 | 37 | typedef void (^PingppCompletion)(NSString *result, PingppError *error); 38 | 39 | @protocol PingppDelegate 40 | 41 | - (void)paymentResult:(NSString *)result; 42 | 43 | @end 44 | 45 | @interface Pingpp : NSObject 46 | 47 | /** 48 | * deprecated 49 | */ 50 | + (void)createPayment:(NSString *)charge viewController:(UIViewController *)viewController appURLScheme:(NSString *)scheme delegate:(id)delegate __attribute__((deprecated)); 51 | 52 | /** 53 | * 支付调用接口 54 | * 55 | * @param charge Charge 对象(JSON 格式字符串 或 NSDictionary) 56 | * @param viewController 银联渠道需要 57 | * @param scheme URL Scheme,支付宝渠道回调需要 58 | * @param completionBlock 支付结果回调 Block 59 | */ 60 | + (void)createPayment:(NSObject *)charge viewController:(UIViewController*)viewController appURLScheme:(NSString *)scheme withCompletion:(PingppCompletion)completionBlock; 61 | 62 | /** 63 | * 支付调用接口(支付宝/微信) 64 | * 65 | * @param charge Charge 对象(JSON 格式字符串 或 NSDictionary) 66 | * @param scheme URL Scheme,支付宝渠道回调需要 67 | * @param completionBlock 支付结果回调 Block 68 | */ 69 | + (void)createPayment:(NSObject *)charge appURLScheme:(NSString *)scheme withCompletion:(PingppCompletion)completion; 70 | 71 | /** 72 | * deprecated 73 | */ 74 | + (void)handleOpenURL:(NSURL *)url delegate:(id)delegate __attribute__((deprecated)); 75 | 76 | /** 77 | * 回调结果接口(支付宝/微信/测试模式) 78 | * 79 | * @param url 结果url 80 | * @param completionBlock 支付结果回调 Block,保证跳转支付过程中,当 app 被 kill 掉时,能通过这个接口得到支付结果 81 | * 82 | * @return 当无法处理 URL 或者 URL 格式不正确时,会返回 NO。 83 | */ 84 | + (BOOL)handleOpenURL:(NSURL *)url withCompletion:(PingppCompletion)completion; 85 | 86 | /** 87 | * 回调结果接口(支付宝/微信/测试模式) 88 | * 89 | * @param url 结果url 90 | * @param sourceApplication 源应用 Bundle identifier 91 | * @param completionBlock 支付结果回调 Block,保证跳转支付过程中,当 app 被 kill 掉时,能通过这个接口得到支付结果 92 | * 93 | * @return 当无法处理 URL 或者 URL 格式不正确时,会返回 NO。 94 | */ 95 | + (BOOL)handleOpenURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication withCompletion:(PingppCompletion)completion; 96 | 97 | /** 98 | * 版本号 99 | * 100 | * @return Pingpp SDK 版本号 101 | */ 102 | + (NSString *)version; 103 | 104 | /** 105 | * 设置 Debug 模式 106 | * 107 | * @param enabled 是否启用 108 | */ 109 | + (void)setDebugMode:(BOOL)enabled; 110 | 111 | /** 112 | * 设置百度钱包导航条背景 113 | */ 114 | + (void)setBdWalletNavBgImage:(UIImage *)image; 115 | 116 | /** 117 | * 设置百度钱包返回键Normal图像 118 | */ 119 | + (void)setBdWalletNavBackNormalImage:(UIImage *)image; 120 | 121 | /** 122 | * 设置百度钱包Title颜色 123 | */ 124 | + (void)setBdWalletNavTitleColor:(UIColor *)color; 125 | 126 | @end 127 | #endif -------------------------------------------------------------------------------- /ios/RCTPingPP.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 86B2B0DF1BE4E27A009A1FA5 /* RCTPingPP.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 86B2B0DE1BE4E27A009A1FA5 /* RCTPingPP.h */; }; 11 | 86B2B0E11BE4E27A009A1FA5 /* RCTPingPP.m in Sources */ = {isa = PBXBuildFile; fileRef = 86B2B0E01BE4E27A009A1FA5 /* RCTPingPP.m */; }; 12 | 86B2B1351BE4E76E009A1FA5 /* libpingpp+wx.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 86B2B1221BE4E76E009A1FA5 /* libpingpp+wx.a */; }; 13 | 86B2B1371BE4E76E009A1FA5 /* libpingpp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 86B2B1261BE4E76E009A1FA5 /* libpingpp.a */; }; 14 | /* End PBXBuildFile section */ 15 | 16 | /* Begin PBXCopyFilesBuildPhase section */ 17 | 86B2B0D91BE4E27A009A1FA5 /* CopyFiles */ = { 18 | isa = PBXCopyFilesBuildPhase; 19 | buildActionMask = 2147483647; 20 | dstPath = "include/$(PRODUCT_NAME)"; 21 | dstSubfolderSpec = 16; 22 | files = ( 23 | 86B2B0DF1BE4E27A009A1FA5 /* RCTPingPP.h in CopyFiles */, 24 | ); 25 | runOnlyForDeploymentPostprocessing = 0; 26 | }; 27 | /* End PBXCopyFilesBuildPhase section */ 28 | 29 | /* Begin PBXFileReference section */ 30 | 86B2B0DB1BE4E27A009A1FA5 /* libRCTPingPP.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTPingPP.a; sourceTree = BUILT_PRODUCTS_DIR; }; 31 | 86B2B0DE1BE4E27A009A1FA5 /* RCTPingPP.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCTPingPP.h; sourceTree = ""; }; 32 | 86B2B0E01BE4E27A009A1FA5 /* RCTPingPP.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RCTPingPP.m; sourceTree = ""; }; 33 | 86B2B1221BE4E76E009A1FA5 /* libpingpp+wx.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = "libpingpp+wx.a"; sourceTree = ""; }; 34 | 86B2B1241BE4E76E009A1FA5 /* WXApi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WXApi.h; sourceTree = ""; }; 35 | 86B2B1251BE4E76E009A1FA5 /* WXApiObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WXApiObject.h; sourceTree = ""; }; 36 | 86B2B1261BE4E76E009A1FA5 /* libpingpp.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libpingpp.a; sourceTree = ""; }; 37 | 86B2B1281BE4E76E009A1FA5 /* Pingpp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Pingpp.h; sourceTree = ""; }; 38 | /* End PBXFileReference section */ 39 | 40 | /* Begin PBXFrameworksBuildPhase section */ 41 | 86B2B0D81BE4E27A009A1FA5 /* Frameworks */ = { 42 | isa = PBXFrameworksBuildPhase; 43 | buildActionMask = 2147483647; 44 | files = ( 45 | 86B2B1371BE4E76E009A1FA5 /* libpingpp.a in Frameworks */, 46 | 86B2B1351BE4E76E009A1FA5 /* libpingpp+wx.a in Frameworks */, 47 | ); 48 | runOnlyForDeploymentPostprocessing = 0; 49 | }; 50 | /* End PBXFrameworksBuildPhase section */ 51 | 52 | /* Begin PBXGroup section */ 53 | 86B2B0D21BE4E27A009A1FA5 = { 54 | isa = PBXGroup; 55 | children = ( 56 | 86B2B1261BE4E76E009A1FA5 /* libpingpp.a */, 57 | 86B2B1281BE4E76E009A1FA5 /* Pingpp.h */, 58 | 86B2B0F31BE4E76E009A1FA5 /* Channels */, 59 | 86B2B0DD1BE4E27A009A1FA5 /* RCTPingPP */, 60 | 86B2B0DC1BE4E27A009A1FA5 /* Products */, 61 | ); 62 | sourceTree = ""; 63 | }; 64 | 86B2B0DC1BE4E27A009A1FA5 /* Products */ = { 65 | isa = PBXGroup; 66 | children = ( 67 | 86B2B0DB1BE4E27A009A1FA5 /* libRCTPingPP.a */, 68 | ); 69 | name = Products; 70 | sourceTree = ""; 71 | }; 72 | 86B2B0DD1BE4E27A009A1FA5 /* RCTPingPP */ = { 73 | isa = PBXGroup; 74 | children = ( 75 | 86B2B0DE1BE4E27A009A1FA5 /* RCTPingPP.h */, 76 | 86B2B0E01BE4E27A009A1FA5 /* RCTPingPP.m */, 77 | ); 78 | path = RCTPingPP; 79 | sourceTree = ""; 80 | }; 81 | 86B2B0F31BE4E76E009A1FA5 /* Channels */ = { 82 | isa = PBXGroup; 83 | children = ( 84 | 86B2B1211BE4E76E009A1FA5 /* Wx */, 85 | ); 86 | path = Channels; 87 | sourceTree = ""; 88 | }; 89 | 86B2B1211BE4E76E009A1FA5 /* Wx */ = { 90 | isa = PBXGroup; 91 | children = ( 92 | 86B2B1221BE4E76E009A1FA5 /* libpingpp+wx.a */, 93 | 86B2B1241BE4E76E009A1FA5 /* WXApi.h */, 94 | 86B2B1251BE4E76E009A1FA5 /* WXApiObject.h */, 95 | ); 96 | path = Wx; 97 | sourceTree = ""; 98 | }; 99 | /* End PBXGroup section */ 100 | 101 | /* Begin PBXNativeTarget section */ 102 | 86B2B0DA1BE4E27A009A1FA5 /* RCTPingPP */ = { 103 | isa = PBXNativeTarget; 104 | buildConfigurationList = 86B2B0E41BE4E27A009A1FA5 /* Build configuration list for PBXNativeTarget "RCTPingPP" */; 105 | buildPhases = ( 106 | 86B2B0D71BE4E27A009A1FA5 /* Sources */, 107 | 86B2B0D81BE4E27A009A1FA5 /* Frameworks */, 108 | 86B2B0D91BE4E27A009A1FA5 /* CopyFiles */, 109 | ); 110 | buildRules = ( 111 | ); 112 | dependencies = ( 113 | ); 114 | name = RCTPingPP; 115 | productName = RCTPingPP; 116 | productReference = 86B2B0DB1BE4E27A009A1FA5 /* libRCTPingPP.a */; 117 | productType = "com.apple.product-type.library.static"; 118 | }; 119 | /* End PBXNativeTarget section */ 120 | 121 | /* Begin PBXProject section */ 122 | 86B2B0D31BE4E27A009A1FA5 /* Project object */ = { 123 | isa = PBXProject; 124 | attributes = { 125 | LastUpgradeCheck = 0710; 126 | ORGANIZATIONNAME = WeFlex; 127 | TargetAttributes = { 128 | 86B2B0DA1BE4E27A009A1FA5 = { 129 | CreatedOnToolsVersion = 7.1; 130 | DevelopmentTeam = JP4369ZCVM; 131 | }; 132 | }; 133 | }; 134 | buildConfigurationList = 86B2B0D61BE4E27A009A1FA5 /* Build configuration list for PBXProject "RCTPingPP" */; 135 | compatibilityVersion = "Xcode 3.2"; 136 | developmentRegion = English; 137 | hasScannedForEncodings = 0; 138 | knownRegions = ( 139 | en, 140 | ); 141 | mainGroup = 86B2B0D21BE4E27A009A1FA5; 142 | productRefGroup = 86B2B0DC1BE4E27A009A1FA5 /* Products */; 143 | projectDirPath = ""; 144 | projectRoot = ""; 145 | targets = ( 146 | 86B2B0DA1BE4E27A009A1FA5 /* RCTPingPP */, 147 | ); 148 | }; 149 | /* End PBXProject section */ 150 | 151 | /* Begin PBXSourcesBuildPhase section */ 152 | 86B2B0D71BE4E27A009A1FA5 /* Sources */ = { 153 | isa = PBXSourcesBuildPhase; 154 | buildActionMask = 2147483647; 155 | files = ( 156 | 86B2B0E11BE4E27A009A1FA5 /* RCTPingPP.m in Sources */, 157 | ); 158 | runOnlyForDeploymentPostprocessing = 0; 159 | }; 160 | /* End PBXSourcesBuildPhase section */ 161 | 162 | /* Begin XCBuildConfiguration section */ 163 | 86B2B0E21BE4E27A009A1FA5 /* Debug */ = { 164 | isa = XCBuildConfiguration; 165 | buildSettings = { 166 | ALWAYS_SEARCH_USER_PATHS = NO; 167 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 168 | CLANG_CXX_LIBRARY = "libc++"; 169 | CLANG_ENABLE_MODULES = YES; 170 | CLANG_ENABLE_OBJC_ARC = YES; 171 | CLANG_WARN_BOOL_CONVERSION = YES; 172 | CLANG_WARN_CONSTANT_CONVERSION = YES; 173 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 174 | CLANG_WARN_EMPTY_BODY = YES; 175 | CLANG_WARN_ENUM_CONVERSION = YES; 176 | CLANG_WARN_INT_CONVERSION = YES; 177 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 178 | CLANG_WARN_UNREACHABLE_CODE = YES; 179 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 180 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 181 | COPY_PHASE_STRIP = NO; 182 | DEBUG_INFORMATION_FORMAT = dwarf; 183 | ENABLE_STRICT_OBJC_MSGSEND = YES; 184 | ENABLE_TESTABILITY = YES; 185 | GCC_C_LANGUAGE_STANDARD = gnu99; 186 | GCC_DYNAMIC_NO_PIC = NO; 187 | GCC_NO_COMMON_BLOCKS = YES; 188 | GCC_OPTIMIZATION_LEVEL = 0; 189 | GCC_PREPROCESSOR_DEFINITIONS = ( 190 | "DEBUG=1", 191 | "$(inherited)", 192 | ); 193 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 194 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 195 | GCC_WARN_UNDECLARED_SELECTOR = YES; 196 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 197 | GCC_WARN_UNUSED_FUNCTION = YES; 198 | GCC_WARN_UNUSED_VARIABLE = YES; 199 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 200 | MTL_ENABLE_DEBUG_INFO = YES; 201 | ONLY_ACTIVE_ARCH = YES; 202 | SDKROOT = iphoneos; 203 | }; 204 | name = Debug; 205 | }; 206 | 86B2B0E31BE4E27A009A1FA5 /* Release */ = { 207 | isa = XCBuildConfiguration; 208 | buildSettings = { 209 | ALWAYS_SEARCH_USER_PATHS = NO; 210 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 211 | CLANG_CXX_LIBRARY = "libc++"; 212 | CLANG_ENABLE_MODULES = YES; 213 | CLANG_ENABLE_OBJC_ARC = YES; 214 | CLANG_WARN_BOOL_CONVERSION = YES; 215 | CLANG_WARN_CONSTANT_CONVERSION = YES; 216 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 217 | CLANG_WARN_EMPTY_BODY = YES; 218 | CLANG_WARN_ENUM_CONVERSION = YES; 219 | CLANG_WARN_INT_CONVERSION = YES; 220 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 221 | CLANG_WARN_UNREACHABLE_CODE = YES; 222 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 223 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 224 | COPY_PHASE_STRIP = NO; 225 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 226 | ENABLE_NS_ASSERTIONS = NO; 227 | ENABLE_STRICT_OBJC_MSGSEND = YES; 228 | GCC_C_LANGUAGE_STANDARD = gnu99; 229 | GCC_NO_COMMON_BLOCKS = YES; 230 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 231 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 232 | GCC_WARN_UNDECLARED_SELECTOR = YES; 233 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 234 | GCC_WARN_UNUSED_FUNCTION = YES; 235 | GCC_WARN_UNUSED_VARIABLE = YES; 236 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 237 | MTL_ENABLE_DEBUG_INFO = NO; 238 | SDKROOT = iphoneos; 239 | VALIDATE_PRODUCT = YES; 240 | }; 241 | name = Release; 242 | }; 243 | 86B2B0E51BE4E27A009A1FA5 /* Debug */ = { 244 | isa = XCBuildConfiguration; 245 | buildSettings = { 246 | FRAMEWORK_SEARCH_PATHS = ( 247 | "$(inherited)", 248 | "$(PROJECT_DIR)/Channels/Alipay", 249 | ); 250 | HEADER_SEARCH_PATHS = "$(SRCROOT)/../../react-native/React"; 251 | LIBRARY_SEARCH_PATHS = ( 252 | "$(inherited)", 253 | "$(PROJECT_DIR)/Channels/Alipay", 254 | "$(PROJECT_DIR)/Channels/ApplePay", 255 | "$(PROJECT_DIR)/Channels/Bfb/Dependencies/ASIHttpRequest", 256 | "$(PROJECT_DIR)/Channels/Bfb/Dependencies/BaiduMobStat/BaiduMobStat", 257 | "$(PROJECT_DIR)/Channels/Bfb/Dependencies/BaiduMobStat", 258 | "$(PROJECT_DIR)/Channels/Bfb/Dependencies/JSONKit", 259 | "$(PROJECT_DIR)/Channels/Bfb/Dependencies/SDWebImage", 260 | "$(PROJECT_DIR)/Channels/Bfb", 261 | "$(PROJECT_DIR)/Channels/UnionPay", 262 | "$(PROJECT_DIR)/Channels/Wx", 263 | "$(PROJECT_DIR)", 264 | ); 265 | OTHER_LDFLAGS = "-ObjC"; 266 | PRODUCT_NAME = "$(TARGET_NAME)"; 267 | SKIP_INSTALL = YES; 268 | }; 269 | name = Debug; 270 | }; 271 | 86B2B0E61BE4E27A009A1FA5 /* Release */ = { 272 | isa = XCBuildConfiguration; 273 | buildSettings = { 274 | FRAMEWORK_SEARCH_PATHS = ( 275 | "$(inherited)", 276 | "$(PROJECT_DIR)/Channels/Alipay", 277 | ); 278 | HEADER_SEARCH_PATHS = "$(SRCROOT)/../../react-native/React"; 279 | LIBRARY_SEARCH_PATHS = ( 280 | "$(inherited)", 281 | "$(PROJECT_DIR)/Channels/Alipay", 282 | "$(PROJECT_DIR)/Channels/ApplePay", 283 | "$(PROJECT_DIR)/Channels/Bfb/Dependencies/ASIHttpRequest", 284 | "$(PROJECT_DIR)/Channels/Bfb/Dependencies/BaiduMobStat/BaiduMobStat", 285 | "$(PROJECT_DIR)/Channels/Bfb/Dependencies/BaiduMobStat", 286 | "$(PROJECT_DIR)/Channels/Bfb/Dependencies/JSONKit", 287 | "$(PROJECT_DIR)/Channels/Bfb/Dependencies/SDWebImage", 288 | "$(PROJECT_DIR)/Channels/Bfb", 289 | "$(PROJECT_DIR)/Channels/UnionPay", 290 | "$(PROJECT_DIR)/Channels/Wx", 291 | "$(PROJECT_DIR)", 292 | ); 293 | OTHER_LDFLAGS = "-ObjC"; 294 | PRODUCT_NAME = "$(TARGET_NAME)"; 295 | SKIP_INSTALL = YES; 296 | }; 297 | name = Release; 298 | }; 299 | /* End XCBuildConfiguration section */ 300 | 301 | /* Begin XCConfigurationList section */ 302 | 86B2B0D61BE4E27A009A1FA5 /* Build configuration list for PBXProject "RCTPingPP" */ = { 303 | isa = XCConfigurationList; 304 | buildConfigurations = ( 305 | 86B2B0E21BE4E27A009A1FA5 /* Debug */, 306 | 86B2B0E31BE4E27A009A1FA5 /* Release */, 307 | ); 308 | defaultConfigurationIsVisible = 0; 309 | defaultConfigurationName = Release; 310 | }; 311 | 86B2B0E41BE4E27A009A1FA5 /* Build configuration list for PBXNativeTarget "RCTPingPP" */ = { 312 | isa = XCConfigurationList; 313 | buildConfigurations = ( 314 | 86B2B0E51BE4E27A009A1FA5 /* Debug */, 315 | 86B2B0E61BE4E27A009A1FA5 /* Release */, 316 | ); 317 | defaultConfigurationIsVisible = 0; 318 | defaultConfigurationName = Release; 319 | }; 320 | /* End XCConfigurationList section */ 321 | }; 322 | rootObject = 86B2B0D31BE4E27A009A1FA5 /* Project object */; 323 | } 324 | -------------------------------------------------------------------------------- /ios/RCTPingPP.xcodeproj/xcuserdata/yorkieliu.xcuserdatad/xcschemes/RCTPingPP.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /ios/RCTPingPP.xcodeproj/xcuserdata/yorkieliu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | RCTPingPP.xcscheme 8 | 9 | orderHint 10 | 17 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 86B2B0DA1BE4E27A009A1FA5 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /ios/RCTPingPP/RCTPingPP.h: -------------------------------------------------------------------------------- 1 | // 2 | // RCTPingPP.h 3 | // RCTPingPP 4 | // 5 | // Created by Yorkie Liu on 10/31/15. 6 | // Copyright © 2015 WeFlex. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "Base/RCTBridgeModule.h" 11 | 12 | @interface RCTPingPP : NSObject 13 | 14 | @end -------------------------------------------------------------------------------- /ios/RCTPingPP/RCTPingPP.m: -------------------------------------------------------------------------------- 1 | // 2 | // RCTPingPP.m 3 | // RCTPingPP 4 | // 5 | // Created by Yorkie Liu on 10/31/15. 6 | // Copyright © 2015 WeFlex. All rights reserved. 7 | // 8 | 9 | #import "RCTPingPP.h" 10 | #import "Base/RCTLog.h" 11 | #import "Pingpp.h" 12 | 13 | @implementation RCTPingPP 14 | 15 | RCT_EXPORT_MODULE() 16 | 17 | RCT_EXPORT_METHOD(setDebugMode:(BOOL)enabled 18 | :(RCTResponseSenderBlock)callback) 19 | { 20 | [Pingpp setDebugMode:enabled]; 21 | callback(@[[NSNull null]]); 22 | } 23 | 24 | RCT_EXPORT_METHOD(handleOpenURLInIOS8:(NSURL *)url 25 | :(RCTResponseSenderBlock)callback) 26 | { 27 | [Pingpp handleOpenURL:url withCompletion:^(NSString *result, PingppError *error) { 28 | callback(@[@(error.code), result]); 29 | }]; 30 | } 31 | 32 | RCT_EXPORT_METHOD(handleOpenURLInIOS9:(NSURL *)url 33 | :(NSString *)sourceApplication 34 | :(RCTResponseSenderBlock)callback) 35 | { 36 | [Pingpp handleOpenURL:url sourceApplication:sourceApplication withCompletion:^(NSString *result, PingppError *error) { 37 | callback(@[@(error.code), result]); 38 | }]; 39 | } 40 | 41 | RCT_EXPORT_METHOD(createPayment:(NSDictionary *)charge 42 | :(NSString *)schema 43 | :(RCTResponseSenderBlock)callback) 44 | { 45 | [Pingpp createPayment:charge appURLScheme:schema withCompletion:^(NSString *result, PingppError *error) { 46 | callback(@[@(error.code), result]); 47 | }]; 48 | } 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /ios/libpingpp.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weflex/react-native-pingpp/4b480c08e17baaa291a2a6023d724cfab8435c64/ios/libpingpp.a -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-pingpp", 3 | "version": "1.0.2", 4 | "description": "A React-Native(RN) binding library for Ping++", 5 | "main": "index.ios.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+ssh://git@github.com/weflex/react-native-pingpp.git" 12 | }, 13 | "keywords": [ 14 | "ios", 15 | "react", 16 | "react-native", 17 | "react-component", 18 | "ping++" 19 | ], 20 | "author": "Yorkie Liu ", 21 | "license": "GPL-2.0", 22 | "bugs": { 23 | "url": "https://github.com/weflex/react-native-pingpp/issues" 24 | }, 25 | "homepage": "https://github.com/weflex/react-native-pingpp#readme" 26 | } 27 | -------------------------------------------------------------------------------- /来读我吧.md: -------------------------------------------------------------------------------- 1 | 2 | # React-Native Pingpp 3 | 4 | 如果你正巧在使用 React-Native 以及 Ping++ 的服务,那就不要吝啬地使用以下命令来享用我吧: 5 | 6 | ```sh 7 | $ npm install react-native-pingpp --save 8 | ``` 9 | 10 | 不过还是请小主访问如下上游的链接来学习相关的文档: 11 | 12 | - iOS: [PingPlusPlus/pingpp-ios](https://github.com/PingPlusPlus/pingpp-ios) 13 | - Android: [PingPlusPlus/pingpp-android](https://github.com/PingPlusPlus/pingpp-android) 14 | 15 | ## 如何让奴家工作在iOS端? 16 | 17 | 1. 首先呢,你需要先去 [PingPlusPlus/pingpp-ios#手动导入](https://github.com/PingPlusPlus/pingpp-ios#手动导入) 阅读一下上游库的预备步骤 18 | 19 | 2. 设置完 Library Links 后呢,可以在 ObjC 里面的 AppDelegate.m 中添加如下代码: 20 | 21 | ``` 22 | // for iOS 8 23 | - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { 24 | return [Pingpp handleOpenURL:url withCompletion:nil]; 25 | } 26 | 27 | // for iOS 9 28 | - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options { 29 | return [Pingpp handleOpenURL:url withCompletion:nil]; 30 | } 31 | ``` 32 | 33 | 3. 下面开始享用 34 | 35 | ```js 36 | const { createPayment } = require('react-native-pingpp'); 37 | 38 | // 小主需要先使用 Ping++ 的服务生成对应的 charge 对象哦 39 | var result = await createPayment(charge, schema); 40 | // 好啦,这里你应该可以看到App跳转到对应的支付应用或网页中去,并且得到了对应的返回值 41 | ``` 42 | 43 | ## 来问我吧 44 | 45 | 一、为什么没有看到 libWechat.a 这个静态库呢 46 | 47 | > 嗯,因为 react-native 使用静态编译来构建程序,所以当你其他库中也使用过 libWechat.a 的话,就会得到重复链接的错误,所以这里需要各位小主自个儿链接或者也可使用奴家为您提供的另一份 React-Native 库:[react-native-wechat](https://github.com/weflex/react-native-wechat)。 48 | 49 | 二、为何不做 Android 版 50 | 51 | > 呵呵哒,因为奴家没空啦,要是小主有时间可以提 PR 哟 :p 52 | 53 | ## License 54 | 55 | GPLv2 @ WeFlex, Inc. 56 | --------------------------------------------------------------------------------