Skip to content

Commit

Permalink
update latest react native project
Browse files Browse the repository at this point in the history
  • Loading branch information
LeowWH committed Jul 2, 2019
1 parent c998ced commit 05b97a4
Show file tree
Hide file tree
Showing 56 changed files with 874 additions and 781 deletions.
3 changes: 0 additions & 3 deletions MOLPayReactExampleProject/.babelrc

This file was deleted.

42 changes: 33 additions & 9 deletions MOLPayReactExampleProject/.flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,58 @@
; For RN Apps installed via npm, "Libraries" folder is inside
; "node_modules/react-native" but in the source repo it is in the root
.*/Libraries/react-native/React.js
.*/Libraries/react-native/ReactNative.js

; Ignore polyfills
.*/Libraries/polyfills/.*

; Ignore metro
.*/node_modules/metro/.*

[include]

[libs]
node_modules/react-native/Libraries/react-native/react-native-interface.js
node_modules/react-native/flow
flow/
node_modules/react-native/flow/

[options]
emoji=true

esproposal.optional_chaining=enable
esproposal.nullish_coalescing=enable

module.system=haste
module.system.haste.use_name_reducers=true
# get basename
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
# strip .js or .js.flow suffix
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
# strip .ios suffix
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
module.system.haste.paths.blacklist=.*/__tests__/.*
module.system.haste.paths.blacklist=.*/__mocks__/.*
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/Animated/src/polyfills/.*
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/Libraries/.*

munge_underscores=true

module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'

module.file_ext=.js
module.file_ext=.jsx
module.file_ext=.json
module.file_ext=.native.js

suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FixMe
suppress_type=$FlowFixMeProps
suppress_type=$FlowFixMeState

suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(4[0-9]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(4[0-9]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError

unsafe.enable_getters_and_setters=true

[version]
^0.49.1
^0.92.0
11 changes: 7 additions & 4 deletions MOLPayReactExampleProject/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ buck-out/
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
# https://docs.fastlane.tools/best-practices/source-control/

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots

# Bundle artifact
*.jsbundle
134 changes: 134 additions & 0 deletions MOLPayReactExampleProject/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/

import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View,Button} from 'react-native';

const instructions = Platform.select({
ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
android:
'Double tap R on your keyboard to reload,\n' +
'Shake or press menu button for dev menu',
});

type Props = {};
export default class App extends Component<Props> {
state = {
string : ""
};

buttonClicked(){
var c = this;
var molpay = require("molpay-mobile-xdk-reactnative-beta");
var paymentDetails = {
// Mandatory String. A value more than '1.00'
'mp_amount': 1.1,

// Mandatory String. Values obtained from MOLPay
'mp_username': 'username',
'mp_password': 'password',
'mp_merchant_ID': 'merchantID',
'mp_app_name': 'appname',
'mp_verification_key': '12345123451234512345',

// Mandatory String. Payment values
'mp_order_ID': 'React0002',
'mp_currency': 'MYR',
'mp_country': 'MY',

// Optional String.
'mp_channel': '', // Use 'multi' for all available channels option. For individual channel seletion, please refer to "Channel Parameter" in "Channel Lists" in the MOLPay API Spec for Merchant pdf.
'mp_bill_description': 'test payment',
'mp_bill_name': 'anyname',
'mp_bill_email': 'example@email.com',
'mp_bill_mobile': '0161111111',
// 'mp_channel_editing': true, // Option to allow channel selection.
'mp_editing_enabled': true, // Option to allow billing information editing.

// Optional for Escrow
// '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

// 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.
// 'mp_request_type': '', // Optional, set 'Status' when doing a transactionRequest

// Optional, use this to customize the UI theme for the payment info screen, the original XDK custom.css file is provided at Example project source for reference and implementation.
// 'mp_custom_css_url': '',

// Optional, set the token id to nominate a preferred token as the default selection, set "new" to allow new card only
// 'mp_preferred_token': '',

// Optional, credit card transaction type, set "AUTH" to authorize the transaction
// 'mp_tcctype': '',

// Optional, set true to process this transaction through the recurring api, please refer the MOLPay Recurring API pdf
// // 'mp_is_recurring': false,

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

// Optional for sandboxed development environment, set boolean value to enable.
// 'mp_sandbox_mode': false,

// Optional, required a valid mp_channel value, this will skip the payment info page and go direct to the payment screen.
// 'mp_express_mode': false,
// "mp_bill_description_edit_disabled": false,

};
// start molpay payment
molpay.startMolpay(paymentDetails,function(data){
console.log(data);
//console.log(paymentDetails);
console.log(this);
alert(JSON.stringify(data));
//callback after payment success
c.setState({
string : data
})

});
};

render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>Welcome to React Native!</Text>
<Text style={styles.instructions}>To get started, edit App.js</Text>
<Text style={styles.instructions}>{instructions}</Text>
<Text style={styles.instructions}>{this.state.string}</Text>
<Button
style={{backgroundColor: 'grey', flex: 0.5}}
onPress={this.buttonClicked.bind(this)}
title="Start Molpay" />
</View>
);
}
}

