master 029780ca6407 cached
16 files
14.3 MB
7.8k tokens
14 symbols
1 requests
Download .txt
Repository: hhjjj1010/cordova-plugin-alipay-v2
Branch: master
Commit: 029780ca6407
Files: 16
Total size: 14.3 MB

Directory structure:
gitextract_t7zpw4hu/

├── README.md
├── package.json
├── plugin.xml
├── src/
│   ├── android/
│   │   ├── PayResult.java
│   │   ├── alipay.gradle
│   │   ├── alipay.java
│   │   └── lib/
│   │       └── alipaysdk-15.8.00.201112210139.aar
│   └── ios/
│       ├── alipay.m
│       └── lib/
│           ├── AlipaySDK.bundle/
│           │   └── bridge.js
│           └── AlipaySDK.framework/
│               ├── AlipaySDK
│               ├── AlipaySDK-inside-Info.plist
│               └── Headers/
│                   ├── AFServiceCenter.h
│                   ├── AFServiceResponse.h
│                   ├── APayAuthInfo.h
│                   └── AlipaySDK.h
└── www/
    └── alipay.js

================================================
FILE CONTENTS
================================================

================================================
FILE: README.md
================================================
# cordova-plugin-alipay-v2(更新至alipaysdk-15.8.00.201112210139.aar)
支付宝的cordova插件其实在github上已经有很多了,但是都已经是以前的版本了。
在2016年11月的时候支付宝进行了一次更新,支付宝的SDK升级到2.0版本。
以前在app中使用支付宝进行支付叫做移动支付,11月之后更名为APP支付。

__本插件仅支持《APP支付》,不支持移动支付__

## 2020-12-05 更新日志
- SDK 更新至alipaysdk-15.8.00.201112210139.aar。
- 将 AlipaySDK 中的 UIWebView 更换为 WKWebView。
- 支持 iOS Universal Link,提高支付稳定性。

## 2019-07-31 更新日志
- Android SDK 更新至alipaySdk-15.6.5-20190718211148.aar。
- iOS SDK 已适配 iPhoneX,支持 IPv6_only 网络和 ATS 安全标准。

## 2018-11-28 更新日志
最近总有人问在iOS上没有回调的问题,真机实测不存在该问题。

__*第一步:在Xcode中检查project的Bundle Identifier是否与其他项目重名。*__

__*第二步:在Xcode中检查project的URL Types上alipay的URL Schemes格式是否正确。*__
Xcode的URL Types上alipay的URL Schemes正确格式应为 __ali2xxxxxxxxxxxxxxx__。
2开头的这串数字是你的APP_ID,英文字母与数字之间没有任何符号!!!

__*第三步:检查调用插件写法是否正确。*__

ionic1上的建议写法
``` js
var payInfo = "xxx";
cordova.plugins.alipay.payment(payInfo, function success(e){
    // TODO 支付成功
},function error(e){
    //TODO 支付失败
    console.log("支付失败" + e.resultStatus);
});
```
ionic3上的建议写法

```js
let payInfo = "xxx";
cordova.plugins.alipay.payment(payInfo, (e) => {
  //TODO 支付成功

}, (e) => {
  //TODO 支付失败
  console.log(e.resultStatus);
});
```

***

# 注意
插件从v1.0.0开始支持cordova-android 7.0.0,因为cordova-android 7.0.0更改了android项目的文件目录,所以不再兼容以前的老版本,升级前请务必注意。

如果项目是之前的cordova-android老版本,请安装插件以前的老版本,在安装的时候带上版本号即可,cordova-plugin-alipay-v2@0.0.4。

#功能说明
1. 根据支付宝的说明文档的建议,为保证安全,签名都放到后端去做,前端只需要接收后台传入签名字符串,使用该插件调用支付宝SDK完成支付
2. APP_ID:对应开放平台中应用的APPID,主要用于iOS平台Xcode构建URL Schemes

***
# 支持平台

1. android (alipaySdk-15.6.5-20190718211148.aar)
2. iOS (Xcode版本须大于7.0,iOS版本须大于或等于9.0)

***
# 安装
## 在线安装
npm安装
```shell
cordova plugin add cordova-plugin-alipay-v2 --variable APP_ID=your AppId
```
git安装
``` shell
cordova plugin add https://github.com/hhjjj1010/cordova-plugin-alipay-v2.git --variable APP_ID=your AppId
```

## 本地安装
下载插件到本地
``` shell
cordova plugin add /your/local/path --variable APP_ID=your AppId
```

***
# 使用 API
## 第一步:订单在服务端签名生成订单信息,具体请参考官网进行[订单签名](https://docs.open.alipay.com/204/105465/)

