Skip to content

Commit 05b97a4

Browse files
committed
update latest react native project
1 parent c998ced commit 05b97a4

56 files changed

Lines changed: 874 additions & 781 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

MOLPayReactExampleProject/.babelrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

MOLPayReactExampleProject/.flowconfig

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,58 @@
1212
; For RN Apps installed via npm, "Libraries" folder is inside
1313
; "node_modules/react-native" but in the source repo it is in the root
1414
.*/Libraries/react-native/React.js
15-
.*/Libraries/react-native/ReactNative.js
15+
16+
; Ignore polyfills
17+
.*/Libraries/polyfills/.*
18+
19+
; Ignore metro
20+
.*/node_modules/metro/.*
1621

1722
[include]
1823

1924
[libs]
2025
node_modules/react-native/Libraries/react-native/react-native-interface.js
21-
node_modules/react-native/flow
22-
flow/
26+
node_modules/react-native/flow/
2327

2428
[options]
2529
emoji=true
2630

31+
esproposal.optional_chaining=enable
32+
esproposal.nullish_coalescing=enable
33+
2734
module.system=haste
35+
module.system.haste.use_name_reducers=true
36+
# get basename
37+
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
38+
# strip .js or .js.flow suffix
39+
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
40+
# strip .ios suffix
41+
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
42+
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
43+
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
44+
module.system.haste.paths.blacklist=.*/__tests__/.*
45+
module.system.haste.paths.blacklist=.*/__mocks__/.*
46+
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/Animated/src/polyfills/.*
47+
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/Libraries/.*
2848

2949
munge_underscores=true
3050

3151
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'
3252

53+
module.file_ext=.js
54+
module.file_ext=.jsx
55+
module.file_ext=.json
56+
module.file_ext=.native.js
57+
3358
suppress_type=$FlowIssue
3459
suppress_type=$FlowFixMe
35-
suppress_type=$FixMe
60+
suppress_type=$FlowFixMeProps
61+
suppress_type=$FlowFixMeState
3662

37-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(4[0-9]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
38-
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]+
63+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
64+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
3965
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
4066
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
4167

42-
unsafe.enable_getters_and_setters=true
43-
4468
[version]
45-
^0.49.1
69+
^0.92.0

MOLPayReactExampleProject/.gitignore

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@ buck-out/
4646
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
4747
# screenshots whenever they are needed.
4848
# For more information about the recommended setup visit:
49-
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
49+
# https://docs.fastlane.tools/best-practices/source-control/
5050

51-
fastlane/report.xml
52-
fastlane/Preview.html
53-
fastlane/screenshots
51+
*/fastlane/report.xml
52+
*/fastlane/Preview.html
53+
*/fastlane/screenshots
54+
55+
# Bundle artifact
56+
*.jsbundle

