leetchi-wallet-services 1.1.1 → 1.2.0
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 +4 -4
- data/README.md +31 -0
- data/lib/leetchi-wallet-services.rb +1 -0
- data/lib/leetchi/immediate_contribution.rb +58 -0
- data/spec/lib/leetchi/immediate_contribution_spec.rb +72 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc26d8921bea8df356743fd0fd2d534aeec418f3
|
4
|
+
data.tar.gz: f638468690d921ae8da932cfda227b041c2b67af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 168fdd1a1ff9d42d472f7bd8a5f2457582433952a2df45e1d5d3842adde53e40f7b46884b7519161e2f063f14cea9c3031c4dc4614e3f7721237c388feb9851f
|
7
|
+
data.tar.gz: e04e4459f75772ed4b36b9832559199848a94fb5882afa79da4ab3803330a75095d9950a1583bf562e0a1c90950a73bc08f27a4dfc7aae23a05d36d1302af933
|
data/README.md
CHANGED
@@ -93,3 +93,34 @@ Make sure that you have run: ```bundle install```
|
|
93
93
|
Then you just have to run the rake task ```rake test``` to run all the test suite.
|
94
94
|
Feel free to report any test failure by creating an issue on the [Gem's Github](https://github.com/Leetchi/leetchi-api-ruby-sdk/issues)
|
95
95
|
|
96
|
+
## Contributing
|
97
|
+
|
98
|
+
1. Fork the repo.
|
99
|
+
|
100
|
+
2. Run the tests. We only take pull requests with passing tests, and it's great
|
101
|
+
to know that you have a clean slate: `bundle && bundle exec rake`
|
102
|
+
|
103
|
+
3. Add a test for your change. Only refactoring and documentation changes
|
104
|
+
require no new tests. If you are adding functionality or fixing a bug, we need
|
105
|
+
a test!
|
106
|
+
|
107
|
+
4. Make the test pass.
|
108
|
+
|
109
|
+
5. Push to your fork and submit a pull request.
|
110
|
+
|
111
|
+
At this point you're waiting on us. We like to at least comment on, if not
|
112
|
+
accept, pull requests within three business days (and, typically, one business
|
113
|
+
day). We may suggest some changes or improvements or alternatives.
|
114
|
+
|
115
|
+
Syntax:
|
116
|
+
|
117
|
+
* Two spaces, no tabs.
|
118
|
+
* No trailing whitespace. Blank lines should not have any space.
|
119
|
+
* Prefer &&/|| over and/or.
|
120
|
+
* MyClass.my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
|
121
|
+
* a = b and not a=b.
|
122
|
+
* Follow the conventions you see used in the source already.
|
123
|
+
|
124
|
+
A contribution can also be as simple as a +1 on issues tickets to show us what you would like to see in this gem.
|
125
|
+
|
126
|
+
That's it for now. Good Hacking...
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Leetchi
|
2
|
+
# An immediate contribution is a request to process directly a payment with a payment card already registred by the user.
|
3
|
+
class ImmediateContribution < Leetchi::Ressource
|
4
|
+
|
5
|
+
# Create an immediate contribution
|
6
|
+
#
|
7
|
+
# * *Args* :
|
8
|
+
# - +data+ -> A JSON with the following attributes (Square brackets for optionals):
|
9
|
+
# * [Tag]
|
10
|
+
# * UserID
|
11
|
+
# * WalletID
|
12
|
+
# * Amount
|
13
|
+
# * PaymentCardID
|
14
|
+
# * [ClientFeeAmount]
|
15
|
+
# * *Returns* :
|
16
|
+
# - An immediate contribution object
|
17
|
+
#
|
18
|
+
def self.create(data)
|
19
|
+
post_request('immediate-contributions', data)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Get an immediate contribution
|
23
|
+
#
|
24
|
+
# * *Args* :
|
25
|
+
# - +immediate_contribution_id+ -> The id of the immediate contribution you want to retrieve
|
26
|
+
# * *Returns* :
|
27
|
+
# - An immediate contribution object
|
28
|
+
#
|
29
|
+
def self.details(immediate_contribution_id)
|
30
|
+
get_request(File.join('immediate-contributions', immediate_contribution_id.to_s))
|
31
|
+
end
|
32
|
+
|
33
|
+
# Refund a given immediate contribution
|
34
|
+
#
|
35
|
+
# * *Args* :
|
36
|
+
# - +data+ -> A JSON with the following attributes (Square brackets for optionals):
|
37
|
+
# * [Tag]
|
38
|
+
# * ImmediateContributionID
|
39
|
+
# * UserID
|
40
|
+
# * *Returns* :
|
41
|
+
# - A refund object
|
42
|
+
#
|
43
|
+
def self.refund(data)
|
44
|
+
post_request(File.join('refunds'), data)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Get a refund object
|
48
|
+
#
|
49
|
+
# * *Args* :
|
50
|
+
# - +immediate_contribution_refund_id+ -> The id of the refund you want to retrieve
|
51
|
+
# * *Returns* :
|
52
|
+
# - A refund object
|
53
|
+
#
|
54
|
+
def self.get_refund(immediate_contribution_refund_id)
|
55
|
+
get_request(File.join('refunds', immediate_contribution_refund_id.to_s))
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
describe Leetchi::ImmediateContribution, :type => :feature do
|
4
|
+
|
5
|
+
let(:new_user) {
|
6
|
+
Leetchi::User.create({
|
7
|
+
'Tag' => 'test',
|
8
|
+
'Email' => 'my@email.com',
|
9
|
+
'FirstName' => 'John',
|
10
|
+
'LastName' => 'Doe',
|
11
|
+
'CanRegisterMeanOfPayment' => true
|
12
|
+
})
|
13
|
+
}
|
14
|
+
|
15
|
+
let(:new_immediate_contribution) do
|
16
|
+
contribution = Leetchi::Contribution.create({
|
17
|
+
'Tag' => 'test_contribution',
|
18
|
+
'UserID' => new_user['ID'],
|
19
|
+
'WalletID' => 0,
|
20
|
+
'Amount' => 10000,
|
21
|
+
'ReturnURL' => 'https://leetchi.com',
|
22
|
+
'RegisterMeanOfPayment' => true
|
23
|
+
})
|
24
|
+
visit(contribution['PaymentURL'])
|
25
|
+
fill_in('number', :with => '4970100000000154')
|
26
|
+
fill_in('cvv', :with => '123')
|
27
|
+
click_button('paybutton')
|
28
|
+
contribution = Leetchi::Contribution.details(contribution['ID'])
|
29
|
+
while contribution["IsSucceeded"] == false do
|
30
|
+
contribution = Leetchi::Contribution.details(contribution['ID'])
|
31
|
+
end
|
32
|
+
payment_card_id = contribution['PaymentCardID']
|
33
|
+
Leetchi::ImmediateContribution.create({
|
34
|
+
'Tag' => 'test_contribution',
|
35
|
+
'UserID' => new_user['ID'],
|
36
|
+
'PaymentCardID' => payment_card_id,
|
37
|
+
'WalletID' => 0,
|
38
|
+
'Amount' => 33300
|
39
|
+
})
|
40
|
+
end
|
41
|
+
|
42
|
+
let(:new_immediate_contribution_refund) {
|
43
|
+
Leetchi::ImmediateContribution.refund({
|
44
|
+
'ContributionID' => new_immediate_contribution['ID'],
|
45
|
+
'UserID' => new_user['ID'],
|
46
|
+
'Tag' => 'test_immediate_contribution_refund'
|
47
|
+
})
|
48
|
+
}
|
49
|
+
|
50
|
+
describe "CREATE" do
|
51
|
+
it "creates an immediate contribution" do
|
52
|
+
expect(new_immediate_contribution['ID']).not_to be_nil
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "GET" do
|
57
|
+
it "get the immediate contribution" do
|
58
|
+
immediate_contribution = Leetchi::ImmediateContribution.details(new_immediate_contribution['ID'])
|
59
|
+
expect(immediate_contribution['ID']).to eq(new_immediate_contribution['ID'])
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "REFUND" do
|
64
|
+
it "creates a refund request for the immediate contribution" do
|
65
|
+
expect(new_immediate_contribution_refund['ID']).not_to be_nil
|
66
|
+
end
|
67
|
+
it "gets the refund request" do
|
68
|
+
immediate_contribution_refund = Leetchi::ImmediateContribution.get_refund(new_immediate_contribution_refund['ID'])
|
69
|
+
expect(immediate_contribution_refund['ID']).to eq(new_immediate_contribution_refund['ID'])
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leetchi-wallet-services
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Geoffroy Lorieux
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -151,6 +151,7 @@ files:
|
|
151
151
|
- lib/leetchi/card.rb
|
152
152
|
- lib/leetchi/contribution.rb
|
153
153
|
- lib/leetchi/expense.rb
|
154
|
+
- lib/leetchi/immediate_contribution.rb
|
154
155
|
- lib/leetchi/operation.rb
|
155
156
|
- lib/leetchi/recurrent_contribution.rb
|
156
157
|
- lib/leetchi/ressource.rb
|
@@ -176,6 +177,7 @@ files:
|
|
176
177
|
- spec/lib/leetchi/card_spec.rb
|
177
178
|
- spec/lib/leetchi/contribution_spec.rb
|
178
179
|
- spec/lib/leetchi/expense_spec.rb
|
180
|
+
- spec/lib/leetchi/immediate_contribution_spec.rb
|
179
181
|
- spec/lib/leetchi/operation_spec.rb
|
180
182
|
- spec/lib/leetchi/recurrent_contribution_spec.rb
|
181
183
|
- spec/lib/leetchi/ressource_spec.rb
|