Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.34.2 #13

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,5 @@ molpayxdk/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin
.gradle/checksums/sha1-checksums.bin
.idea/compiler.xml
.idea/gradle.xml
.gradle/config.properties
molpayxdk/build/
19 changes: 13 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 32
compileSdk 34

defaultConfig {
applicationId "com.molpay.molpayxdkproject"
minSdkVersion 16
targetSdkVersion 32
minSdkVersion 21
targetSdkVersion 34
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
namespace 'com.molpay.molpayxdkproject'

viewBinding {
enabled = true
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'com.google.android.gms:play-services-wallet:19.3.0'
testImplementation 'junit:junit:4.13.2'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.12.0'
implementation project(':molpayxdk')
}

This file was deleted.

5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
</activity>
<activity android:name="com.molpay.molpayxdk.MOLPayActivity"
android:label=""/>

<!-- Enabling this flag is required in order to use the PaymentsClient -->
<meta-data
android:name="com.google.android.gms.wallet.api.enabled"
android:value="true" />
</application>

</manifest>
89 changes: 71 additions & 18 deletions app/src/main/java/com/molpay/molpayxdkproject/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,27 @@
import android.view.MenuItem;
import android.widget.TextView;

import com.google.android.gms.wallet.button.ButtonConstants;
import com.google.android.gms.wallet.button.ButtonOptions;
import com.google.android.gms.wallet.button.PayButton;
import com.molpay.molpayxdk.MOLPayActivity;
import com.molpay.molpayxdk.googlepay.ActivityGP;
import com.molpay.molpayxdk.googlepay.UtilGP;

import org.json.JSONException;

import java.util.Calendar;
import java.util.HashMap;

public class MainActivity extends AppCompatActivity {

private PayButton googlePayButton;

private void restartmolpay() {
HashMap<String, Object> paymentDetails = new HashMap<>();
paymentDetails.put(MOLPayActivity.mp_amount, "1.10");

// TODO: Enter your merchant account credentials before test run
paymentDetails.put(MOLPayActivity.mp_username, "");
paymentDetails.put(MOLPayActivity.mp_password, "");
paymentDetails.put(MOLPayActivity.mp_merchant_ID, "");
Expand All @@ -33,24 +43,58 @@ private void restartmolpay() {
paymentDetails.put(MOLPayActivity.mp_bill_description, "bill description");
paymentDetails.put(MOLPayActivity.mp_bill_name, "bill name");
paymentDetails.put(MOLPayActivity.mp_bill_email, "[email protected]");
paymentDetails.put(MOLPayActivity.mp_bill_mobile, "01234567888");
paymentDetails.put(MOLPayActivity.mp_channel_editing, false);
paymentDetails.put(MOLPayActivity.mp_editing_enabled, true);
paymentDetails.put(MOLPayActivity.mp_express_mode, false);
paymentDetails.put(MOLPayActivity.mp_dev_mode, false);
paymentDetails.put(MOLPayActivity.mp_preferred_token, "new");
paymentDetails.put(MOLPayActivity.mp_bill_mobile, "123456789");

// TODO: Learn more about optional parameters here https://github.com/RazerMS/Mobile-XDK-RazerMS_Android_Studio/wiki/Installation-Guidance#prepare-the-payment-detail-object
// paymentDetails.put(MOLPayActivity.mp_channel_editing, false);
// paymentDetails.put(MOLPayActivity.mp_editing_enabled, true);
// paymentDetails.put(MOLPayActivity.mp_express_mode, false);
// paymentDetails.put(MOLPayActivity.mp_dev_mode, false);
// paymentDetails.put(MOLPayActivity.mp_preferred_token, "new");

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

private void googlePayPayment() {
HashMap<String, Object> paymentDetails = new HashMap<>();

/*
TODO: Follow Google’s instructions to request production access for your app: https://developers.google.com/pay/api/android/guides/test-and-deploy/request-prod-access
*
Choose the integration type Gateway when prompted, and provide screenshots of your app for review.
After your app has been approved, test your integration in production by set mp_sandbox_mode = false & use production mp_verification_key & mp_merchant_ID.
Then launching Google Pay from a signed, release build of your app.
*/
paymentDetails.put(MOLPayActivity.mp_sandbox_mode, true); // Only set to false once you have request production access for your app

// TODO: Enter your merchant account credentials before test run
paymentDetails.put(MOLPayActivity.mp_merchant_ID, ""); // Your sandbox / production merchant ID
paymentDetails.put(MOLPayActivity.mp_verification_key, ""); // Your sandbox / production verification key

paymentDetails.put(MOLPayActivity.mp_amount, "1.11"); // Must be in 2 decimal points format
paymentDetails.put(MOLPayActivity.mp_order_ID, Calendar.getInstance().getTimeInMillis()); // Must be unique
paymentDetails.put(MOLPayActivity.mp_currency, "MYR"); // Must matched mp_country
paymentDetails.put(MOLPayActivity.mp_country, "MY"); // Must matched mp_currency
paymentDetails.put(MOLPayActivity.mp_bill_description, "The bill description");
paymentDetails.put(MOLPayActivity.mp_bill_name, "The bill name");
paymentDetails.put(MOLPayActivity.mp_bill_email, "[email protected]");
paymentDetails.put(MOLPayActivity.mp_bill_mobile, "123456789");

Intent intent = new Intent(MainActivity.this, ActivityGP.class); // Used ActivityGP for Google Pay
intent.putExtra(MOLPayActivity.MOLPayPaymentDetails, paymentDetails);
startActivityForResult(intent, MOLPayActivity.MOLPayXDK);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);

Log.e("logGooglePay" , "onActivityResult requestCode = " + requestCode);
Log.e("logGooglePay" , "onActivityResult resultCode = " + resultCode);

if (requestCode == MOLPayActivity.MOLPayXDK && resultCode == RESULT_OK){
Log.d(MOLPayActivity.MOLPAY, "MOLPay result = "+data.getStringExtra(MOLPayActivity.MOLPayTransactionResult));
TextView tw = (TextView)findViewById(R.id.resultTV);
Expand All @@ -65,18 +109,27 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
}

// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// int id = item.getItemId();
//
// if (id == R.id.action_settings) {
// return true;
// }
//
// return super.onOptionsItemSelected(item);
// }
// The Google Pay button is a layout file – take the root view
googlePayButton = findViewById(R.id.googlePayButton);

try {
// TODO: Choose your preferred Google Pay button : https://developers.google.com/pay/api/android/guides/brand-guidelines
googlePayButton.initialize(
ButtonOptions.newBuilder()
.setButtonTheme(ButtonConstants.ButtonTheme.DARK)
.setButtonType(ButtonConstants.ButtonType.PAY)
.setCornerRadius(99)
.setAllowedPaymentMethods(UtilGP.getAllowedPaymentMethods().toString())
.build()
);
googlePayButton.setOnClickListener(view -> {
googlePayPayment();
});
} catch (JSONException e) {
// Keep Google Pay button hidden (consider logging this to your app analytics service)
}
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
Expand All @@ -89,7 +142,7 @@ public boolean onCreateOptionsMenu(Menu menu) {
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();

// closebtn clicked
// START clicked
if (id == R.id.newBtn) {
restartmolpay();
}
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay">
android:background="#0038a3"
app:titleTextColor="@color/white"
app:subtitleTextColor="@color/white">
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>

Expand Down
10 changes: 9 additions & 1 deletion app/src/main/res/layout/content_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,13 @@
android:id="@+id/resultTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
android:text="Tap Google Pay button or START for other payments" />

<com.google.android.gms.wallet.button.PayButton
android:id="@+id/googlePayButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="19dp" />

</RelativeLayout>
5 changes: 0 additions & 5 deletions app/src/main/res/menu/menu_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.molpay.molpayxdkproject.MainActivity">
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:title="@string/action_settings"
app:showAsAction="never" />
<item
android:id="@+id/newBtn"
android:orderInCategory="200"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="white">#FFFFFF</color>
</resources>
3 changes: 1 addition & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<resources>
<string name="app_name">RazerMSXDKProject</string>
<string name="action_settings">Settings</string>
<string name="app_name">Fiuu XDK Android</string>
<string name="restart">Start</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:actionMenuTextColor">#00d600</item>
</style>

<style name="AppTheme.NoActionBar">
Expand Down
33 changes: 22 additions & 11 deletions molpayxdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ plugins {
}

android {
compileSdkVersion 31
compileSdk 34
defaultConfig {
minSdkVersion 16
targetSdkVersion 31
versionCode 1
versionName "1.0"
minSdkVersion 21
targetSdkVersion 34
}
buildTypes {
release {
Expand All @@ -21,24 +19,37 @@ android {
sourceCompatibility(JavaVersion.VERSION_1_8)
targetCompatibility(JavaVersion.VERSION_1_8)
}

viewBinding {
enabled = true
}
}

dependencies {
testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13.2'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.12.0'
// implementation 'androidx.multidex:multidex:2.0.1'

// Google Pay
implementation 'com.google.zxing:core:3.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation "androidx.lifecycle:lifecycle-viewmodel:2.7.0"
implementation "com.google.android.gms:play-services-pay:16.4.0"
implementation "com.google.android.gms:play-services-wallet:19.3.0"
implementation 'org.apache.commons:commons-lang3:3.4'
}

afterEvaluate {
publishing {
publications {
release(MavenPublication) {
from components.release
groupId ='com.rms.mobile'
artifactId = 'mobile_xdk'
version = '3.33.9'
groupId ='com.github.FiuuPayment'
artifactId = 'Mobile-XDK-Fiuu_Android_Library'
version = '3.34.1'
}
}
}
Expand Down

This file was deleted.

10 changes: 10 additions & 0 deletions molpayxdk/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
<application>
<activity android:name=".MOLPayActivity"
android:configChanges="orientation|screenSize" />
<activity android:name=".googlepay.ActivityGP"
android:configChanges="orientation|screenSize" />
<activity
android:name=".googlepay.WebActivity"
android:exported="false" />

<!-- Enabling this flag is required in order to use the PaymentsClient -->
<meta-data
android:name="com.google.android.gms.wallet.api.enabled"
android:value="true" />
</application>

</manifest>
Loading