mangopay 3.0.4 → 3.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b879f9e9eef6c3ab9eb34eee2903775e4b03d4b5
4
- data.tar.gz: 992fbe12c90c33b124b87d370c154e73d615159a
3
+ metadata.gz: c28334dab15cfdac4d4f1453a6fcddb7c7dc8f0c
4
+ data.tar.gz: 20ffe961fbf98c8851b2b0d139e020bf30375d23
5
5
  SHA512:
6
- metadata.gz: 1e1a16abe97bc05d4197151b8efcde440190e01db0bc83bd48769242d2b9be7dce54083bb38060790cbeda21e71febe14faa1dce6cc8720175a7c041c4ce65ce
7
- data.tar.gz: a1050afd747cadd2603d9f31082ecfdb24882c9518b454c528feac11578717fb8e7cddfac21c926cdc23d75fb4f8a2eb0f487036bce978f3223895204a3f3fa9
6
+ metadata.gz: 76006200d9346883f6fc15a8747a4d1f2e0b6409e54eefeeed3cb9b5672cf9a599a7fab87944b396f1e5961094ed61113bb27822aeab819de580cffc5aef9bb2
7
+ data.tar.gz: 649ed785f090b45a3215b6e9d5e9cb4e2b52eb8de3335561be4a9b3eb8d1356e7275ad3eecd53f374155576dc41ab089c0fc0cb9b22f0f5b834c8f1b174fc418
data/README.md CHANGED
@@ -1,3 +1,9 @@
1
+ #### ***
2
+ THE MANGOPAY V2 IS NOT RELEASED YET.
3
+
4
+ PLEASE USE THE V1 API FOR NOW: https://github.com/MangoPay/mangopay-ruby-sdk
5
+ ####***
6
+
1
7
  # MangoPay2 Ruby SDK
2
8
 
3
9
  The gem for interacting with the version 2 of the MangoPay API.
data/lib/mangopay.rb CHANGED
@@ -23,6 +23,8 @@ require 'mangopay/wallet'
23
23
  require 'mangopay/bank_account'
24
24
  require 'mangopay/card_registration'
25
25
  require 'mangopay/card'
26
+ require 'mangopay/event'
27
+ require 'mangopay/kyc_document'
26
28
 
27
29
  module MangoPay
28
30
 
@@ -36,7 +38,7 @@ module MangoPay
36
38
  end
37
39
 
38
40
  def root_url
39
- @root_url || (@preproduction == true ? "https://api-preprod.mangopay.com" : "https://api.mangopay.com")
41
+ @root_url || (@preproduction == true ? "https://api.sandbox.mangopay.com" : "https://api.mangopay.com")
40
42
  end
41
43
  end
42
44
 
@@ -66,7 +68,7 @@ module MangoPay
66
68
  def self.request(method, url, params={}, filters={}, headers = request_headers, before_request_proc = nil)
67
69
  uri = api_uri(url)
68
70
  uri.query = URI.encode_www_form(filters) unless filters.empty?
69
-
71
+
70
72
  res = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
71
73
  req = Net::HTTP::const_get(method.capitalize).new(uri.request_uri, headers)
72
74
  req.body = MangoPay::JSON.dump(params)
@@ -81,7 +83,17 @@ module MangoPay
81
83
  data = {}
82
84
  end
83
85
 
84
- raise MangoPay::ResponseError.new(uri, res.code, data) unless res.is_a? Net::HTTPOK
86
+ ############### TEMP!!!! #######################################################
87
+ #pp method, uri.request_uri, params #, filters, headers
88
+ #pp res, data
89
+ #puts
90
+
91
+ if (!(res.is_a? Net::HTTPOK))
92
+ ex = MangoPay::ResponseError.new(uri, res.code, data)
93
+ ############## TEMP!!!! ########################################################
94
+ #pp ex, data
95
+ raise ex
96
+ end
85
97
 
86
98
  # copy pagination info if any
