-
Notifications
You must be signed in to change notification settings - Fork 4
Registering a Card
Before you make a payment please check if your SDK is initialized
Card registration is done through conducting a pre-authorization configured to reserve £1.01 in the customer’s bank account, which then can be Voided in order for transaction not to appear in the customer’s bank statement.
In order to register a new card you need to perform the request with full card details:
register_card = Judopay::RegisterCard.new(
:your_consumer_reference => '12345',
:your_payment_reference => '67890',
:card_number => '4976000000003436',
:expiry_date => '12/20',
:cv2 => '452',
)You can check on the required fields and the format of each field in the Judopay REST API reference.
After you fill RegisterCard model you need to send the request to the API. Your code will look like that:
response_register_card = register_card.create
if response_register_card.result == 'Success'
puts 'Card registered successful'
else
puts 'There were some problems while processing your request'
endIf the register card is successful, you'll receive a response Mash like this:
{
"receipt_id"=>"xxxxxxxxx",
"your_payment_reference"=>"xxxxxxxxx",
"type"=>"PreAuth",
"created_at"=>"2016-09-27T08:49:23.0001+01:00",
"result"=>"Success",
"message"=>"xxxxxxxxx",
"judo_id"=>'xxxxxxxxx,
"merchant_name"=>"xxxxxxxxx",
"appears_on_statement_as"=>"xxxxxxxxx",
"original_amount"=>"1.01",
"amount_collected"=>"0.00",
"net_amount"=>"1.01",
"amount"=>"1.01",
"currency"=>"GBP",
"card_details"=>{
"card_lastfour"=>"3436",
"end_date"=>"1220",
"card_token"=>"xxxxxxxxx",
"card_type"=>1
},
"consumer"=>{
"consumer_token"=>"xxxxxxxxx",
"your_consumer_reference"=>"xxxxxxxxx"
},
"risks"=>{
"post_code_check"=>"UNKNOWN"
}
}After that you need to save cardToken & consumerToken values to perform a Token Payments
It is also important to handle different exceptions in your code. See our Error handling section.