implement .env

This commit is contained in:
riz081 2025-08-05 11:03:08 +07:00
parent 6d519d96cf
commit 1c1d580a38
6 changed files with 68 additions and 20 deletions

27
.env.example Normal file
View File

@ -0,0 +1,27 @@
# ==============================================
# QRIS PAYMENT CONFIGURATION - ENVIRONMENT VARIABLES
# ==============================================
# Copy this file to .env and fill in the values
# ==============================================
# Midtrans API Configuration
MIDTRANS_SANDBOX_AUTH=your_midtrans_sandbox_auth_here
MIDTRANS_PRODUCTION_AUTH=your_midtrans_production_auth_here
MIDTRANS_CHARGE_URL=https://api.sandbox.midtrans.com/v2/charge
MIDTRANS_STATUS_BASE_URL=https://api.sandbox.midtrans.com/v2/
MIDTRANS_SIMULATOR_URL=https://simulator.sandbox.midtrans.com/v2/qris/index
# Backend Configuration
BACKEND_BASE_URL=your_backend_base_url_here
WEBHOOK_URL=your_webhook_url_here
# Application Settings
MAX_REFRESH_ATTEMPTS=5
DEFAULT_QR_EXPIRATION_MINUTES=1
# ==============================================
# INSTRUCTIONS:
# 1. Copy this file to .env in the same directory
# 2. Fill in the actual values
# 3. NEVER commit .env to version control!
# ==============================================

2
.gitignore vendored
View File

@ -1,5 +1,7 @@
*.iml
.gradle
.env
*.env
/local.properties
/.idea/caches
/.idea/libraries

View File

@ -42,6 +42,22 @@ android {
jniLibs.srcDirs = ['libs']
}
}
buildFeatures {
buildConfig true // Ini yang mengaktifkan fitur BuildConfig
}
defaultConfig {
// Tambahkan semua buildConfigField yang dibutuhkan
buildConfigField "int", "MAX_REFRESH_ATTEMPTS", "5"
buildConfigField "int", "DEFAULT_QR_EXPIRATION_MINUTES", "1"
buildConfigField "String", "MIDTRANS_SANDBOX_AUTH", "\"Basic U0ItTWlkLXNlcnZlci1PM2t1bXkwVDl4M1VvYnVvVTc3NW5QbXc=\""
buildConfigField "String", "MIDTRANS_PRODUCTION_AUTH", "\"TWlkLXNlcnZlci1sMlZPalotdVlVanpvNnU4VzAtYmF1a2o=\""
buildConfigField "String", "MIDTRANS_CHARGE_URL", "\"https://api.sandbox.midtrans.com/v2/charge\""
buildConfigField "String", "MIDTRANS_STATUS_BASE_URL", "\"https://api.sandbox.midtrans.com/v2/\""
buildConfigField "String", "BACKEND_BASE_URL", "\"https://be-edc.msvc.app\""
buildConfigField "String", "WEBHOOK_URL", "\"https://be-edc.msvc.app/webhooks/midtrans\""
}
}
dependencies {

View File

@ -1,4 +1,5 @@
package com.example.bdkipoc.qris.model;
import com.example.bdkipoc.BuildConfig;
import android.util.Log;
import java.util.HashMap;
@ -46,17 +47,17 @@ public class QrisTransaction {
// Provider expiration mapping
private static final Map<String, Integer> PROVIDER_EXPIRATION_MAP = new HashMap<String, Integer>() {{
put("shopeepay", 1);
put("shopee", 1);
put("airpay shopee", 1);
put("gopay", 1);
put("dana", 1);
put("ovo", 1);
put("linkaja", 1);
put("link aja", 1);
put("jenius", 1);
put("qris", 1);
put("others", 1);
put("shopeepay", BuildConfig.DEFAULT_QR_EXPIRATION_MINUTES);
put("shopee", BuildConfig.DEFAULT_QR_EXPIRATION_MINUTES);
put("airpay shopee", BuildConfig.DEFAULT_QR_EXPIRATION_MINUTES);
put("gopay", BuildConfig.DEFAULT_QR_EXPIRATION_MINUTES);
put("dana", BuildConfig.DEFAULT_QR_EXPIRATION_MINUTES);
put("ovo", BuildConfig.DEFAULT_QR_EXPIRATION_MINUTES);
put("linkaja", BuildConfig.DEFAULT_QR_EXPIRATION_MINUTES);
put("link aja", BuildConfig.DEFAULT_QR_EXPIRATION_MINUTES);
put("jenius", BuildConfig.DEFAULT_QR_EXPIRATION_MINUTES);
put("qris", BuildConfig.DEFAULT_QR_EXPIRATION_MINUTES);
put("others", BuildConfig.DEFAULT_QR_EXPIRATION_MINUTES);
}};
// Provider display name mapping

View File

@ -1,4 +1,5 @@
package com.example.bdkipoc.qris.network;
import com.example.bdkipoc.BuildConfig;
import android.util.Log;
import com.example.bdkipoc.qris.model.QrisRepository;
@ -28,14 +29,14 @@ public class QrisApiService {
private static final String TAG = "QrisApiService";
// API Endpoints
private static final String MIDTRANS_SANDBOX_AUTH = "Basic U0ItTWlkLXNlcnZlci1PM2t1bXkwVDl4M1VvYnVvVTc3NW5QbXc=";
private static final String MIDTRANS_PRODUCTION_AUTH = "TWlkLXNlcnZlci1sMlZPalotdVlVanpvNnU4VzAtYmF1a2o=";
private static final String MIDTRANS_AUTH = MIDTRANS_SANDBOX_AUTH; // Default to sandbox
private static final String MIDTRANS_CHARGE_URL = "https://api.sandbox.midtrans.com/v2/charge";
private static final String MIDTRANS_STATUS_BASE_URL = "https://api.sandbox.midtrans.com/v2/";
private String backendBase = "https://be-edc.msvc.app";
private String webhookUrl = "https://be-edc.msvc.app/webhooks/midtrans";
private static final String MIDTRANS_SANDBOX_AUTH = BuildConfig.MIDTRANS_SANDBOX_AUTH;
private static final String MIDTRANS_PRODUCTION_AUTH = BuildConfig.MIDTRANS_PRODUCTION_AUTH;
private static final String MIDTRANS_AUTH = BuildConfig.MIDTRANS_SANDBOX_AUTH;
private static final String MIDTRANS_CHARGE_URL = BuildConfig.MIDTRANS_CHARGE_URL;
private static final String MIDTRANS_STATUS_BASE_URL = BuildConfig.MIDTRANS_STATUS_BASE_URL;
private String backendBase = BuildConfig.BACKEND_BASE_URL;
private String webhookUrl = BuildConfig.WEBHOOK_URL;
/**
* Generate new QR code via Midtrans API

View File

@ -1,4 +1,5 @@
package com.example.bdkipoc.qris.presenter;
import com.example.bdkipoc.BuildConfig;
import android.os.Handler;
import android.os.Looper;
@ -36,7 +37,7 @@ public class QrisResultPresenter implements QrisResultContract.Presenter {
private boolean isPaymentMonitorActive = false;
private String lastKnownStatus = "pending";
private int refreshCounter = 0;
private static final int MAX_REFRESH_ATTEMPTS = 5;
private static final int MAX_REFRESH_ATTEMPTS = BuildConfig.MAX_REFRESH_ATTEMPTS;
public QrisResultPresenter() {
this.repository = QrisRepository.getInstance();