Skip to content

Commit

Permalink
Merge pull request #223 from Mangopay/feature/google-pay-direct-v2
Browse files Browse the repository at this point in the history
Feature/google pay direct v2
  • Loading branch information
iulian03 committed Jul 7, 2023
2 parents 68b928e + 1c86a37 commit 6ff3eba
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 20 deletions.
4 changes: 2 additions & 2 deletions lib/mangopay.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ def root_url
end

def http_timeout
@http_timeout || 30000
@http_timeout || 30
end

def http_max_retries
@http_max_retries || 1
end

def http_open_timeout
@http_open_timeout || 60000
@http_open_timeout || 30
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/mangopay/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ def initialize(request_url, code, details)
super(message) if message
end

def type; @details['Type']; end
def type; @details['Type'] || @details['type']; end
def error; @details['error']; end
def errors; @details['errors'] || error; end

def message;
if error
msg = error
else
msg = @details['Message']
msg = @details['Message'] || @details['message']
msg += errors.sort.map {|k,v| " #{k}: #{v}"}.join if (errors && errors.is_a?(Hash))
msg
end
Expand Down
2 changes: 1 addition & 1 deletion lib/mangopay/pay_in.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class Direct < Resource
include HTTPCalls::Create

def self.url(*)
"#{MangoPay.api_path}/payins/googlepay/#{CGI.escape(class_name.downcase)}"
"#{MangoPay.api_path}/payins/payment-methods/googlepay"
end
end
end
Expand Down
21 changes: 21 additions & 0 deletions spec/mangopay/payin_googlepay_direct_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
describe MangoPay::PayIn::GooglePay::Direct, type: :feature do
include_context 'payins'

def check_type_and_status(payin)
expect(payin['Type']).to eq('PAYIN')
expect(payin['Nature']).to eq('REGULAR')
expect(payin['PaymentType']).to eq('GOOGLE_PAY')
expect(payin['ExecutionType']).to eq('DIRECT')
expect(payin['Status']).to eq('CREATED')
end

describe 'CREATE' do
it 'creates a googlepay direct payin' do
pending("Cannot be tested due to impossibility to generate payment_data in test")
created = new_payin_googlepay_direct
expect(created['Id']).not_to be_nil
check_type_and_status(created)
end
end
end

53 changes: 38 additions & 15 deletions spec/mangopay/shared_resources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,27 +261,50 @@ def create_new_document(user)
let(:new_payin_googlepay_direct) do
MangoPay::PayIn::GooglePay::Direct.create(
AuthorId: new_natural_user['Id'],
CreditedUserId: new_wallet['Owners'][0],
CreditedWalletId: new_wallet['Id'],
DebitedFunds: {Currency: 'EUR', Amount: 199},
Fees: {Currency: 'EUR', Amount: 1},
PaymentData: {
TransactionId: '061EB32181A2D9CA42AD16031B476EEBAA62A9A095AD660E2759FBA52B51A61',
Network: 'VISA',
TokenData: "tokenData"
},
StatementDescriptor: "ruby",
ReturnURL: MangoPay.configuration.root_url,
Tag: 'Test PayIn/GooglePay/Direct',
IpAddress: "2001:0620:0000:0000:0211:24FF:FE80:C12C",
SecureModeReturnURL: 'http://test.com',
SecureMode: 'DEFAULT',
ReturnURL: 'https://mangopay.com/docs/please-ignore',
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"
},
PaymentData: "{\"signature\":\"MEUCIQCLXOan2Y9DobLVSOeD5V64Peayvz0ZAWisdz/1iTdthAIgVFb4Hve4EhtW81k46SiMlnXLIiCn1h2+vVQGjHe+sSo\\u003d\",\"intermediateSigningKey\":{\"signedKey\":\"{\\\"keyValue\\\":\\\"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEDGRER6R6PH6K39YTIYX+CpDNej6gQgvi/Wx19SOPtiDnkjAl4/LF9pXlvZYe+aJH0Dy095I6BlfY8bNBB5gjPg\\\\u003d\\\\u003d\\\",\\\"keyExpiration\\\":\\\"1688521049102\\\"}\",\"signatures\":[\"MEYCIQDup1B+rkiPAWmpg7RmqY0NfgdGhmdyL8wvAX+6C1aOU2QIhAIZACSDQ/ZexIyEia5KrRlG2B+y3AnKNlhRzumRcnNOR\"]},\"protocolVersion\":\"ECv2\",\"signedMessage\":\"{\\\"encryptedMessage\\\":\\\"YSSGK9yFdKP+mJB5+wAjnOujnThPM1E/KbbJxd3MDzPVI66ip1DBESldvQXYjjeLq6Rf1tKE9oLwwaj6u0/gU7Z9t3g1MoW+9YoEE1bs1IxImif7IQGAosfYjjbBBfDkOaqEs2JJC5qt6xjKO9lQ/E6JPkPFGqF7+OJ1vzmD83Pi3sHWkVge5MhxXQ3yBNhrjus3kV7zUoYA+uqNrciWcWypc1NndF/tiwSkvUTzM6n4dS8X84fkJiSO7PZ65C0yw0mdybRRnyL2fFdWGssve1zZFAvYfzcpNamyuZGGlu/SCoayitojmMsqe5Cu0efD9+WvvDr9PA+Vo1gzuz7LmiZe81SGvdFhRoq62FBAUiwSsi2A3pWinZxM2XbYNph+HJ5FCNspWhz4ur9JG4ZMLemCXuaybvL++W6PWywAtoiE0mQcBIX3vhOq5itv0RkaKVe6nbcAS2UryRz2u/nDCJLKpIv2Wi11NtCUT2mgD8F6qfcXhvVZHyeLqZ1OLgCudTTSdKirzezbgPTg4tQpW++KufeD7bgG+01XhCWt+7/ftqcSf8n//gSRINne8j2G6w+2\\\",\\\"ephemeralPublicKey\\\":\\\"BLY2+R8C0T+BSf/W3HEq305qH63IGmJxMVmbfJ6+x1V7GQg9W9v7eHc3j+8TeypVn+nRlPu98tivuMXECg+rWZs\\\\u003d\\\",\\\"tag\\\":\\\"MmEjNdLfsDNfYd/FRUjoJ4/IfLypNRqx8zgHfa6Ftmo\\\\u003d\\\"}\"}",
Billing: {
Address: {
AddressLine1: 'AddressLine1',
AddressLine2: 'AddressLine2',
City: 'City',
Region: 'Region',
PostalCode: 'PostalCode',
CountryIso: 'FR'
}
FirstName: 'FName',
LastName: 'LName',
Address: {
AddressLine1: 'AddressLine1',
AddressLine2: 'AddressLine2',
City: 'City',
Region: 'Region',
PostalCode: 'PostalCode',
Country: 'FR'
}
},
Shipping: {
FirstName: 'FName',
LastName: 'LName',
Address: {
AddressLine1: 'AddressLine1',
AddressLine2: 'AddressLine2',
City: 'City',
Region: 'Region',
PostalCode: 'PostalCode',
Country: 'FR'
}
}
)
end
Expand Down

0 comments on commit 6ff3eba

Please sign in to comment.