├── .gitignore ├── README.md ├── package.json ├── plugin.xml ├── src ├── android │ ├── AliPay.java │ └── libs │ │ └── alipaySdk-20161129.jar └── ios │ ├── CDVAlipayBase.h │ ├── CDVAlipayBase.m │ └── lib │ ├── AlipaySDK.bundle │ ├── bar@2x.png │ ├── refresh@2x.png │ ├── refresh_click@2x.png │ ├── shutdown@2x.png │ └── shutdown_click@2x.png │ └── AlipaySDK.framework │ ├── AlipaySDK │ ├── Headers │ ├── APayAuthInfo.h │ └── AlipaySDK.h │ ├── Info.plist │ └── en.lproj │ └── InfoPlist.strings └── www └── alipay.base.js /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cordova-alipay-base 2 | 3 | Cordova 支付宝基础功能插件 4 | 5 | # 功能 6 | 7 | 仅实现APP的支付宝支付功能 8 | 9 | # 安装 10 | 11 | 0. 背景 12 | 13 | 本插件来源于 https://github.com/pipitang/cordova-alipay-base ,根据最新的SDK做了修正。 14 | 15 | 配套提交了ionic-native插件。 16 | 17 | 1. 运行 18 | 19 | ``` 20 | cordova plugin add https://github.com/xueron/cordova-alipay-base --variable APP_ID=your_app_id 21 | 22 | ``` 23 | 24 | 2. cordova各种衍生命令行都应该支持,例如phonegap或者ionic。 25 | 26 | # 使用方法 27 | 28 | ## 注意 29 | 30 | 阿里官方的例子只是演示了支付参数的调用,在实际项目中决不可使用。在客户端使用appkey,更别提private_key了,危险隐患重重。 31 | 32 | 安全的使用方式应该是由服务端保存key,然后根据客户端传来的订单id,装载订单内容,生成支付字符串,最后由客户端提交给支付网关。 33 | 34 | ## API 35 | 36 | ### 支付API 37 | 38 | 39 | ``` 40 | Alipay.Base.pay(parameters, success, failure); 41 | 42 | ``` 43 | 44 | 此处第一个参数为json对象,请从服务端获取,直接传给改方法。 45 | 客户端会对服务端返回的JSON对象属性进行排序,js层不需要关心。具体服务端参数合成,java代码请参照一下内容及阿里官方文档,注意createLinkString上得注释: 46 | 47 | 在项目中客户端使用如下: 48 | ``` 49 | orderService.checkout(orderId, $scope.selectPay).then(function (parameters) { 50 | if ('Wechat' === $scope.selectPay) callNativeWexinPayment(parameters); { 51 | else Alipay.Base.pay(parameters, function(result){ 52 | if(result.resultStatus==='9000'||result.resultStatus==='8000') finishPayment(); 53 | else showPaymentError(null); 54 | }, showPaymentError); 55 | } 56 | 57 | ``` 58 | 59 | ionic 2使用方法如下: 60 | ``` 61 | import { Alipay, AlipayOrder } from 'ionic-native'; 62 | 63 | ...... 64 | payInfo: AlipayOrder; // 从服务器端返回。 65 | 66 | ...... 67 | Alipay.pay(this.payInfo) 68 | .then(res => { 69 | console.log(res); 70 | this.payResult = res; 71 | }, err => { 72 | console.log(err); 73 | this.payResult = err; 74 | }) 75 | .catch(e => { 76 | console.log(e); 77 | this.payResult = e; 78 | }); 79 | ...... 80 | 81 | ``` 82 | 83 | 服务端如下,(PHP)JSON返回: 84 | 85 | ``` 86 | //组装系统参数 87 | $params["app_id"] = $alipayOrder->app_id; 88 | $params["method"] = 'alipay.trade.app.pay'; 89 | $params["format"] = 'json'; 90 | $params["charset"] = 'UTF-8'; 91 | $params["sign_type"] = 'RSA'; 92 | $params["timestamp"] = date("Y-m-d H:i:s"); 93 | $params["version"] = '1.0'; 94 | $params["notify_url"] = $alipayOrder->notify_url; 95 | $params["biz_content"] = $alipayOrder->biz_content; 96 | $sign = $this->getDI()->get(AlipayService::class)->sign($params); 97 | $this->logger->debug("支付签名=$sign"); 98 | $params['sign'] = $sign; 99 | 100 | // 101 | array_walk($params, function (&$v, $k) { 102 | $v = urlencode($v); 103 | }); 104 | 105 | return json_encode($params); 106 | 107 | ``` 108 | 109 | # FAQ 110 | 111 | Q: Android如何调试? 112 | 113 | A: 如果怀疑插件有BUG,请使用tag名称为cordova-alipay-base查看日志。 114 | 115 | Q: Windows 版本? 116 | 117 | A: 这个很抱歉,有个哥们买了Lumia之后一直在抱怨应用太少,你也很不幸,有这个需求:) 欢迎 pull request. 118 | 119 | 120 | # TODO 121 | 122 | # 许可证 123 | 124 | [MIT LICENSE](http://opensource.org/licenses/MIT) 125 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.0.10", 3 | "name": "cordova-alipay-base", 4 | "cordova_name": "Alipay Basic Mobile Payment Plugin", 5 | "description": "阿里支付移动支付Cordova插件", 6 | "license": "MIT license", 7 | "repo": "https://github.com/xueron/cordova-alipay-base", 8 | "issue": "https://github.com/xueron/cordova-alipay-base/issues", 9 | "keywords": [ 10 | "alipay", 11 | "阿里支付", 12 | "支付宝" 13 | ], 14 | "platforms": [ 15 | "android", 16 | "ios" 17 | ], 18 | "engines": [ 19 | { 20 | "name": "cordova", 21 | "version": ">=3.5.0" 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | Alipay Basic Mobile Payment Plugin 7 | MIT license 8 | 阿里支付移动支付Cordova插件 9 | cordova alipay 阿里支付 支付宝 10 | https://github.com/xueron/cordova-alipay-base 11 | https://github.com/xueron/cordova-alipay-base/issues 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | CFBundleURLSchemes 37 | 38 | ALI$APP_ID 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /src/android/AliPay.java: -------------------------------------------------------------------------------- 1 | package org.apache.cordova.alipay.base; 2 | 3 | import android.text.TextUtils; 4 | import android.util.Log; 5 | 6 | import com.alipay.sdk.app.PayTask; 7 | 8 | import org.apache.cordova.CallbackContext; 9 | import org.apache.cordova.CordovaInterface; 10 | import org.apache.cordova.CordovaPlugin; 11 | import org.apache.cordova.CordovaWebView; 12 | import org.json.JSONArray; 13 | import org.json.JSONException; 14 | import org.json.JSONObject; 15 | 16 | import java.util.ArrayList; 17 | import java.util.Collections; 18 | import java.util.Iterator; 19 | import java.util.List; 20 | import java.util.Map; 21 | 22 | public class AliPay extends CordovaPlugin { 23 | public static final String RESULT_STATUS = "resultStatus"; 24 | public static final String RESULT = "result"; 25 | public static final String MEMO = "memo"; 26 | private static String TAG = "cordova-alipay-base"; 27 | 28 | 29 | @Override 30 | public void initialize(CordovaInterface cordova, CordovaWebView webView) { 31 | super.initialize(cordova, webView); 32 | } 33 | 34 | @Override 35 | public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException { 36 | Log.d(TAG, "Execute:" + action + " with :" + args.toString()); 37 | if (action.equals("pay")) { 38 | String payParameters = null; 39 | if (args.get(0) instanceof JSONObject){ 40 | JSONObject obj = args.getJSONObject(0); 41 | payParameters = buildCallString(obj, callbackContext); 42 | }else if (args.get(0) instanceof String){ 43 | payParameters = (String) args.get(0); 44 | }else{ 45 | callbackContext.error("Unsported parameter:" + args.get(0)); 46 | return true; 47 | } 48 | doCallPayment(callbackContext, payParameters); 49 | }else{ 50 | callbackContext.error("Known service: " + action); 51 | } 52 | return true; 53 | } 54 | 55 | private void doCallPayment(final CallbackContext callbackContext, final String parameters) { 56 | cordova.getThreadPool().execute(new Runnable() { 57 | @Override 58 | public void run() { 59 | try { 60 | Log.d(TAG, "Calling Alipay with: " + parameters); 61 | PayTask task = new PayTask(cordova.getActivity()); 62 | // 调用支付接口,获取支付结果 63 | Map rawResult = task.payV2(parameters, true); 64 | Log.d(TAG, "Alipay returns:" + rawResult.toString()); 65 | final JSONObject result = buildPaymentResult(rawResult); 66 | cordova.getActivity().runOnUiThread(new Runnable() { 67 | @Override 68 | public void run() { 69 | callbackContext.success(result); 70 | } 71 | }); 72 | } 73 | catch (JSONException e){ 74 | Log.e(TAG, "Manipulating json", e); 75 | callbackContext.error("Manipulating json"); 76 | } 77 | } 78 | 79 | }); 80 | } 81 | 82 | private String buildCallString(JSONObject args, CallbackContext context) throws JSONException { 83 | StringBuffer buf = new StringBuffer(); 84 | List keys = new ArrayList(); 85 | Iterator itr = args.keys(); 86 | while (itr.hasNext()) { 87 | String key = itr.next(); 88 | if (TextUtils.isEmpty(key)) continue;; 89 | if ("sign".equals(key)) continue;; 90 | keys.add(key); 91 | } 92 | 93 | //Let's sort the order info and attach sign to the end 94 | Collections.sort(keys); 95 | keys.add("sign"); 96 | 97 | for (String key : keys){ 98 | String value = args.getString(key); 99 | if (TextUtils.isEmpty(value)){ 100 | Log.w(TAG, "Empty value for: " + key); 101 | continue; 102 | } 103 | buf.append(key).append('='); 104 | buf.append(value); 105 | buf.append('&'); 106 | } 107 | if (buf.length() > 0) buf.deleteCharAt(buf.length() - 1); 108 | return buf.toString(); 109 | } 110 | 111 | private JSONObject buildPaymentResult(Map rawResult) throws JSONException { 112 | JSONObject result = new JSONObject(); 113 | if (rawResult == null) { 114 | return result; 115 | } 116 | 117 | for (String key : rawResult.keySet()) { 118 | if (TextUtils.equals(key, "resultStatus")) { 119 | result.put(RESULT_STATUS, rawResult.get(key)); 120 | } else if (TextUtils.equals(key, "result")) { 121 | result.put(RESULT, rawResult.get(key)); 122 | } else if (TextUtils.equals(key, "memo")) { 123 | result.put(MEMO, rawResult.get(key)); 124 | } 125 | } 126 | 127 | return result; 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /src/android/libs/alipaySdk-20161129.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xueron/cordova-alipay-base/1e353bc218431db21ca3a1fb4695f457f471a1af/src/android/libs/alipaySdk-20161129.jar -------------------------------------------------------------------------------- /src/ios/CDVAlipayBase.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface CDVAlipayBase : CDVPlugin 4 | 5 | @property(nonatomic,strong)NSString *appId; 6 | @property(nonatomic,strong)NSString *currentCallbackId; 7 | 8 | - (void) pay:(CDVInvokedUrlCommand*)command; 9 | @end 10 | -------------------------------------------------------------------------------- /src/ios/CDVAlipayBase.m: -------------------------------------------------------------------------------- 1 | #import "CDVAlipayBase.h" 2 | 3 | #import 4 | 5 | @implementation CDVAlipayBase 6 | 7 | -(void)pluginInitialize 8 | { 9 | self.appId = [[self.commandDelegate settings] objectForKey:@"app_id"]; 10 | } 11 | 12 | 13 | - (void) pay:(CDVInvokedUrlCommand*)command 14 | { 15 | self.currentCallbackId = command.callbackId; 16 | 17 | if ([self.appId length] == 0) 18 | { 19 | [self failWithCallbackID:self.currentCallbackId withMessage:@"支付APP_ID设置错误"]; 20 | return; 21 | } 22 | 23 | //从参数中合成paymentString,绝不能把private_key放在客户端中,阿里给的例子太有误导性,新手很容易图简单直接拿来用,殊不知危险性有多高。为了保证安全性,支付字符串需要从服务端合成。 24 | NSMutableDictionary *args = [command argumentAtIndex:0]; 25 | 26 | //For the client-server based payment, the signed content must be extractly same. In other 27 | // words, the order of properties matters on both both sides. 28 | NSArray *sortedKeys = [args.allKeys sortedArrayUsingDescriptors:@[[NSSortDescriptor sortDescriptorWithKey:@"self" ascending:YES]]]; 29 | 30 | NSMutableString * orderString = [NSMutableString string]; 31 | //Let's remove the sign and sign_type properties first 32 | for (NSString * key in sortedKeys) { 33 | if ([@"sign" isEqualToString:key]) continue; 34 | [orderString appendFormat:@"%@=%@&", key, [args objectForKey:key]]; 35 | } 36 | [orderString appendFormat:@"%@=%@&", @"sign", [args objectForKey:@"sign"]]; 37 | [orderString deleteCharactersInRange:NSMakeRange([orderString length] -1, 1)]; 38 | NSLog(@"orderString = %@", orderString); 39 | 40 | 41 | 42 | NSMutableString * schema = [NSMutableString string]; 43 | [schema appendFormat:@"ALI%@", self.appId]; 44 | NSLog(@"schema = %@",schema); 45 | 46 | [[AlipaySDK defaultService] payOrder:orderString fromScheme:schema callback:^(NSDictionary *resultDic) { 47 | [self successWithCallbackID:self.currentCallbackId messageAsDictionary:resultDic]; 48 | }]; 49 | } 50 | 51 | - (void)handleOpenURL:(NSNotification *)notification 52 | { 53 | NSURL* url = [notification object]; 54 | 55 | if ([url.scheme rangeOfString:self.appId].length > 0) 56 | { 57 | //跳转支付宝钱包进行支付,处理支付结果 58 | [[AlipaySDK defaultService] processOrderWithPaymentResult:url standbyCallback:^(NSDictionary *resultDic) { 59 | [self successWithCallbackID:self.currentCallbackId messageAsDictionary:resultDic]; 60 | }]; 61 | } 62 | } 63 | 64 | - (void)successWithCallbackID:(NSString *)callbackID withMessage:(NSString *)message 65 | { 66 | NSLog(@"message = %@",message); 67 | CDVPluginResult *commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:message]; 68 | [self.commandDelegate sendPluginResult:commandResult callbackId:callbackID]; 69 | } 70 | 71 | - (void)failWithCallbackID:(NSString *)callbackID withMessage:(NSString *)message 72 | { 73 | NSLog(@"message = %@",message); 74 | CDVPluginResult *commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:message]; 75 | [self.commandDelegate sendPluginResult:commandResult callbackId:callbackID]; 76 | } 77 | 78 | - (void)successWithCallbackID:(NSString *)callbackID messageAsDictionary:(NSDictionary *)message 79 | { 80 | NSLog(@"message = %@",message); 81 | CDVPluginResult *commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:message]; 82 | [self.commandDelegate sendPluginResult:commandResult callbackId:callbackID]; 83 | } 84 | 85 | - (void)failWithCallbackID:(NSString *)callbackID messageAsDictionary:(NSDictionary *)message 86 | { 87 | NSLog(@"message = %@",message); 88 | CDVPluginResult *commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:message]; 89 | [self.commandDelegate sendPluginResult:commandResult callbackId:callbackID]; 90 | } 91 | 92 | @end 93 | -------------------------------------------------------------------------------- /src/ios/lib/AlipaySDK.bundle/bar@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xueron/cordova-alipay-base/1e353bc218431db21ca3a1fb4695f457f471a1af/src/ios/lib/AlipaySDK.bundle/bar@2x.png -------------------------------------------------------------------------------- /src/ios/lib/AlipaySDK.bundle/refresh@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xueron/cordova-alipay-base/1e353bc218431db21ca3a1fb4695f457f471a1af/src/ios/lib/AlipaySDK.bundle/refresh@2x.png -------------------------------------------------------------------------------- /src/ios/lib/AlipaySDK.bundle/refresh_click@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xueron/cordova-alipay-base/1e353bc218431db21ca3a1fb4695f457f471a1af/src/ios/lib/AlipaySDK.bundle/refresh_click@2x.png -------------------------------------------------------------------------------- /src/ios/lib/AlipaySDK.bundle/shutdown@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xueron/cordova-alipay-base/1e353bc218431db21ca3a1fb4695f457f471a1af/src/ios/lib/AlipaySDK.bundle/shutdown@2x.png -------------------------------------------------------------------------------- /src/ios/lib/AlipaySDK.bundle/shutdown_click@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xueron/cordova-alipay-base/1e353bc218431db21ca3a1fb4695f457f471a1af/src/ios/lib/AlipaySDK.bundle/shutdown_click@2x.png -------------------------------------------------------------------------------- /src/ios/lib/AlipaySDK.framework/AlipaySDK: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xueron/cordova-alipay-base/1e353bc218431db21ca3a1fb4695f457f471a1af/src/ios/lib/AlipaySDK.framework/AlipaySDK -------------------------------------------------------------------------------- /src/ios/lib/AlipaySDK.framework/Headers/APayAuthInfo.h: -------------------------------------------------------------------------------- 1 | // 2 | // APAuthInfo.h 3 | // AliSDKDemo 4 | // 5 | // Created by 方彬 on 14-7-18. 6 | // Copyright (c) 2014年 Alipay.com. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface APayAuthInfo : NSObject 12 | 13 | @property(nonatomic, copy)NSString *appID; 14 | @property(nonatomic, copy)NSString *pid; 15 | @property(nonatomic, copy)NSString *redirectUri; 16 | 17 | /** 18 | * 初始化AuthInfo 19 | * 20 | * @param appIDStr 应用ID 21 | * @param productIDStr 产品码 该商户在aboss签约的产品,用户获取pid获取的参数 22 | * @param pidStr 商户ID 可不填 23 | * @param uriStr 授权的应用回调地址 比如:alidemo://auth 24 | * 25 | * @return authinfo实例 26 | */ 27 | - (id)initWithAppID:(NSString *)appIDStr 28 | pid:(NSString *)pidStr 29 | redirectUri:(NSString *)uriStr; 30 | 31 | - (NSString *)description; 32 | - (NSString *)wapDescription; 33 | @end 34 | -------------------------------------------------------------------------------- /src/ios/lib/AlipaySDK.framework/Headers/AlipaySDK.h: -------------------------------------------------------------------------------- 1 | // 2 | // AlipaySDK.h 3 | // AlipaySDK 4 | // 5 | // Created by 方彬 on 14-4-28. 6 | // Copyright (c) 2014年 Alipay. All rights reserved. 7 | // 8 | 9 | 10 | //////////////////////////////////////////////////////// 11 | ////////////////version:2.1 motify:2014.12.24////////// 12 | ///////////////////Merry Christmas=。=////////////////// 13 | //////////////////////////////////////////////////////// 14 | 15 | 16 | #import "APayAuthInfo.h" 17 | typedef enum { 18 | ALIPAY_TIDFACTOR_IMEI, 19 | ALIPAY_TIDFACTOR_IMSI, 20 | ALIPAY_TIDFACTOR_TID, 21 | ALIPAY_TIDFACTOR_CLIENTKEY, 22 | ALIPAY_TIDFACTOR_VIMEI, 23 | ALIPAY_TIDFACTOR_VIMSI, 24 | ALIPAY_TIDFACTOR_CLIENTID, 25 | ALIPAY_TIDFACTOR_APDID, 26 | ALIPAY_TIDFACTOR_MAX 27 | } AlipayTidFactor; 28 | 29 | typedef void(^CompletionBlock)(NSDictionary *resultDic); 30 | 31 | @interface AlipaySDK : NSObject 32 | 33 | /** 34 | * 创建支付单例服务 35 | * 36 | * @return 返回单例对象 37 | */ 38 | + (AlipaySDK *)defaultService; 39 | 40 | /** 41 | * 用于设置SDK使用的window,如果没有自行创建window无需设置此接口 42 | */ 43 | @property (nonatomic, weak) UIWindow *targetWindow; 44 | 45 | /** 46 | * 支付接口 47 | * 48 | * @param orderStr 订单信息 49 | * @param schemeStr 调用支付的app注册在info.plist中的scheme 50 | * @param compltionBlock 支付结果回调Block,用于wap支付结果回调(非跳转钱包支付) 51 | */ 52 | - (void)payOrder:(NSString *)orderStr 53 | fromScheme:(NSString *)schemeStr 54 | callback:(CompletionBlock)completionBlock; 55 | 56 | /** 57 | * 处理钱包或者独立快捷app支付跳回商户app携带的支付结果Url 58 | * 59 | * @param resultUrl 支付结果url 60 | * @param completionBlock 支付结果回调 61 | */ 62 | - (void)processOrderWithPaymentResult:(NSURL *)resultUrl 63 | standbyCallback:(CompletionBlock)completionBlock; 64 | 65 | 66 | 67 | /** 68 | * 获取交易token。 69 | * 70 | * @return 交易token,若无则为空。 71 | */ 72 | - (NSString *)fetchTradeToken; 73 | 74 | /** 75 | * 是否已经使用过 76 | * 77 | * @return YES为已经使用过,NO反之 78 | */ 79 | - (BOOL)isLogined; 80 | 81 | /** 82 | * 当前版本号 83 | * 84 | * @return 当前版本字符串 85 | */ 86 | - (NSString *)currentVersion; 87 | 88 | /** 89 | * 当前版本号 90 | * 91 | * @return tid相关信息 92 | */ 93 | - (NSString*)queryTidFactor:(AlipayTidFactor)factor; 94 | 95 | /** 96 | * 測試所用,realse包无效 97 | * 98 | * @param url 测试环境 99 | */ 100 | - (void)setUrl:(NSString *)url; 101 | 102 | 103 | ////////////////////////////////////////////////////////////////////////////////////////////// 104 | //////////////////////////h5 拦截支付入口/////////////////////////////////////////////////////// 105 | ////////////////////////////////////////////////////////////////////////////////////////////// 106 | 107 | /** 108 | * url order 获取接口 109 | * 110 | * @param urlStr 拦截的 url string 111 | * 112 | * @return 获取到的url order info 113 | */ 114 | - (NSString*)fetchOrderInfoFromH5PayUrl:(NSString*)urlStr; 115 | 116 | 117 | /** 118 | * url支付接口 119 | * 120 | * @param orderStr 订单信息 121 | * @param schemeStr 调用支付的app注册在info.plist中的scheme 122 | * @param compltionBlock 支付结果回调Block 123 | */ 124 | - (void)payUrlOrder:(NSString *)orderStr 125 | fromScheme:(NSString *)schemeStr 126 | callback:(CompletionBlock)completionBlock; 127 | 128 | 129 | ////////////////////////////////////////////////////////////////////////////////////////////// 130 | //////////////////////////授权1.0////////////////////////////////////////////////////////////// 131 | ////////////////////////////////////////////////////////////////////////////////////////////// 132 | 133 | /** 134 | * 快登授权 135 | * @param authInfo 需授权信息 136 | * @param completionBlock 授权结果回调,若在授权过程中,调用方应用被系统终止,则此block无效, 137 | 需要调用方在appDelegate中调用processAuthResult:standbyCallback:方法获取授权结果 138 | */ 139 | - (void)authWithInfo:(APayAuthInfo *)authInfo 140 | callback:(CompletionBlock)completionBlock; 141 | 142 | 143 | /** 144 | * 处理授权信息Url 145 | * 146 | * @param resultUrl 钱包返回的授权结果url 147 | * @param completionBlock 授权结果回调 148 | */ 149 | - (void)processAuthResult:(NSURL *)resultUrl 150 | standbyCallback:(CompletionBlock)completionBlock; 151 | 152 | ////////////////////////////////////////////////////////////////////////////////////////////// 153 | //////////////////////////授权2.0////////////////////////////////////////////////////////////// 154 | ////////////////////////////////////////////////////////////////////////////////////////////// 155 | 156 | /** 157 | * 快登授权2.0 158 | * 159 | * @param infoStr 授权请求信息字符串 160 | * @param schemeStr 调用授权的app注册在info.plist中的scheme 161 | * @param completionBlock 授权结果回调,若在授权过程中,调用方应用被系统终止,则此block无效, 162 | 需要调用方在appDelegate中调用processAuth_V2Result:standbyCallback:方法获取授权结果 163 | */ 164 | - (void)auth_V2WithInfo:(NSString *)infoStr 165 | fromScheme:(NSString *)schemeStr 166 | callback:(CompletionBlock)completionBlock; 167 | 168 | /** 169 | * 处理授权信息Url 170 | * 171 | * @param resultUrl 钱包返回的授权结果url 172 | * @param completionBlock 授权结果回调 173 | */ 174 | - (void)processAuth_V2Result:(NSURL *)resultUrl 175 | standbyCallback:(CompletionBlock)completionBlock; 176 | 177 | @end 178 | -------------------------------------------------------------------------------- /src/ios/lib/AlipaySDK.framework/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xueron/cordova-alipay-base/1e353bc218431db21ca3a1fb4695f457f471a1af/src/ios/lib/AlipaySDK.framework/Info.plist -------------------------------------------------------------------------------- /src/ios/lib/AlipaySDK.framework/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xueron/cordova-alipay-base/1e353bc218431db21ca3a1fb4695f457f471a1af/src/ios/lib/AlipaySDK.framework/en.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /www/alipay.base.js: -------------------------------------------------------------------------------- 1 | var exec = require('cordova/exec'); 2 | 3 | module.exports = { 4 | Base:{ 5 | pay: function (order, successCallback, errorCallback) { 6 | cordova.exec(successCallback, errorCallback, "AlipayBase", "pay", [order]); 7 | } 8 | } 9 | }; 10 | --------------------------------------------------------------------------------