Make a payment 


1. Show the card entry form

Create an Intent for the MakePaymentWithLinkedCardActivity with the required Intent extras:

public void onPayWithCardBtnClick(View view) {
	...
Intent intent = new Intent(this, PurchaseActivity.class);
intent.putExtra(MyPos.INTENT_EXTRA_CART_ITEMS,      mIPCCartItems);
intent.putExtra(MyPos.INTENT_EXTRA_ORDER_ID,        
                      String.valueOf(System.currentTimeMillis()));
intent.putExtra(MyPos.INTENT_EXTRA_CARD_TOKEN,      cardToken);
startActivityForResult(intent, MyPos.REQUEST_CODE_PURCHASE);
	...
}

Note: Please make sure that you are using a unique Reference ID for each different consumer

 

2. Check the payment result

In your calling Activity, override the onActivityResult method to receive a reference of the payment card, customer ID and transaction reference from Performing a Payment:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if( resultCode == RESULT_OK  && requestCode == MyPos.REQUEST_CODE_PURCHASE){
        int status = data.getIntExtra(MyPos.INTENT_EXTRA_STATUS,             
                                              MyPos.STATUS_INTERNAL_API_ERROR);
        if( status == MyPos.STATUS_SUCCESS) {
            String tranRef = 
               data.getStringExtra(MyPos.INTENT_EXTRA_TRANSACTION_REFERENCE);
.
.
.
    }
}

 

Refund


Refunding a payment requires that you have the transactionRef of the payment transaction. Check that you have initialized the SDK before attempting to perform a refund.

 

1. Show the card entry form

Create an Intent for the MakeRefundActivity with the required Intent extras:

public void onRefundBtnClick(View view) {
	...
Intent intent = new Intent(this, RefundActivity.class);
intent.putExtra(MyPos.INTENT_EXTRA_TRANSACTION_REFERENCE, transactionRef);
intent.putExtra(MyPos.INTENT_EXTRA_AMOUNT, amount);
if( !orderId.equalsIgnoreCase(""))
    intent.putExtra(MyPos.INTENT_EXTRA_ORDER_ID, orderId);
startActivityForResult(intent, MyPos.REQUEST_CODE_REFUND);
	...
}

 

2. Check the payment result

In your calling Activity, override the onActivityResult method to receive a transaction reference of the operation and the reference of the original transaction:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if( resultCode == RESULT_OK  && requestCode == MyPos.REQUEST_CODE_REFUND){
    int status = data.getIntExtra(MyPos.INTENT_EXTRA_STATUS, 
                                            MyPos.STATUS_INTERNAL_API_ERROR);
    if( status == MyPos.STATUS_SUCCESS) {
        float amount = data.getFloatExtra(MyPos.INTENT_EXTRA_AMOUNT, 0.00f);
        String currency = data.getStringExtra(MyPos.INTENT_EXTRA_CURRENCY);
        String transactionReference = 
                 data.getStringExtra(MyPos.INTENT_EXTRA_TRANSACTION_REFERENCE);
}

 

Show card payment screen


Create an intent for the Payment Activity with the required

public void onPayBtnClick(View view) {
	...
		ArrayList<CartItem>         mIPCCartItems
public CartItem(String article, int quantity, float price){..}
Intent intent = new Intent(this, PurchaseActivity.class);
intent.putExtra(MyPos.INTENT_EXTRA_CART_ITEMS,      mIPCCartItems);
intent.putExtra(MyPos.INTENT_EXTRA_ORDER_ID,          
                             String.valueOf(System.currentTimeMillis()));
startActivityForResult(intent, MyPos.REQUEST_CODE_PURCHASE);
	...
}