MOLPayReactExampleProject/App.js

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
/**
2+
* Sample React Native App
3+
* https://github.com/facebook/react-native
4+
*
5+
* @format
6+
* @flow
7+
*/
8+
9+
import React, {Component} from 'react';
10+
import {Platform, StyleSheet, Text, View,Button} from 'react-native';
11+
12+
const instructions = Platform.select({
13+
ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
14+
android:
15+
'Double tap R on your keyboard to reload,\n' +
16+
'Shake or press menu button for dev menu',
17+
});
18+
19+
type Props = {};
20+
export default class App extends Component<Props> {
21+
state = {
22+
string : ""
23+
};
24+
25+
buttonClicked(){
26+
var c = this;
27+
var molpay = require("molpay-mobile-xdk-reactnative-beta");
28+
var paymentDetails = {
29+
// Mandatory String. A value more than '1.00'
30+
'mp_amount': 1.1,
31+
32+
// Mandatory String. Values obtained from MOLPay
33+
'mp_username': 'username',
34+
'mp_password': 'password',
35+
'mp_merchant_ID': 'merchantID',
36+
'mp_app_name': 'appname',
37+
'mp_verification_key': '12345123451234512345',
38+
39+
// Mandatory String. Payment values
40+
'mp_order_ID': 'React0002',
41+
'mp_currency': 'MYR',
42+
'mp_country': 'MY',
43+
44+
// Optional String.
45+
'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.
46+
'mp_bill_description': 'test payment',
47+
'mp_bill_name': 'anyname',
48+
'mp_bill_email': 'example@email.com',
49+
'mp_bill_mobile': '0161111111',
50+
// 'mp_channel_editing': true, // Option to allow channel selection.
51+
'mp_editing_enabled': true, // Option to allow billing information editing.
52+
53+
// Optional for Escrow
54+
// 'mp_is_escrow': '', // Optional for Escrow, put "1" to enable escrow
55+
56+
// Optional for credit card BIN restrictions
57+
//'mp_bin_lock': ['414170', '414171'], // Optional for credit card BIN restrictions
58+
//'mp_bin_lock_err_msg': 'Only UOB allowed', // Optional for credit card BIN restrictions
59+
60+
// For transaction request use only, do not use this on payment process
61+
// 'mp_transaction_id': '', // Optional, provide a valid cash channel transaction id here will display a payment instruction screen.
62+
// 'mp_request_type': '', // Optional, set 'Status' when doing a transactionRequest
63+
64+
// 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.
65+
// 'mp_custom_css_url': '',
66+
67+
// Optional, set the token id to nominate a preferred token as the default selection, set "new" to allow new card only
68+
// 'mp_preferred_token': '',
69+
70+
// Optional, credit card transaction type, set "AUTH" to authorize the transaction
71+
// 'mp_tcctype': '',
72+
73+
// Optional, set true to process this transaction through the recurring api, please refer the MOLPay Recurring API pdf
74+
// // 'mp_is_recurring': false,
75+
76+
// Optional for channels restriction
77+
// 'mp_allowed_channels': ['credit','credit3'],
78+
79+
// Optional for sandboxed development environment, set boolean value to enable.
80+
// 'mp_sandbox_mode': false,
81+
82+
// Optional, required a valid mp_channel value, this will skip the payment info page and go direct to the payment screen.
83+
// 'mp_express_mode': false,
84+
// "mp_bill_description_edit_disabled": false,
85+
86+
};
87+
// start molpay payment
88+
molpay.startMolpay(paymentDetails,function(data){
89+
console.log(data);
90+
//console.log(paymentDetails);
91+
console.log(this);
92+
alert(JSON.stringify(data));
93+
//callback after payment success
94+
c.setState({
95+
string : data
96+
})
97+
98+
});
99+
};
100+
101+
render() {
102+
return (
103+
<View style={styles.container}>
104+
<Text style={styles.welcome}>Welcome to React Native!</Text>
105+
<Text style={styles.instructions}>To get started, edit App.js</Text>
106+
<Text style={styles.instructions}>{instructions}</Text>
107+
<Text style={styles.instructions}>{this.state.string}</Text>
108+
<Button
109+
style={{backgroundColor: 'grey', flex: 0.5}}
110+
onPress={this.buttonClicked.bind(this)}
111+
title="Start Molpay" />
112+
</View>
113+
);
114+
}
115+
}
116+
117+
const styles = StyleSheet.create({
118+
container: {
119+
flex: 1,
120+
justifyContent: 'center',
121+
alignItems: 'center',
122+
backgroundColor: '#F5FCFF',
123+
},
124+
welcome: {
125+
fontSize: 20,
126+
textAlign: 'center',
127+
margin: 10,
128+
},
129+
instructions: {
130+
textAlign: 'center',
131+
color: '#333333',
132+
marginBottom: 5,
133+
},
134+
});
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
/**
2+
* @format
3+
*/
4+
15
import 'react-native';
26
import React from 'react';
3-
import Index from '../index.ios.js';
7+
import App from '../App';
48

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

812
it('renders correctly', () => {
9-
const tree = renderer.create(
10-
<Index />
11-
);
13+
renderer.create(<App />);
1214
});

MOLPayReactExampleProject/__tests__/index.android.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

MOLPayReactExampleProject/android/app/BUCK

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,13 @@
88
# - `buck install -r android/app` - compile, install and run application
99
#
1010