### 带有签名信息的订单信息示例
``` js
var payInfo = "app_id=2015052600090779&biz_content=%7B%22timeout_express%22%3A%2230m%22%2C%22product_code%22%3A%22QUICK_MSECURITY_PAY%22%2C%22total_amount%22%3A%220.01%22%2C%22subject%22%3A%221%22%2C%22body%22%3A%22%E6%88%91%E6%98%AF%E6%B5%8B%E8%AF%95%E6%95%B0%E6%8D%AE%22%2C%22out_trade_no%22%3A%22IQJZSRC1YMQB5HU%22%7D&charset=utf-8&format=json&method=alipay.trade.app.pay&notify_url=http%3A%2F%2Fdomain.merchant.com%2Fpayment_notify&sign_type=RSA2&timestamp=2016-08-25%2020%3A26%3A31&version=1.0&sign=cYmuUnKi5QdBsoZEAbMXVMmRWjsuUj%2By48A2DvWAVVBuYkiBj13CFDHu2vZQvmOfkjE0YqCUQE04kqm9Xg3tIX8tPeIGIFtsIyp%2FM45w1ZsDOiduBbduGfRo1XRsvAyVAv2hCrBLLrDI5Vi7uZZ77Lo5J0PpUUWwyQGt0M4cj8g%3D";
```

## 第二步:调用支付插件

__ionic1 代码示例__
``` js
cordova.plugins.alipay.payment(payInfo,function success(e){
  // 支付成功

},function error(e){
  //TODO 支付失败
  console.log("支付失败" + e.resultStatus);
});
```

### ionic3 代码示例
ionic3上使用时须在import结束后添加 declare let cordova。
``` js
cordova.plugins.alipay.payment(payInfo, (e) => {
  //TODO 支付成功

}, (e) => {
      //TODO 支付失败
      console.log("支付失败" + e.resultStatus);
    });
```
### 回调函数参数说明
e.resultStatus  状态代码
e.result  本次操作返回的结果数据
e.memo 提示信息

e.resultStatus:9000  订单支付成功;8000 正在处理中;调用function success

error.resultStatus:4000  订单支付失败;6001  用户中途取消;6002 网络连接出错 ;调用function error

