Performing a Token Pre Authorization

ofetisov edited this page Jun 13, 2017 · 7 revisions

Before you make a payment please check if your SDK is initialized

Include a model

Add model inclusion to your source code:

require 'judopay/models/token_preauth'
Create token pre-authorization

To make a new token pre-authorization you need to have valid Card and Consumer Tokens. They could be obtained after any successful payment or card registration. To perform a token pre-authorization you need to put them in TokenPayment model:

    # response_register_card - successfull RegisterCard response
    token_preauth =
      :your_consumer_reference => 'xxxxxxxxx',
      :your_payment_reference => 'xxxxxxxxx',
      :amount => 5.01,
      :currency => 'GBP',
      :consumer_token => response_register_card.consumer.consumer_token,
      :card_token => response_register_card.card_details.card_token,
      :cv2 => '452'

Note: Please make sure that the Consumer Reference used and the card token matches the ones used when the card token was originally generated. Remember to assign a unique payment reference for each payment requested.

You can check on the required fields and the format of each field in the Judopay REST API reference.

Check the result

And after that, you need to send the request to the API. Your code will look like that:

    result_token_preauth = token_preauth.create
    if result_token_preauth.result == 'Success'
        puts 'Preauth successful'
        puts 'There were some problems while processing your preauth'

If the pre-authorization is successful, you'll receive a response Mash like this:


It is also important to handle different exceptions in your code. See our Error handling section.

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.