Integrate the PayButton for PAX

Install
PayButton requires
minSdkVersion 17
and
compileSdkVersion 28
.
  • Add our repository to your
    project's
    top level
    build.gradle
    :
allprojects { repositories { google() jcenter() maven { url "http://releases.payworks.io/artifactory/mpos" } } }
  • 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 } }
  • You will need to 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' } }
  • Add the following exclusion rules to your module's
    build.gradle
    :
plugins { id 'com.android.application' id 'kotlin-android' }
  • 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.58.0' implementation 'io.payworks:mpos.android.accessories.pax:2.58.0' }
If you want to use ProGuard with your application make sure to add the necessary rules to your ProGuard configuration.
Note:
If you see the error message,
Accessory update required
, it means your BroadPOS P2PE version is not compatible with the SDK. To update your BroadPOS P2PE, contact Customer Support.
  • Update your
    AndroidManifest.xml
    to enable a larger heap size by setting
    android:largeHeap="true"
    . This is required to accommodate for situations where an update of the terminals is required and bigger chunks of data are requested and transferred.
<application [...] android:largeHeap="true"> [...] </application>
  • Update your
    AndroidManifest.xml
    to enable 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, do the following:
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(); } }
See more information about the completed transaction statuses and what they mean here.
If you have problems with
onActivityResult
not being called, this issue might be caused by starting the PayButton Activity from the wrong Activity / Fragment. This Stackoverflow post might help you resolve the issue.
Only ready-made receipt are offered for the PAX A920.
Starting from Android SDK
2.53
, RNIB accessibility mode is introduced to allow 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: in order to support this feature, the firmware version must be
7.1.2_V02.5.10
and above.
Use a Real Card Reader
To test with a real card reader, order the Developer Kit. You can find more information about our Developer Kits here.
You can then retrieve your
merchantIdentifier
and
merchantSecretKey
through the Gateway Manager and change the
providerMode
to
ProviderMode.TEST
.
Then create the
accessoryParameters
with the reader family and connection you want to use.
For more information about the accessory and transaction parameters see the SDK Integration documentation.
Navigation Bar and Status Bar visibility / Kiosk mode
You can use your application in kiosk mode by using methods provided by PAX. Please use them with caution, don't mix these methods with regular Android window UI flags as this may cause unpredictable behavior. Our recommendation is to disable the navigation bar in your
onResume()
and to show it again in your
onPause()
. This makes sure that whenever you exit the app the flags are removed. For changing the visibility of Navigation Bar and Status Bar use those methods:
MiscSettings.setStatusBarVisible(getApplicationContext(), true/false); MiscSettings.setNavigationBarVisible(getApplicationContext(), true/false);