Performing a Token Payment

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

Check that you have initialized the SDK before attempting to make a Token Payment.

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 tokenPaymentPage = new TokenPaymentPage(judo, viewModel);
Navigation.PushAsync(tokenPaymentPage);

3. Receive the payment result

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

        // close token payment page
        await Navigation.PopAsync();
    }
};
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.