87
99
  ['x-number-of-pages', 'x-number-of-items'].each { |k|
@@ -0,0 +1,16 @@
1
+ module MangoPay
2
+ class Event < Resource
3
+
4
+ # Fetches list of events (PayIns, PayOuts, Transfers).
5
+ #
6
+ # Optional +filters+ is a hash accepting following keys:
7
+ # - +page+, +per_page+: pagination params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
8
+ # - +EventType+: {PAYIN_NORMAL_CREATED, PAYIN_NORMAL_SUCCEEDED, PAYIN_NORMAL_FAILED etc...} (see http://docs.mangopay.com/api-references/events/)
9
+ # - +BeforeDate+ (timestamp): filters events with Date _before_ this date
10
+ # - +AfterDate+ (timestamp): filters events with Date _after_ this date
11
+ #
12
+ def self.fetch(filters={})
13
+ MangoPay.request(:get, url(), {}, filters)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,49 @@
1
+ require 'base64'
2
+
3
+ module MangoPay
4
+ class KycDocument < Resource
5
+
6
+ def self.create(user_id, params)
7
+ MangoPay.request(:post, url(user_id), params)
8
+ end
9
+
10
+ def self.update(user_id, document_id, params = {})
11
+ MangoPay.request(:put, url(user_id, document_id), params)
12
+ end
13
+
14
+ def self.fetch(user_id, document_id)
15
+ MangoPay.request(:get, url(user_id, document_id))
16
+ end
17
+
18
+ # Adds the file page (attachment) to the given document.
19
+ #
20
+ # See http://docs.mangopay.com/api-references/kyc/pages/ :
21
+ # - Document have to be in 'CREATED' Status
22
+ # - You can create as many pages as needed
23
+ # - Change Status to 'VALIDATION_ASKED' to submit KYC documents
24
+ #
25
+ # The file_or_base64 param may be:
26
+ # - either a File instance
27
+ # - or a string: in this case it has to be Base64 encoded!
28
+ #
29
+ def self.create_page(user_id, document_id, file_or_base64)
30
+ base64 = (file_or_base64.is_a? File) ? Base64.encode64(file_or_base64.read) : file_or_base64;
31
+ # normally it returns 204 HTTP code on success
32
+ begin
33
+ MangoPay.request(:post, url(user_id, document_id) + '/pages', {'File' => base64})
34
+ rescue MangoPay::ResponseError => ex
35
+ raise ex unless ex.code == '204'
36
+ end
37
+ end
38
+
39
+ private
40
+
41
+ def self.url(user_id, document_id = nil)
42
+ if document_id
43
+ "/v2/#{MangoPay.configuration.client_id}/users/#{CGI.escape(user_id.to_s)}/KYC/documents/#{CGI.escape(document_id.to_s)}"
44
+ else
45
+ "/v2/#{MangoPay.configuration.client_id}/users/#{CGI.escape(user_id.to_s)}/KYC/documents"
46
+ end
47
+ end
48
+ end
49
+ end
@@ -1,26 +1,25 @@
1
- module MangoPay
2
- class Transaction < Resource
3
- include MangoPay::HTTPCalls::Fetch
4
-
5
- # Fetches list of transactions belonging to the given +wallet_id+.
6
- #
7
- # Optional +filters+ is a hash accepting following keys:
8
- # - +page+, +per_page+: pagination params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
9
- # - +Status+: TransactionStatus {CREATED, SUCCEEDED, FAILED}
10
- # - +Type+: TransactionType {PAYIN, PAYOUT, TRANSFER}
11
- # - +Nature+: TransactionNature {NORMAL, REFUND, REPUDIATION}
12
- # - +Direction+: TransactionDirection {DEBIT, CREDIT}
13
- # - +BeforeDate+ (timestamp): filters transactions with CreationDate _before_ this date
14
- # - +AfterDate+ (timestamp): filters transactions with CreationDate _after_ this date
15
- #
16
- def self.fetch(wallet_id, filters={})
17
- MangoPay.request(:get, url(wallet_id), {}, filters)
18
- end
19
-
20
- private
21
-
22
- def self.url(wallet_id)
23
- "/v2/#{MangoPay.configuration.client_id}/wallets/#{CGI.escape(wallet_id.to_s)}/transactions"
24
- end
25
- end
26
- end
1
+ module MangoPay
2
+ class Transaction < Resource
3
+
4
+ # Fetches list of transactions belonging to the given +wallet_id+.
5
+ #
6
+ # Optional +filters+ is a hash accepting following keys:
7
+ # - +page+, +per_page+: pagination params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
8
+ # - +Status+: TransactionStatus {CREATED, SUCCEEDED, FAILED}
9
+ # - +Type+: TransactionType {PAYIN, PAYOUT, TRANSFER}
10
+ # - +Nature+: TransactionNature {NORMAL, REFUND, REPUDIATION}
11
+ # - +Direction+: TransactionDirection {DEBIT, CREDIT}
12
+ # - +BeforeDate+ (timestamp): filters transactions with CreationDate _before_ this date
13
+ # - +AfterDate+ (timestamp): filters transactions with CreationDate _after_ this date
14
+ #
15
+ def self.fetch(wallet_id, filters={})
16
+ MangoPay.request(:get, url(wallet_id), {}, filters)
17
+ end
18
+
19
+ private
20
+
21
+ def self.url(wallet_id)
22
+ "/v2/#{MangoPay.configuration.client_id}/wallets/#{CGI.escape(wallet_id.to_s)}/transactions"
23
+ end
24
+ end
25
+ end
@@ -1,3 +1,3 @@
1
1
  module MangoPay
2
- VERSION = '3.0.4'
2
+ VERSION = '3.0.5'
3
3
  end
data/mangopay.gemspec CHANGED
@@ -8,12 +8,12 @@ Gem::Specification.new do |s|
8
8
  s.summary = "Ruby bindings for the version 2 of the MangoPay API"
9
9
  s.description = <<-EOF
10
10
  The mangopay Gem makes interacting with MangoPay Services much easier.
11
- For any questions regarding the use of MangoPay's Services feel free to contact us at http://www.mangopay.com/contact-us/
12
- You can find more documentation about MangoPay Services at http://www.mangopay.com/
11
+ For any questions regarding the use of MangoPay's Services feel free to contact us at http://www.mangopay.com/get-started-2/
12
+ You can find more documentation about MangoPay Services at http://docs.mangopay.com/
13
13
  EOF
14
- s.authors = ['Geoffroy Lorieux']
14
+ s.authors = ['Geoffroy Lorieux', 'Sergiusz Woznicki']
15
15
  s.email = 'it-support@mangopay.com'
16
- s.homepage = 'http://www.mangopay.com/'
16
+ s.homepage = 'http://docs.mangopay.com/'
17
17
  s.license = 'MIT'
18
18
 
19
19
  s.required_ruby_version = '>= 1.9.2'
@@ -0,0 +1,33 @@
1
+ require_relative '../../spec_helper'
2
+
3
+ describe MangoPay::Event do
4
+
5
+ include_context 'payins'
6
+ include_context 'payouts'
7
+
8
+ describe 'FETCH' do
9
+
10
+ it 'accepts filtering params' do
11
+
12
+ # let's have at least 2 events
13
+ payin = new_payin_card_direct
14
+ payout = create_new_payout_bankwire(payin)
15
+
16
+ # get all
17
+ events = MangoPay::Event.fetch()
18
+ expect(events).to be_kind_of(Array)
19
+ expect(events.count).to be >= 2
20
+
21
+ # only one per page
22
+ events = MangoPay::Event.fetch({'per_page' => 1})
23
+ expect(events).to be_kind_of(Array)
24
+ expect(events.count).to eq 1
25
+
26
+ # filter by date
27
+ events = MangoPay::Event.fetch({'AfterDate' => payin['CreationDate'], 'BeforeDate' => payin['CreationDate']})
28
+ expect(events).to be_kind_of(Array)
29
+ expect(events.count).to be >= 1
30
+ expect(events.count {|e| e['RessourceId'] == payin['Id']}).to be >= 1
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,60 @@
1
+ require_relative '../../spec_helper'
2
+
3
+ describe MangoPay::KycDocument do
4
+ include_context 'kyc_documents'
5
+
6
+ describe 'CREATE' do
7
+ it 'creates a document' do
8
+ expect(new_document['Id']).to_not be_nil
9
+ expect(new_document['Type']).to eq('IDENTITY_PROOF')
10
+ expect(new_document['Status']).to eq('CREATED')
11
+ expect(new_document['RefusedReasonType']).to be_nil
12
+ expect(new_document['RefusedReasonMessage']).to be_nil
13
+ end
14
+ end
15
+
16
+ describe 'UPDATE' do
17
+ it 'updates a document' do
18
+ updated_document = MangoPay::KycDocument.update(new_natural_user['Id'], new_document['Id'], {
19
+ Status: 'VALIDATION_ASKED'
20
+ })
21
+ expect(updated_document['Id']).to eq(new_document['Id'])
22
+ expect(updated_document['Status']).to eq('VALIDATION_ASKED')
23
+ end
24
+ end
25
+
26
+ describe 'FETCH' do
27
+ it 'fetches a document' do
28
+ document = MangoPay::KycDocument.fetch(new_natural_user['Id'], new_document['Id'])
29
+ expect(document['Id']).to eq(new_document['Id'])
30
+ end
31
+ end
32
+
33
+ describe 'CREATE PAGE' do
34
+
35
+ def create_page(file)
36
+ MangoPay::KycDocument.create_page(new_natural_user['Id'], new_document['Id'], file)
37
+ end
38
+
39
+ it 'accepts File instance' do
40
+ file = File.open(__FILE__)
41
+ ret = create_page(file)
42
+ expect(ret).to be_nil
43
+ end
44
+
45
+ it 'accepts base64-encoded string' do
46
+ file = Base64.encode64('any file content...')
47
+ ret = create_page(file)
48
+ expect(ret).to be_nil
49
+ end
50
+
51
+ it 'fails when input string is not base64-encoded' do
52
+ file = 'any file content...'
53
+ expect { create_page(file) }.to raise_error { |err|
54
+ err.should be_a MangoPay::ResponseError
55
+ err.code.should eq '400'
56
+ err.type.should eq 'param_error'
57
+ }
58
+ end
59
+ end
60
+ end
@@ -1,70 +1,70 @@
1
- require_relative '../../spec_helper'
2
-
3
- describe MangoPay::PayIn::Card::Direct, type: :feature do
4
- include_context 'wallets'
5
- include_context 'payins'
6
-
7
- def check_type_and_status(payin)
8
- expect(payin['Type']).to eq('PAYIN')
9
- expect(payin['Nature']).to eq('REGULAR')
10
- expect(payin['PaymentType']).to eq('CARD')
11
- expect(payin['ExecutionType']).to eq('DIRECT')
12
-
13
- # SUCCEEDED
14
- expect(payin['Status']).to eq('SUCCEEDED')
15
- expect(payin['ResultCode']).to eq('000000')
16
- expect(payin['ResultMessage']).to eq('Success')
17
- expect(payin['ExecutionDate']).to be > 0
18
- end
19
-
20
- describe 'CREATE' do
21
- it 'creates a card direct payin' do
22
- created = new_payin_card_direct
23
- expect(created['Id']).not_to be_nil
24
- check_type_and_status(created)
25
- end
26
- end
27
-
28
- describe 'FETCH' do
29
- it 'fetches a payin' do
30
- created = new_payin_card_direct
31
- fetched = MangoPay::PayIn.fetch(created['Id'])
32
- expect(fetched['Id']).to eq(created['Id'])
33
- expect(fetched['CreationDate']).to eq(created['CreationDate'])
34
- expect(fetched['CreditedFunds']).to eq(created['CreditedFunds'])
35
- expect(fetched['CreditedWalletId']).to eq(created['CreditedWalletId'])
36
- check_type_and_status(created)
37
- check_type_and_status(fetched)
38
- end
39
- end
40
-
41
- describe 'REFUND' do
42
- it 'refunds a payin' do
43
- payin = new_payin_card_direct
44
- refund = MangoPay::PayIn.refund(payin['Id'], {AuthorId: payin['AuthorId']})
45
- expect(refund['Id']).not_to be_nil
46
- expect(refund['Status']).to eq('SUCCEEDED')
47
- expect(refund['Type']).to eq('PAYOUT')
48
- expect(refund['Nature']).to eq('REFUND')
49
- expect(refund['InitialTransactionType']).to eq('PAYIN')
50
- expect(refund['InitialTransactionId']).to eq(payin['Id'])
51
- expect(refund['DebitedWalletId']).to eq(payin['CreditedWalletId'])
52
- end
53
- end
54
-
55
- describe 'CASH FLOW' do
56
- it 'changes balances correctly' do
57
- wlt = new_wallet
58
- wallets_check_amounts(wlt, 0)
59
-
60
- # payin: feed wlt1 with money
61
- payin = create_new_payin_card_direct(wlt, 1000)
62
- wallets_reload_and_check_amounts(wlt, 1000)
63
-
64
- # refund the payin
65
- refund = MangoPay::PayIn.refund(payin['Id'], {AuthorId: payin['AuthorId']})
66
- wallets_reload_and_check_amounts(wlt, 0)
67
- end
68
- end
69
-
70
- end
1
+ require_relative '../../spec_helper'
2
+
3
+ describe MangoPay::PayIn::Card::Direct, type: :feature do
4
+ include_context 'wallets'
5
+ include_context 'payins'
6
+
7
+ def check_type_and_status(payin)
8
+ expect(payin['Type']).to eq('PAYIN')
9
+ expect(payin['Nature']).to eq('REGULAR')
10
+ expect(payin['PaymentType']).to eq('CARD')
11
+ expect(payin['ExecutionType']).to eq('DIRECT')
12
+
13
+ # SUCCEEDED
14
+ expect(payin['Status']).to eq('SUCCEEDED')
15
+ expect(payin['ResultCode']).to eq('000000')
16
+ expect(payin['ResultMessage']).to eq('Success')
17
+ expect(payin['ExecutionDate']).to be > 0
18
+ end
19
+
20
+ describe 'CREATE' do
21
+ it 'creates a card direct payin' do
22
+ created = new_payin_card_direct
23
+ expect(created['Id']).not_to be_nil
24
+ check_type_and_status(created)
25
+ end
26
+ end
27
+
28
+ describe 'FETCH' do
29
+ it 'fetches a payin' do
30
+ created = new_payin_card_direct
31
+ fetched = MangoPay::PayIn.fetch(created['Id'])
32
+ expect(fetched['Id']).to eq(created['Id'])
33
+ expect(fetched['CreationDate']).to eq(created['CreationDate'])
34
+ expect(fetched['CreditedFunds']).to eq(created['CreditedFunds'])
35
+ expect(fetched['CreditedWalletId']).to eq(created['CreditedWalletId'])
36
+ check_type_and_status(created)
37
+ check_type_and_status(fetched)
38
+ end
39
+ end
40
+
41
+ describe 'REFUND' do
42
+ it 'refunds a payin' do
43
+ payin = new_payin_card_direct
44
+ refund = MangoPay::PayIn.refund(payin['Id'], {AuthorId: payin['AuthorId']})
45
+ expect(refund['Id']).not_to be_nil
46
+ expect(refund['Status']).to eq('SUCCEEDED')
47
+ expect(refund['Type']).to eq('PAYOUT')
48
+ expect(refund['Nature']).to eq('REFUND')
49
+ expect(refund['InitialTransactionType']).to eq('PAYIN')
50
+ expect(refund['InitialTransactionId']).to eq(payin['Id'])
51
+ expect(refund['DebitedWalletId']).to eq(payin['CreditedWalletId'])
52
+ end
53
+ end
54
+
55
+ describe 'CASH FLOW' do
56
+ it 'changes balances correctly' do
57
+ wlt = new_wallet
58
+ wallets_check_amounts(wlt, 0)
59
+
60
+ # payin: feed wlt1 with money
61
+ payin = create_new_payin_card_direct(wlt, 1000)
62
+ wallets_reload_and_check_amounts(wlt, 1000)
63
+
64
+ # refund the payin
65
+ refund = MangoPay::PayIn.refund(payin['Id'], {AuthorId: payin['AuthorId']})
66
+ wallets_reload_and_check_amounts(wlt, 0)
67
+ end
68
+ end
69
+
70
+ end
@@ -40,13 +40,16 @@ describe MangoPay::PayIn::Card::Web, type: :feature do
40
40
  describe 'REFUND' do
41
41
  it 'refunds a payin' do
42
42
  payin = new_payin_card_web
43
- expect {
44
- MangoPay::PayIn.refund(payin['Id'], {AuthorId: payin['AuthorId']})
45
- }.to raise_error { |err|
46
- err.should be_a MangoPay::ResponseError
47
- err.type.should eq 'other'
48
- err.message.should eq "Impossible to refund the transaction, can't have negative amount."
49
- }
43
+ refund = MangoPay::PayIn.refund(payin['Id'], {AuthorId: payin['AuthorId']})
44
+ expect(refund['Id']).not_to be_nil
45
+ expect(refund['Type']).to eq('PAYOUT')
46
+ expect(refund['Nature']).to eq('REFUND')
47
+ expect(refund['InitialTransactionType']).to eq('PAYIN')
48
+ expect(refund['InitialTransactionId']).to eq(payin['Id'])
49
+ expect(refund['DebitedWalletId']).to eq(payin['CreditedWalletId'])
50
+ expect(refund['Status']).to eq('FAILED')
51
+ expect(refund['ResultCode']).to eq('001001')
52
+ expect(refund['ResultMessage']).to eq('Unsufficient wallet balance')
50
53
  end
51
54
  end
52
55
 
@@ -1,55 +1,56 @@
1
- require_relative '../../spec_helper'
2
-
3
- describe MangoPay::PayOut::BankWire, type: :feature do
4
- include_context 'bank_accounts'
5
- include_context 'payins'
6
- include_context 'payouts'
7
-
8
- def check_type_and_status(payout)
9
- expect(payout['Type']).to eq('PAYOUT')
10
- expect(payout['Nature']).to eq('REGULAR')
11
- expect(payout['PaymentType']).to eq('BANK_WIRE')
12
-
13
- # linked to correct bank account
14
- expect(payout['BankAccountId']).to eq(new_bank_account['Id'])
15
-
16
- # not SUCCEEDED yet: waiting for processing
17
- expect(payout['Status']).to eq('CREATED')
18
- expect(payout['ResultCode']).to be_nil
19
- expect(payout['ResultMessage']).to be_nil
20
- expect(payout['ExecutionDate']).to be_nil
21
- end
22
-
23
- describe 'CREATE' do
24
-
25
- it 'creates a bank wire payout' do
26
- payin = new_payin_card_direct # this payin is successfull so payout may happen
27
- payout = create_new_payout_bankwire(payin)
28
- expect(payout['Id']).not_to be_nil
29
- check_type_and_status(payout)
30
- expect(payout['DebitedWalletId']).to eq(payin['CreditedWalletId'])
31
- end
32
-
33
- it 'fails if not enough money' do
34
- payin = new_payin_card_web # this payin is NOT processed yet so payout may NOT happen
35
- expect {
36
- create_new_payout_bankwire(payin)
37
- }.to raise_error { |err|
38
- err.should be_a MangoPay::ResponseError
39
- err.type.should eq 'other'
40
- }
41
- end
42
- end
43
-
44
- describe 'FETCH' do
45
- it 'fetches a payout' do
46
- created = new_payout_bankwire
47
- fetched = MangoPay::PayOut.fetch(created['Id'])
48
- expect(fetched['Id']).to eq(created['Id'])
49
- expect(fetched['CreationDate']).to eq(created['CreationDate'])
50
- check_type_and_status(created)
51
- check_type_and_status(fetched)
52
- end
53
- end
54
-
55
- end
1
+ require_relative '../../spec_helper'
2
+
3
+ describe MangoPay::PayOut::BankWire, type: :feature do
4
+ include_context 'bank_accounts'
5
+ include_context 'payins'
6
+ include_context 'payouts'
7
+
8
+ def check_type_and_status(payout, check_status = true)
9
+ expect(payout['Type']).to eq('PAYOUT')
10
+ expect(payout['Nature']).to eq('REGULAR')
11
+ expect(payout['PaymentType']).to eq('BANK_WIRE')
12
+ expect(payout['ExecutionDate']).to be_nil
13
+
14
+ # linked to correct bank account
15
+ expect(payout['BankAccountId']).to eq(new_bank_account['Id'])
16
+
17
+ if (check_status)
18
+ # not SUCCEEDED yet: waiting for processing
19
+ expect(payout['Status']).to eq('CREATED')
20
+ expect(payout['ResultCode']).to be_nil
21
+ expect(payout['ResultMessage']).to be_nil
22
+ end
23
+ end
24
+
25
+ describe 'CREATE' do
26
+
27
+ it 'creates a bank wire payout' do
28
+ payin = new_payin_card_direct # this payin is successfull so payout may happen
29
+ payout = create_new_payout_bankwire(payin)
30
+ expect(payout['Id']).not_to be_nil
31
+ check_type_and_status(payout)
32
+ expect(payout['DebitedWalletId']).to eq(payin['CreditedWalletId'])
33
+ end
34
+
35
+ it 'fails if not enough money' do
36
+ payin = new_payin_card_web # this payin is NOT processed yet so payout may NOT happen
37
+ payout = create_new_payout_bankwire(payin)
38
+ check_type_and_status(payout, false)
39
+ expect(payout['Status']).to eq('FAILED')
40
+ expect(payout['ResultCode']).to eq('001001')
41
+ expect(payout['ResultMessage']).to eq('Unsufficient wallet balance')
42
+ end
43
+ end
44
+
45
+ describe 'FETCH' do
46
+ it 'fetches a payout' do
47
+ created = new_payout_bankwire
48
+ fetched = MangoPay::PayOut.fetch(created['Id'])
49
+ expect(fetched['Id']).to eq(created['Id'])
50
+ expect(fetched['CreationDate']).to eq(created['CreationDate'])
51
+ check_type_and_status(created)
52
+ check_type_and_status(fetched)
53
+ end
54
+ end
55
+
56
+ end
@@ -40,7 +40,7 @@ shared_context 'users' do
40
40
  FirstName: 'John',
41
41
  LastName: 'Doe',
42
42
  Address: 'Here',
43
- Birthday: '',
43
+ Birthday: 1300186358,
44
44
  Birthplace: 'Paris',
45
45
  Nationality: 'FR',
46
46
  CountryOfResidence: 'FR',
@@ -52,13 +52,14 @@ shared_context 'users' do
52
52
  let(:new_legal_user) {
53
53
  MangoPay::LegalUser.create({
54
54
  Name: 'Super',
55
+ Email: 'super@email.com',
55
56
  LegalPersonType: 'BUSINESS',
56
57
  HeadquartersAddress: 'Here',
57
58
  LegalRepresentativeFirstName: 'John',
58
59
  LegalRepresentativeLastName: 'Doe',
59
60
  LegalRepresentativeAdress: 'Here',
60
61
  LegalRepresentativeEmail: 'john@doe.com',
61
- LegalRepresentativeBirthday: '',
62
+ LegalRepresentativeBirthday: 1300186358,
62
63
  LegalRepresentativeNationality: 'FR',
63
64
  LegalRepresentativeCountryOfResidence: 'FR',
64
65
  Statute: '',
@@ -113,6 +114,19 @@ shared_context 'bank_accounts' do
113
114
  }
114
115
  end
115
116
 
117
+ ###############################################
118
+ shared_context 'kyc_documents' do
119
+ ###############################################
120
+ include_context 'users'
121
+
122
+ let(:new_document) {
123
+ MangoPay::KycDocument.create(new_natural_user['Id'], {
124
+ Type: 'IDENTITY_PROOF',
125
+ Tag: 'Test document'
126
+ })
127
+ }
128
+ end
129
+
116
130
  ###############################################
117
131
  shared_context 'payins' do
118
132
  ###############################################
@@ -157,10 +171,14 @@ shared_context 'payins' do
157
171
  data = {
158
172
  data: cardreg['PreregistrationData'],
159
173
  accessKeyRef: cardreg['AccessKey'],
160
- cardNumber: 4970101122334406,
174
+ cardNumber: 4970100000000154,
161
175
  cardExpirationDate: 1214,
162
176
  cardCvx: 123}
163
177
  res = Net::HTTP.post_form(URI(cardreg['CardRegistrationURL']), data)
178
+ ############### TEMP!!!! #######################################################
179
+ #pp :post, cardreg['CardRegistrationURL'], data
180
+ #pp res, res.body
181
+ #puts
164
182
  raise Exception, [res, res.body] unless (res.is_a?(Net::HTTPOK) && res.body.start_with?('data='))
165
183
  cardreg['RegistrationData'] = res.body
166
184
 
data/spec/spec_helper.rb CHANGED
@@ -1,20 +1,20 @@
1
- require_relative '../lib/mangopay'
2
- require_relative './lib/mangopay/shared_resources'
3
-
4
- require 'capybara/rspec'
5
- require 'capybara-webkit'
6
- require 'fileutils'
7
- require 'pp'
8
-
9
- Capybara.default_driver = :webkit
10
-
11
- def reset_mangopay_configuration
12
- MangoPay.configure do |c|
13
- c.preproduction = true
14
- c.client_id = 'example'
15
- c.client_passphrase = 'uyWsmnwMQyTnqKgi8Y35A3eVB7bGhqrebYqA1tL6x2vYNpGPiY'
16
- c.temp_dir = File.expand_path('../tmp', __FILE__)
17
- FileUtils.mkdir_p(c.temp_dir) unless File.directory?(c.temp_dir)
18
- end
19
- end
20
- reset_mangopay_configuration
1
+ require_relative '../lib/mangopay'
2
+ require_relative './lib/mangopay/shared_resources'
3
+
4
+ require 'capybara/rspec'
5
+ require 'capybara-webkit'
6
+ require 'fileutils'
7
+ require 'pp'
8
+
9
+ Capybara.default_driver = :webkit
10
+
11
+ def reset_mangopay_configuration
12
+ MangoPay.configure do |c|
13
+ c.preproduction = true
14
+ c.client_id = 'sdk-unit-tests'
15
+ c.client_passphrase = 'cqFfFrWfCcb7UadHNxx2C9Lo6Djw8ZduLi7J9USTmu8bhxxpju'
16
+ c.temp_dir = File.expand_path('../tmp', __FILE__)
17
+ FileUtils.mkdir_p(c.temp_dir) unless File.directory?(c.temp_dir)
18
+ end
19
+ end
20
+ reset_mangopay_configuration
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mangopay
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.4
4
+ version: 3.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geoffroy Lorieux
8
+ - Sergiusz Woznicki
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-09-26 00:00:00.000000000 Z
12
+ date: 2013-11-20 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: multi_json
@@ -96,8 +97,8 @@ dependencies:
96
97
  version: 4.0.0
97
98
  description: |2
98
99
  The mangopay Gem makes interacting with MangoPay Services much easier.
99
- For any questions regarding the use of MangoPay's Services feel free to contact us at http://www.mangopay.com/contact-us/
100
- You can find more documentation about MangoPay Services at http://www.mangopay.com/
100
+ For any questions regarding the use of MangoPay's Services feel free to contact us at http://www.mangopay.com/get-started-2/
101
+ You can find more documentation about MangoPay Services at http://docs.mangopay.com/
101
102
  email: it-support@mangopay.com
102
103
  executables:
103
104
  - mangopay
@@ -119,8 +120,10 @@ files:
119
120
  - lib/mangopay/card_registration.rb
120
121
  - lib/mangopay/client.rb
121
122
  - lib/mangopay/errors.rb
123
+ - lib/mangopay/event.rb
122
124
  - lib/mangopay/http_calls.rb
123
125
  - lib/mangopay/json.rb
126
+ - lib/mangopay/kyc_document.rb
124
127
  - lib/mangopay/legal_user.rb
125
128
  - lib/mangopay/natural_user.rb
126
129
  - lib/mangopay/payin.rb
@@ -137,7 +140,9 @@ files:
137
140
  - spec/lib/mangopay/card_registration_spec.rb
138
141
  - spec/lib/mangopay/client_spec.rb
139
142
  - spec/lib/mangopay/configuration_spec.rb
143
+ - spec/lib/mangopay/event_spec.rb
140
144
  - spec/lib/mangopay/fetch_filters_spec.rb
145
+ - spec/lib/mangopay/kyc_document_spec.rb
141
146
  - spec/lib/mangopay/payin_card_direct_spec.rb
142
147
  - spec/lib/mangopay/payin_card_web_spec.rb
143
148
  - spec/lib/mangopay/payout_bankwire_spec.rb
@@ -148,7 +153,7 @@ files:
148
153
  - spec/lib/mangopay/wallet_spec.rb
149
154
  - spec/spec_helper.rb
150
155
  - spec/tmp/.keep
151
- homepage: http://www.mangopay.com/
156
+ homepage: http://docs.mangopay.com/
152
157
  licenses:
153
158
  - MIT
154
159
  metadata: {}
@@ -178,7 +183,9 @@ test_files:
178
183
  - spec/lib/mangopay/card_registration_spec.rb
179
184
  - spec/lib/mangopay/client_spec.rb
180
185
  - spec/lib/mangopay/configuration_spec.rb
186
+ - spec/lib/mangopay/event_spec.rb
181
187
  - spec/lib/mangopay/fetch_filters_spec.rb
188
+ - spec/lib/mangopay/kyc_document_spec.rb
182
189
  - spec/lib/mangopay/payin_card_direct_spec.rb
183
190
  - spec/lib/mangopay/payin_card_web_spec.rb
184
191
  - spec/lib/mangopay/payout_bankwire_spec.rb