11+
load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")
12+
1113
lib_deps = []
1214

13-
for jarfile in glob(['libs/*.jar']):
14-
name = 'jars__' + jarfile[jarfile.rindex('/') + 1: jarfile.rindex('.jar')]
15-
lib_deps.append(':' + name)
16-
prebuilt_jar(
17-
name = name,
18-
binary_jar = jarfile,
19-
)
15+
create_aar_targets(glob(["libs/*.aar"]))
2016

21-
for aarfile in glob(['libs/*.aar']):
22-
name = 'aars__' + aarfile[aarfile.rindex('/') + 1: aarfile.rindex('.aar')]
23-
lib_deps.append(':' + name)
24-
android_prebuilt_aar(
25-
name = name,
26-
aar = aarfile,
27-
)
17+
create_jar_targets(glob(["libs/*.jar"]))
2818

2919
android_library(
3020
name = "all-libs",
@@ -45,12 +35,12 @@ android_library(
4535

4636
android_build_config(
4737
name = "build_config",
48-
package = "com.molpayreactexampleproject",
38+
package = "com.test0270",
4939
)
5040

5141
android_resource(
5242
name = "res",
53-
package = "com.molpayreactexampleproject",
43+
package = "com.test0270",
5444
res = "src/main/res",
5545
)
5646

MOLPayReactExampleProject/android/app/build.gradle

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ import com.android.build.OutputFile
7272
* ]
7373
*/
7474

75+
project.ext.react = [
76+
entryFile: "index.js"
77+
]
78+
7579
apply from: "../../node_modules/react-native/react.gradle"
7680

7781
/**
@@ -90,25 +94,26 @@ def enableSeparateBuildPerCPUArchitecture = false
9094
def enableProguardInReleaseBuilds = false
9195

9296
android {
93-
compileSdkVersion 27
94-
buildToolsVersion "27.0.0"
97+
compileSdkVersion rootProject.ext.compileSdkVersion
98+
99+
compileOptions {
100+
sourceCompatibility JavaVersion.VERSION_1_8
101+
targetCompatibility JavaVersion.VERSION_1_8
102+
}
95103

96104
defaultConfig {
97-
applicationId "com.molpayreactexampleproject"
98-
minSdkVersion 16
99-
targetSdkVersion 22
105+
applicationId "com.test0270"
106+
minSdkVersion rootProject.ext.minSdkVersion
107+
targetSdkVersion rootProject.ext.targetSdkVersion
100108
versionCode 1
101109
versionName "1.0"
102-
ndk {
103-
abiFilters "armeabi-v7a", "x86"
104-
}
105110
}
106111
splits {
107112
abi {
108113
reset()
109114
enable enableSeparateBuildPerCPUArchitecture
110115
universalApk false // If true, also generate a universal APK
111-
include "armeabi-v7a", "x86"
116+
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
112117
}
113118
}
114119
buildTypes {
@@ -122,7 +127,7 @@ android {
122127
variant.outputs.each { output ->
123128
// For each separate APK per architecture, set a unique version code as described here:
124129
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
125-
def versionCodes = ["armeabi-v7a":1, "x86":2]
130+
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4]
126131
def abi = output.getFilter(OutputFile.ABI)
127132
if (abi != null) { // null for the universal-debug, universal-release variants
128133
output.versionCodeOverride =
@@ -133,10 +138,10 @@ android {
133138
}
134139

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

142147
// Run this once to be able to run the application with BUCK
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""Helper definitions to glob .aar and .jar targets"""
2+
3+
def create_aar_targets(aarfiles):
4+
for aarfile in aarfiles:
5+
name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")]
6+
lib_deps.append(":" + name)
7+
android_prebuilt_aar(
8+
name = name,
9+
aar = aarfile,
10+
)
11+
12+
def create_jar_targets(jarfiles):
13+
for jarfile in jarfiles:
14+
name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")]
15+
lib_deps.append(":" + name)
16+
prebuilt_jar(
17+
name = name,
18+
binary_jar = jarfile,
19+
)

0 commit comments

Comments
 (0)