spec/mangopay/shared_resources.rb in mangopay-3.11.1 vs spec/mangopay/shared_resources.rb in mangopay-3.12.0
- old
+ new
@@ -391,10 +391,32 @@
# 3rd step: update (fills-in CardId) and return it
MangoPay::CardRegistration.update(cardreg['Id'],
RegistrationData: cardreg['RegistrationData'])
end
+ let(:new_card_registration_completed_for_deposit) do
+ # 1st step: create
+ cardreg = new_card_registration
+
+ # 2nd step: tokenize by payline (fills-in RegistrationData)
+ data = {
+ data: cardreg['PreregistrationData'],
+ accessKeyRef: cardreg['AccessKey'],
+ cardNumber: 4970105181818183,
+ cardExpirationDate: 1226,
+ cardCvx: 123}
+
+ res = Net::HTTP.post_form(URI(cardreg['CardRegistrationURL']), data)
+ raise Exception, [res, res.body] unless res.is_a?(Net::HTTPOK) && res.body.start_with?('data=')
+
+ cardreg['RegistrationData'] = res.body
+
+ # 3rd step: update (fills-in CardId) and return it
+ MangoPay::CardRegistration.update(cardreg['Id'],
+ RegistrationData: cardreg['RegistrationData'])
+ end
+
let(:new_payin_card_direct) { create_new_payin_card_direct(new_wallet) }
def create_new_payin_card_direct(to_wallet, amnt = 1000)
cardreg = new_card_registration_completed
MangoPay::PayIn::Card::Direct.create(
@@ -479,10 +501,25 @@
IpAddress: "2001:0620:0000:0000:0211:24FF:FE80:C12C"
)
end
###############################################
+ # pre-authorized direct deposit
+ ###############################################
+
+ def create_new_payin_pre_authorized_deposit_direct(deposit_id, author_id, credited_wallet_id)
+ MangoPay::PayIn::PreAuthorized::Direct.create_pre_authorized_deposit_pay_in(
+ AuthorId: author_id,
+ CreditedWalletId: credited_wallet_id,
+ DebitedFunds: {Currency: 'EUR', Amount: 500},
+ Fees: {Currency: 'EUR', Amount: 0},
+ DepositId: deposit_id,
+ Tag: 'lorem ipsum'
+ )
+ end
+
+ ###############################################
# bankwire/direct
###############################################
let(:new_payin_bankwire_direct) { create_new_payin_bankwire_direct(new_wallet) }
@@ -576,5 +613,59 @@
OwnerName: new_natural_user['FirstName'],
Country: 'LU'
}, new_wallet['Id'])
end
end
+
+
+###############################################
+# deposits
+###############################################
+
+def create_new_deposit(card_registration_id, author_id)
+ MangoPay::Deposit.create(
+ {
+ AuthorId: author_id,
+ DebitedFunds: {Currency: 'EUR', Amount: 1000},
+ CardId: card_registration_id,
+ SecureModeReturnURL: 'http://mangopay-sandbox-test.com',
+ StatementDescriptor: "lorem",
+ Culture: 'FR',
+ IpAddress: "2001:0620:0000:0000:0211:24FF:FE80:C12C",
+ 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"
+ },
+ Billing: {
+ Address: {
+ AddressLine1: 'AddressLine1',
+ AddressLine2: 'AddressLine2',
+ City: 'City',
+ Region: 'Region',
+ PostalCode: 'PostalCode',
+ Country: 'FR'
+ },
+ FirstName: 'Joe',
+ LastName: 'Blogs'
+ },
+ Shipping: {
+ Address: {
+ AddressLine1: 'AddressLine1',
+ AddressLine2: 'AddressLine2',
+ City: 'City',
+ Region: 'Region',
+ PostalCode: 'PostalCode',
+ Country: 'FR'
+ },
+ FirstName: 'Joe',
+ LastName: 'Blogs'
+ }
+ }
+ )
+end
\ No newline at end of file