在我的 react native 项目中,我已经在 android 中实现了支付原生 sdk(react native 不支持)。所以我试图用原生模块调用原生 sdk。
我可以从反应原生模块调用支付SDKUI,但是当结果的时候不能将结果发送回反应原生组件..
支付网关是 -> PAYUBIZ
有关更多详细信息,请在下面找到代码..
在支付网关结束时,我在 android native alert 中显示了支付响应。
使用的代码..
1. Created NATIVE MODULES in react native side..
import {NativeModules} from 'react-native';
module.exports = NativeModules.PayUBizAccess;
in button action following code to call native method from android
PayUBizAccess.showPayuBiz();
2. Created ReactContextBaseJavaModule based PayUBizModule
@ReactMethod
public void showPayuBiz() {
final Activity activity = getCurrentActivity();
Intent intent = new Intent(activity, PayuActivity.class);
getReactApplicationContext().startActivity(intent);
}
PayuActivity.class is the payment activity class
3. Display results after payment success or failure..
@Override
public void onActivityResult(int requestCode, int resultCode, final Intent data) {
if (requestCode == PayuConstants.PAYU_REQUEST_CODE) {
if (data != null) {
new AlertDialog.Builder(this)
.setCancelable(false)
.setMessage("Payu's Data : " + data.getStringExtra("payu_response") + "\n\n\n Merchant's Data: " + data.getStringExtra("result"))
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.dismiss();
finish();
}
}).show();
} else {
Toast.makeText(this, getString(R.string.could_not_receive_data), Toast.LENGTH_LONG).show();
}
}
}
4. After alert clicking button in alert it directly moves to react native component..
所以现在我希望结果数据能够反应原生,请建议我任何解决方案
提前致谢