transact_pro 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +10 -3
- data/lib/transact_pro/request.rb +12 -2
- data/lib/transact_pro/request_specs.rb +11 -1
- data/lib/transact_pro/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e0af839e8839922430d553e7e220075ba9374cb
|
4
|
+
data.tar.gz: e6c2999131f36cc1560b2d22e397800375a1202f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c55a5fa322591602ca3cddc1ece2cd62bf9e473b7c02af6f52cae1a70c217d1b7d60d40a2313e4d93b6f7e02733cccdb93eba45f5754d3c2d6fb6c886fe26855
|
7
|
+
data.tar.gz: 611f31f00ff8ffb80af259252e13ae96d8b8ff550cddc6fcbe92eeffb65ead3e10a55ff39f048362c9722da03e2bcef90051bb6d24ceb83573561f50789b339f
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -50,7 +50,10 @@ gem 'transact_pro'
|
|
50
50
|
The gem implements `gateway`, `request` and `response` objects that handle communication with the remote API for you.
|
51
51
|
All communication is done synchroniously and without failsafes, so if something goes wrong during the remote request (HTTP timeout etc.), you get the raw error and get to handle it.
|
52
52
|
|
53
|
-
|
53
|
+
Consult `lib/transact_pro/request_specs.rb` for details
|
54
|
+
on what parameters the various requests expect.
|
55
|
+
|
56
|
+
Please note that in this gem all configuration option hash keys are constant-case symbols like `:GUID` whereas all parameter keys for requests to the API are snake-case symbols like `:merchant_transaction_id`. Make sure all values are `String`s.
|
54
57
|
|
55
58
|
### 1. `TransactPro::Gateway`
|
56
59
|
|
@@ -81,6 +84,9 @@ options = {
|
|
81
84
|
}
|
82
85
|
|
83
86
|
gateway = TransactPro::Gateway.new(options)
|
87
|
+
|
88
|
+
# Access an initialized gateway instance's underlying options, for example
|
89
|
+
gateway.options[:HOSTED_FIELDS_JS_URI] # for HostedFields
|
84
90
|
```
|
85
91
|
|
86
92
|
### 2. `TransactPro::Request`
|
@@ -90,6 +96,8 @@ Use the `Gateway` instance's `#request` method to build and perform requests.
|
|
90
96
|
```rb
|
91
97
|
options = {
|
92
98
|
method: :status_request, # mandatory, exclusively symbol objects for value
|
99
|
+
# + request parameters from `lib/transact_pro/request_specs.rb`
|
100
|
+
|
93
101
|
request_type: 'transaction_status',
|
94
102
|
init_transaction_id: "abc123",
|
95
103
|
# Note that passing :guid and :pwd is possible and `#call` will always override
|
@@ -103,9 +111,8 @@ options = {
|
|
103
111
|
}
|
104
112
|
|
105
113
|
request_instance = gateway.request(options)
|
114
|
+
request_instance.details #=> {url: "...", params: {...}} # see what will be POSTed to where
|
106
115
|
request_instance.call #=> response
|
107
|
-
|
108
|
-
# TransactPro::Request instances also have #to_s method to inspect what parameters are used in the request.
|
109
116
|
```
|
110
117
|
|
111
118
|
### 3. `TransactPro::Response`
|
data/lib/transact_pro/request.rb
CHANGED
@@ -25,6 +25,16 @@ class TransactPro::Request
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def call
|
28
|
+
# does prep
|
29
|
+
details
|
30
|
+
|
31
|
+
@raw_response = RestClient.post(@url, @postable_params)
|
32
|
+
@response = TransactPro::Response.new(@raw_response.to_s)
|
33
|
+
end
|
34
|
+
|
35
|
+
def details
|
36
|
+
return @details if defined?(@details)
|
37
|
+
|
28
38
|
@defaults ||= TransactPro::RequestSpecs.const_get(
|
29
39
|
"#{method.to_s.upcase}_DEFAULTS"
|
30
40
|
)
|
@@ -58,11 +68,11 @@ class TransactPro::Request
|
|
58
68
|
|
59
69
|
@url = "#{@request_options[:API_URI]}?a=#{sendable_method}"
|
60
70
|
|
61
|
-
@
|
62
|
-
@response = TransactPro::Response.new(@raw_response.to_s)
|
71
|
+
@details = {url: @url, params: @postable_params}
|
63
72
|
end
|
64
73
|
|
65
74
|
private
|
75
|
+
|
66
76
|
def validate(key, string, regex)
|
67
77
|
unless string[regex]
|
68
78
|
raise TransactPro::Request::ValidationError.new(
|
@@ -40,6 +40,7 @@ module TransactPro
|
|
40
40
|
BIN_PHONE = %r'\A[0-9\-_]{3,25}\z' # ns(3..25)
|
41
41
|
MERCHANT_SITE_URL = %r'\A.{1,255}\z' # ans(1..255)
|
42
42
|
MERCHANT_REFERRING_NAME = %r'\A.{1,21}\z' # ans(1..21)
|
43
|
+
BACK_URL = %r'\A.{1,255}\z' # ans(1..255)
|
43
44
|
F_EXTENDED = %r'\A\d+\z' # n
|
44
45
|
|
45
46
|
# 10. Table
|
@@ -72,7 +73,10 @@ module TransactPro
|
|
72
73
|
# merchant_site_url ans(1..255) Purchase site URL.
|
73
74
|
# merchant_referring_name ans(1..21) Must not be send by default. See chapter 3.5 for description if you need
|
74
75
|
# to use it.
|
76
|
+
# custom_return_url ans(1..255) Custom return URL
|
77
|
+
# custom_callback_url ans(1..255) Custom callback URL
|
75
78
|
INIT_SPEC = {
|
79
|
+
# method: :init
|
76
80
|
guid: {mandatory: true, format: GUID_REGEX},
|
77
81
|
pwd: {mandatory: true, format: PASSWORD_DIGEST_REGEX},
|
78
82
|
rs: {mandatory: true, format: ROUTING_REGEX},
|
@@ -93,7 +97,9 @@ module TransactPro
|
|
93
97
|
bin_name: {mandatory: false, format: BIN_NAME},
|
94
98
|
bin_phone: {mandatory: false, format: BIN_PHONE},
|
95
99
|
merchant_site_url: {mandatory: true, format: MERCHANT_SITE_URL},
|
96
|
-
merchant_referring_name: {mandatory: false, format: MERCHANT_REFERRING_NAME}
|
100
|
+
merchant_referring_name: {mandatory: false, format: MERCHANT_REFERRING_NAME},
|
101
|
+
custom_return_url: {mandatory: false, format: BACK_URL},
|
102
|
+
custom_callback_url: {mandatory: false, format: BACK_URL}
|
97
103
|
}.freeze
|
98
104
|
|
99
105
|
INIT_DEFAULTS = {
|
@@ -103,6 +109,7 @@ module TransactPro
|
|
103
109
|
}.freeze
|
104
110
|
|
105
111
|
INIT_RECURRING_REGISTRATION_SPEC = INIT_SPEC.
|
112
|
+
# method: :init_recurring_registration
|
106
113
|
dup.merge(save_card: {mandatory: true, format: %r'\d+'}).freeze
|
107
114
|
INIT_RECURRING_REGISTRATION_DEFAULTS = INIT_DEFAULTS.
|
108
115
|
dup.merge(save_card: "1").freeze
|
@@ -117,6 +124,7 @@ module TransactPro
|
|
117
124
|
# amount n Transaction amount, in MINOR units (i.e. 2150 for $21.50 transaction)
|
118
125
|
# description uns(5..255) Order items description
|
119
126
|
INIT_RECURRENT_SPEC = {
|
127
|
+
# method: :init_recurrent
|
120
128
|
guid: {mandatory: true, format: GUID_REGEX},
|
121
129
|
pwd: {mandatory: true, format: PASSWORD_DIGEST_REGEX},
|
122
130
|
rs: {mandatory: true, format: ROUTING_REGEX},
|
@@ -135,6 +143,7 @@ module TransactPro
|
|
135
143
|
# init_transaction_id h(40) init_transaction_id received for this recurrent transaction
|
136
144
|
# f_extended n Return extended charge details (optional)
|
137
145
|
CHARGE_RECURRENT_SPEC = {
|
146
|
+
# method: :charge_recurrent
|
138
147
|
guid: {mandatory: true, format: GUID_REGEX},
|
139
148
|
pwd: {mandatory: true, format: PASSWORD_DIGEST_REGEX},
|
140
149
|
init_transaction_id: {mandatory: true, format: TID_REGEX},
|
@@ -154,6 +163,7 @@ module TransactPro
|
|
154
163
|
# guid ans(19) Your GUID
|
155
164
|
# pwd h(40) SHA1 hash of your processing password
|
156
165
|
STATUS_REQUEST_SPEC = {
|
166
|
+
# method: :status_request
|
157
167
|
guid: {mandatory: true, format: GUID_REGEX},
|
158
168
|
pwd: {mandatory: true, format: PASSWORD_DIGEST_REGEX},
|
159
169
|
request_type: {mandatory: true, format: 'transaction_status'},
|
data/lib/transact_pro/version.rb
CHANGED