Skip to content

Commit

Permalink
Merge pull request #228 from Mangopay/feature/card-validation-endpoint
Browse files Browse the repository at this point in the history
Feature/card validation endpoint
  • Loading branch information
iulian03 committed Sep 4, 2023
2 parents bb296db + 63ab8f1 commit 7c4aa77
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 5 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
5 changes: 0 additions & 5 deletions lib/mangopay/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ def fetch_wallet_transactions(funds_type, currency_iso_code, filters = {})
MangoPay.request(:get, url() + "/wallets/#{funds_type}/#{currency_iso_code}/transactions", {}, filters)
end

def validate(client_id, card_id)
url = "#{MangoPay.api_path}/cards/#{card_id}/validate"
MangoPay.request(:post, url)
end

def create_bank_account(params)
MangoPay.request(:post, url() + "/bankaccounts/iban", params)
end
Expand Down
9 changes: 9 additions & 0 deletions spec/mangopay/card_registration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,13 @@
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
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 7c4aa77

Please sign in to comment.