Skip to content

Performing a Token Pre authorization

James Goodwin edited this page Mar 24, 2017 · 3 revisions

Check that you have initialized the SDK before attempting to make a Token Pre-Authorization.

1. Configuring the Judo instance

Using the PaymentReceiptModel returned from registering a card, create the TokenPaymentDefaultsViewModel:

var cardType = (CardNetwork)Enum.Parse(typeof(CardNetwork), receipt.CardDetails.CardType.ToString());
var lastFour = receipt.CardDetails.CardLastfour;
var expiryDate = receipt.CardDetails.EndDate;
var token = receipt.CardDetails.CardToken;
var consumerToken = receipt.Consumer.ConsumerToken;
var consumerReference = receipt.Consumer.YourConsumerReference;
var viewModel = new TokenPaymentDefaultsViewModel(lastFour, expiryDate, token, consumerToken, cardType);

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. Create a PaymentPage to show the card entry screen

var tokenPreAuthPage = new TokenPreAuthPage(judo, viewModel);
Navigation.PushAsync(tokenPreAuthPage);

3. Receive the payment result

tokenPreAuthPage.resultHandler += async (sender, result) =>
{
    if ("Success".Equals(result.Response.Result))
    {
        // handle successful token pre authorization

        // close token pre authorization page
        await Navigation.PopAsync();
    }
};