Skip to content

Commit

Permalink
Fix return ios result
Browse files Browse the repository at this point in the history
  • Loading branch information
zatyanuar committed Mar 18, 2019
1 parent fdaea16 commit 432f0d7
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private void startMolpay(MethodCall call, Result result) {
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", "1");
paymentDetails.put("wrapper_version", "2");
paymentDetails.put("mp_credit_card_no", call.argument(""));
paymentDetails.put("mp_credit_card_expiry", call.argument(""));
paymentDetails.put("mp_credit_card_cvv", call.argument(""));
Expand Down
6 changes: 3 additions & 3 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ class _MyAppState extends State<MyApp> {
// 'mp_is_escrow': '', // Optional for Escrow, put "1" to enable escrow

// Optional for credit card BIN restrictions
'mp_bin_lock': ['414170', '414171'], // Optional for credit card BIN restrictions
'mp_bin_lock_err_msg': 'Only UOB allowed', // Optional for credit card BIN restrictions
// 'mp_bin_lock': ['414170', '414171'], // Optional for credit card BIN restrictions
// 'mp_bin_lock_err_msg': 'Only UOB allowed', // Optional for credit card BIN restrictions

// For transaction request use only, do not use this on payment process
// 'mp_transaction_id': '', // Optional, provide a valid cash channel transaction id here will display a payment instruction screen.
Expand All @@ -78,7 +78,7 @@ class _MyAppState extends State<MyApp> {
// 'mp_is_recurring': false,

// Optional for channels restriction
'mp_allowed_channels': ['credit','credit3'],
// 'mp_allowed_channels': ['credit','credit3'],

// Optional for sandboxed development environment, set boolean value to enable.
// 'mp_sandbox_mode': false,
Expand Down
16 changes: 15 additions & 1 deletion ios/Classes/MolpayMobileXdkFlutterBetaPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ -(void)startMolpay{

[paymentDetailsMutable setObject:[NSNumber numberWithBool:YES] forKey:@"is_submodule"];
[paymentDetailsMutable setObject:@"molpay-mobile-xdk-flutter-beta-ios" forKey:@"module_id"];
[paymentDetailsMutable setObject:@"1" forKey:@"wrapper_version"];
[paymentDetailsMutable setObject:@"2" forKey:@"wrapper_version"];

mp = [[MOLPayLib alloc] initWithDelegate:self andPaymentDetails:paymentDetailsMutable];

Expand Down Expand Up @@ -85,6 +85,20 @@ - (void)transactionResult: (NSDictionary *)result
{
// Payment status results returned here
NSLog(@"transactionResult result = %@", result);

NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:result
options:NSJSONWritingPrettyPrinted // Pass 0 if you don't care about the readability of the generated string
error:&error];

NSString *resultString;
if (! jsonData) {
resultString = [NSString stringWithFormat:@"Error while converting result to json format: %@", error];
} else {
resultString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}

_result(resultString);

// All success cash channel payments will display a payment instruction, we will let the user to close manually
if ([[result objectForKey:@"pInstruction"] integerValue] == 1 && isPaymentInstructionPresent == NO && isCloseButtonClick == NO)
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.23.1
version: 0.23.2
author: MOLPay Mobile Division <[email protected]>
homepage: https://github.com/MOLPay/molpay-mobile-xdk-flutter-beta

Expand Down

0 comments on commit 432f0d7

Please sign in to comment.