当e.resultStatus为9000时,请去服务端验证支付结果,建议商户依赖异步通知
 同步返回的结果必须放置到服务端进行验证,具体请查看[验证的规则](https://doc.open.alipay.com/doc2/detail.htmspm=0.0.0.0.xdvAU6&treeId=59&articleId=103665&docType=1) 。


***
# TIPS
## 1. iOS上支付成功之后无法回调
Xcode的URL Types上alipay的URL Schemes正确格式应为ali2xxxxxxxxxxxxxxx。2开头的这串数字是你的APP_ID,英文字母与数字之间没有任何符号!!!

## 2. 沙箱环境
在我个人的开发过程中确实是没有使用到沙箱环境,都是直接真实支付1分钱来做测试。
如要使用沙箱环境,请自行参考[官方文档](https://docs.open.alipay.com/200/105311/)。


================================================
FILE: package.json
================================================
{
  "name": "cordova-plugin-alipay-v2",
  "version": "2.0.0",
  "description": "a cordova plugin, a JS version of Alipay SDK(20190718211148)",
  "cordova": {
    "id": "cordova-plugin-alipay-v2",
    "platforms": [
      "android",
      "ios"
    ]
  },
  "keywords": [
    "ecosystem:cordova",
    "cordova-android",
    "cordova-ios",
    "alipay",
    "cordova-plugin-alipay",
    "cordova-plugin-alipay-v2"
  ],
  "repository": {
    "type": "git",
    "url": "git+https://github.com/hhjjj1010/cordova-plugin-alipay-v2.git"
  },
  "bugs": {
    "url": "https://github.com/hhjjj1010/cordova-plugin-alipay-v2/issues"
  },
  "homepage": "https://github.com/hhjjj1010/cordova-plugin-alipay-v2#readme",
  "author": "hhjjj1010",
  "license": "ISC"
}


================================================
FILE: plugin.xml
================================================
<?xml version='1.0' encoding='utf-8'?>
<plugin id="cordova-plugin-alipay-v2" version="2.0.0" xmlns="http://apache.org/cordova/ns/plugins/1.0"
        xmlns:android="http://schemas.android.com/apk/res/android">
    <name>alipay</name>
    <preference name="APP_ID"/>
    <js-module name="alipay" src="www/alipay.js">
        <clobbers target="cordova.plugins.alipay"/>
    </js-module>
    <platform name="android">
        <config-file parent="/*" target="res/xml/config.xml">
            <feature name="alipay">
                <param name="android-package" value="cn.hhjjj.alipay.alipay"/>
            </feature>
        </config-file>
        <config-file parent="/*" target="AndroidManifest.xml">
            <uses-permission android:name="android.permission.INTERNET"/>
            <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
            <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
        </config-file>

        <source-file src="src/android/alipay.java" target-dir="src/cn/hhjjj/alipay"/>
        <source-file src="src/android/PayResult.java" target-dir="src/cn/hhjjj/alipay"/>
        <lib-file src="src/android/lib/alipaysdk-15.8.00.201112210139.aar" />
        <framework src="src/android/alipay.gradle" custom="true" type="gradleReference"/>

    </platform>

    <platform name="ios">
        <config-file parent="/*" target="config.xml">
            <feature name="alipay">
                <param name="ios-package" value="alipay"/>
            </feature>
            <preference name="alipayid" value="$APP_ID"/>
        </config-file>
        <config-file target="*-Info.plist" parent="CFBundleURLTypes">
            <array>
                <dict>
                    <key>CFBundleURLName</key>
                    <string>alipay</string>
                    <key>CFBundleURLSchemes</key>
                    <array>
                        <string>ali$APP_ID</string>
                    </array>
                </dict>
            </array>
        </config-file>

        <framework src="CoreTelephony.framework" weak="true"/>
        <framework src="SystemConfiguration.framework" weak="true"/>
        <framework src="CoreMotion.framework" weak="true"/>
        <framework src="CFNetwork.framework" weak="true"/>
        <framework src="libc++.tbd" weak="true"/>
        <framework src="libz.tbd" weak="true"/>
        <framework src="CoreText.framework" weak="true"/>
        <framework src="CoreGraphics.framework" weak="true"/>
        <framework src="UIKit.framework" weak="true"/>
        <framework src="QuartzCore.framework" weak="true"/>
        <framework src="Foundation.framework" weak="true"/>

        <framework src="src/ios/lib/AlipaySDK.framework" custom="true"/>
        <resource-file src="src/ios/lib/AlipaySDK.bundle"/>
        <source-file src="src/ios/alipay.m"/>
    </platform>
</plugin>


================================================
FILE: src/android/PayResult.java
================================================
package cn.hhjjj.alipay;

import java.util.Map;

import android.text.TextUtils;

public class PayResult {
    private String resultStatus;
    private String result;
    private String memo;

    public PayResult(Map<String, String> rawResult) {
        if (rawResult == null) {
            return;
        }

        for (String key : rawResult.keySet()) {
            if (TextUtils.equals(key, "resultStatus")) {
                resultStatus = rawResult.get(key);
            } else if (TextUtils.equals(key, "result")) {
                result = rawResult.get(key);
            } else if (TextUtils.equals(key, "memo")) {
                memo = rawResult.get(key);
            }
        }
    }

    @Override
    public String toString() {
        return "resultStatus={" + resultStatus + "};memo={" + memo
                + "};result={" + result + "}";
    }


    /**
     * @return the resultStatus
     */
    public String getResultStatus() {
        return resultStatus;
    }

    /**
     * @return the memo
     */
    public String getMemo() {
        return memo;
    }

    /**
     * @return the result
     */
    public String getResult() {
        return result;
    }
}

================================================
FILE: src/android/alipay.gradle
================================================
repositories{
    jcenter()
    flatDir{
        dirs 'libs'
    }
}

dependencies {
    compile (name: 'alipaysdk-15.8.00.201112210139', ext: 'aar')
}


================================================
FILE: src/android/alipay.java
================================================
package cn.hhjjj.alipay;

import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CallbackContext;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.alipay.sdk.app.PayTask;

import android.os.Handler;
import android.os.Message;
import android.util.Log;

import java.util.Map;

import android.widget.Toast;
import android.text.TextUtils;
import android.annotation.SuppressLint;

/**
 * This class echoes a string called from JavaScript.
 */
public class alipay extends CordovaPlugin {

    private static final int SDK_PAY_FLAG = 1;

    @Override
    public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
        if (action.equals("payment")) {
            String orderInfo = args.getString(0);
            this.payment(orderInfo, callbackContext);
            return true;
        }
        return false;
    }

    private void payment(String orderInfo, final CallbackContext callbackContext) {

        final String payInfo = orderInfo;
        cordova.getThreadPool().execute(new Runnable() {
            @Override
            public void run() {
                PayTask alipay = new PayTask(cordova.getActivity());
                Map<String, String> result = alipay.payV2(payInfo, true);
                Log.i("msp", result.toString());

                Message msg = new Message();
                msg.what = SDK_PAY_FLAG;
                msg.obj = result;
                mHandler.sendMessage(msg);

                PayResult payResult = new PayResult(result);
                String resultInfo = payResult.getResult();// 同步返回需要验证的信息
                String resultStatus = payResult.getResultStatus();
                // 判断resultStatus 为9000则代表支付成功
                if (TextUtils.equals(resultStatus, "9000")) {
                    // 该笔订单是否真实支付成功,需要依赖服务端的异步通知。
                    callbackContext.success(new JSONObject(result));
                } else {
                    // 该笔订单真实的支付结果,需要依赖服务端的异步通知。
                    callbackContext.error(new JSONObject(result));
                }
            }
        });

    }

    @SuppressLint("HandlerLeak")
    private Handler mHandler = new Handler() {
        @SuppressWarnings("unused")
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case SDK_PAY_FLAG: {
                    @SuppressWarnings("unchecked")
                    PayResult payResult = new PayResult((Map<String, String>) msg.obj);
                    /**
                     对于支付结果,请商户依赖服务端的异步通知结果。同步通知结果,仅作为支付结束的通知。
                     */
                    String resultInfo = payResult.getResult();// 同步返回需要验证的信息
                    String resultStatus = payResult.getResultStatus();
                    // 判断resultStatus 为9000则代表支付成功
                    // 判断resultStatus 为9000则代表支付成功
                    if (TextUtils.equals(resultStatus, "9000")) {
                        // 该笔订单是否真实支付成功,需要依赖服务端的异步通知。
                        Toast.makeText(cordova.getActivity(), "支付成功" + resultStatus, Toast.LENGTH_SHORT);
                    } else {
                        // 该笔订单真实的支付结果,需要依赖服务端的异步通知。
                        Toast.makeText(cordova.getActivity(), "支付失败" + resultStatus, Toast.LENGTH_SHORT);
                    }
                    break;
                }
                default:
                    break;
            }
        }

        ;
    };

}