const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/**
* @format
*/

import 'react-native';
import React from 'react';
import Index from '../index.ios.js';
import App from '../App';

// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';

it('renders correctly', () => {
const tree = renderer.create(
<Index />
);
renderer.create(<App />);
});
12 changes: 0 additions & 12 deletions MOLPayReactExampleProject/__tests__/index.android.js

This file was deleted.

22 changes: 6 additions & 16 deletions MOLPayReactExampleProject/android/app/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,13 @@
# - `buck install -r android/app` - compile, install and run application
#

load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")

lib_deps = []

for jarfile in glob(['libs/*.jar']):
name = 'jars__' + jarfile[jarfile.rindex('/') + 1: jarfile.rindex('.jar')]
lib_deps.append(':' + name)
prebuilt_jar(
name = name,
binary_jar = jarfile,
)
create_aar_targets(glob(["libs/*.aar"]))

for aarfile in glob(['libs/*.aar']):
name = 'aars__' + aarfile[aarfile.rindex('/') + 1: aarfile.rindex('.aar')]
lib_deps.append(':' + name)
android_prebuilt_aar(
name = name,
aar = aarfile,
)
create_jar_targets(glob(["libs/*.jar"]))

android_library(
name = "all-libs",
Expand All @@ -45,12 +35,12 @@ android_library(

android_build_config(
name = "build_config",
package = "com.molpayreactexampleproject",
package = "com.test0270",
)

android_resource(
name = "res",
package = "com.molpayreactexampleproject",
package = "com.test0270",
res = "src/main/res",
)

Expand Down
33 changes: 19 additions & 14 deletions MOLPayReactExampleProject/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ import com.android.build.OutputFile
* ]
*/

project.ext.react = [
entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"

/**
Expand All @@ -90,25 +94,26 @@ def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false

android {
compileSdkVersion 27
buildToolsVersion "27.0.0"
compileSdkVersion rootProject.ext.compileSdkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
applicationId "com.molpayreactexampleproject"
minSdkVersion 16
targetSdkVersion 22
applicationId "com.test0270"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
buildTypes {
Expand All @@ -122,7 +127,7 @@ android {
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
Expand All @@ -133,10 +138,10 @@ android {
}

dependencies {
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:27.0.0"
compile "com.facebook.react:react-native:+" // From node_modules
compile project(':molpay-mobile-xdk-reactnative-beta')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation project(':molpay-mobile-xdk-reactnative-beta')
}

// Run this once to be able to run the application with BUCK
Expand Down
19 changes: 19 additions & 0 deletions MOLPayReactExampleProject/android/app/build_defs.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""Helper definitions to glob .aar and .jar targets"""
def create_aar_targets(aarfiles):
for aarfile in aarfiles:
name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")]
lib_deps.append(":" + name)
android_prebuilt_aar(
name = name,
aar = aarfile,
)
def create_jar_targets(jarfiles):
for jarfile in jarfiles:
name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")]
lib_deps.append(":" + name)
prebuilt_jar(
name = name,
binary_jar = jarfile,
)
Loading

0 comments on commit 05b97a4

Please sign in to comment.