Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sandbox #40

Merged
merged 1 commit into from Aug 10, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

add sandbox

  • Loading branch information
ZakZheng committed Aug 5, 2019
commit 36a7347c6e9ca1cbd3457c7ef93d620448bb9f29
@@ -88,6 +88,10 @@ try {
}
```

### Alipay.setAlipaySandbox(isSandbox)

- `isSandbox` {boolean} Whether to open sandbox. Must be payed before use. See [使用沙箱环境](https://docs.open.alipay.com/200/105311)

### Alipay.pay(orderStr)

- `orderStr` {String} Order info in query string format. Must be signed before use. See [App payment request params description](https://docs.open.alipay.com/204/105465/).
@@ -121,6 +125,8 @@ import Alipay from '@0x5e/react-native-alipay';
// APP支付
try {
// 打开沙箱
Alipay.setAlipaySandbox(true)
let orderStr = 'app_id=xxxx&method=alipay.trade.app.pay&charset=utf-8&timestamp=2014-07-24 03:07:50&version=1.0&notify_url=https%3A%2F%2Fapi.xxx.com%2Fnotify&biz_content=%7B%22subject%22%3A%22%E5%A4%A7%E4%B9%90%E9%80%8F%22%2C%22out_trade_no%22%3A%22xxxx%22%2C%22total_amount%22%3A%229.00%22%2C%22product_code%22%3A%22QUICK_MSECURITY_PAY%22%7D&sign_type=RSA2&sign=xxxx'; // get from server, signed
let response = await Alipay.pay(orderStr);
console.info(response);
@@ -1,6 +1,7 @@

package com.reactlibrary;

import com.alipay.sdk.app.EnvUtils;
import com.alipay.sdk.app.H5PayCallback;
import com.alipay.sdk.util.H5PayResultModel;
import com.alipay.sdk.app.AuthTask;
@@ -42,6 +43,16 @@ public void run() {
thread.start();
}

// 添加沙箱模式
@ReactMethod
public void setAlipaySandbox(Boolean isSandbox) {
if(isSandbox){
EnvUtils.setEnv(EnvUtils.EnvEnum.SANDBOX);
}else {
EnvUtils.setEnv(EnvUtils.EnvEnum.ONLINE);
}
}

@ReactMethod
public void pay(final String orderInfo, final Promise promise) {
Runnable runnable = new Runnable() {
@@ -10,6 +10,9 @@ declare namespace Alipay {

function authWithInfo(infoStr: string): IResult;

// 设置沙箱模式
function setAlipaySandbox(isSandbox: boolean): void

function pay(infoStr: string): IResult;

function payInterceptorWithUrl(infoStr: string): {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.