================================================
FILE: src/ios/alipay.m
================================================
/********* alipay.m Cordova Plugin Implementation *******/

#import <Cordova/CDV.h>
#import <AlipaySDK/AlipaySDK.h>

@interface alipay : CDVPlugin {
    // Member variables go here.
    NSString *app_id;
    NSString *callbackId;
}

- (void)payment:(CDVInvokedUrlCommand*)command;
@end

@implementation alipay

#pragma mark "API"
- (void)pluginInitialize {
    CDVViewController *viewController = (CDVViewController *)self.viewController;
    app_id = [viewController.settings objectForKey:@"alipayid"];
}

- (void)payment:(CDVInvokedUrlCommand*)command
{
    callbackId = command.callbackId;
    NSString* orderString = [command.arguments objectAtIndex:0];
    NSString* appScheme = [NSString stringWithFormat:@"ali%@", app_id];
    [[AlipaySDK defaultService] payOrder:orderString fromScheme:appScheme callback:^(NSDictionary *resultDic) {
        CDVPluginResult* pluginResult;
        
        if ([[resultDic objectForKey:@"resultStatus"]  isEqual: @"9000"]) {
            pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:resultDic];
            [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
        } else {
            pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:resultDic];
            [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
        }
        
    }];
}

- (void)handleOpenURL:(NSNotification *)notification {
    NSURL* url = [notification object];
    
    if ([url isKindOfClass:[NSURL class]] && [url.scheme isEqualToString:[NSString stringWithFormat:@"ali%@", app_id]])
    {
        [[AlipaySDK defaultService] processOrderWithPaymentResult:url standbyCallback:^(NSDictionary *resultDic) {
            
            CDVPluginResult* pluginResult;
            
            if ([[resultDic objectForKey:@"resultStatus"] isEqual: @"9000"]) {
                pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:resultDic];
                [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
            } else {
                pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:resultDic];
                [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
            }
        }];
    }
}

@end


================================================
FILE: src/ios/lib/AlipaySDK.bundle/bridge.js
================================================
!function(){if(!window.AlipayJSBridge){window.alipayjsbridgeSetTitle=function(e){document.title=e,t("alipayjsbridge://setTitle?title="+encodeURIComponent(e))},window.alipayjsbridgeRefresh=function(){t("alipayjsbridge://onRefresh?")},window.alipayjsbridgeBack=function(){t("alipayjsbridge://onBack?")},window.alipayjsbridgeExit=function(e){t("alipayjsbridge://onExit?bsucc="+e)},window.alipayjsbridgeShowBackButton=function(e){t("alipayjsbridge://showBackButton?bshow="+e)},window.AlipayJSBridge={version:"2.0",addListener:function(e,i){a[e]=i},hasListener:function(e){if(!a[e])return!1;return!0},callListener:function(e,i,n){var t;n&&(t=function(e){var i="";e&&(i=encodeURIComponent(JSON.stringify(e)));var a="func=h5JsFuncCallback&cbId="+n+"&data="+i;o(a)});var r=a[e];r?r(i,t):console.log("AlipayJSBridge: no h5JsFunc ",e+i)},callNativeFunc:function(e,a,t){var r="";t&&(r="cb_"+i+++"_"+(new Date).getTime(),n[r]=t);var d="";a&&(d=encodeURIComponent(JSON.stringify(a)));o("func="+e+"&cbId="+r+"&data="+d)},callBackFromNativeFunc:function(e,i){var a=n[e];a&&(a(i),delete n[i])}};var e,i=1,n={},a={};window.CustomEvent?e=new CustomEvent("alipayjsbridgeready"):(e=document.createEvent("Event")).initEvent("alipayjsbridgeready",!0,!0),document.dispatchEvent(e),setTimeout(function(){if(window.AlipayJSBridgeInitArray){var e=window.AlipayJSBridgeInitArray;delete window.AlipayJSBridgeInitArray;for(var i=0;i<e.length;i++)try{e[i](AlipayJSBridge)}catch(e){setTimeout(function(){throw e})}}},0)}function t(e){window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.MQPJSBridgeScheme&&window.webkit.messageHandlers.MQPJSBridgeScheme.postMessage&&window.webkit.messageHandlers.MQPJSBridgeScheme.postMessage(e)}function o(e){t("alipayjsbridge://callNativeFunc?"+e)}}();


