Sezzle Android SDK allows you to offer Sezzle in your android app.
Download via Gradle:
implementation "com.sezzle:sezzlemerchantsdkandroid:1.0.2"or Maven:
<dependency>
<groupId>com.sezzle</groupId>
<artifactId>sezzlemerchantsdkandroid</artifactId>
<version>1.0.2</version>
</dependency>Before you start the initialization for Sezzle SDK, you must have a merchant account with Sezzle.
You will need your public API Key from Sezzle Merchant Dashboard.
You must set this key as follows:
Sezzle.Companion.initialize(new Sezzle.Configuration(
"public key",
Sezzle.Environment.PRODUCTION,
Sezzle.LOG_LEVEL_DEBUG,
Sezzle.Location.US
));public keycomes from the Sezzle Merchant Dashboard.environmentcan be set toSezzle.Environment.SANDBOXfor test.log levelis available in theSezzleobject.locationeither US or CA is available in theSezzle.Locationobject.
Checkout creation is the process in which a customer uses Sezzle to pay for a purchase in your app.
You should create an Order and a Customer and launch the Sezzle checkout using the startCheckout function.
Sezzle.startCheckout(this@MainActivity, customerModel(), orderModel())- Please look at the Sezzle Docs for the structure of the Customer and Order objects.
activityis the activity where you want to start the checkout.Customeris the object containing the customer's information.Orderis the object containing the order information.
- Make sure your activity implements
Sezzle.CheckoutCallbacks. - Override
onActivityResultlike so
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (Sezzle.handleCheckoutData(this, requestCode, resultCode, data)) {
return
}
super.onActivityResult(requestCode, resultCode, data)
}- Override the handler functions
onSezzleCheckoutError,onSezzleCheckoutCancelledandonSezzleCheckoutSuccesslike so
override fun onSezzleCheckoutError(message: String?) {
Toast.makeText(this, "Checkout Error: $message", Toast.LENGTH_LONG).show()
}
override fun onSezzleCheckoutCancelled() {
Toast.makeText(this, "Checkout Cancelled", Toast.LENGTH_LONG).show()
}
override fun onSezzleCheckoutSuccess(token: String) {
Toast.makeText(this, "Checkout token: $token", Toast.LENGTH_LONG).show()
}Once the checkout is completed successfully, the token will be passed to onSezzleCheckoutSuccess. Send the token to your backend
and capture from there. For more information on this and other backend endpoints,
look at the Sezzle Docs.
Sezzle widget component and Modal components are used in product pages to educated users about Sezzle-payment.
To display the widget, the SDK provides a SezzlePromotionButton class. SezzlePromotionButton is implemented as follows:
<com.sezzle.sezzlemerchantsdkandroid.SezzlePromotionButton
android:id="@+id/promo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
app:sezzleTextSize="16sp"
android:layout_below="@+id/modal_button"
app:sezzleLogoType="SezzleLogoColorTextBlack" />or
// Option1 - Load via findViewById
val sezzlePromo = findViewById<SezzlePromotionButton>(R.id.promo)
sezzlePromo.setLabel("or 4 interest-free payments with {sezzle_logo}")or
// Option2 - Initialize
val sezzlePromotionButton2 = SezzlePromotionButton(this)
sezzlePromotionButton2.configWithLocalStyling(SezzleLogoType.SEZZLE_LOGO_BLACK_TEXT_BLACK)
sezzlePromotionButton2.setLabel("or 4 interest-free payments with {sezzle_logo}")
findViewById<RelativeLayout>(R.id.relative_layout).addView(sezzlePromotionButton2)Configure the style of the SezzlePromotionButton sezzleLogoType: SezzleLogoType, typeface: Typeface?, sezzleTextColor: Int, sezzleTextSize: Int
configWithLocalStylingthat will use the local styles.
// You can custom with the SezzleLogoType, Typeface, TextSize, TextColor
sezzlePromotionButton2.configWithLocalStyling(
SezzleLogoType.SEZZLE_LOGO_BLACK_TEXT_BLACK,
ResourcesCompat.getFont(this, R.font.xyz),
android.R.color.darker_gray,
R.dimen.sezzle_promotion_size);Show the modal by calling showSiteModal
Sezzle.showSiteModal(this@MainActivity, "2.0.1", "fr")- Version and language support can be found at Sezzle Modals
- Use the [link] (https://media.sezzle.com/shopify-app/assets/sezzle-modal-2.0.0-en.html) to test the
version and language you want to pass in
showSiteModalto make sure they are valid.