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

Commit

Permalink
Release v1.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
PatilShreyas committed Jul 15, 2019
1 parent 4978154 commit d731ef5
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 36 deletions.
1 change: 0 additions & 1 deletion EasyUpiPayment/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

}

dependencies {
Expand Down
4 changes: 3 additions & 1 deletion EasyUpiPayment/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
package="com.shreyaspatil.EasyUpiPayment">

<application>
<activity android:name="com.shreyaspatil.EasyUpiPayment.ui.PaymentUiActivity"></activity>
<activity
android:name="com.shreyaspatil.EasyUpiPayment.ui.PaymentUiActivity"
android:theme="@style/Theme.MaterialComponents.Light.NoActionBar" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ private EasyUpiPayment(@NonNull final Activity mActivity, @NonNull Payment mPaym
/**
* Starts the payment Transaction. Calling this method launches the Payment Menu
* and shows installed UPI apps in device and let user choose one of them to pay.
*
*/
public void startPayment() {
Intent payIntent = new Intent(mActivity, PaymentUiActivity.class);
Expand All @@ -44,6 +43,13 @@ public void setPaymentStatusListener(@NonNull PaymentStatusListener mListener) {
singleton.setListener(mListener);
}

/**
* Removes the PaymentStatusListener which is already registered.
*/
public void detachListener() {
Singleton.getInstance().detachListener();
}

/**
* Builder for {@link EasyUpiPayment}.
*/
Expand Down Expand Up @@ -167,7 +173,7 @@ public Builder setDescription(@NonNull String description) {
@NonNull
public Builder setAmount(@NonNull String amount) {
if (!amount.contains(".")) {
throw new IllegalStateException("Amount should be in decimal format XX.XX");
throw new IllegalStateException("Amount should be in decimal format XX.XX (For e.g. 100.00)");
}

payment.setAmount(amount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import com.shreyaspatil.EasyUpiPayment.listener.PaymentStatusListener;


public final class Singleton {
private static Singleton instance = null;

Expand All @@ -19,14 +18,18 @@ public static Singleton getInstance() {

@NonNull
public PaymentStatusListener getListener() {
return listener;
return instance.listener;
}

void setListener(@NonNull PaymentStatusListener listener) {
instance.listener = listener;
}

public void setListener(@NonNull PaymentStatusListener listener) {
this.listener = listener;
public void detachListener() {
instance.listener = null;
}

public boolean isListenerRegistered() {
return (listener != null);
return (instance.listener != null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_upipay);

// Get instance of Singleton class
singleton = Singleton.getInstance();

//Get Payment Information
Expand Down Expand Up @@ -93,21 +94,27 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
if(response == null) {
callbackTransactionCancelled();
Log.d(TAG, "Response is null");
finish();
}

TransactionDetails transactionDetails = getTransactionDetails(response);

//Update Listener onTransactionCompleted()
callbackTransactionComplete(transactionDetails);

//Check if success, submitted or failed
if (transactionDetails.getStatus().toLowerCase().equals("success")) {
callbackTransactionSuccess();
} else if (transactionDetails.getStatus().toLowerCase().equals("submitted")) {
callbackTransactionSubmitted();
} else {
callbackTransactionFailed();

TransactionDetails transactionDetails = getTransactionDetails(response);

//Update Listener onTransactionCompleted()
callbackTransactionComplete(transactionDetails);

//Check if success, submitted or failed
try {
if (transactionDetails.getStatus().toLowerCase().equals("success")) {
callbackTransactionSuccess();
} else if (transactionDetails.getStatus().toLowerCase().equals("submitted")) {
callbackTransactionSubmitted();
} else {
callbackTransactionFailed();
}
} catch (Exception e) {
callbackTransactionCancelled();
callbackTransactionFailed();
}
}
} else {
Log.e(TAG, "Intent Data is null. User cancelled");
Expand Down Expand Up @@ -174,7 +181,4 @@ private void callbackTransactionComplete(TransactionDetails transactionDetails)
singleton.getListener().onTransactionCompleted(transactionDetails);
}
}



}
9 changes: 9 additions & 0 deletions EasyUpiPayment/src/main/res/drawable/ic_close.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z" />
</vector>
15 changes: 9 additions & 6 deletions EasyUpiPayment/src/main/res/layout/apps_bottomsheet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:paddingBottom="8dp">
<TextView
style="@style/TextAppearance.AppCompat.Medium"

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
Expand All @@ -22,14 +23,16 @@
android:textColor="#000"
android:text="@string/text_pay_using" />

<Button
style="@style/Widget.AppCompat.Button.Borderless.Colored"
<ImageButton
android:id="@+id/cancelPaymentButton"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_margin="8dp"
android:text="@string/text_payment_cancel" />
android:layout_marginBottom="8dp"
android:background="@android:color/transparent"
android:src="@drawable/ic_close" />
</RelativeLayout>


Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ In your `build.gradle` file of app module, add below dependency to import this l

```gradle
dependencies {
implementation 'com.shreyaspatil:EasyUpiPayment:1.0'
implementation 'com.shreyaspatil:EasyUpiPayment:1.1'
}
```

Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

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

//implementation project(path: ':EasyUpiPayment')
}
4 changes: 3 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.easyupipayment">

<application
Expand All @@ -8,7 +9,8 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ protected void onCreate(Bundle savedInstanceState) {
//Create instance of EasyUpiPayment
final EasyUpiPayment easyUpiPayment = new EasyUpiPayment.Builder()
.with(this)
.setPayeeVpa("PAYEE_VPA")
.setPayeeVpa("example@vpa")
.setPayeeName("PAYEE_NAME")
.setTransactionId("TRANSACTION_ID")
.setTransactionRefId("TRANSACTION_REF_ID")
.setDescription("DESCRIPTION_OR_SHORT_NOTE")
.setAmount("AMOUNT IN DECIMALS XX.XX IN INR")
.setAmount("AMOUNT IN XX.XX DECIMAL FORMAT")
.build();

//Register Listener for Events
Expand Down

0 comments on commit d731ef5

Please sign in to comment.