================================================
FILE: src/ios/lib/AlipaySDK.framework/AlipaySDK
================================================
[File too large to display: 14.3 MB]

================================================
FILE: src/ios/lib/AlipaySDK.framework/Headers/AFServiceCenter.h
================================================
//
//  AFServiceCenter.h
//  AFServiceSDK
//
//  Created by jiajunchen on 02/01/2018.
//  Copyright © 2018 antfin. All rights reserved.
//

#import <Foundation/Foundation.h>

@class AFServiceResponse;

/**
 SDK支持的业务枚举值

 - AFServiceEInvoice: 电子发票
 - AFServiceAuth: 账户授权
 */
typedef NS_ENUM(NSUInteger, AFService) {
    AFServiceEInvoice,
    AFServiceAuth,
    AFServiceDeduct
};


extern NSString * const kAFServiceOptionBizParams;      // 钱包服务调用入参
extern NSString * const kAFServiceOptionCallbackScheme; // 业务回跳当前app的scheme
extern NSString * const kAFServiceOptionNotUseLanding;  // 不使用支付宝提示下载页做补偿,为true时需要商户自己处理用户未安装支付宝的情况
extern NSString * const kAFServiceBizParamsKeyUrl;      // 独立签约入参url

typedef void(^AFServiceResultBlock)(AFServiceResponse *response);

@interface AFServiceCenter : NSObject

/**
 调用钱包服务

 @param service 业务service, 见AFService枚举值
 @param params  参数Dictionary, key值详情参见kAFServiceOptionBizParams、kAFServiceOptionCallbackScheme注释
 @param block   业务结果回调的block, block参数是AFServiceResponse类型,业务结果通过result属性获取,如果未用户未安装支付宝并且kAFServiceOptionNotUseLanding未设置为true,会使用H5landing页做补偿,这种情况下不会有block回调结果。
 */
+ (void)callService:(AFService)service
         withParams:(NSDictionary *)params
      andCompletion:(AFServiceResultBlock)block;


/**
 处理钱包服务回跳APP的URL

 @param url 回跳URL
 @param block 业务结果回掉的block,详情见调用接口入参上的block。注意此接口上的block只有在跳转钱包后,当前APP被系统回收的情况下回跳才生效
 */
+ (void)handleResponseURL:(NSURL *)url
           withCompletion:(AFServiceResultBlock)block;

@end


================================================
FILE: src/ios/lib/AlipaySDK.framework/Headers/AFServiceResponse.h
================================================
//
//  AFServiceResponse.h
//  AFServiceSDK
//
//  Created by jiajunchen on 08/01/2018.
//  Copyright © 2018 antfin. All rights reserved.
//

#import <Foundation/Foundation.h>

/**
 钱包服务调用结果状态吗

 - AFResSuccess: 默认值,业务调用成功,结果数据参见result字段
 - AFResInvalidService: service枚举值错误
 - AFResInvalidURL: 钱包回跳URL错误
 - AFResRepeatCall: 业务重复调用(3s内)
 - AFResOpenURLErr: 跳转失败
 */
typedef NS_ENUM(NSUInteger, AFResCode) {
    AFResSuccess = 0,
    AFResInvalidService = 100,
    AFResInvalidURL,
    AFResRepeatCall,
    AFResOpenURLErr,
};


@interface AFServiceResponse : NSObject


/**
 业务调用状态吗
 */
@property (nonatomic, assign) AFResCode responseCode;


/**
 业务结果Dictionary, 内容请参考具体业务方接入文档
 */
@property (readonly) NSDictionary *result;

@end


================================================
FILE: src/ios/lib/AlipaySDK.framework/Headers/APayAuthInfo.h
================================================
//
//  APAuthInfo.h
//  APAuth
//
//  Created by antfin on 17-10-24.
//  Copyright (c) 2017年 AntFin. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface APayAuthInfo : NSObject

