Performing a Token Payment

Zeno Foltin edited this page Jul 21, 2018 · 13 revisions

Check that you have initialized the SDK before attempting to make a token payment.

1. Show the card entry form

Create an Intent for the PaymentActivity with the required Intent extras, using the saved receipt obtained from registering the card:

Intent intent = new Intent(this, PaymentActivity.class);
intent.putExtra(Judo.JUDO_OPTIONS, new Judo.Builder()
        .setJudoId("<JUDO_ID>")
        .setAmount("1.00")
        .setCurrency(Currency.GBP)
        .setConsumerReference(receipt.getConsumer().getYourConsumerReference())
        .setCardToken(receipt.getCardDetails())
        .build());

startActivityForResult(intent, TOKEN_PAYMENT_REQUEST);

Note: Please make sure that the Consumer Reference used and the card token matches the ones used when the card token was originally generated.

2. Check the payment result

In your calling Activity, override the onActivityResult() method to receive a receipt from the token payment:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if(requestCode == TOKEN_PAYMENT_REQUEST) {
        switch (resultCode) {
            case JudoPay.RESULT_SUCCESS:
                Receipt receipt = data.getParcelableExtra(JudoPay.JUDO_RECEIPT);
                // handle successful payment
            }
    }
}
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.