Skip to content

Commit

Permalink
chore: embed ipay88 SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
semirp committed Mar 22, 2024
1 parent 8f6ce6f commit e0489ef
Show file tree
Hide file tree
Showing 27 changed files with 2,112 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ build-and-publish:
- if: $CI_COMMIT_TAG
artifacts:
paths:
- ipay88/build/outputs/aar/
- ipay88/build/outputs/
when: manual
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ SONATYPE_HOST=S01
RELEASE_SIGNING_ENABLED=true

android.defaults.buildfeatures.buildconfig=true
android.nonFinalResIds=false
android.nonFinalResIds=false
8 changes: 6 additions & 2 deletions ipay88/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {

android {
namespace 'io.primer.ipay88'
compileSdkVersion 34
compileSdk 34

defaultConfig {
minSdkVersion 21
Expand Down Expand Up @@ -36,11 +36,15 @@ android {
buildTypes.each {
it.buildConfigField 'String', 'SDK_VERSION_STRING', "\"$VERSION_NAME\""
}

packagingOptions {
resources.excludes.add("META-INF/*")
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation libs.android.appcompat
}

apply from: "$rootDir/config/publish.gradle"
apply from: "$rootDir/config/publish.gradle"
Binary file removed ipay88/libs/classes.jar
Binary file not shown.
Binary file added ipay88/libs/httpclient-4.5.jar
Binary file not shown.
Binary file added ipay88/libs/httpcore-4.4.1.jar
Binary file not shown.
17 changes: 12 additions & 5 deletions ipay88/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,15 @@
java.lang.Object readResolve();
}

-dontwarn com.androids.ipay.R$drawable
-dontwarn com.androids.ipay.R$id
-dontwarn com.androids.ipay.R$layout
-dontwarn com.androids.ipay.R$string

-dontwarn javax.naming.InvalidNameException
-dontwarn javax.naming.NamingException
-dontwarn javax.naming.directory.Attribute
-dontwarn javax.naming.directory.Attributes
-dontwarn javax.naming.ldap.LdapName
-dontwarn javax.naming.ldap.Rdn
-dontwarn org.ietf.jgss.GSSContext
-dontwarn org.ietf.jgss.GSSCredential
-dontwarn org.ietf.jgss.GSSException
-dontwarn org.ietf.jgss.GSSManager
-dontwarn org.ietf.jgss.GSSName
-dontwarn org.ietf.jgss.Oid
110 changes: 110 additions & 0 deletions ipay88/src/main/java/com/ipay/DESProcessor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package com.ipay;

import java.security.NoSuchAlgorithmException;
import javax.crypto.Cipher;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;

public class DESProcessor {
private String iv = "";
private IvParameterSpec ivspec;
private SecretKeySpec keyspec;
private Cipher cipher;
private String SecretKey = "";

public DESProcessor() {
this.ivspec = new IvParameterSpec(this.iv.getBytes());
this.keyspec = new SecretKeySpec(this.SecretKey.getBytes(), "AES");

try {
this.cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
} catch (NoSuchAlgorithmException var2) {
var2.printStackTrace();
} catch (NoSuchPaddingException var3) {
var3.printStackTrace();
}

}

public byte[] encrypt(String text) throws Exception {
if (text != null && text.length() != 0) {
Object var2 = null;

try {
this.cipher.init(1, this.keyspec, this.ivspec);
byte[] encrypted = this.cipher.doFinal(padString(text).getBytes());
return encrypted;
} catch (Exception var4) {
throw new Exception("[encrypt] " + var4.getMessage());
}
} else {
throw new Exception("Empty string");
}
}

public byte[] decrypt(String code) throws Exception {
if (code != null && code.length() != 0) {
Object var2 = null;

try {
this.cipher.init(2, this.keyspec, this.ivspec);
byte[] decrypted = this.cipher.doFinal(hexToBytes(code));
return decrypted;
} catch (Exception var4) {
throw new Exception("[decrypt] " + var4.getMessage());
}
} else {
throw new Exception("Empty string");
}
}

public static String bytesToHex(byte[] data) {
if (data == null) {
return null;
} else {
int len = data.length;
String str = "";

for(int i = 0; i < len; ++i) {
if ((data[i] & 255) < 16) {
str = str + "0" + Integer.toHexString(data[i] & 255);
} else {
str = str + Integer.toHexString(data[i] & 255);
}
}

return str;
}
}

public static byte[] hexToBytes(String str) {
if (str == null) {
return null;
} else if (str.length() < 2) {
return null;
} else {
int len = str.length() / 2;
byte[] buffer = new byte[len];

for(int i = 0; i < len; ++i) {
buffer[i] = (byte)Integer.parseInt(str.substring(i * 2, i * 2 + 2), 16);
}

return buffer;
}
}

private static String padString(String source) {
char paddingChar = ' ';
int size = 16;
int x = source.length() % size;
int padLength = size - x;

for(int i = 0; i < padLength; ++i) {
source = source + paddingChar;
}

return source;
}
}
37 changes: 37 additions & 0 deletions ipay88/src/main/java/com/ipay/IPayIH.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.ipay;

import android.content.Context;
import android.content.Intent;
import java.io.Serializable;

public final class IPayIH {
public static IPayIH _IPayIH;
public static final int PAY_METHOD_CREDIT_CARD = 0;
public static final int ENV_PRODUCTION = 1;
public static final int ENV_DVL3 = 2;
public static final int ENV_SANDBOX = 3;

public static IPayIH getInstance() {
IPayIHActivity._IPayIH = new IPayIH();
return IPayIHActivity._IPayIH;
}

public final Intent checkout(IPayIHPayment IPayIHPayment, Context paramContext, IPayIHResultDelegate paramPayPalResultDelegate, int iPayMethod) {
Intent paramContext2 = (new Intent(paramContext, IPayIHActivity.class)).putExtra("com.ipay.android.IPAY_PAYMENT", IPayIHPayment);
paramContext2.putExtra("com.paypal.android.RESULT_DELEGATE", (Serializable)paramPayPalResultDelegate);
paramContext2.putExtra("com.ipay.android.IPAY_METHOD", iPayMethod);
return paramContext2;
}

public final Intent requery(IPayIHR r, Context paramContext, IPayIHResultDelegate paramPayPalResultDelegate) {
Intent paramContext2 = (new Intent(paramContext, IPayIHAcitivityR.class)).putExtra("rrr", r);
paramContext2.putExtra("com.paypal.android.RESULT_DELEGATE", (Serializable)paramPayPalResultDelegate);
return paramContext2;
}

public final Intent selectPaymentMethod(IPayIHPayment IPayIHPayment, Context paramContext, IPayIHResultDelegate paramPayPalResultDelegate) {
Intent paramContext2 = (new Intent(paramContext, IPayIHSelectionActivity.class)).putExtra("com.ipay.android.IPAY_PAYMENT", IPayIHPayment);
paramContext2.putExtra("com.paypal.android.RESULT_DELEGATE", (Serializable)paramPayPalResultDelegate);
return paramContext2;
}
}
72 changes: 72 additions & 0 deletions ipay88/src/main/java/com/ipay/IPayIHAcitivityR.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.ipay;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.StrictMode;
import android.os.Build.VERSION;
import android.os.StrictMode.ThreadPolicy;
import android.os.StrictMode.ThreadPolicy.Builder;
import android.util.Log;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;

public class IPayIHAcitivityR extends Activity {
public static IPayIH _IPayIH;
private IPayIHResultDelegate ipayResult;

protected final void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
IPayIHR ipaypayment = (IPayIHR)this.getIntent().getSerializableExtra("rrr");
if (ipaypayment != null) {
HttpPost postMethod = new HttpPost("https://payment.ipay88.com.my/ePayment/enquiry.asp");

try {
if (VERSION.SDK_INT > 9) {
ThreadPolicy policy = (new Builder()).permitAll().build();
StrictMode.setThreadPolicy(policy);
}

String local_MerchantCode = ipaypayment.getMerchantCode();
String local_RefID = ipaypayment.getRefNo();
String local_Amount = ipaypayment.getAmount();
List<NameValuePair> nameValuePairs = new ArrayList(3);
nameValuePairs.add(new BasicNameValuePair("MerchantCode", local_MerchantCode));
nameValuePairs.add(new BasicNameValuePair("RefNo", local_RefID));
nameValuePairs.add(new BasicNameValuePair("Amount", local_Amount));
postMethod.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpClient client = new DefaultHttpClient();
HttpResponse response = client.execute(postMethod);
String pcm_response = EntityUtils.toString(response.getEntity());
pcm_response = pcm_response.trim();
Log.i("sss333", pcm_response);
this.setStatus(local_MerchantCode, local_RefID, local_Amount, pcm_response);
} catch (Exception var11) {
var11.printStackTrace();
}
}

}

public void setStatus(String MerchantCode, String RefNo, String Amount, String Result) {
Intent data = new Intent();
data.putExtra("SOMETHING", "EXTRAS");
this.ipayResult = (IPayIHResultDelegate)this.getIntent().getSerializableExtra("com.paypal.android.RESULT_DELEGATE");
this.ipayResult.onRequeryResult(MerchantCode, RefNo, Amount, Result);
if (this.getParent() == null) {
this.setResult(-1, data);
} else {
this.getParent().setResult(-1, data);
}

this.finish();
}
}
Loading

0 comments on commit e0489ef

Please sign in to comment.