@property(nonatomic, copy)NSString *appID;
@property(nonatomic, copy)NSString *pid;
@property(nonatomic, copy)NSString *redirectUri;

/**
 *  初始化AuthInfo
 *
 *  @param appIDStr     应用ID
 *  @param pidStr       商户ID   可不填
 *  @param uriStr       授权的应用回调地址  比如:alidemo://auth
 *
 *  @return authinfo实例
 */
- (id)initWithAppID:(NSString *)appIDStr
                pid:(NSString *)pidStr
        redirectUri:(NSString *)uriStr;

- (NSString *)description;
- (NSString *)wapDescription;

@end


================================================
FILE: src/ios/lib/AlipaySDK.framework/Headers/AlipaySDK.h
================================================
//
//  AlipaySDK.h
//  AlipaySDK
//
//  Created by antfin on 17-10-24.
//  Copyright (c) 2017年 AntFin. All rights reserved.
//


////////////////////////////////////////////////////////
///////////////// 支付宝标准版本支付SDK ///////////////////
///////// version:15.8.00  motify:2020.11.12///////////
////////////////////////////////////////////////////////

#import <UIKit/UIKit.h>
#import "APayAuthInfo.h"
#import "AFServiceCenter.h"
#import "AFServiceResponse.h"

typedef void(^CompletionBlock)(NSDictionary *resultDic);

typedef enum {
    ALIPAY_TIDFACTOR_IMEI,
    ALIPAY_TIDFACTOR_IMSI,
    ALIPAY_TIDFACTOR_TID,
    ALIPAY_TIDFACTOR_CLIENTKEY,
    ALIPAY_TIDFACTOR_VIMEI,
    ALIPAY_TIDFACTOR_VIMSI,
    ALIPAY_TIDFACTOR_CLIENTID,
    ALIPAY_TIDFACTOR_APDID,
    ALIPAY_TIDFACTOR_MAX
} AlipayTidFactor;

@interface AlipaySDK : NSObject

/**
 *  创建支付单例服务
 *
 *  @return 返回单例对象
 */
+ (AlipaySDK *)defaultService;

/**
 *  用于设置SDK使用的window,如果没有自行创建window无需设置此接口
 */
@property (nonatomic, weak) UIWindow *targetWindow;

//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////支付宝支付相关接口/////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////

/**
 *  支付接口
 *
 *  @param orderStr        支付订单信息字串
 *  @param schemeStr       调用支付的app注册在info.plist中的scheme
 *  @param completionBlock 支付结果回调Block,用于wap支付结果回调
                           跳转支付宝支付时只有当processOrderWithPaymentResult接口的completionBlock为nil时会使用这个bolock
 */
- (void)payOrder:(NSString *)orderStr
      fromScheme:(NSString *)schemeStr
        callback:(CompletionBlock)completionBlock;

/**
 *  支付接口 v2
 *
 *  @param orderStr        支付订单信息字串
 *  @param dynamicLaunch   是否使用动态配置策略跳转支付宝支付
 *  @param schemeStr       调用支付的app注册在info.plist中的scheme
 *  @param completionBlock 支付结果回调Block,用于wap支付结果回调
 跳转支付宝支付时只有当processOrderWithPaymentResult接口的completionBlock为nil时会使用这个bolock
 */
- (void)payOrder:(NSString *)orderStr
   dynamicLaunch:(BOOL)dynamicLaunch
      fromScheme:(NSString *)schemeStr
        callback:(CompletionBlock)completionBlock;

/**
 *  处理支付宝app支付后跳回商户app携带的支付结果Url
 *
 *  @param resultUrl        支付宝app返回的支付结果url
 *  @param completionBlock  支付结果回调 为nil时默认使用支付接口的completionBlock
 */
- (void)processOrderWithPaymentResult:(NSURL *)resultUrl
                      standbyCallback:(CompletionBlock)completionBlock;

/**
 *  获取交易token。
 *
 *  @return 交易token,若无则为空。
 */
- (NSString *)fetchTradeToken;


//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////支付宝授权 2.0 相关接口////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////

/**
 *  快登授权2.0
 *
 *  @param infoStr          授权请求信息字串
 *  @param schemeStr        调用授权的app注册在info.plist中的scheme
 *  @param completionBlock  授权结果回调,需要调用方在appDelegate中调用processAuth_V2Result:standbyCallback:方法获取授权结果
 *                          若在授权过程中,调用方应用被系统终止则此block无效(此时会调用'processAuth_V2Result:standbyCallback:'传入的standbyCallback)
 */
- (void)auth_V2WithInfo:(NSString *)infoStr
             fromScheme:(NSString *)schemeStr
               callback:(CompletionBlock)completionBlock;

