On this page, you can find additional configuration for adding MB WAY to your Components integration.
Before you begin
Before starting your MB WAY integration:
- Make sure you've integrated Components v3.7.0 or later.
- Add MB WAY in your test Customer Area.
Set up the MB WAY Component
-
Import the MB WAY Component to your
build.gradle
file.implementation "com.adyen.checkout:mbway:<latest-version>"
For the latest version, refer to our GitHub.
-
Build a client-side configuration of the MB WAY Component.
val mbwayConfiguration = MBWayConfiguration.Builder(context, "YOUR_CLIENT_KEY") // When you're ready to accept live payments, change the value to one of our live environments. .setEnvironment(Environment.TEST) .build()
-
Add the Component view to your layout. You will attach the initialized component to this view when collecting payment details.
<com.adyen.checkout.mbway.MBWayView android:id="@+id/YOUR_COMPONENT_VIEW_ID" .../>
Collect payment details
In this step, we use the client-side Component to collect the phone number from your shopper.
-
Deserialize the
/paymentMethods
response with theSERIALIZER
object.val paymentMethodsApiResponse = PaymentMethodsApiResponse.SERIALIZER.deserialize(paymentMethodsResponse)
-
From the result, get the object containing
paymentMethods.type
: mbway. -
Initialize an instance of the Component. To do this, you need to call
PROVIDER.get
from the MB WAY Component and pass the following:- The context (for example,
this@YourActivity
) - The
PaymentMethod
object (for example,paymentMethod
) - The
mbwayConfiguration
object
val mbwayComponent = MBWayComponent.PROVIDER.get(this@YourActivity, paymentMethod, mbwayConfiguration)
- The context (for example,
-
Attach the Component to the view to start getting your shopper's payment details. You need to call
attach
from the payment method's Component view and pass in:- the
mbwayComponent
- the context (for example,
this@YourActivity
)
MBWayView.attach(mbwayComponent, this@YourActivity)
- the
-
You start receiving updates when the shopper enters their phone number. Check if
isValid
is true, and if the shopper proceeds to pay, pass thepaymentComponentState.data.paymentMethod
to your server.mbwayComponent.observe(this@MainActivity) { state -> if (state?.isValid == true) { //serialize data val paymentComponentData = PaymentComponentData.SERIALIZER.serialize(state.data) // When the shopper proceeds to pay, pass the serialized `state.data` to your server to send a /payments request } }
Handle the await action
Step 1: Deserialize the action object
- In your client-side app, deserialize the
action
object from the/payments
response:val action = Action.SERIALIZER.deserialize(paymentResponse.action)
Step 2: Initialize the Component
-
Before initializing the Component, make sure that you've added the following to your
build.gradle
file:implementation "com.adyen.checkout:await:<latest-version>"
Check the latest version on GitHub.
-
Create a configuration object for the Component, passing your client key:
val awaitConfiguration = AwaitConfiguration.Builder(context, "YOUR_CLIENT_KEY") .setEnvironment(Environment.TEST) .build()
-
To initialize an instance of the Component, call
PROVIDER.get
from the Component and pass in the context (for example,this@YourActivity
), application class, and the configuration object created in the previous step:val awaitComponent = AwaitComponent.PROVIDER.get(this@YourActivity, application, awaitConfiguration)
-
From your instance, call
handleAction
and pass:- the context (for example,
this@YourActivity
) - the
action
object from the deserialized/payments
response.
awaitComponent.handleAction(this@YourActivity, action)
- the context (for example,
Step 3: Check the payment result
The Component notifies the observer
with the actionComponentData
object from the data in intent.data
. Pass this to your server to make a /payments/details
request.
awaitComponent.observe(this) { actionComponentData ->
// Send a /payments/details/ call containing the `actionComponentData`
sendPaymentDetails(actionComponentData)
}
Test and go live
To test your MB WAY integration, you can use any telephone number, for example +351234567890.
You can trigger a specific resultCode
value by appending a code to the shopperStatement
value in your /payments request:
resultCode |
Code to append to shopperStatement |
---|---|
Authorised default test response |
-c1 |
Pending | -c3 and wait 15 minutes after making the /payments request |
Refused | -c5 |
For example, to receive resultCode
: Refused, include the following in your /payments request:
{
// Produce a REFUSED payment result.
"shopperStatement": "MBWay shopper statement-c5"
}
You can check the status of MB WAY test payments in your Customer Area > Transactions > Payments.
Before you can accept live MB WAY payments, you need to add MB WAY in your live Customer Area.