affirm / affirm-merchant-sdk-android Goto Github PK
View Code? Open in Web Editor NEWIntegrate Affirm into your Android app
License: BSD 3-Clause "New" or "Revised" License
Integrate Affirm into your Android app
License: BSD 3-Clause "New" or "Revised" License
JIRA ticket created.
Add a parameter to turn on HTML styling in ala button text rendering.
As the price amount (and other amounts shipping and tax) in all functions is not in cents, due to that prequal screen is showing incorrect amount. Though it shows correct amount in ala message but internally when processed for prequal it takes 500 as $5 amount (screenshot attached). Affirm api and prequal docs all provides guideline to use amount in USD cents (e.g., $100 = 10000) so I think it will be good to keep that consistent in SDK also. https://docs.affirm.com/Integrate_Affirm/Monthly_Payment_Messaging
okhttp3
is currently at 4.9.0 but this SDK points to 3.14.1 from April 2019. This version of OKHttp doesn't work on Android API 30.
(This is of course easy to work around in apps by declaring our own okhttp dependency.)
It may be necessary for a merchant to clear the cookies, please provide a method to do so
It would be great to allow
Affirm.startCheckout(fragment: androidx.fragment.app.Fragment, checkout: Checkout, useVCN: Boolean)
As it is, the result is can only be dispatched back to the Activity instead of the initiating Fragment.
Hello, can this SDK be used for Java or Scala server? Is there any limitations?
Fatal Exception: java.lang.AssertionError: java.lang.NoSuchFieldException: CAD
at com.google.gson.internal.bind.TypeAdapters$EnumTypeAdapter.(TypeAdapters.java:792)
at com.google.gson.internal.bind.TypeAdapters$30.create(TypeAdapters.java:818)
at com.google.gson.Gson.getAdapter(Gson.java:458)
at com.google.gson.Gson.getAdapter(Gson.java:556)
at com.affirm.android.model.$AutoValue_Checkout$GsonTypeAdapter.(.java:47)
at com.affirm.android.model.Checkout.typeAdapter(Checkout.java:24)
at com.affirm.android.model.AutoValueGson_AffirmAdapterFactory.create(AutoValueGson_AffirmAdapterFactory.java:39)
at com.google.gson.Gson.getAdapter(Gson.java:458)
at com.google.gson.Gson.toJson(Gson.java:696)
at com.google.gson.Gson.toJson(Gson.java:683)
at com.google.gson.Gson.toJson(Gson.java:638)
at com.google.gson.Gson.toJson(Gson.java:618)
at com.affirm.android.CheckoutRequest.parseToJsonObject(CheckoutRequest.java:187)
at com.affirm.android.CheckoutRequest.create(CheckoutRequest.java:93)
at com.affirm.android.CheckoutBaseActivity.onAttached(CheckoutBaseActivity.java:49)
at com.affirm.android.AffirmActivity.onCreate(AffirmActivity.java:39)
at android.app.Activity.performCreate(Activity.java:7955)
at android.app.Activity.performCreate(Activity.java:7944)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3423)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3595)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2147)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7811)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1076)
Fatal Exception: java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType
at com.affirm.android.AffirmClient$1.onResponse(AffirmClient.java:86)
at com.google.firebase.perf.network.InstrumentOkHttpEnqueueCallback.onResponse(InstrumentOkHttpEnqueueCallback.java:71)
at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
at java.lang.Thread.run(Thread.java:1012)
This seems similar to: square/retrofit#3751
I can't tell if you're using Retrofit, but considering your last release was in early 2022 I would guess you also need to make changes to support R8
{ "status_code": 400, "message": "Please contact the merchant to complete your purchase.", "code": "inactive-merchant", "type": "invalid_request", "field": "merchant" }
Please see the following examples:
affirmPromotionButton1.configWithLocalStyling( AffirmColor.AFFIRM_COLOR_TYPE_BLUE, AffirmLogoType.AFFIRM_DISPLAY_TYPE_TEXT, ResourcesCompat.getFont(this, R.font.atlantic_time), android.R.color.darker_gray, R.dimen.affirm_promotion_size);
affirmPromotionButton1.configWithLocalStyling( AffirmColor.AFFIRM_COLOR_TYPE_BLUE, AffirmLogoType.AFFIRM_DISPLAY_TYPE_TEXT);
We have been recently seeing crashes while fetching affirm Promotion text. The scenario occurs when affirm outages happen.
Fatal Exception: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
at com.google.gson.Gson.fromJson(Gson.java:939)
at com.google.gson.Gson.fromJson(Gson.java:865)
at com.affirm.android.AffirmHttpClient.createExceptionAndTrackFromResponse(AffirmHttpClient.java:105)
at com.affirm.android.PromoRequest$1.onResponse(PromoRequest.java:134)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:174)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Affirm SDK Version 2.0.11
Android OS: 9
It would be great if there is way to throw the exception out by some manner so the client applications can handle it. At this point, client applications can't handle the exception as it doesn't occur in the layer where the PromotionRequest is triggered, wrapping a try catch is not helping.
Dear Affirm Support Team,
I am writing to report an issue we have encountered with the Affirm SDK in our application. Below are the details of the issue:
OS Version:
Device Information:
UI Steps to Reproduce the Issue:
Complete Error Trace / Stack:
Fatal Exception: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at androidx.fragment.app.FragmentManager.checkStateLoss(FragmentManager.java:1610)
at androidx.fragment.app.FragmentManager.enqueueAction(FragmentManager.java:1650)
at androidx.fragment.app.BackStackRecord.commitInternal(BackStackRecord.java:341)
at androidx.fragment.app.BackStackRecord.commit(BackStackRecord.java:306)
at com.affirm.android.AffirmFragment.removeFragment(AffirmFragment.java:42)
at com.affirm.android.CheckoutFragment.onWebViewError(CheckoutFragment.java:127)
at com.affirm.android.AffirmWebViewClient.onRenderProcessGone(AffirmWebViewClient.java:71)
at org.chromium.android_webview.AwContents.onRenderProcessGone(chromium-TrichromeWebViewGoogle.aab-stable-636712330:49)
at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
at android.os.MessageQueue.next(MessageQueue.java:335)
at android.os.Looper.loop(Looper.java:183)
at android.app.ActivityThread.main(ActivityThread.java:7723)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:997)
We would appreciate your assistance in resolving this matter as soon as possible. If you require any additional information or further details, please do not hesitate to contact us.
Thank you for your support.
Creation of Checkout class indicates that MetaData is a Nullable item, but while calling Affirm.startCheckout with this it crashes expecting MetaData to be NonNull.
This started happening when we upgraded from 2.0.6
to 2.0.10
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.gson.JsonObject.addProperty(java.lang.String, java.lang.String)' on a null object reference
at com.affirm.android.CheckoutRequest.create(CheckoutRequest.java:99)
at com.affirm.android.CheckoutBaseActivity.onAttached(CheckoutBaseActivity.java:49)
at com.affirm.android.AffirmActivity.onCreate(AffirmActivity.java:39)
at android.app.Activity.performCreate(Activity.java:7815)
at android.app.Activity.performCreate(Activity.java:7804)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1318)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3349)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3513)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2109)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7682)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
Device: Pixel 3
OS: 9
SDK Version: 2.0.10
This appears to still be an issue, please email me: [email protected] if you need a public API key to reproduce this.
Hi, we run this SDK in production. We've recently faced with many crashes in our app's checkout page because of this issue, please find the stacktrace below:
com.affirm.android.CheckoutRequest in <init> at line 51
com.affirm.android.CheckoutRequest in <init> at line 56
com.affirm.android.CheckoutBaseActivity in onAttached at line 59
com.affirm.android.AffirmActivity in onCreate at line 52
android.app.Activity in performCreate at line 8041
android.app.Activity in performCreate at line 8030
android.app.Instrumentation in callActivityOnCreate at line 1307
android.app.ActivityThread in performLaunchActivity at line 3246
android.app.ActivityThread in handleLaunchActivity at line 3410
android.app.servertransaction.LaunchActivityItem in execute at line 83
android.app.servertransaction.TransactionExecutor in executeCallbacks at line 135
android.app.servertransaction.TransactionExecutor in execute at line 95
android.app.ActivityThread$H in handleMessage at line 2017
android.os.Handler in dispatchMessage at line 107
android.os.Looper in loop at line 214
android.app.ActivityThread in main at line 7397
java.lang.reflect.Method in invoke
com.android.internal.os.RuntimeInit$MethodAndArgsCaller in run at line 492
com.android.internal.os.ZygoteInit in main at line 935
For some reason the SDK is unable to locate gson. We also have an indirect dependency to gson, maybe that's causing the issue?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.