|
|
|
@@ -4,6 +4,7 @@ import com.alipay.sdk.app.AuthTask;
|
|
|
|
|
import com.alipay.sdk.app.PayTask;
|
|
|
|
|
import com.alipay.sdk.app.EnvUtils;
|
|
|
|
|
import com.facebook.react.bridge.Arguments;
|
|
|
|
|
import com.facebook.react.bridge.Promise;
|
|
|
|
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
|
|
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
|
|
|
import com.facebook.react.bridge.ReactMethod;
|
|
|
|
@@ -33,6 +34,20 @@ public class AlipayModule extends ReactContextBaseJavaModule {
|
|
|
|
|
// callback.invoke("Received numberArgument: " + numberArgument + " stringArgument: " + stringArgument);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
public void authInfo(final String infoStr, final Callback promise) {
|
|
|
|
|
Runnable runnable = new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
AuthTask alipay = new AuthTask(getCurrentActivity());
|
|
|
|
|
Map<String, String> map = alipay.authV2(infoStr, true);
|
|
|
|
|
promise.invoke(getWritableMap(map));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
Thread thread = new Thread(runnable);
|
|
|
|
|
thread.start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ReactMethod
|
|
|
|
|
public void setAlipaySandbox(Boolean isSandbox) {
|
|
|
|
|
if (isSandbox) {
|
|
|
|
@@ -48,11 +63,7 @@ public class AlipayModule extends ReactContextBaseJavaModule {
|
|
|
|
|
public void run() {
|
|
|
|
|
PayTask alipay = new PayTask(getCurrentActivity());
|
|
|
|
|
Map<String, String> result = alipay.payV2(orderInfo, true);
|
|
|
|
|
WritableMap map = Arguments.createMap();
|
|
|
|
|
map.putString("memo", result.get("memo"));
|
|
|
|
|
map.putString("result", result.get("result"));
|
|
|
|
|
map.putString("resultStatus", result.get("resultStatus"));
|
|
|
|
|
promise.invoke(map);
|
|
|
|
|
promise.invoke(getWritableMap(result));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
// 必须异步调用
|
|
|
|
@@ -60,4 +71,11 @@ public class AlipayModule extends ReactContextBaseJavaModule {
|
|
|
|
|
payThread.start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private WritableMap getWritableMap(Map<String, String> map) {
|
|
|
|
|
WritableMap writableMap = Arguments.createMap();
|
|
|
|
|
for (Map.Entry<String, String> entry : map.entrySet()) {
|
|
|
|
|
writableMap.putString(entry.getKey(), entry.getValue());
|
|
|
|
|
}
|
|
|
|
|
return writableMap;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|