Performing a Pre Authorization

ofetisov edited this page Jun 13, 2017 · 6 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/card_preauth'
Create pre-authorization

To make a new pre-authorization with full card details:

preauth =
  :your_consumer_reference => 'xxxxxxxx',
  :your_payment_reference => 'xxxxxxxx',
  :amount => 5.01,
  :card_number => '4976000000003436',
  :expiry_date => '12/20',
  :cv2 => '452',
  :currency => 'GBP',
  :card_address => {
    :line1 => '32 Edward Street',
    :town => 'Camborne',
    :postcode => 'TR14 8PA'
  :consumer_location => {
    :latitude => 51.5033630,
    :longitude => -0.1276250

Note: Please make sure that you are using a unique Consumer Reference for each different consumer, and a unique Payment Reference for each transaction.

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

Check the pre-authorization result

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

    result_preauth = preauth.create
    if result_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 array 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.