GiftCard Operations with myPOS Smart SDK

The PL GiftCard feature enables merchants to activate, deactivate, and check balances of gift cards directly from a myPOS Smart terminal using the myPOS SDK.

1. Perform GiftCard Activation

To issue a new gift card, use MyPOSGiftCardActivation:

// Build the preauth request
MyPOSGiftCardActivation activation = MyPOSGiftCardActivation.builder()
	// Mandatory parameters
        .productAmount(1.23)
        .currency(Currency.EUR)
        .foreignTransactionId(UUID.randomUUID().toString())
	// Optional parameters
        // Set print receipt mode
	.printMerchantReceipt(MyPOSUtil.RECEIPT_ON)
	.printCustomerReceipt(MyPOSUtil.RECEIPT_ON)
        .build();

// Start the transaction
MyPOSAPI.openGiftCardActivationActivity(MainActivity.this, activation, ACTIVATION_REQUEST_CODE, skipConfirmationScreen);

2. Perform GiftCard Deactivation

To deactivate an existing gift card:

// Start the transaction
MyPOSAPI.openGiftCardDeactivationActivity(MainActivity.this, UUID.randomUUID().toString(), GIFTCARD_DEACTIVATION_REQUEST_CODE);

3. Perform GiftCard Balance Check

To check the remaining balance of a gift card:

// Start the transaction
MyPOSAPI.openGiftCardCheckBalanceActivity(MainActivity.this, UUID.randomUUID().toString(), GIFTCARD_BALANCE_CHECK_REQUEST_CODE);

4. Handle the Result

Use the onActivityResult() method in your activity to handle results from all gift card operations:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // The same request code as when calling MyPOSAPI.openGiftCardActivationActivity
    if (requestCode == ACTIVATION_REQUEST_CODE) {
        // The transaction was processed, handle the response
        if (resultCode == RESULT_OK) {
            // Something went wrong in the Payment core app and the result couldn't be returned properly
            if (data == null) {
                Toast.makeText(this, "Transaction cancelled", Toast.LENGTH_SHORT).show();
                return;
            }
            int transactionResult = data.getIntExtra("status", TransactionProcessingResult.TRANSACTION_FAILED);

            Toast.makeText(this, "GiftCard transaction has completed. Result: " + transactionResult, Toast.LENGTH_SHORT).show();

            // TODO: handle each transaction response accordingly
            if (transactionResult == TransactionProcessingResult.TRANSACTION_SUCCESS) {
                // Transaction is successful
            }
        } else {
            // The user cancelled the transaction
            Toast.makeText(this, "Transaction cancelled", Toast.LENGTH_SHORT).show();
        }
    }
}

The same result-handling logic applies to activation, deactivation, and balance check operations. Just match the requestCode accordingly.