buildscript { ... dependencies { classpath "com.android.tools.build:gradle:7.2.2" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21" } }
android { ... buildTypes { ... debug { matchingFallbacks = ['release'] } } }
dependencies { ... // This is the Default UI dependency implementation 'io.payworks:paybutton-android:2.96.0' // Add this dependency if you want to use Pax card reader implementation 'io.payworks:mpos.android.accessories.pax:2.96.0' // Add this dependency if you want to use Miura card reader implementation 'io.payworks:mpos.java.accessories.miura:2.96.0' // Add this dependency if you want to connect to the Miura via bluetooth implementation 'io.payworks:mpos.android.comlinks.bluetooth:2.96.0' // Add this dependency if you want to connect to the Miura via wifi implementation 'io.payworks:mpos.java.comlinks.tcp:2.96.0' }
<!-- Needed for Default UI !--> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.READ_PHONE_STATE"/> <!-- Needed for Miura integrations !--> <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <!-- Needed for Pax integrations !--> <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"/>
val mposUi = MposUi.initialize( context, ProviderMode.TEST, "MerchantIdentifier", "MerchantSecret" )
val mposUi = MposUi.create( ProviderMode.TEST, "MerchantIdentifier", "MerchantSecret" )
MposUi mposUi = MposUi.create( ProviderMode.MOCK, "yourMerchantIdentifier", "yourMerchantSecret");
ui.getConfiguration().setSummaryFeatures(EnumSet.of(MposUiConfiguration.SummaryFeature.PRINT_RECEIPT, MposUiConfiguration.SummaryFeature.SEND_RECEIPT_VIA_EMAIL)
val configuration = UiConfiguration( paymentOptions = setOf(PaymentOption.CARD, PaymentOption.MOTO), signatureCapture = SignatureCapture.ON_SCREEN, resultDisplayBehavior = ResultDisplayBehavior.DISPLAY_INDEFINITELY, accessibilityModeOption = AccessibilityModeOption.OPTION_VISIBLE, summaryFeatures = setOf( SummaryFeature.CAPTURE_TRANSACTION, SummaryFeature.PRINT_CUSTOMER_RECEIPT, SummaryFeature.PRINT_MERCHANT_RECEIPT, SummaryFeature.REFUND_TRANSACTION, SummaryFeature.SEND_RECEIPT_VIA_EMAIL ), terminalParameters = AccessoryParameters.Builder(AccessoryFamily.PAX) .integrated() .build() ) mposUi.configuration = configuration
UiConfiguration configuration = new UiConfiguration.Builder() .paymentOptions( EnumSet.of( UiConfiguration.PaymentOption.CARD, UiConfiguration.PaymentOption.MOTO ) ) .signatureCapture(UiConfiguration.SignatureCapture.ON_SCREEN) .resultDisplayBehavior(UiConfiguration.ResultDisplayBehavior.DISPLAY_INDEFINITELY) .accessibilityModeOption(UiConfiguration.AccessibilityModeOption.OPTION_VISIBLE) .summaryFeatures( EnumSet.of( UiConfiguration.SummaryFeature.SEND_RECEIPT_VIA_EMAIL, UiConfiguration.SummaryFeature.PRINT_CUSTOMER_RECEIPT, UiConfiguration.SummaryFeature.PRINT_MERCHANT_RECEIPT, UiConfiguration.SummaryFeature.REFUND_TRANSACTION, UiConfiguration.SummaryFeature.CAPTURE_TRANSACTION ) ) .terminalParameters( new AccessoryParameters.Builder(AccessoryFamily.PAX) .integrated() .build() ) .build(); mposUi.setConfiguration(configuration);
AccessoryParameters.Builder(AccessoryFamily.MIURA_MPI) .bluetooth() .build()
new AccessoryParameters.Builder(AccessoryFamily.MIURA_MPI) .bluetooth() .build();
val transactionParameters = TransactionParameters.Builder() .charge(BigDecimal("5.00"), Currency.EUR) .subject("Bouquet of Flowers") .customIdentifier("yourReferenceForTheTransaction") .build()
TransactionParameters transactionParameters = TransactionParameters.Builder() .charge(BigDecimal("5.00"), Currency.EUR) .subject("Bouquet of Flowers") .customIdentifier("yourReferenceForTheTransaction") .build()
val intent = mposUi.createTransactionIntent(transactionParameters) startActivityForResult(intent, MposUi.REQUEST_CODE_PAYMENT)
Intent intent = mposUi.createTransactionIntent(transactionParameters); startActivityForResult(intent, MposUi.REQUEST_CODE_PAYMENT);
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) if (requestCode == MposUi.REQUEST_CODE_PAYMENT) if (resultCode == MposUi.RESULT_CODE_APPROVED) { val transactionIdentifier = data?.extras?.get(MposUi.RESULT_EXTRA_TRANSACTION_IDENTIFIER) val transactionObject = mposUi.latestTransaction Snackbar.make(findViewById(android.R.id.content), "Transaction approved\n$transactionIdentifier", Snackbar.LENGTH_SHORT).show() } else { Snackbar.make(findViewById(android.R.id.content), "Transaction was declined, aborted, or failed", Snackbar.LENGTH_SHORT).show() } }
@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 String transactionIdentifier = data.getStringExtra(MposUi.RESULT_EXTRA_TRANSACTION_IDENTIFIER); Transaction transactionObject = mposUi.getLatestTransaction(); Toast.makeText(this, "Transaction approved, identifier: " + transactionIdentifier, 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(); } } }