Skip to content

Commit

Permalink
added card validation function
Browse files Browse the repository at this point in the history
  • Loading branch information
Iulian Masar committed Aug 31, 2023
1 parent 2c79a3b commit d9d1dc7
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/mangopay/card.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ def fingerprint_url(fingerprint)
def get_pre_authorizations(card_id, filters = {})
MangoPay.request(:get, "#{MangoPay.api_path}/cards/#{card_id}/preauthorizations")
end

def validate(card_id, params)
url = "#{MangoPay.api_path}/cards/#{card_id}/validation"
MangoPay.request(:post, url, params)
end
end
end
end
10 changes: 10 additions & 0 deletions spec/mangopay/card_registration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,14 @@
expect(transactions).to be_an(Array)
end
end

describe 'VALIDATE CARD' do
it "validates a card" do
created = new_card_registration_completed
validated = create_card_validation(created['UserId'], created['CardId'])

expect(validated).to_not be_nil
expect(validated['Validity']).to be('VALID')
end
end
end
21 changes: 21 additions & 0 deletions spec/mangopay/shared_resources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,27 @@ def create_new_payin_preauthorized_direct(to_wallet, amnt = 1000)
)
end

def create_card_validation(author_id, card_id)
params = {
AuthorId: author_id,
SecureModeReturnURL: "https://mangopay.com",
IpAddress: "2001:0620:0000:0000:0211:24FF:FE80:C12C",
Tag: "custom meta",
BrowserInfo: {
AcceptHeader: "text/html, application/xhtml+xml, application/xml;q=0.9, /;q=0.8",
JavaEnabled: true,
Language: "FR-FR",
ColorDepth: 4,
ScreenHeight: 1800,
ScreenWidth: 400,
JavascriptEnabled: true,
TimeZoneOffset: "+60",
UserAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
}
}
MangoPay::Card.validate(card_id, params)
end

###############################################
# pre-authorized direct deposit
###############################################
Expand Down

0 comments on commit d9d1dc7

Please sign in to comment.