How to Add a Card
Before starting the card registration process, make sure the myPOS SDK has been properly initialized in your app.
Display the Card Entry Form
To prompt users to add a card, you need to start the StoreCardActivity with a small verification amount. Here's how:
public void onAddCardBtnClick(View view) {
...
Intent intent = new Intent(this, StoreCardActivity.class);
intent.putExtra(MyPos.INTENT_EXTRA_VERIFICATION_AMOUNT, 0.05f);
startActivityForResult(intent, MyPos.REQUEST_CODE_STORE_CARD);
...
}
Important: Always use a unique Reference ID for each consumer when registering a card.
MyPos.INTENT_EXTRA_VERIFICATION_AMOUNT is used to specify a small amount (e.g., 0.05 EUR) that will be temporarily charged during the tokenization process. Some card issuers do not allow tokenization with a 0.00 amount.
After the card is added, you can automatically refund the charged amount — see the next step.
Enable Automatic Refund (Optional)
To automatically refund the verification amount after the card is stored, simply add this extra flag:
intent.putExtra(MyPos.INTENT_EXTRA_AUTO_REVERSE, true);
Handle the Result
To capture the result of the card registration process, override the onActivityResult() method in your
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if( resultCode == RESULT_OK && requestCode == MyPos.REQUEST_CODE_STORE_CARD){
int status = data.getIntExtra(MyPos.INTENT_EXTRA_STATUS,
MyPos.STATUS_INTERNAL_API_ERROR
);
if( status == MyPos.STATUS_SUCCESS) {
String cardToken = data.getStringExtra(MyPos.INTENT_EXTRA_CARD_TOKEN);
String cardCustomName =
data.getStringExtra(MyPos.INTENT_EXTRA_CARD_CUSTOM_NAME);
}