Skip to content

Commit

Permalink
BETA 0.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
LeowWH committed Jun 16, 2017
1 parent f7b1962 commit 3831a57
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 164 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ android {

dependencies {
compile 'com.facebook.react:react-native:+'
compile 'com.molpay:molpay-mobile-xdk-android:3.12.0'
compile 'com.molpay:molpay-mobile-xdk-android:3.13.0'
}
52 changes: 8 additions & 44 deletions android/src/main/java/com/molpayxdk/MOLPayReact.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@
import org.json.JSONObject;

import java.util.HashMap;
import java.util.Iterator;

import javax.annotation.Nullable;

/**
* Created by leow on 10/11/2016 AD.
*/
public class MOLPayReact extends ReactContextBaseJavaModule{
public static HashMap<String, Object> paymentDetails = new HashMap<>();
public static HashMap<String, Object> paymentDetails;
public static Callback successCallback;
public static Callback errorCallback;

Expand All @@ -32,6 +30,7 @@ public MOLPayReact(ReactApplicationContext reactContext) {

@ReactMethod
public void setPaymentDetails(String str,@Nullable Callback successCallback, @Nullable Callback errorCallback){
paymentDetails = new HashMap<>();
if(successCallback != null){
this.successCallback = successCallback;
}
Expand All @@ -40,49 +39,14 @@ public void setPaymentDetails(String str,@Nullable Callback successCallback, @Nu
}
try{
JSONObject obj = new JSONObject(str);
paymentDetails.put(MOLPayActivity.mp_amount, obj.getString("mp_amount"));
paymentDetails.put(MOLPayActivity.mp_username, obj.getString("mp_username"));
paymentDetails.put(MOLPayActivity.mp_password, obj.getString("mp_password"));
paymentDetails.put(MOLPayActivity.mp_merchant_ID, obj.getString("mp_merchant_ID"));
paymentDetails.put(MOLPayActivity.mp_app_name, obj.getString("mp_app_name"));
paymentDetails.put(MOLPayActivity.mp_verification_key, obj.getString("mp_verification_key"));

paymentDetails.put(MOLPayActivity.mp_order_ID, obj.getString("mp_order_ID"));
paymentDetails.put(MOLPayActivity.mp_currency, obj.getString("mp_currency"));
paymentDetails.put(MOLPayActivity.mp_country, obj.getString("mp_country"));
paymentDetails.put(MOLPayActivity.mp_channel, obj.getString("mp_channel"));
paymentDetails.put(MOLPayActivity.mp_bill_description, obj.getString("mp_bill_description"));
paymentDetails.put(MOLPayActivity.mp_bill_name, obj.getString("mp_bill_name"));
paymentDetails.put(MOLPayActivity.mp_bill_email, obj.getString("mp_bill_email"));
paymentDetails.put(MOLPayActivity.mp_bill_mobile, obj.getString("mp_bill_mobile"));
paymentDetails.put(MOLPayActivity.mp_channel_editing, obj.getString("mp_channel_editing"));
paymentDetails.put(MOLPayActivity.mp_editing_enabled, obj.getString("mp_editing_enabled"));
paymentDetails.put(MOLPayActivity.mp_transaction_id, obj.getString("mp_transaction_id"));//8064815
paymentDetails.put(MOLPayActivity.mp_request_type, obj.getString("mp_request_type"));
paymentDetails.put(MOLPayActivity.mp_bin_lock, obj.getString("mp_bin_lock"));
paymentDetails.put(MOLPayActivity.mp_bin_lock_err_msg, obj.getString("mp_bin_lock_err_msg"));
paymentDetails.put(MOLPayActivity.mp_is_escrow, obj.getString("mp_is_escrow"));
paymentDetails.put(MOLPayActivity.mp_filter, obj.getString("mp_filter"));
paymentDetails.put(MOLPayActivity.mp_custom_css_url, obj.getString("mp_custom_css_url"));
paymentDetails.put(MOLPayActivity.mp_preferred_token, obj.getString("mp_preferred_token"));
paymentDetails.put(MOLPayActivity.mp_tcctype, obj.getString("mp_tcctype"));
paymentDetails.put(MOLPayActivity.mp_is_recurring, obj.getString("mp_is_recurring"));
paymentDetails.put(MOLPayActivity.mp_allowed_channels, obj.getString("mp_allowed_channels"));
paymentDetails.put(MOLPayActivity.mp_sandbox_mode, obj.getString("mp_sandbox_mode"));
paymentDetails.put(MOLPayActivity.mp_express_mode, obj.getString("mp_express_mode"));
paymentDetails.put(MOLPayActivity.mp_advanced_email_validation_enabled, obj.getString("mp_advanced_email_validation_enabled"));
paymentDetails.put(MOLPayActivity.mp_advanced_phone_validation_enabled, obj.getString("mp_advanced_phone_validation_enabled"));
paymentDetails.put(MOLPayActivity.mp_bill_name_edit_disabled, obj.getString("mp_bill_name_edit_disabled"));
paymentDetails.put(MOLPayActivity.mp_bill_email_edit_disabled, obj.getString("mp_bill_email_edit_disabled"));
paymentDetails.put(MOLPayActivity.mp_bill_mobile_edit_disabled, obj.getString("mp_bill_mobile_edit_disabled"));
paymentDetails.put(MOLPayActivity.mp_bill_description_edit_disabled, obj.getString("mp_bill_description_edit_disabled"));
paymentDetails.put(MOLPayActivity.mp_language, obj.getString("mp_language"));
paymentDetails.put(MOLPayActivity.mp_dev_mode, obj.getString("mp_dev_mode"));
Iterator<String> iter = obj.keys();
while (iter.hasNext()) {
String key = iter.next();
paymentDetails.put(key, obj.getString(key));
}
paymentDetails.put("is_submodule", true);
paymentDetails.put("module_id", "molpay-mobile-xdk-reactnative-beta-android");
paymentDetails.put("wrapper_version", "0");


}catch(Exception e){
if(this.errorCallback != null){
this.errorCallback.invoke(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.app.Activity;
import android.content.Intent;
import java.util.HashMap;

import com.molpay.molpayxdk.MOLPayActivity;

Expand Down
3 changes: 0 additions & 3 deletions android/src/main/java/com/molpayxdk/MOLPayReactPackage.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
import java.util.Collections;
import java.util.List;

/**
* Created by leow on 10/11/2016 AD.
*/
public class MOLPayReactPackage implements ReactPackage{

@Override
Expand Down
60 changes: 3 additions & 57 deletions index.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,76 +2,22 @@ import {
NativeModules
} from 'react-native';

var jsonparse = function(paymentDetails) {
var payment = {
mp_amount: "",
mp_username: "",
mp_password: "",
mp_merchant_ID: "",
mp_app_name: "",
mp_verification_key: "",
mp_order_ID: "",
mp_currency: "",
mp_country: "",
mp_channel: "",
mp_bill_description: "",
mp_bill_name: "",
mp_bill_email: "",
mp_bill_mobile: "",
mp_channel_editing: "",
mp_editing_enabled: "",
mp_transaction_id: "",
mp_request_type: "",
mp_bin_lock: "",
mp_bin_lock_err_msg: "",
mp_is_escrow: "",
mp_filter: "",
mp_custom_css_url: "",
mp_preferred_token: "",
mp_tcctype: "",
mp_is_recurring: "",
mp_allowed_channels: "",
mp_sandbox_mode: "",
mp_express_mode: "",
mp_advanced_email_validation_enabled: "",
mp_advanced_phone_validation_enabled: "",
mp_bill_name_edit_disabled: "",
mp_bill_email_edit_disabled: "",
mp_bill_mobile_edit_disabled: "",
mp_bill_description_edit_disabled: "",
mp_language: "",
mp_dev_mode: ""
}

for(var key in payment){
if(paymentDetails[key]){
payment[key] = paymentDetails[key]
}else{
payment[key] = "";
}
}
payment = JSON.stringify(payment);
return payment;
}

var molpay = {
startMolpay: function(paymentDetails, successCallback, errorCallback) {
var completePayment;
if (typeof paymentDetails === "string") {
try {
paymentDetails = JSON.parse(paymentDetails);
completePayment = jsonparse(paymentDetails);
paymentDetails = JSON.parse(JSON.stringify(paymentDetails));
} catch (e) {
if (errorCallback) {
errorCallback("Payment Details content wrong value or format");
return;
}
}
} else if (typeof paymentDetails === "object") {
completePayment = jsonparse(paymentDetails);
paymentDetails = JSON.stringify(paymentDetails);
}

NativeModules.MOLPay.setPaymentDetails(completePayment, function(paymentResult) {
NativeModules.MOLPay.setPaymentDetails(paymentDetails, function(paymentResult) {
if (successCallback) {
successCallback(paymentResult);
}
Expand Down
57 changes: 1 addition & 56 deletions index.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,75 +2,20 @@ import {
NativeModules
} from 'react-native';

var jsonparse = function(paymentDetails) {
var payment = {
mp_amount: "",
mp_username: "",
mp_password: "",
mp_merchant_ID: "",
mp_app_name: "",
mp_verification_key: "",
mp_order_ID: "",
mp_currency: "",
mp_country: "",
mp_channel: "",
mp_bill_description: "",
mp_bill_name: "",
mp_bill_email: "",
mp_bill_mobile: "",
mp_channel_editing: "",
mp_editing_enabled: "",
mp_transaction_id: "",
mp_request_type: "",
mp_bin_lock: "",
mp_bin_lock_err_msg: "",
mp_is_escrow: "",
mp_filter: "",
mp_custom_css_url: "",
mp_preferred_token: "",
mp_tcctype: "",
mp_is_recurring: "",
mp_allowed_channels: "",
mp_sandbox_mode: "",
mp_express_mode: "",
mp_advanced_email_validation_enabled: "",
mp_advanced_phone_validation_enabled: "",
mp_bill_name_edit_disabled: "",
mp_bill_email_edit_disabled: "",
mp_bill_mobile_edit_disabled: "",
mp_bill_description_edit_disabled: "",
mp_language: "",
mp_dev_mode: ""
}

for (var key in payment) {
if (paymentDetails[key]) {
payment[key] = paymentDetails[key]
} else {
payment[key] = "";
}
}
return payment;
}

var molpay = {
startMolpay: function(paymentDetails, successCallback, errorCallback) {
var completePayment;
if (typeof paymentDetails === "string") {
try {
paymentDetails = JSON.parse(paymentDetails);
completePayment = jsonparse(paymentDetails);
} catch (e) {
if (errorCallback) {
errorCallback("Payment Details content wrong value or format");
return;
}
}
} else if (typeof paymentDetails === "object") {
completePayment = jsonparse(paymentDetails);
}

NativeModules.MOLPayReactManager.setPaymentDetails(completePayment, function(paymentResult) {
NativeModules.MOLPayReactManager.setPaymentDetails(paymentDetails, function(paymentResult) {
if (successCallback) {
successCallback(JSON.stringify(paymentResult));
}
Expand Down
2 changes: 1 addition & 1 deletion ios/MOLPayXDK.bundle/molpay-mobile-xdk-www/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html> <html> <head> <meta charset="utf-8"> <title></title> <meta name="description" content=""> <!-- <meta name="viewport" content="width=device-width"> --> <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"> <meta name="format-detection" content="telephone=no"> <!-- Place favicon.ico and apple-touch-icon.png in the root directory --> <link rel="stylesheet" href="styles/vendor.34eb91d2.css"> <link rel="stylesheet" href="styles/main.88dcea2c.css"> </head> <body ng-app="molpayXsdkApp"> <div class="header"> </div> <div id="app-body" class="app-body container-fluid"> <div class="row"> <div class="hidden-xs col-sm-2 col-md-3 col-lg-4"></div> <div class="col-xs-12 col-sm-8 col-md-6 col-lg-4" ng-view=""></div> <div class="hidden-xs col-sm-2 col-md-3 col-lg-4"></div> </div> </div> <div ng-show="isStarting || isLoading" class="text-center"> <br> <p>{{label_preparing}}</p> <p>{{label_pleasewait}}</p> </div> <div class="footer"> </div> <div ng-show="isLoading || D7ARequeryActiveNow" class="loading text-center vertical-center"> <div class="loadingbackground"></div> <i class="fa fa-spinner fa-spin fa-3x"></i> <div class="loading-text">{{label_loading}}</div> </div> <script src="scripts/vendor.f57621ed.js"></script> <script src="scripts/scripts.69e44cc3.js"></script> </body> </html>
<!doctype html> <html> <head> <meta charset="utf-8"> <title></title> <meta name="description" content=""> <!-- <meta name="viewport" content="width=device-width"> --> <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"> <meta name="format-detection" content="telephone=no"> <!-- Place favicon.ico and apple-touch-icon.png in the root directory --> <link rel="stylesheet" href="styles/vendor.34eb91d2.css"> <link rel="stylesheet" href="styles/main.88dcea2c.css"> </head> <body ng-app="molpayXsdkApp"> <div class="header"> </div> <div id="app-body" class="app-body container-fluid"> <div class="row"> <div class="hidden-xs col-sm-2 col-md-3 col-lg-4"></div> <div class="col-xs-12 col-sm-8 col-md-6 col-lg-4" ng-view=""></div> <div class="hidden-xs col-sm-2 col-md-3 col-lg-4"></div> </div> </div> <div ng-show="isStarting || isLoading" class="text-center"> <br> <p>{{label_preparing}}</p> <p>{{label_pleasewait}}</p> </div> <div class="footer"> </div> <div ng-show="isLoading || D7ARequeryActiveNow" class="loading text-center vertical-center"> <div class="loadingbackground"></div> <i class="fa fa-spinner fa-spin fa-3x"></i> <div class="loading-text">{{label_loading}}</div> </div> <script src="scripts/vendor.f57621ed.js"></script> <script src="scripts/scripts.7f48ad2d.js"></script> </body> </html>

This file was deleted.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "molpay-mobile-xdk-reactnative-beta",
"version": "0.12.2",
"version": "0.13.0",
"description": "MOLPay mobile payment for React Native (BETA)",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down

0 comments on commit 3831a57

Please sign in to comment.