mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-02-21 00:23:00 +08:00
feat(alipay): add alipay support. (#1097)
* add cordova-alipay-base plugin. to support Alipay payment * change ALI_PID to APP_ID, make it same with the latest SDK * rewrite comments
This commit is contained in:
parent
13484f9843
commit
2eea3df2c4
@ -3,9 +3,9 @@ import { initAngular1 } from './ng1';
|
||||
const DEVICE_READY_TIMEOUT = 5000;
|
||||
|
||||
declare var window;
|
||||
|
||||
import { ActionSheet } from './plugins/actionsheet';
|
||||
import { AdMob } from './plugins/admob';
|
||||
import { Alipay } from './plugins/alipay';
|
||||
import { AndroidFingerprintAuth } from './plugins/android-fingerprint-auth';
|
||||
import { AppAvailability } from './plugins/appavailability';
|
||||
import { AppRate } from './plugins/apprate';
|
||||
@ -130,6 +130,7 @@ import { Zip } from './plugins/zip';
|
||||
export * from './plugins/3dtouch';
|
||||
export * from './plugins/actionsheet';
|
||||
export * from './plugins/admob';
|
||||
export * from './plugins/alipay';
|
||||
export * from './plugins/android-fingerprint-auth';
|
||||
export * from './plugins/appavailability';
|
||||
export * from './plugins/apprate';
|
||||
@ -256,6 +257,7 @@ export * from './plugins/zip';
|
||||
window['IonicNative'] = {
|
||||
ActionSheet,
|
||||
AdMob,
|
||||
Alipay,
|
||||
AndroidFingerprintAuth,
|
||||
AppAvailability,
|
||||
AppRate,
|
||||
|
111
src/plugins/alipay.ts
Normal file
111
src/plugins/alipay.ts
Normal file
@ -0,0 +1,111 @@
|
||||
import { Plugin, Cordova } from './plugin';
|
||||
/**
|
||||
* @link https://doc.open.alipay.com/docs/doc.htm?spm=a219a.7629140.0.0.wlOhAE&treeId=193&articleId=105465&docType=1
|
||||
*
|
||||
* All values need be urlencoded.
|
||||
*/
|
||||
export interface AlipayOrder {
|
||||
/**
|
||||
* appId assigned by Alipay
|
||||
*/
|
||||
app_id: string;
|
||||
|
||||
/**
|
||||
* Api name.
|
||||
* Should be: alipay.trade.app.pay
|
||||
*/
|
||||
method: string;
|
||||
|
||||
/**
|
||||
* Data format
|
||||
* Default: "JSON"
|
||||
*/
|
||||
format?: string;
|
||||
|
||||
/**
|
||||
* Charset
|
||||
* Possible values: "UTF-8", "GBK"
|
||||
* Default: "UTF-8"
|
||||
*/
|
||||
charset: string;
|
||||
|
||||
/**
|
||||
* Sign method
|
||||
* Default: 'RSA'
|
||||
*/
|
||||
sign_type: string;
|
||||
|
||||
/**
|
||||
* Sign value. Should be got from server side.
|
||||
* Default: 'RSA'
|
||||
*/
|
||||
sign: string;
|
||||
|
||||
/**
|
||||
* Timestamp, formated like "yyyy-MM-dd HH:mm:ss", e.g. 2014-07-24 03:07:50
|
||||
*/
|
||||
timestamp: string;
|
||||
|
||||
/**
|
||||
* Api version. Fixed value '1.0'
|
||||
*/
|
||||
version: string;
|
||||
|
||||
/**
|
||||
* Notify url.
|
||||
*/
|
||||
notify_url: string;
|
||||
|
||||
/**
|
||||
* biz content. formated in json. see alipay doc for detail.
|
||||
*/
|
||||
biz_content: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Alipay
|
||||
* @description
|
||||
* This plugin is used for Alipay APP support. Integrated with the latest SDK.
|
||||
*
|
||||
* Requires Cordova plugin: `cordova-alipay-base`. For more info, please see the [Alipay plugin docs](https://github.com/xueron/cordova-alipay-base).
|
||||
*
|
||||
* @usage
|
||||
* ```
|
||||
* import { Alipay } from 'ionic-native';
|
||||
*
|
||||
* // Should get from server side with sign.
|
||||
* let alipayOrder = {
|
||||
...
|
||||
* };
|
||||
*
|
||||
* Alipay.pay(alipayOrder)
|
||||
* .then(result => {
|
||||
* console.log(result); // Success
|
||||
* })
|
||||
* .catch(error => {
|
||||
* console.log(error); // Failed
|
||||
* });
|
||||
*
|
||||
* ```
|
||||
*
|
||||
* @interfaces
|
||||
* AlipayOrder
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'Alipay',
|
||||
plugin: 'cordova-alipay-base',
|
||||
pluginRef: 'Alipay.Base',
|
||||
repo: 'https://github.com/xueron/cordova-alipay-base',
|
||||
platforms: ['Android', 'iOS'],
|
||||
install: 'ionic plugin add https://github.com/xueron/cordova-alipay-base --variable APP_ID=your_app_id'
|
||||
})
|
||||
export class Alipay {
|
||||
/**
|
||||
* Open Alipay to perform App pay
|
||||
* @param order { AlipayOrder } alipay options
|
||||
* @returns {Promise<any>} Returns a Promise that resolves with the success return, or rejects with an error.
|
||||
*/
|
||||
@Cordova()
|
||||
static pay(order: AlipayOrder): Promise<any> { return; }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user