Skip to content

Commit

Permalink
update credit card parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
IzzatyAnuar committed Nov 22, 2018
1 parent 44e831c commit 31b7334
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This is the beta but functional MOLPay Flutter payment module that is ready to b

## Installation

1) Add `molpay_mobile_xdk_flutter_beta`
1) Add `molpay_mobile_xdk_flutter_beta` in pubspec.yaml

```
dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,34 +37,48 @@ private MolpayMobileXdkFlutterBetaPlugin(Activity activity) {
@Override
public void onMethodCall(MethodCall call, Result result) {
if (call.method.equals("startMolpay")) {
startMolpay(call,result);
startMolpay(call, result);
} else {
result.notImplemented();
}
}

private void startMolpay(MethodCall call, Result result){
private void startMolpay(MethodCall call, Result result) {
Field[] fields = MOLPayActivity.class.getDeclaredFields();
HashMap<String, Object> paymentDetails = new HashMap<>();
HashMap<String, Object> paymentDetails = new HashMap<>();
paymentDetails.put("is_submodule", true);
paymentDetails.put("module_id", "molpay-mobile-xdk-flutter-beta-android");
paymentDetails.put("wrapper_version", "0");
for (Field f : fields) {
if(call.argument(f.getName()) != null){
paymentDetails.put(f.getName(), call.argument(f.getName()));
}
}
paymentDetails.put("mp_credit_card_no", call.argument(""));
paymentDetails.put("mp_credit_card_expiry", call.argument(""));
paymentDetails.put("mp_credit_card_cvv", call.argument(""));

Intent intent = new Intent(activity, MOLPayActivity.class);
intent.putExtra(MOLPayActivity.MOLPayPaymentDetails, paymentDetails);
activity.startActivityForResult(intent, MOLPayActivity.MOLPayXDK);
this.results = result;
if (call.argument("mp_credit_card_no") != null) {
paymentDetails.put("mp_credit_card_no", call.argument("mp_credit_card_no"));
}
if (call.argument("mp_credit_card_expiry") != null) {
paymentDetails.put("mp_credit_card_expiry", call.argument("mp_credit_card_expiry"));
}
if (call.argument("mp_credit_card_cvv") != null) {
paymentDetails.put("mp_credit_card_cvv", call.argument("mp_credit_card_cvv"));
}

for (Field f : fields) {
if (call.argument(f.getName()) != null) {
paymentDetails.put(f.getName(), call.argument(f.getName()));
}
}

Intent intent = new Intent(activity, MOLPayActivity.class);
intent.putExtra(MOLPayActivity.MOLPayPaymentDetails, paymentDetails);
activity.startActivityForResult(intent, MOLPayActivity.MOLPayXDK);
this.results = result;
}

@Override
public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == MOLPayActivity.MOLPayXDK && resultCode == Activity.RESULT_OK){
this.results.success(data.getStringExtra(MOLPayActivity.MOLPayTransactionResult));
if (requestCode == MOLPayActivity.MOLPayXDK && resultCode == Activity.RESULT_OK) {
this.results.success(data.getStringExtra(MOLPayActivity.MOLPayTransactionResult));
}
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: molpay_mobile_xdk_flutter_beta
description: MOLPay mobile payment for Flutter (BETA)
version: 0.22.0
version: 0.22.1
author: MOLPay Mobile Division <[email protected]>
homepage: https://github.com/MOLPay/molpay-mobile-xdk-flutter-beta

Expand Down

0 comments on commit 31b7334

Please sign in to comment.