-
Notifications
You must be signed in to change notification settings - Fork 4
Saving a Card
Before you make a payment please check if your SDK is initialized
Card saving is done in a same way as a card registration but there is a difference - it's done without a hold of £1.01 in the customer’s bank account. You should select this method if you want just to save the card and verify it only in a future use.
In order to save a new card you need to perform the request with full card details:
save_card = Judopay::SaveCard.new(
:your_consumer_reference => 'ххххххххххх',
: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 SaveCard model you need to send the request to the API. Your code will look like that:
result_save_card = save_card.create
if result_save_card.result == 'Success'
puts 'Card saved successfuly'
else
puts 'There were some problems while processing your request'
endIf card is sucessfully saved, you'll receive a response Mash like this:
{
"receipt_id"=>"xxxxxxxx",
"your_payment_reference"=>"Judo_RegisterCard_636105641726900778",
"type"=>"Register",
"created_at"=>"2016-09-27T09:09:32.7369+01:00",
"result"=>"Success",
"message"=>"Register Card",
"judo_id"=>'xxxxxxxx',
"merchant_name"=>"xxxxxxxx",
"appears_on_statement_as"=>"xxxxxxxx",
"original_amount"=>"0.00",
"net_amount"=>"0.00",
"amount"=>"0.00",
"currency"=>"GBP",
"card_details"=>{
"card_lastfour"=>"3436",
"end_date"=>"1220",
"card_token"=>"xxxxxxxx",
"card_type"=>1
},
"consumer"=>{
"consumer_token"=>"xxxxxxxx",
"your_consumer_reference"=>"xxxxxxxx"
},
"risks"=>{
"post_code_check"=>"UNKNOWN"
}
}After that you need to save card_token and consumer_token values to perform a Token Payments or Token Pre-auth.
It is also important to handle different exceptions in your code. See our Error handling section.