Payment Using a Stored Card
If you've already tokenized a customer's card, you can use the saved card token to perform a payment without prompting the user to re-enter their details.
Initiate the Payment with Stored Card
To perform a payment using a previously stored card, launch the PurchaseActivity 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);
...
}
Important: Always ensure each customer has a unique Reference ID to maintain correct payment mapping and tokenization history.
Handle the Payment Result
Once the payment is complete, capture the result inside onActivityResult() in your calling activity:
@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);
.
.
.
}
}
Summary
- Use a stored card token to streamline repeat purchases for returning users.
- Always provide a unique order ID for every transaction.
- Handle the result to capture the transaction reference and confirm success.