paydunya 1.0.5 → 1.0.6
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 +5 -5
- data/lib/paydunya/checkout/onsite_invoice.rb +16 -34
- data/lib/paydunya/checkout/redirect_invoice.rb +76 -79
- data/lib/paydunya/checkout/store.rb +6 -28
- data/lib/paydunya/checkout.rb +11 -12
- data/lib/paydunya/direct_pay.rb +8 -13
- data/lib/paydunya/setup.rb +11 -39
- data/lib/paydunya/utilities.rb +17 -35
- data/lib/paydunya/version.rb +3 -1
- data/lib/paydunya.rb +10 -10
- metadata +57 -55
- data/.gitignore +0 -19
- data/.travis.yml +0 -7
- data/Gemfile +0 -4
- data/LICENSE.txt +0 -22
- data/Rakefile +0 -9
- data/paydunya.gemspec +0 -25
- data/test/test_paydunya.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 24a9d10ead29f6d4ae0b4bbb81c3c576e1ecabb714149b792403c13b0633bbe5
|
4
|
+
data.tar.gz: 3e8ce40f3180befaef7bfd2cc4ca99e8ae0bfcb0952ad71e049190d49d744977
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e1956671e2303318e5ba6f796e2b0ab56a2547c8220bdb0c47c79cd25af163bbe8cdf149b2425fad1752ad4e73921168719dddeb33ada69690d302d928a94da
|
7
|
+
data.tar.gz: 66738304107e30c2619a2789a1c3cf9707bd64aaa7f4dea648a32af2d23339626d3ba6e7fa11d398392d33d5d39ba65d368dfcef6a6b713a3c58019e1b79928b
|
@@ -1,46 +1,28 @@
|
|
1
1
|
module Paydunya
|
2
2
|
module Onsite
|
3
3
|
class Invoice < Paydunya::Checkout::Invoice
|
4
|
-
|
5
4
|
attr_accessor :invoice_token
|
6
5
|
|
7
|
-
def
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
result = http_json_request(Paydunya::Setup.opr_charge_base_url,payload)
|
18
|
-
|
19
|
-
if result["response_code"] == "00"
|
20
|
-
rebuild_invoice(result["invoice_data"])
|
21
|
-
@response_code = result["response_code"]
|
22
|
-
@response_text = result["response_text"]
|
23
|
-
true
|
24
|
-
else
|
25
|
-
@response_code = result["response_code"]
|
26
|
-
@response_text = result["response_text"]
|
27
|
-
false
|
28
|
-
end
|
6
|
+
def charge(opr_token, confirm_token)
|
7
|
+
result = send_post_request(Paydunya::Setup.opr_charge_base_url, {
|
8
|
+
token: opr_token,
|
9
|
+
confirm_token: confirm_token
|
10
|
+
})
|
11
|
+
rebuild_invoice(result['invoice_data']) if result['response_code'] == '00'
|
12
|
+
@response_code = result['response_code']
|
13
|
+
@response_text = result['response_text']
|
14
|
+
result['response_code'] == '00'
|
29
15
|
end
|
30
16
|
|
31
17
|
def create(account_alias)
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
}
|
39
|
-
|
40
|
-
result = http_json_request(Paydunya::Setup.opr_base_url,payload)
|
18
|
+
result = send_post_request(Paydunya::Setup.opr_base_url, {
|
19
|
+
invoice_data: build_invoice_payload,
|
20
|
+
opr_data: {
|
21
|
+
account_alias: account_alias
|
22
|
+
}
|
23
|
+
})
|
41
24
|
create_response(result)
|
42
25
|
end
|
43
|
-
|
44
26
|
end
|
45
27
|
end
|
46
|
-
end
|
28
|
+
end
|
@@ -1,45 +1,46 @@
|
|
1
1
|
module Paydunya
|
2
2
|
module Checkout
|
3
3
|
class Invoice < Paydunya::Checkout::Core
|
4
|
-
|
5
|
-
|
6
|
-
attr_accessor :customer, :custom_data, :cancel_url, :return_url, :callback_url, :invoice_url, :receipt_url
|
4
|
+
attr_accessor :items, :total_amount, :taxes, :description, :currency, :store, :customer, :custom_data,
|
5
|
+
:cancel_url, :return_url, :callback_url, :invoice_url, :receipt_url, :token
|
7
6
|
|
8
7
|
def initialize
|
8
|
+
super
|
9
9
|
@items = {}
|
10
10
|
@taxes = {}
|
11
11
|
@channels = []
|
12
12
|
@custom_data = {}
|
13
13
|
@customer = {}
|
14
14
|
@total_amount = 0.0
|
15
|
-
@currency =
|
15
|
+
@currency = 'fcfa'
|
16
16
|
@store = Paydunya::Checkout::Store
|
17
17
|
@return_url = @store.return_url
|
18
18
|
@cancel_url = @store.cancel_url
|
19
19
|
@callback_url = @store.callback_url
|
20
|
+
@token = ''
|
20
21
|
end
|
21
22
|
|
22
23
|
# Adds invoice items to the @items hash, the idea is to allow this function to be used in a loop
|
23
|
-
def add_item(name,quantity,unit_price,total_price,description=
|
24
|
+
def add_item(name, quantity, unit_price, total_price, description = '')
|
24
25
|
@items.merge!({
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
26
|
+
"item_#{@items.size}": {
|
27
|
+
name: name,
|
28
|
+
quantity: quantity,
|
29
|
+
unit_price: unit_price,
|
30
|
+
total_price: total_price,
|
31
|
+
description: description
|
32
|
+
}
|
33
|
+
})
|
33
34
|
end
|
34
35
|
|
35
36
|
# Adds invoice tax to the @taxes hash, the idea is to allow this function to be used in a loop
|
36
|
-
def add_tax(name,amount)
|
37
|
+
def add_tax(name, amount)
|
37
38
|
@taxes.merge!({
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
"tax_#{@taxes.size}": {
|
40
|
+
name: name,
|
41
|
+
amount: amount
|
42
|
+
}
|
43
|
+
})
|
43
44
|
end
|
44
45
|
|
45
46
|
def add_channel(channel)
|
@@ -53,108 +54,104 @@ module Paydunya
|
|
53
54
|
end
|
54
55
|
end
|
55
56
|
|
56
|
-
def add_custom_data(key,value)
|
57
|
-
@custom_data[
|
57
|
+
def add_custom_data(key, value)
|
58
|
+
@custom_data[key.to_s] = value
|
58
59
|
end
|
59
60
|
|
60
61
|
def get_items
|
62
|
+
warn '[DEPRECATION] `get_items` is deprecated. Please use `items` instead.'
|
61
63
|
@items
|
62
64
|
end
|
63
65
|
|
64
66
|
def get_taxes
|
67
|
+
warn '[DEPRECATION] `get_taxes` is deprecated. Please use `taxes` instead.'
|
65
68
|
@taxes
|
66
69
|
end
|
67
70
|
|
68
71
|
def get_customer_info(key)
|
69
|
-
|
72
|
+
warn "[DEPRECATION] `get_customer_info(key)` is deprecated. Please use `customer['some_key]` instead."
|
73
|
+
@customer[key.to_s]
|
70
74
|
end
|
71
75
|
|
72
76
|
def get_custom_data(key)
|
73
|
-
|
77
|
+
warn "[DEPRECATION] `get_custom_data(key)` is deprecated. Please use `custom_data['some_key]` instead."
|
78
|
+
@custom_data[key.to_s]
|
74
79
|
end
|
75
80
|
|
76
81
|
def confirm(token)
|
77
|
-
result =
|
82
|
+
result = send_get_request("#{Paydunya::Setup.checkout_confirm_base_url}#{token}")
|
78
83
|
unless result.size > 0
|
79
|
-
@response_text =
|
84
|
+
@response_text = 'Invoice Not Found'
|
80
85
|
@response_code = 1002
|
81
86
|
@status = Paydunya::FAIL
|
82
87
|
return false
|
83
88
|
end
|
84
89
|
|
85
|
-
if result[
|
90
|
+
if result['status'] == 'completed'
|
86
91
|
rebuild_invoice(result)
|
87
|
-
@response_text = result[
|
92
|
+
@response_text = result['response_text']
|
88
93
|
true
|
89
94
|
else
|
90
|
-
@status = result[
|
91
|
-
@items = result[
|
92
|
-
@taxes = result[
|
93
|
-
@description = result[
|
94
|
-
@custom_data = result[
|
95
|
-
@total_amount = result[
|
95
|
+
@status = result['status']
|
96
|
+
@items = result['invoice']['items']
|
97
|
+
@taxes = result['invoice']['taxes']
|
98
|
+
@description = result['invoice']['description']
|
99
|
+
@custom_data = result['custom_data']
|
100
|
+
@total_amount = result['invoice']['total_amount']
|
96
101
|
@response_text = "Invoice status is #{result['status'].upcase}"
|
97
102
|
false
|
98
103
|
end
|
99
104
|
end
|
100
105
|
|
101
106
|
def create
|
102
|
-
result =
|
107
|
+
result = send_post_request(Paydunya::Setup.checkout_base_url, build_invoice_payload)
|
103
108
|
create_response(result)
|
104
109
|
end
|
105
110
|
|
106
111
|
protected
|
112
|
+
|
107
113
|
def build_invoice_payload
|
108
|
-
{ :
|
109
|
-
:
|
110
|
-
:
|
111
|
-
:
|
112
|
-
:
|
113
|
-
:
|
114
|
+
{ invoice: {
|
115
|
+
items: @items,
|
116
|
+
taxes: @taxes,
|
117
|
+
channels: @channels,
|
118
|
+
total_amount: @total_amount,
|
119
|
+
description: description
|
114
120
|
},
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
}
|
121
|
+
store: {
|
122
|
+
name: @store.name,
|
123
|
+
tagline: @store.tagline,
|
124
|
+
postal_address: @store.postal_address,
|
125
|
+
phone: @store.phone_number,
|
126
|
+
logo_url: @store.logo_url,
|
127
|
+
website_url: @store.website_url
|
128
|
+
},
|
129
|
+
custom_data: @custom_data,
|
130
|
+
actions: {
|
131
|
+
cancel_url: @cancel_url,
|
132
|
+
return_url: @return_url,
|
133
|
+
callback_url: @callback_url
|
134
|
+
} }
|
130
135
|
end
|
131
136
|
|
132
|
-
def rebuild_invoice(result={})
|
133
|
-
@status = result[
|
134
|
-
@customer = result[
|
135
|
-
@items = result[
|
136
|
-
@taxes = result[
|
137
|
-
@description = result[
|
138
|
-
@custom_data = result[
|
139
|
-
@total_amount = result[
|
140
|
-
@receipt_url = result[
|
137
|
+
def rebuild_invoice(result = {})
|
138
|
+
@status = result['status']
|
139
|
+
@customer = result['customer']
|
140
|
+
@items = result['invoice']['items']
|
141
|
+
@taxes = result['invoice']['taxes']
|
142
|
+
@description = result['invoice']['description']
|
143
|
+
@custom_data = result['custom_data']
|
144
|
+
@total_amount = result['invoice']['total_amount']
|
145
|
+
@receipt_url = result['receipt_url']
|
141
146
|
end
|
142
147
|
|
143
|
-
def create_response(result={})
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
true
|
151
|
-
else
|
152
|
-
@response_text = result["response_text"]
|
153
|
-
@response_code = result["response_code"]
|
154
|
-
@invoice_url = nil
|
155
|
-
@status = Paydunya::FAIL
|
156
|
-
false
|
157
|
-
end
|
148
|
+
def create_response(result = {})
|
149
|
+
@response_text = result['response_text']
|
150
|
+
@response_code = result['response_code']
|
151
|
+
@status = result['response_code'] == '00' ? Paydunya::SUCCESS : Paydunya::FAIL
|
152
|
+
@invoice_url = result['response_code'] == '00' ? (result['invoice_token'] || result['response_text']) : nil
|
153
|
+
@token = result['token']
|
154
|
+
result['response_code'] == '00'
|
158
155
|
end
|
159
156
|
end
|
160
157
|
end
|
@@ -1,34 +1,12 @@
|
|
1
1
|
module Paydunya
|
2
2
|
module Checkout
|
3
3
|
module Store
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
@@website_url = nil
|
9
|
-
@@logo_url = nil
|
10
|
-
@@cancel_url = nil
|
11
|
-
@@return_url = nil
|
12
|
-
@@callback_url = nil
|
4
|
+
class << self
|
5
|
+
attr_accessor :name, :tagline, :postal_address, :phone_number,
|
6
|
+
:website_url, :logo_url, :cancel_url, :return_url, :callback_url
|
7
|
+
end
|
13
8
|
|
14
|
-
|
15
|
-
def self.name; @@name; end
|
16
|
-
def self.tagline=(tagline); @@tagline = tagline; end
|
17
|
-
def self.tagline; @@tagline; end
|
18
|
-
def self.postal_address=(postal_address); @@postal_address = postal_address; end
|
19
|
-
def self.postal_address; @@postal_address; end
|
20
|
-
def self.phone_number=(phone_number); @@phone_number = phone_number; end
|
21
|
-
def self.phone_number; @@phone_number; end
|
22
|
-
def self.website_url=(website_url); @@website_url = website_url; end
|
23
|
-
def self.website_url; @@website_url; end
|
24
|
-
def self.logo_url=(logo_url); @@logo_url = logo_url; end
|
25
|
-
def self.logo_url; @@logo_url; end
|
26
|
-
def self.cancel_url=(cancel_url); @@cancel_url = cancel_url; end
|
27
|
-
def self.cancel_url; @@cancel_url; end
|
28
|
-
def self.return_url=(return_url); @@return_url = return_url; end
|
29
|
-
def self.return_url; @@return_url; end
|
30
|
-
def self.callback_url=(callback_url); @@callback_url = callback_url; end
|
31
|
-
def self.callback_url; @@callback_url; end
|
9
|
+
self.name = 'Untitled Store'
|
32
10
|
end
|
33
11
|
end
|
34
|
-
end
|
12
|
+
end
|
data/lib/paydunya/checkout.rb
CHANGED
@@ -4,22 +4,21 @@ module Paydunya
|
|
4
4
|
include Paydunya::Utilities
|
5
5
|
attr_accessor :status, :response_text, :response_code, :transaction_id, :description, :token, :result
|
6
6
|
|
7
|
-
def push_results(result={})
|
7
|
+
def push_results(result = {})
|
8
8
|
@result = result
|
9
|
-
@transaction_id = result[
|
10
|
-
@description = result[
|
11
|
-
@response_code = result[
|
12
|
-
@response_text = result[
|
13
|
-
@token = result[
|
14
|
-
@response_code ==
|
9
|
+
@transaction_id = result['transaction_id']
|
10
|
+
@description = result['description']
|
11
|
+
@response_code = result['response_code']
|
12
|
+
@response_text = result['response_text']
|
13
|
+
@token = result['token']
|
14
|
+
@status = @response_code == '00' ? Paydunya::SUCCESS : Paydunya::FAIL
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
%w
|
21
|
-
|
22
|
-
|
23
|
-
).each do |lib|
|
20
|
+
%w[checkout/redirect_invoice
|
21
|
+
checkout/onsite_invoice
|
22
|
+
checkout/store].each do |lib|
|
24
23
|
require File.join(File.dirname(__FILE__), lib)
|
25
|
-
end
|
24
|
+
end
|
data/lib/paydunya/direct_pay.rb
CHANGED
@@ -1,20 +1,15 @@
|
|
1
1
|
module Paydunya
|
2
2
|
class DirectPay < Paydunya::Checkout::Core
|
3
|
-
|
4
|
-
def credit_account(payee_account,amount)
|
3
|
+
def credit_account(account_alias, amount, withdraw_mode = nil)
|
5
4
|
payload = {
|
6
|
-
:account_alias
|
7
|
-
:
|
5
|
+
account_alias: account_alias,
|
6
|
+
amount: amount,
|
7
|
+
withdraw_mode: withdraw_mode
|
8
8
|
}
|
9
9
|
|
10
|
-
result =
|
11
|
-
|
12
|
-
|
13
|
-
true
|
14
|
-
else
|
15
|
-
push_results(result)
|
16
|
-
false
|
17
|
-
end
|
10
|
+
result = send_post_request(Paydunya::Setup.direct_pay_credit_base_url, payload)
|
11
|
+
push_results(result)
|
12
|
+
result['response_code'] == '00'
|
18
13
|
end
|
19
14
|
end
|
20
|
-
end
|
15
|
+
end
|
data/lib/paydunya/setup.rb
CHANGED
@@ -1,59 +1,31 @@
|
|
1
1
|
module Paydunya
|
2
2
|
module Setup
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
@@token = nil
|
7
|
-
@@mode = "test"
|
8
|
-
|
9
|
-
ROOT_URL_BASE = "https://app.paydunya.com"
|
10
|
-
|
11
|
-
LIVE_CHECKOUT_INVOICE_BASE_URL = "#{ROOT_URL_BASE}/api/v1/checkout-invoice/create"
|
12
|
-
TEST_CHECKOUT_INVOICE_BASE_URL = "#{ROOT_URL_BASE}/sandbox-api/v1/checkout-invoice/create"
|
13
|
-
|
14
|
-
LIVE_CHECKOUT_CONFIRM_BASE_URL = "#{ROOT_URL_BASE}/api/v1/checkout-invoice/confirm/"
|
15
|
-
TEST_CHECKOUT_CONFIRM_BASE_URL = "#{ROOT_URL_BASE}/sandbox-api/v1/checkout-invoice/confirm/"
|
16
|
-
|
17
|
-
LIVE_OPR_BASE_URL = "#{ROOT_URL_BASE}/api/v1/opr/create"
|
18
|
-
TEST_OPR_BASE_URL = "#{ROOT_URL_BASE}/sandbox-api/v1/opr/create"
|
19
|
-
|
20
|
-
LIVE_OPR_CHARGE_BASE_URL = "#{ROOT_URL_BASE}/api/v1/opr/charge"
|
21
|
-
TEST_OPR_CHARGE_BASE_URL = "#{ROOT_URL_BASE}/sandbox-api/v1/opr/charge"
|
22
|
-
|
23
|
-
LIVE_DIRECT_PAY_CREDIT_BASE_URL = "#{ROOT_URL_BASE}/api/v1/direct-pay/credit-account"
|
24
|
-
TEST_DIRECT_PAY_CREDIT_BASE_URL = "#{ROOT_URL_BASE}/sandbox-api/v1/direct-pay/credit-account"
|
3
|
+
class << self
|
4
|
+
attr_accessor :root_url, :master_key, :private_key, :public_key, :token, :mode
|
5
|
+
end
|
25
6
|
|
26
|
-
|
27
|
-
def self.master_key; @@master_key; end
|
28
|
-
def self.private_key=(private_key); @@private_key = private_key; end
|
29
|
-
def self.private_key; @@private_key; end
|
30
|
-
def self.public_key=(public_key); @@public_key = public_key; end
|
31
|
-
def self.public_key; @@public_key; end
|
32
|
-
def self.token=(token); @@token = token; end
|
33
|
-
def self.token; @@token; end
|
7
|
+
self.root_url = 'https://app.paydunya.com'
|
34
8
|
|
35
|
-
|
36
|
-
def self.mode; @@mode; end
|
9
|
+
self.mode = 'test'
|
37
10
|
|
38
11
|
def self.checkout_base_url
|
39
|
-
|
12
|
+
"#{mode == 'live' ? '/api' : '/sandbox-api'}/v1/checkout-invoice/create"
|
40
13
|
end
|
41
14
|
|
42
15
|
def self.checkout_confirm_base_url
|
43
|
-
|
16
|
+
"#{mode == 'live' ? '/api' : '/sandbox-api'}/v1/checkout-invoice/confirm/"
|
44
17
|
end
|
45
18
|
|
46
19
|
def self.opr_base_url
|
47
|
-
|
20
|
+
"#{mode == 'live' ? '/api' : '/sandbox-api'}/v1/opr/create"
|
48
21
|
end
|
49
22
|
|
50
23
|
def self.opr_charge_base_url
|
51
|
-
|
24
|
+
"#{mode == 'live' ? '/api' : '/sandbox-api'}/v1/opr/charge"
|
52
25
|
end
|
53
26
|
|
54
27
|
def self.direct_pay_credit_base_url
|
55
|
-
|
28
|
+
"#{mode == 'live' ? '/api' : '/sandbox-api'}/v1/direct-pay/credit-account"
|
56
29
|
end
|
57
|
-
|
58
30
|
end
|
59
|
-
end
|
31
|
+
end
|
data/lib/paydunya/utilities.rb
CHANGED
@@ -1,44 +1,26 @@
|
|
1
1
|
module Paydunya
|
2
2
|
module Utilities
|
3
|
-
def http_json_request(baseurl,payload={})
|
4
|
-
conn = Faraday.new(:url => baseurl, :ssl => {:verify => false}) do |faraday|
|
5
|
-
faraday.request :json
|
6
|
-
faraday.adapter Faraday.default_adapter
|
7
|
-
end
|
8
3
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
4
|
+
def connection
|
5
|
+
Faraday.new(url: Paydunya::Setup.root_url,
|
6
|
+
ssl: { verify: false },
|
7
|
+
headers: {
|
8
|
+
'Content-Type' => 'application/json',
|
9
|
+
'User-Agent' => 'Paydunya Checkout API Ruby client v1 aka Neptune',
|
10
|
+
'PAYDUNYA-PUBLIC-KEY' => Paydunya::Setup.public_key,
|
11
|
+
'PAYDUNYA-PRIVATE-KEY' => Paydunya::Setup.private_key,
|
12
|
+
'PAYDUNYA-MASTER-KEY' => Paydunya::Setup.master_key,
|
13
|
+
'PAYDUNYA-TOKEN' => Paydunya::Setup.token,
|
14
|
+
'PAYDUNYA-MODE' => Paydunya::Setup.mode
|
15
|
+
})
|
19
16
|
end
|
20
17
|
|
21
|
-
def
|
22
|
-
|
23
|
-
|
24
|
-
result = conn.get do |req|
|
25
|
-
req.headers["User-Agent"] = "Paydunya Checkout API Ruby client v1 aka Neptune"
|
26
|
-
req.headers['PAYDUNYA-PUBLIC-KEY'] = Paydunya::Setup.public_key
|
27
|
-
req.headers['PAYDUNYA-PRIVATE-KEY'] = Paydunya::Setup.private_key
|
28
|
-
req.headers['PAYDUNYA-MASTER-KEY'] = Paydunya::Setup.master_key
|
29
|
-
req.headers['PAYDUNYA-TOKEN'] = Paydunya::Setup.token
|
30
|
-
req.headers['PAYDUNYA-MODE'] = Paydunya::Setup.mode
|
31
|
-
end
|
32
|
-
|
33
|
-
json_to_hash(result.body)
|
34
|
-
end
|
35
|
-
|
36
|
-
def hash_to_json(params={})
|
37
|
-
MultiJson.dump params
|
18
|
+
def send_post_request(url, payload = {})
|
19
|
+
JSON.parse connection.post(url, payload.to_json).body
|
38
20
|
end
|
39
21
|
|
40
|
-
def
|
41
|
-
|
22
|
+
def send_get_request(url, params = nil)
|
23
|
+
JSON.parse connection.get(url, params).body
|
42
24
|
end
|
43
25
|
end
|
44
|
-
end
|
26
|
+
end
|
data/lib/paydunya/version.rb
CHANGED
data/lib/paydunya.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'faraday'
|
3
|
-
require '
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require "paydunya/direct_pay"
|
4
|
+
require 'paydunya/version'
|
5
|
+
require 'paydunya/setup'
|
6
|
+
require 'paydunya/utilities'
|
7
|
+
require 'paydunya/checkout'
|
8
|
+
require 'paydunya/direct_pay'
|
9
9
|
|
10
10
|
module Paydunya
|
11
|
-
SUCCESS =
|
12
|
-
FAIL =
|
13
|
-
PENDING =
|
11
|
+
SUCCESS = 'success'
|
12
|
+
FAIL = 'fail'
|
13
|
+
PENDING = 'pending'
|
14
14
|
end
|
metadata
CHANGED
@@ -1,109 +1,119 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paydunya
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PAYDUNYA
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: faraday
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.4'
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 1.
|
22
|
+
version: 1.4.2
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '1.
|
29
|
+
version: '1.4'
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 1.
|
32
|
+
version: 1.4.2
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
34
|
+
name: awesome_print
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - "~>"
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '1.10'
|
40
37
|
- - ">="
|
41
38
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
43
|
-
type: :
|
39
|
+
version: '0'
|
40
|
+
type: :development
|
44
41
|
prerelease: false
|
45
42
|
version_requirements: !ruby/object:Gem::Requirement
|
46
43
|
requirements:
|
47
|
-
- - "~>"
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: '1.10'
|
50
44
|
- - ">="
|
51
45
|
- !ruby/object:Gem::Version
|
52
|
-
version:
|
46
|
+
version: '0'
|
53
47
|
- !ruby/object:Gem::Dependency
|
54
|
-
name:
|
48
|
+
name: guard-rspec
|
55
49
|
requirement: !ruby/object:Gem::Requirement
|
56
50
|
requirements:
|
57
|
-
- - "
|
51
|
+
- - ">="
|
58
52
|
- !ruby/object:Gem::Version
|
59
|
-
version: 0
|
60
|
-
type: :
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
61
55
|
prerelease: false
|
62
56
|
version_requirements: !ruby/object:Gem::Requirement
|
63
57
|
requirements:
|
64
|
-
- - "
|
58
|
+
- - ">="
|
65
59
|
- !ruby/object:Gem::Version
|
66
|
-
version: 0
|
60
|
+
version: '0'
|
67
61
|
- !ruby/object:Gem::Dependency
|
68
|
-
name:
|
62
|
+
name: rake
|
69
63
|
requirement: !ruby/object:Gem::Requirement
|
70
64
|
requirements:
|
71
|
-
- - "~>"
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
version: '0.9'
|
74
65
|
- - ">="
|
75
66
|
- !ruby/object:Gem::Version
|
76
|
-
version: 0
|
77
|
-
type: :
|
67
|
+
version: '0'
|
68
|
+
type: :development
|
78
69
|
prerelease: false
|
79
70
|
version_requirements: !ruby/object:Gem::Requirement
|
80
71
|
requirements:
|
81
|
-
- - "~>"
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
version: '0.9'
|
84
72
|
- - ">="
|
85
73
|
- !ruby/object:Gem::Version
|
86
|
-
version: 0
|
74
|
+
version: '0'
|
87
75
|
- !ruby/object:Gem::Dependency
|
88
|
-
name:
|
76
|
+
name: rspec
|
89
77
|
requirement: !ruby/object:Gem::Requirement
|
90
78
|
requirements:
|
91
|
-
- - "
|
79
|
+
- - ">="
|
92
80
|
- !ruby/object:Gem::Version
|
93
|
-
version: '
|
81
|
+
version: '0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
94
86
|
- - ">="
|
95
87
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
88
|
+
version: '0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: simplecov
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
97
96
|
type: :development
|
98
97
|
prerelease: false
|
99
98
|
version_requirements: !ruby/object:Gem::Requirement
|
100
99
|
requirements:
|
101
|
-
- - "
|
100
|
+
- - ">="
|
102
101
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
102
|
+
version: '0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: webmock
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
104
107
|
- - ">="
|
105
108
|
- !ruby/object:Gem::Version
|
106
|
-
version:
|
109
|
+
version: '0'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
107
117
|
description: Ruby library for integrating with the PAYDUNYA Gateway
|
108
118
|
email:
|
109
119
|
- paydunya@paydunya.com
|
@@ -111,12 +121,7 @@ executables: []
|
|
111
121
|
extensions: []
|
112
122
|
extra_rdoc_files: []
|
113
123
|
files:
|
114
|
-
- ".gitignore"
|
115
|
-
- ".travis.yml"
|
116
|
-
- Gemfile
|
117
|
-
- LICENSE.txt
|
118
124
|
- README.md
|
119
|
-
- Rakefile
|
120
125
|
- lib/paydunya.rb
|
121
126
|
- lib/paydunya/checkout.rb
|
122
127
|
- lib/paydunya/checkout/onsite_invoice.rb
|
@@ -126,10 +131,9 @@ files:
|
|
126
131
|
- lib/paydunya/setup.rb
|
127
132
|
- lib/paydunya/utilities.rb
|
128
133
|
- lib/paydunya/version.rb
|
129
|
-
- paydunya.gemspec
|
130
|
-
- test/test_paydunya.rb
|
131
134
|
homepage: https://paydunya.com/developers/ruby
|
132
|
-
licenses:
|
135
|
+
licenses:
|
136
|
+
- MIT
|
133
137
|
metadata: {}
|
134
138
|
post_install_message: |-
|
135
139
|
Thanks for installing PAYDUNYA Ruby client.
|
@@ -141,17 +145,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
141
145
|
requirements:
|
142
146
|
- - ">="
|
143
147
|
- !ruby/object:Gem::Version
|
144
|
-
version: '0'
|
148
|
+
version: '3.0'
|
145
149
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
150
|
requirements:
|
147
151
|
- - ">="
|
148
152
|
- !ruby/object:Gem::Version
|
149
153
|
version: '0'
|
150
154
|
requirements: []
|
151
|
-
|
152
|
-
|
153
|
-
signing_key:
|
155
|
+
rubygems_version: 3.2.15
|
156
|
+
signing_key:
|
154
157
|
specification_version: 4
|
155
158
|
summary: Ruby client bindings for the PAYDUNYA API
|
156
|
-
test_files:
|
157
|
-
- test/test_paydunya.rb
|
159
|
+
test_files: []
|
data/.gitignore
DELETED
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/LICENSE.txt
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2015 PAYDUNYA
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
DELETED
data/paydunya.gemspec
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'paydunya/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |gem|
|
7
|
-
gem.name = "paydunya"
|
8
|
-
gem.version = Paydunya::VERSION
|
9
|
-
gem.author = "PAYDUNYA"
|
10
|
-
gem.email = ["paydunya@paydunya.com"]
|
11
|
-
gem.description = %q{Ruby library for integrating with the PAYDUNYA Gateway}
|
12
|
-
gem.summary = %q{Ruby client bindings for the PAYDUNYA API}
|
13
|
-
gem.homepage = "https://paydunya.com/developers/ruby"
|
14
|
-
gem.post_install_message = "Thanks for installing PAYDUNYA Ruby client.\nYou may read full API docs at https://paydunya.com/developers/ruby"
|
15
|
-
|
16
|
-
gem.files = `git ls-files`.split($/)
|
17
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
-
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
|
-
gem.require_paths = ["lib"]
|
20
|
-
gem.add_dependency('rest-client', '~> 1.7', '>= 1.7.2')
|
21
|
-
gem.add_dependency('multi_json', '~> 1.10', '>= 1.10.1')
|
22
|
-
gem.add_dependency('faraday','~> 0.9.0')
|
23
|
-
gem.add_dependency('faraday_middleware','~> 0.9', '>= 0.9.1')
|
24
|
-
gem.add_development_dependency('rake', '~> 10.2', '>= 10.2.2')
|
25
|
-
end
|
data/test/test_paydunya.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'paydunya'
|
3
|
-
|
4
|
-
class TestPaydunya < Test::Unit::TestCase
|
5
|
-
def test_checkout_invoice_items
|
6
|
-
invoice = Paydunya::Checkout::Invoice.new
|
7
|
-
invoice.add_item("Article 1", 1, 1000, 1000, "Description optionnelle")
|
8
|
-
invoice.add_item("Article 2", 5, 5000, 25000)
|
9
|
-
invoice.total_amount = 26000
|
10
|
-
invoice.description = "Unit::Test Invoice from Ruby lang"
|
11
|
-
assert_instance_of(Hash, invoice.get_items)
|
12
|
-
assert_equal(2, invoice.get_items.size)
|
13
|
-
assert_instance_of(Hash, invoice.get_items[:item_0])
|
14
|
-
assert_equal(5, invoice.get_items[:item_0].size)
|
15
|
-
end
|
16
|
-
end
|