/**
 *  处理支付宝app授权后跳回商户app携带的授权结果Url
 *
 *  @param resultUrl        支付宝app返回的授权结果url
 *  @param completionBlock  授权结果回调,用于处理跳转支付宝授权过程中商户APP被系统终止的情况
 */
- (void)processAuth_V2Result:(NSURL *)resultUrl
             standbyCallback:(CompletionBlock)completionBlock;


//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////支付宝授权 1.0 相关接口////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////


/**
 *  快登授权
 *  @param authInfo         授权相关信息
 *  @param completionBlock  授权结果回调,若在授权过程中,调用方应用被系统终止,则此block无效,
                            需要调用方在appDelegate中调用processAuth_V2Result:standbyCallback:方法获取授权结果
 */
- (void)authWithInfo:(APayAuthInfo *)authInfo
            callback:(CompletionBlock)completionBlock;

/**
 *  处理支付宝app授权后跳回商户app携带的授权结果Url
 *
 *  @param resultUrl        支付宝app返回的授权结果url
 *  @param completionBlock  授权结果回调
 */
- (void)processAuthResult:(NSURL *)resultUrl
          standbyCallback:(CompletionBlock)completionBlock;


//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////支付宝 h5 支付转 native 支付接口////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
/**
 *  从h5链接中获取订单串并支付接口(自版本15.4.0起,推荐使用该接口)
 *
 *  @param urlStr     拦截的 url string
 *
 *  @return YES为成功获取订单信息并发起支付流程;NO为无法获取订单信息,输入url是普通url
 */
- (BOOL)payInterceptorWithUrl:(NSString *)urlStr
                   fromScheme:(NSString *)schemeStr
                     callback:(CompletionBlock)completionBlock;



//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////支付宝 tid 相关信息获取接口/////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////

/**
 *  获取当前tid相关信息
 *
 *  @return tid相关信息
 */
- (NSString*)queryTidFactor:(AlipayTidFactor)factor;



//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////支付宝支付环境相关信息接口//////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////

/**
 *  是否已经使用过
 *
 *  @return YES为已经使用过,NO反之
 */
- (BOOL)isLogined;

/**
 *  获取当前版本号
 *
 *  @return 当前版本字符串
 */
- (NSString *)currentVersion;

/**
 *  測試所用,realse包无效
 *
 *  @param url  测试环境
 */
- (void)setUrl:(NSString *)url;

/**
 *  支付前主动更新本地配置
 *
 *  @param block 更新请求结果回调
 */
- (void)fetchSdkConfigWithBlock:(void(^)(BOOL success))block;


typedef void(^APLogBlock)(NSString *log);

/**
*   接收AlipaySDK的log信息
*
*  @param logBlock 打印log的回调block
*/
+ (void)startLogWithBlock:(APLogBlock)logBlock;

/**
*   停止输出log,会释放logBlock
*
*
*/
+ (void)stopLog;

@end


================================================
FILE: www/alipay.js
================================================
var exec = require('cordova/exec');

exports.payment = function(payInfo, success, error) {
    exec(success, error, "alipay", "payment", [payInfo]);
};
Download .txt
gitextract_t7zpw4hu/

├── README.md
├── package.json
├── plugin.xml
├── src/
│   ├── android/
│   │   ├── PayResult.java
│   │   ├── alipay.gradle
│   │   ├── alipay.java
│   │   └── lib/
│   │       └── alipaysdk-15.8.00.201112210139.aar
│   └── ios/
│       ├── alipay.m
│       └── lib/
│           ├── AlipaySDK.bundle/
│           │   └── bridge.js
│           └── AlipaySDK.framework/
│               ├── AlipaySDK
│               ├── AlipaySDK-inside-Info.plist
│               └── Headers/
│                   ├── AFServiceCenter.h
│                   ├── AFServiceResponse.h
│                   ├── APayAuthInfo.h
│                   └── AlipaySDK.h
└── www/
    └── alipay.js
Download .txt
SYMBOL INDEX (14 symbols across 5 files)

