Adyen checkout mbway-base component

Adyen checkout mbway-base component client for Adyen's Checkout API.

License

License

GroupId

GroupId

com.adyen.checkout
ArtifactId

ArtifactId

mbway-base
Last Version

Last Version

4.0.0-alpha02
Release Date

Release Date

Type

Type

aar
Description

Description

Adyen checkout mbway-base component
Adyen checkout mbway-base component client for Adyen's Checkout API.
Project URL

Project URL

https://github.com/Adyen/adyen-android
Source Code Management

Source Code Management

https://github.com/Adyen/adyen-android

Download mbway-base

How to add to project

<!-- https://jarcasting.com/artifacts/com.adyen.checkout/mbway-base/ -->
<dependency>
    <groupId>com.adyen.checkout</groupId>
    <artifactId>mbway-base</artifactId>
    <version>4.0.0-alpha02</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/com.adyen.checkout/mbway-base/
implementation 'com.adyen.checkout:mbway-base:4.0.0-alpha02'
// https://jarcasting.com/artifacts/com.adyen.checkout/mbway-base/
implementation ("com.adyen.checkout:mbway-base:4.0.0-alpha02")
'com.adyen.checkout:mbway-base:aar:4.0.0-alpha02'
<dependency org="com.adyen.checkout" name="mbway-base" rev="4.0.0-alpha02">
  <artifact name="mbway-base" type="aar" />
</dependency>
@Grapes(
@Grab(group='com.adyen.checkout', module='mbway-base', version='4.0.0-alpha02')
)
libraryDependencies += "com.adyen.checkout" % "mbway-base" % "4.0.0-alpha02"
[com.adyen.checkout/mbway-base "4.0.0-alpha02"]

Dependencies

compile (2)

Group / Artifact Type Version
com.adyen.checkout : base-v3 jar 4.0.0-alpha02
org.jetbrains.kotlin : kotlin-stdlib jar 1.4.10

Project Modules

There are no modules declared in this project.

Adyen Components for Android

Adyen Components for Android allows you to accept in-app payments by providing you with the building blocks you need to create a checkout experience.

For an overview of how you can integrate with Adyen on Android check out the Documentation Website


DropIn Preview


Support

If you have a feature request, or spotted a bug or a technical problem, create a GitHub issue. For other questions, contact our support team.

Installation

The Components are available through jcenter, you only need to add the Gradle dependency.

Import with Gradle

Import the Component module for the Payment Method you want to use by adding it to your build.gradle file. For example, for the Drop-in solution you should add:

implementation "com.adyen.checkout:drop-in:3.8.0"

For a Credit Card component you should add:

implementation "com.adyen.checkout:card-ui:3.8.0"

Drop-in

The Drop-in is the implementation that handles the presentation of all available payment methods and the subsequent entry of a customer's payment details. It is initialized with the response of /paymentMethods, and provides everything you need to make an API call to /payments and /payments/details.

Usage

The Drop-in requires the response of the /paymentMethods endpoint to be initialized. To pass the response to Drop-in, decode the response to the PaymentMethodsApiResponse class.

You can provide the raw JSONObject to the SERIALIZER object to deserialize the data.

val paymentMethodsApiResponse = PaymentMethodsApiResponse.SERIALIZER.deserialize(jsonObject)

The Drop-in relies on you to implement the calls to your server. When calling /payments or /payments/details is required, it will trigger an intent to the DropInService which you need to extend. The data comes as a JSONObject that you can use to compose your final /payments call on your back end. After the call, you return a CallResult with a type and message, each type expects a certain message.

  • ACTION - If the result contains an action object, return it in the message to continue the payment flow.
  • FINISHED - If there is no action the payment flow is finished, the message will be passed along as the result.
  • ERROR - If an error happened during the connection.
class YourDropInService : DropInService() {
    override fun makePaymentsCall(paymentComponentData: JSONObject): CallResult {
        // make /payments call with the component data
        return CallResult(CallResult.ResultType.ACTION, "action JSON object")
    }
    
    override fun makeDetailsCall(actionComponentData: JSONObject): CallResult {
        // make /payments/details call with the component data
        return CallResult(CallResult.ResultType.FINISHED, "Success")
    }
}

Don't forget to also add the service your manifest.

<service
    android:name=".YourDropInService"
    android:permission="android.permission.BIND_JOB_SERVICE"/>

Some payment methods need additional configuration. For example, to enable the card form, the Drop-in needs a public key from the Customer Area to be used for encryption. These payment method specific configuration parameters can be set in the DropInConfiguration:

val dropInConfiguration = DropInConfiguration.Builder(this@MainActivity,
resultIntent, YourDropInService::class.java)
    .addCardConfiguration(cardConfiguration)
    .build()

You can find an example on how to create the cardConfiguration in the Components section.

After serializing the payment methods and creating the configuration, the Drop-in is ready to be initialized. Just call the .startPayment() method, the final result sent on the CallResult will be added to your resultIntent to start your Activity.

DropIn.startPayment(this@YourActivity, paymentMethodsApiResponse, dropInConfiguration)

Components

In order to have more flexibility over the checkout flow, you can use our Components to present each payment method individually in your own Activity.

To do that you need the data of that specific payment method parsed to the PaymentMethod class, and to create the configuration object (check out the docs for a more detailed guide on how to initialize the CardConfiguration.Builder).

val cardConfiguration = CardConfiguration.Builder(context).build()
        
val cardComponent = CardComponent.PROVIDER.get(this@YourActivity, paymentMethod, cardConfiguration)

Then you need to add the Component View to your layout.

<com.adyen.checkout.card.CardView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"/>

Then, after the component is initialized, you can attach it to the view to start getting user data.

cardView.attach(cardComponent, this@YourActivity)

From this moment you will start receiving updates when the user inputs data. When the data is valid, you can send it to the /payments endpoint.

cardComponent.observe(this@MainActivity, Observer { 
    if (it?.isValid == true) {
        // you can now use it.data to send your payments/ request
    }
})

ProGuard

If you use ProGuard or R8, the following rules should be enough to maintain all expected functionality. Please let us know if you find any issues.

-keep class com.adyen.checkout.base.model.** { *; }
-keep class com.adyen.threeds2.** { *; }
-keepclassmembers public class * implements com.adyen.checkout.base.PaymentComponent {
   public <init>(...);
}
-keepclassmembers public class * implements com.adyen.checkout.base.ActionComponent {
   public <init>(...);
}

Common Issues

  • Our TextInputLayout uses a MaterialComponents style, so it requires your app theme to extend Theme.MaterialComponents. If you use a Theme.AppCompat you might need to override this style. But note that this will also change the appearance of the TextInputLayout.
<style name="AdyenCheckout.TextInputLayout" >
    <item name="boxStrokeColor">@color/colorAccent</item>
    <item name="hintTextAppearance">@style/AdyenCheckout.HintTextStyle</item>
    <item name="android:minHeight">@dimen/input_layout_height</item>
</style>

See also

License

This repository is open source and available under the MIT license. For more information, see the LICENSE file.

com.adyen.checkout

Adyen

Versions

Version
4.0.0-alpha02
4.0.0-alpha01
3.8.3
3.8.2
3.8.1
3.8.0
3.7.3
3.7.2
3.7.1
3.7.0