Integrating PayButton with a PAX Device

Follow these steps to integrate PayButton with a PAX device:
  1. Install
    minSdkVersion 17
    and
    compileSdkVersion 2
    .
  2. Add the repository to your project's top level
    build.gradle
    :
    allprojects { repositories { google() jcenter() maven { url "https://repo.visa.com/mpos-releases/" } } }
  3. Add build dependencies as classpaths:
    buildscript { repositories { google() jcenter() } dependencies { classpath "com.android.tools.build:gradle:4.1.1" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.31" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } }
  4. Make sure the app supports Java 8 features by setting the compatibility levels in your module's
    build.gradle
    :
    android{ ... compileOptions { sourceCompatibility = 1.8 targetCompatibility = 1.8 } buildTypes { release { // ... } debug { // Required for our internal libraries // https://developer.android.com/studio/build/dependencies#resolve_matching_errors matchingFallbacks = ['release'] } } packagingOptions { exclude 'META-INF/*' exclude 'LICENSE.txt' exclude 'asm-license.txt' } }
  5. Add these exclusion rules to your module's
    build.gradle
    :
    plugins { id 'com.android.application' id 'kotlin-android' }
  6. Add the libraries to the dependencies section of your module's
    build.gradle
    :
    dependencies { ... // Starting from 2.48.0 (included), we migrated to Jetpack. implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' // Add these two dependencies for PAX implementation 'io.payworks:mpos.android.ui:2.94.0' implementation 'io.payworks:mpos.android.accessories.pax:2.94.0' }
    If you want to use ProGuard with your application, make sure to add the necessary rules to your ProGuard configuration. You can find more information here.
    If you see the
    Accessory update required
    error message, your BroadPOS P2PE version is not compatible with the PayButton SDK. To update your BroadPOS P2PE, contact Customer Support.
  7. Update your
    AndroidManifest.xml
    file to enable a larger heap size by setting
    android:largeHeap="true"
    . This setting is required to accommodate situations in which an update of the terminals is required and bigger chunks of data are requested and transferred.
    <application [...] android:largeHeap="true"> [...] </application>
  8. Update your
    AndroidManifest.xml
    file to enable these permissions:
    <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.READ_PHONE_STATE"/> <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="com.pax.permission.ICC"/> <uses-permission android:name="com.pax.permission.PICC"/> <uses-permission android:name="com.pax.permission.MAGCARD"/> <uses-permission android:name="com.pax.permission.PED"/>
Perform a Payment
To start a payment in mock mode:
void paymentButtonClicked() { MposUi ui = MposUi.initialize(this, ProviderMode.MOCK, "merchantIdentifier", "merchantSecretKey"); ui.getConfiguration().setSummaryFeatures(EnumSet.of( // Add this line, if you do want to offer Printing Customer Receipt MposUiConfiguration.SummaryFeature.PRINT_CUSTOMER_RECEIPT, // Add this line, if you do want to offer Printing Merchant Receipt MposUiConfiguration.SummaryFeature.PRINT_MERCHANT_RECEIPT, // Add this line, if you do want to offer Sending Receipt via Email MposUiConfiguration.SummaryFeature.SEND_RECEIPT_VIA_EMAIL) ); // If it's a MOCK card reader, please use the code as below AccessoryParameters accessoryParameters = new AccessoryParameters.Builder(AccessoryFamily.MOCK) .mocked() .build(); /* If it's a TEST card reader, please use the code as below AccessoryParameters accessoryParameters = new AccessoryParameters.Builder(AccessoryFamily.PAX) .integrated() .build();*/ //Add this line to enable RNIB accessibility mode which allows blind and visually impaired people to pay with ease. ui.getConfiguration().setAccessibilityModeOption(MposUiConfiguration.AccessibilityModeOption.OPTION_VISIBLE); // Add this line to set terminal parameters ui.getConfiguration().setTerminalParameters(accessoryParameters); // Add this line to set printer parameters ui.getConfiguration().setPrinterParameters(accessoryParameters); // Add this line if you would like to collect the customer signature on the receipt (as opposed to the digital signature) // ui.getConfiguration().setSignatureCapture(MposUiConfiguration.SignatureCapture.ON_RECEIPT); TransactionParameters transactionParameters = new TransactionParameters.Builder() .charge(new BigDecimal("5.00"), io.mpos.transactions.Currency.EUR) .subject("Bouquet of Flowers") .customIdentifier("yourReferenceForTheTransaction") .build(); Intent intent = ui.createTransactionIntent(transactionParameters); startActivityForResult(intent, MposUi.REQUEST_CODE_PAYMENT); }
The result is then delivered to your activity:
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == MposUi.REQUEST_CODE_PAYMENT) { if (resultCode == MposUi.RESULT_CODE_APPROVED) { // Transaction was approved Toast.makeText(this, "Transaction approved", Toast.LENGTH_LONG).show(); } else { // Card was declined, or transaction was aborted, or failed // (e.g. no internet or accessory not found) Toast.makeText(this, "Transaction was declined, aborted, or failed", Toast.LENGTH_LONG).show(); } // Grab the processed transaction in case you need it // (e.g. the transaction identifier for a refund). // Keep in mind that the returned transaction might be null // (e.g. if it could not be registered). Transaction transaction = MposUi.getInitializedInstance().getTransaction(); } }
For more information about the completed transaction status messages, click this link.
If you have problems with
onActivityResult
not being called, this issue might be caused by starting the PayButton Activity from the wrong Activity or Fragment. This Stackoverflow post might help you resolve the issue.
Only ready-made receipt are offered for the PAX A920 terminal. For more information, see Summary Screen.
Starting from Android SDK version 2.53, RNIB accessibility mode is introduced to enable blind and visually impaired people to pay with ease. Merchants can enable accessibility mode after starting a transaction by clicking the accessibility icon on the top right corner. When enabled, the voice guide will be played to help the shoppers to enter the PIN and complete the transaction. Note that in order to support this feature, the firmware version must be 7.1.2_V02.5.10 or later.
Use a Real Card Reader
To test with a real card reader, order the developer kit. You can find more information about developer kits here.
You can then retrieve your
merchantIdentifier
and
merchantSecretKey
through the Gateway Manager and change the
providerMode
field to
ProviderMode.TEST
.
Then, create the
accessoryParameters
with the card reader family and connection you want to use.
For more information about the accessory and transaction parameters, see the SDK custom integration documentation.
Navigation Bar and Status Bar Visibility/Kiosk Mode Settings
You can use your application in Kiosk mode by using methods provided by PAX. The recommendation is to use these methods with caution, and to not mix these methods with regular Android window UI flags because doing so might cause unpredictable behavior. The preferred recommendation is to disable the navigation bar in your
onResume()
and to show it again in your
onPause()
. This setting ensures that the flags are removed whenever you exit the app. To change the visibility of the navigation bar and the status bar, use this method:
MiscSettings.setStatusBarVisible(getApplicationContext(), true/false); MiscSettings.setNavigationBarVisible(getApplicationContext(), true/false);