Mastercard Sonic Branding - Android SDK provides SonicController and SonicView as a public interface to the sdk.
Sonic Controller
SonicController provides a set of APIs for playing sound, animation, and haptics feedback. Initialize SonicController as follows:
import androidx.fragment.app.Fragment
import com.mastercard.sonic.controller.SonicController
class SonicFragment : Fragment(R.layout.fragment_sonic) {
private val sonicController = SonicController()
}
import androidx.fragment.app.Fragment;
import com.mastercard.sonic.controller.SonicController;
public class SonicFragment extends Fragment {
private SonicController sonicController = new SonicController();
public SonicFragment(){
}
}
prepare() method to prepare a set of resources with below parameters
sonicType param for sonic type merchant app wants to prepare
sonicCue param for the cue merchant app wants to prepare
sonicEnvironment Environment for which sonic is getting prepared
production - for production environment
sandbox - for development and testing.
merchant merchant information for that sonic is getting prepared
isHapticsEnabled enabling/disabling haptics feedback, default value is true.
context is current state of the application
OnPrepareListener.onPrepared callback with status code as success, partial success, or failure.
fun play(sonicView: SonicView? = null, onCompleteListener: OnCompleteListener)
play() should be call after successful prepare(). This plays the sonic (sound and/or animation)
sonicView the view in which animation will play
completion provides status in callback with status code success, partially success or fail.
Sonic View
SonicView is a custom view that displays the Sonic Animation with a background. You can add SonicView into the parent view with any width and height value. It is recommended to provide the following properties to SonicView with a proper value.
Property
Description
Type
Default Value
android:layout_width
Set the width
Integer
320dp, if width is provided as wrap_content
android:layout_height
Set the height
Integer
240dp, if height is provided as wrap_content
sonicBackground
Set the sonic background color. It can set background color as black or white
Enum
black
Note: It is recommended to add SonicView on a full screen without padding. Padding is used to add space between two views. When you add padding to the SonicView, the background of the parent view gets displayed in the padded part which can lead to a bad user experience.
You can add SonicView either in XML or programmatically as follows:
Add SonicView in XML
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<!-- SonicView in a full screen -->
<com.mastercard.sonic.widget.SonicView
android:id="@+id/sonic_view"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<!-- app:sonicBackground="white" will enable white background when animation will be played-->
<!-- app:sonicBackground="black" will enable black background when animation will be played-->
</androidx.constraintlayout.widget.ConstraintLayout>
Create an instance of SonicView in Fragment/Activity.
Below properties needs to be provided by merchant to configure SonicMerchant.
Property
Description
Type
Required
Reference
merchantName
Name that the business is known by. It will be the name that is used on all official communications. This information can be obtained by contacting your payment processor, acquiring bank’s customer support and merchant services department or Mastercard Representative.
Note: If you are a service provider that engages in 1-to-many integrations, you can include your business name
String
Yes
merchantId
Merchant ID (Merchant Identification Number) is a unique identifier(15-digit code) assigned to each merchant at a time of onboarding process by their payment processor or acquiring bank for Mastercard Transactions.
This information can be obtained by contacting payment processor or acquiring bank’s customer support or merchant services department.
String
No
countryCode
3 digit ISO country code of the merchant accepting the Mastercard payments. The country is identified based on the country where the POS device is installed and accepting payments, or the merchant’s country associated with its app.
String
Yes
city
City of the merchant is identified based on the location where the POS device is installed and accepting Mastercard payments, or the merchant’s city associated with its app.
String
No
merchantCategoryCodes
Merchant Category Code (MCC) is a four-digit code used to categorize businesses based on the type of products or services. This information can be obtained by contacting your payment processor, acquiring bank’s customer support and merchant services department or Mastercard Representative.
Note: If you are a service provider that engages in 1-to-many integrations, please insert [‘MCC 0000’]