Upgrade to Android SDK 1.0.0
In a nutshell
Upgrade from 0.0.x or 0.1.x by updating the dependency, compiling against API level 37, and passing the Paystack object to launch.
Update the dependency
Change the paystack-ui version in the dependencies block of your app-level build file:
- build.gradle
1dependencies {2 implementation 'com.paystack.android:paystack-ui:1.0.0'3}
paystack-ui includes paystack-core, so you don't need to add it separately.
Compile against API level 37
The SDK requires your app to compile against Android API level 37. Set compileSdk = 37 in your app-level build file. Your minSdk can stay at 23 or higher.
Pass the Paystack object to launch
What you change depends on the version you're upgrading from:
- 0.1.5 and earlier:
build()stored your configuration globally, andlaunchtook only the access code. - 0.1.6: the
PaymentSheetconstructor took thePaystackobject, andlaunchtook only the access code. - 0.1.7 and 0.1.8:
launchalready takes thePaystackobject. Skip to move theme and display audience settings.
In 0.1.5 and earlier, your code looks like this:
- Kotlin
- Java
1Paystack.builder()2 .setPublicKey("pk_domain_xxxxxxxx")3 .build()45paymentSheet = PaymentSheet(this, ::paymentComplete)6paymentSheet.launch("ACCESS_CODE")7
In 1.0.0, keep the object that build() returns and pass it to launch with the access code:
- Kotlin
- Java
1val paystack = Paystack.builder()2 .setPublicKey("pk_domain_xxxxxxxx")3 .build()45paymentSheet = PaymentSheet(this, ::paymentComplete)6paymentSheet.launch(paystack, "ACCESS_CODE")7
If you're on 0.1.6, move the Paystack object from the PaymentSheet constructor to launch. The constructor now takes only your Activity or Fragment and the callback.
Your callback's type doesn't change. It still receives a PaymentSheetResult that's Completed, Cancelled, or Failed. See payment sheet result for when the sheet returns each one.
Move theme and display audience settings
In 0.1.3 to 0.1.8, you could call setThemeMode and, from 0.1.6, setDisplayAudience on Paystack.Builder. Version 1.0.0 removes both methods and their PaystackThemeMode and DisplayAudience types from paystack-core. Pass the same settings with a PaymentSheetConfig when you launch the sheet:
- Kotlin
- Java
1val sheetConfig = PaymentSheetConfig.builder()2 .setThemeMode(PaymentSheetConfig.ThemeMode.DARK)3 .setDisplayAudience(PaymentSheetConfig.DisplayAudience.MERCHANT_FACING)4 .build()56paymentSheet.launch(paystack, "ACCESS_CODE", sheetConfig)7
Both settings now use types nested in PaymentSheetConfig: PaymentSheetConfig.ThemeMode and PaymentSheetConfig.DisplayAudience.
Remove calls to APIs that no longer exist
Version 1.0.0 removes these from the public API:
- The
createPaymentSheetextension functions. Use thePaymentSheetconstructor instead. SdkNotInitializedException. There's no global configuration to initialize, so you can remove code that catches it.- The
paystack-coreAPI services and models, such asPaystackConfig. They're now internal to the SDK: Android Lint reports any use of them, and they can change without notice. ThePaymentSheetis the only supported way to accept payments with the SDK.
Enable Google Pay
If you want to offer Google Pay, add this entry inside the <application> element of your AndroidManifest.xml. Without it, the SDK hides Google Pay:
- AndroidManifest.xml
1<application>2 <!-- other application elements -->34 <meta-data5 android:name="com.google.android.gms.wallet.api.enabled"6 android:value="true" />7</application>8
You also need to enable Google Pay on your integration. See activating Google Pay.
Google must approve your app before you can accept live Google Pay payments. See Google Pay in the Android SDK reference.
Test the upgrade
Build your app with your test public key and an access code from a test transaction, then launch the payment sheet. You should see the TEST badge and the payment channels that apply to the transaction. Pay with the Success test card on the card screen and confirm your callback receives a Completed result with a transaction reference.
Version 1.0.0 also adds more payment channels, Jetpack Compose support, and payment sheet configuration. See the Android SDK reference for details.