Skip to content
This repository has been archived by the owner on Nov 11, 2023. It is now read-only.

Commit

Permalink
Release v2.0
Browse files Browse the repository at this point in the history
Release v2.0
  • Loading branch information
PatilShreyas authored Dec 9, 2019
2 parents 2ed3b6e + 1384564 commit 78ab930
Show file tree
Hide file tree
Showing 12 changed files with 424 additions and 74 deletions.
116 changes: 116 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions EasyUpiPayment/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: "com.jfrog.bintray"

version = "1.1"
version = "2.0"

android {
compileSdkVersion 29
Expand All @@ -26,9 +26,9 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.annotation:annotation:1.1.0'

Expand Down Expand Up @@ -140,7 +140,7 @@ bintray {
pkg {
repo = "maven"
// it is the name that appears in bintray when logged
name = "com.shreyaspatil:EasyUpiPayment" // TODO
name = "com.shreyaspatil:EasyUpiPayment"
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = ["Apache-2.0"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ public interface PaymentStatusListener {
void onTransactionSubmitted();
void onTransactionFailed();
void onTransactionCancelled();

void onAppNotFound();
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class Payment implements Serializable {
private String txnRefId;
private String description;
private String amount;
private String defaultPackage;
private final String currency = "INR";

public String getVpa() {
Expand Down Expand Up @@ -71,4 +72,12 @@ public void setAmount(String amount) {
public String getCurrency() {
return currency;
}

public String getDefaultPackage() {
return defaultPackage;
}

public void setDefaultPackage(String defaultPackage) {
this.defaultPackage = defaultPackage;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.shreyaspatil.EasyUpiPayment.model;

public enum PaymentApp {
NONE(""),
AMAZON_PAY(Package.AMAZON_PAY),
BHIM_UPI(Package.BHIM_UPI),
GOOGLE_PAY(Package.GOOGLE_PAY),
PAYTM(Package.PAYTM),
PHONE_PE(Package.PHONE_PE);

private String mPackageName;

PaymentApp(String mPackageName) {
this.mPackageName = mPackageName;
}

public String getPackageName() {
return mPackageName;
}

private static final class Package {
static final String AMAZON_PAY = "in.amazon.mShop.android.shopping";
static final String BHIM_UPI = "in.org.npci.upiapp";
static final String GOOGLE_PAY = "com.google.android.apps.nbu.paisa.user";
static final String PHONE_PE = "com.phonepe.app";
static final String PAYTM = "net.one97.paytm";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import java.util.List;
import java.util.Map;

import static com.shreyaspatil.EasyUpiPayment.EasyUpiPayment.APP_NOT_FOUND;

public final class PaymentUiActivity extends AppCompatActivity {
private static final String TAG = "PaymentUiActivity";
public static final int PAYMENT_REQUEST = 4400;
Expand Down Expand Up @@ -60,12 +62,21 @@ protected void onCreate(Bundle savedInstanceState) {
Intent paymentIntent = new Intent(Intent.ACTION_VIEW);
paymentIntent.setData(uri);

// Check if app is installed or not
// Check for Default package
if (payment.getDefaultPackage() != null) {
paymentIntent.setPackage(payment.getDefaultPackage());
//startActivityForResult(intent, PAYMENT_REQUEST);
}

// Check if other UPI apps are exists or not.
if(paymentIntent.resolveActivity(getPackageManager()) != null) {
List<ResolveInfo> intentList = getPackageManager().queryIntentActivities(paymentIntent, 0);
List<ResolveInfo> intentList = getPackageManager()
.queryIntentActivities(paymentIntent, 0);
showApps(intentList, paymentIntent);
} else {
Toast.makeText(this,"No UPI app found! Please Install to Proceed!", Toast.LENGTH_SHORT).show();
Toast.makeText(this, "No UPI app found! Please Install to Proceed!",
Toast.LENGTH_SHORT).show();
callbackOnAppNotFound();
}
}

Expand All @@ -88,7 +99,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == PAYMENT_REQUEST) {
if (data != null) {
//Get Response from activity intent
// Get Response from activity intent
String response = data.getStringExtra("response");

if(response == null) {
Expand Down Expand Up @@ -135,7 +146,7 @@ private Map<String, String> getQueryString(String url) {
return map;
}

//Make TransactionDetails object from response string
// Make TransactionDetails object from response string
private TransactionDetails getTransactionDetails(String response) {
Map<String, String> map = getQueryString(response);

Expand All @@ -145,13 +156,29 @@ private TransactionDetails getTransactionDetails(String response) {
String status = map.get("Status");
String transactionRefId = map.get("txnRef");

return new TransactionDetails(transactionId, responseCode, approvalRefNo, status, transactionRefId);
return new TransactionDetails(
transactionId,
responseCode,
approvalRefNo,
status,
transactionRefId
);
}

// Checks whether listener is registered
private boolean isListenerRegistered() {
return (Singleton.getInstance().isListenerRegistered());
}

private void callbackOnAppNotFound() {
Log.e(APP_NOT_FOUND, "No UPI app found on device.");

if (isListenerRegistered()) {
singleton.getListener().onAppNotFound();
}
finish();
}

private void callbackTransactionSuccess() {
if (isListenerRegistered()) {
singleton.getListener().onTransactionSuccess();
Expand Down
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

//EasyUpiPayment Library
implementation 'com.shreyaspatil:EasyUpiPayment:1.1'
// EasyUpiPayment Library
implementation 'com.shreyaspatil:EasyUpiPayment:2.0'

//implementation project(path: ':EasyUpiPayment')
}
Loading

0 comments on commit 78ab930

Please sign in to comment.