From 76df1802b1597b3ae435102b3a803c60d8bea336 Mon Sep 17 00:00:00 2001 From: Michael Shafrir Date: Fri, 2 Aug 2019 00:20:57 -0400 Subject: [PATCH] Add Fragment support to payment confirmation/authentication flow - Create `AuthActivityStarter.Host` class that represents an object that has `startActivityForResult` - Updated fragments example to demonstrate starting payment auth flow from a fragment and receiving the result --- example/AndroidManifest.xml | 2 +- example/build.gradle | 2 +- ...ayout.xml => fragments_example_layout.xml} | 2 +- .../launch_payment_session_fragment.xml | 26 ++ example/res/values/strings.xml | 5 +- .../activity/FragmentExampesActivity.java | 317 ++++++++++++++++++ .../example/activity/LauncherActivity.java | 4 +- .../PaymentSessionFromFragmentActivity.java | 164 --------- .../android/PaymentAuthWebViewStarter.java | 25 +- .../com/stripe/android/PaymentController.java | 121 ++++--- .../stripe/android/PaymentRelayStarter.java | 19 +- .../main/java/com/stripe/android/Stripe.java | 134 +++++++- .../android/Stripe3ds2CompletionStarter.java | 26 +- .../android/view/AuthActivityStarter.java | 54 +++ .../PaymentAuthWebViewStarterTest.java | 8 +- .../stripe/android/PaymentControllerTest.java | 32 +- .../android/PaymentRelayStarterTest.java | 4 +- .../Stripe3ds2CompletionStarterTest.java | 4 +- .../stripe/android/StripePaymentAuthTest.java | 27 +- 19 files changed, 665 insertions(+), 311 deletions(-) rename example/res/layout/{payment_session_from_fragment_layout.xml => fragments_example_layout.xml} (100%) create mode 100644 example/src/main/java/com/stripe/example/activity/FragmentExampesActivity.java delete mode 100644 example/src/main/java/com/stripe/example/activity/PaymentSessionFromFragmentActivity.java diff --git a/example/AndroidManifest.xml b/example/AndroidManifest.xml index 27a56cd534e..504172e2445 100644 --- a/example/AndroidManifest.xml +++ b/example/AndroidManifest.xml @@ -97,7 +97,7 @@ android:name=".activity.PaymentAuthActivity" /> + android:name=".activity.FragmentExampesActivity" /> diff --git a/example/build.gradle b/example/build.gradle index a44deee3802..4c5d1ad791a 100644 --- a/example/build.gradle +++ b/example/build.gradle @@ -65,7 +65,7 @@ android { buildTypes { debug { - minifyEnabled true + minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } release { diff --git a/example/res/layout/payment_session_from_fragment_layout.xml b/example/res/layout/fragments_example_layout.xml similarity index 100% rename from example/res/layout/payment_session_from_fragment_layout.xml rename to example/res/layout/fragments_example_layout.xml index 11cc4d62dc5..55e21ba1c4f 100644 --- a/example/res/layout/payment_session_from_fragment_layout.xml +++ b/example/res/layout/fragments_example_layout.xml @@ -1,4 +1,5 @@ + - \ No newline at end of file diff --git a/example/res/layout/launch_payment_session_fragment.xml b/example/res/layout/launch_payment_session_fragment.xml index 43314fb4f6a..3aeac8315f8 100644 --- a/example/res/layout/launch_payment_session_fragment.xml +++ b/example/res/layout/launch_payment_session_fragment.xml @@ -9,6 +9,15 @@ android:orientation="vertical" android:id="@+id/root"> + +