FILE: src/android/PayResult.java
  class PayResult (line 1) | public class PayResult {
    private String resultStatus;
    private St...
    method PayResult (line 1) | public PayResult(Map<String, String> rawResult) {
        if (rawResul...
    method toString (line 1) | @Override
    public String toString() {
        return "resultStatus=...
    method getResultStatus (line 1) | public String getResultStatus() {
        return resultStatus;
    }
    method getMemo (line 1) | public String getMemo() {
        return memo;
    }
    method getResult (line 1) | public String getResult() {
        return result;
    }

FILE: src/android/alipay.java
  class alipay (line 25) | public class alipay extends CordovaPlugin {
    method execute (line 29) | @Override
    method payment (line 39) | private void payment(String orderInfo, final CallbackContext callbackC...
    method handleMessage (line 72) | @SuppressWarnings("unused")

FILE: src/ios/lib/AlipaySDK.bundle/bridge.js
  function t (line 1) | function t(e){window.webkit&&window.webkit.messageHandlers&&window.webki...
  function o (line 1) | function o(e){t("alipayjsbridge://callNativeFunc?"+e)}

FILE: src/ios/lib/AlipaySDK.framework/Headers/AFServiceCenter.h
  type AFServiceEInvoice (line 19) | typedef NS_ENUM(NSUInteger, AFService) {

FILE: src/ios/lib/AlipaySDK.framework/Headers/AlipaySDK.h
  type AlipayTidFactor (line 22) | typedef enum {
Condensed preview — 16 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (32K chars).
[
  {
    "path": "README.md",
    "chars": 3764,
    "preview": "# cordova-plugin-alipay-v2(更新至alipaysdk-15.8.00.201112210139.aar)\n支付宝的cordova插件其实在github上已经有很多了,但是都已经是以前的版本了。\n在2016年11月的"
  },
  {
    "path": "package.json",
    "chars": 749,
    "preview": "{\n  \"name\": \"cordova-plugin-alipay-v2\",\n  \"version\": \"2.0.0\",\n  \"description\": \"a cordova plugin, a JS version of Alipay"
  },
  {
    "path": "plugin.xml",
    "chars": 2890,
    "preview": "<?xml version='1.0' encoding='utf-8'?>\n<plugin id=\"cordova-plugin-alipay-v2\" version=\"2.0.0\" xmlns=\"http://apache.org/co"
  },
  {
    "path": "src/android/PayResult.java",
    "chars": 1191,
    "preview": "package cn.hhjjj.alipay;\r\rimport java.util.Map;\r\rimport android.text.TextUtils;\r\rpublic class PayResult {\r    private St"
  },
  {
    "path": "src/android/alipay.gradle",
    "chars": 152,
    "preview": "repositories{\n    jcenter()\n    flatDir{\n        dirs 'libs'\n    }\n}\n\ndependencies {\n    compile (name: 'alipaysdk-15.8."
  },
  {
    "path": "src/android/alipay.java",
    "chars": 3458,
    "preview": "package cn.hhjjj.alipay;\n\nimport org.apache.cordova.CordovaPlugin;\nimport org.apache.cordova.CallbackContext;\n\nimport or"
  },
  {
    "path": "src/ios/alipay.m",
    "chars": 2389,
    "preview": "/********* alipay.m Cordova Plugin Implementation *******/\n\n#import <Cordova/CDV.h>\n#import <AlipaySDK/AlipaySDK.h>\n\n@in"
  },
  {
    "path": "src/ios/lib/AlipaySDK.bundle/bridge.js",
    "chars": 1781,
    "preview": "!function(){if(!window.AlipayJSBridge){window.alipayjsbridgeSetTitle=function(e){document.title=e,t(\"alipayjsbridge://se"
  },
  {
    "path": "src/ios/lib/AlipaySDK.framework/Headers/AFServiceCenter.h",
    "chars": 1481,
    "preview": "//\n//  AFServiceCenter.h\n//  AFServiceSDK\n//\n//  Created by jiajunchen on 02/01/2018.\n//  Copyright © 2018 antfin. All r"
  },
  {
    "path": "src/ios/lib/AlipaySDK.framework/Headers/AFServiceResponse.h",
    "chars": 732,
    "preview": "//\n//  AFServiceResponse.h\n//  AFServiceSDK\n//\n//  Created by jiajunchen on 08/01/2018.\n//  Copyright © 2018 antfin. All"
  },
  {
    "path": "src/ios/lib/AlipaySDK.framework/Headers/APayAuthInfo.h",
    "chars": 685,
    "preview": "//\n//  APAuthInfo.h\n//  APAuth\n//\n//  Created by antfin on 17-10-24.\n//  Copyright (c) 2017年 AntFin. All rights reserved"
  },
  {
    "path": "src/ios/lib/AlipaySDK.framework/Headers/AlipaySDK.h",
    "chars": 6186,
    "preview": "//\n//  AlipaySDK.h\n//  AlipaySDK\n//\n//  Created by antfin on 17-10-24.\n//  Copyright (c) 2017年 AntFin. All rights reserv"
  },
  {
    "path": "www/alipay.js",
    "chars": 152,
    "preview": "var exec = require('cordova/exec');\n\nexports.payment = function(payInfo, success, error) {\n    exec(success, error, \"ali"
  }
]

// ... and 3 more files (download for full content)

About this extraction

This page contains the full source code of the hhjjj1010/cordova-plugin-alipay-v2 GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 16 files (14.3 MB), approximately 7.8k tokens, and a symbol index with 14 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!