allprojects { repositories { google() jcenter() maven { url "https://repo.visa.com/mpos-releases/" } } }
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 } }
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' } }
plugins { id 'com.android.application' id 'kotlin-android' }
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.96.0' implementation 'io.payworks:mpos.android.accessories.pax:2.96.0' }
<application [...] android:largeHeap="true"> [...] </application>
<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"/>
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); }
@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(); } }
MiscSettings.setStatusBarVisible(getApplicationContext(), true/false); MiscSettings.setNavigationBarVisible(getApplicationContext(), true/false);