paytrace 0.1.13 → 0.1.14
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/lib/paytrace/api/fields.rb +30 -0
- data/lib/paytrace/api/gateway.rb +2 -2
- data/lib/paytrace/api/request.rb +30 -7
- data/lib/paytrace/configuration.rb +18 -0
- data/lib/paytrace/debug.rb +6 -4
- data/lib/paytrace/transaction.rb +64 -0
- data/lib/paytrace/version.rb +1 -1
- data/test/paytrace/address_spec.rb +8 -8
- data/test/paytrace/api/request_spec.rb +6 -6
- data/test/paytrace/configuration_spec.rb +29 -0
- data/test/paytrace/level3_data_spec.rb +136 -0
- data/test/paytrace/transaction_spec.rb +8 -8
- data/test/scripts/run_change_password.rb +12 -0
- data/test/scripts/run_export_transactions.rb +1 -1
- data/test/scripts/run_level3_data.rb +97 -0
- data/test/scripts/run_recur_payments_integration.rb +20 -1
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc1307bbdaf427227ab1ee30bd21117d0b9f8969
|
4
|
+
data.tar.gz: 85f8bad34a822d70af78ae6dcc2c1e1bd0b5d344
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a02f49b0ddb2937f3b40e85a0c40114542901c0a5e6e82e31438d3a97a75b8d972a364f56163b2596b12de7820f1ac8ac2fe4f62a5913e23305f57ae96c93596
|
7
|
+
data.tar.gz: cd412acbb7a6244c33359527ca0a9c86c7d0318c1a7513e29ad4c6486b69a956a9a6629aeaa7670db18d8e192f22ca1287d30f43dab99e8b50dbc82b820bb652
|
data/lib/paytrace/api/fields.rb
CHANGED
@@ -11,6 +11,36 @@ module PayTrace
|
|
11
11
|
email: "EMAIL",
|
12
12
|
description: "DESCRIPTION",
|
13
13
|
tax_amount: "TAX",
|
14
|
+
national_tax: "NTAX",
|
15
|
+
new_password: "NEWPSWD",
|
16
|
+
new_password_confirmation: "NEWPSWD2",
|
17
|
+
# level 3 stuff
|
18
|
+
merchant_tax_id: "MERCHANTTAXID",
|
19
|
+
customer_tax_id: "CUSTOMERTAXID",
|
20
|
+
ccode: "CCODE",
|
21
|
+
line_item: "LINEITEM",
|
22
|
+
line_items: "LINEITEMS",
|
23
|
+
ccode_li: "CCODELI",
|
24
|
+
discount: "DISCOUNT",
|
25
|
+
freight: "FREIGHT",
|
26
|
+
duty: "DUTY",
|
27
|
+
add_tax: "ADDTAX",
|
28
|
+
add_tax_rate: "ADDTAXRATE",
|
29
|
+
product_id: "PRODUCTID",
|
30
|
+
quantity: "QUANTITY",
|
31
|
+
measure: "MEASURE",
|
32
|
+
unit_cost: "UNITCOST",
|
33
|
+
additional_tax_included: "ADDTAXIND",
|
34
|
+
additional_tax_included_li: "ADDTAXINDLI",
|
35
|
+
add_tax_li: "ADDTAXLI",
|
36
|
+
add_tax_rate_li: "ADDTAXRATELI",
|
37
|
+
discount_li: "DISCOUNTLI",
|
38
|
+
amount_li: "AMOUNTLI",
|
39
|
+
discount_included: "DISCOUNTIND",
|
40
|
+
line_item_is_gross: "NETGROSSIND",
|
41
|
+
is_debit_or_credit: "DCIND",
|
42
|
+
discount_rate: "DISCOUNTRATE",
|
43
|
+
|
14
44
|
return_clr: "RETURNCLR",
|
15
45
|
return_bin: "RETURNBIN",
|
16
46
|
enable_partial_authentication: "ENABLEPARTIALAUTH",
|
data/lib/paytrace/api/gateway.rb
CHANGED
@@ -41,7 +41,7 @@ module PayTrace
|
|
41
41
|
@@raise_exceptions = raise_exceptions
|
42
42
|
end
|
43
43
|
|
44
|
-
def send_request(request,
|
44
|
+
def send_request(request, multi_value_response_fields = [])
|
45
45
|
@@last_request = request.to_parms_string if @@debug
|
46
46
|
unless (@@debug && @@next_response)
|
47
47
|
res = @connection.post PayTrace.configuration.url, parmlist: request.to_parms_string
|
@@ -51,7 +51,7 @@ module PayTrace
|
|
51
51
|
end
|
52
52
|
|
53
53
|
@@last_response = raw_response
|
54
|
-
response = PayTrace::API::Response.new(raw_response,
|
54
|
+
response = PayTrace::API::Response.new(raw_response, multi_value_response_fields)
|
55
55
|
@@last_response_object = response
|
56
56
|
|
57
57
|
@@next_response = nil # just to be sure
|
data/lib/paytrace/api/request.rb
CHANGED
@@ -5,20 +5,24 @@ module PayTrace
|
|
5
5
|
|
6
6
|
def initialize
|
7
7
|
@field_delim = "|"
|
8
|
+
@multi_field_delim = "+"
|
8
9
|
@value_delim = "~"
|
10
|
+
@multi_value_delim = "="
|
9
11
|
|
10
12
|
@params= {
|
11
|
-
user_name: PayTrace.configuration.user_name,
|
12
|
-
password: PayTrace.configuration.password,
|
13
|
-
terms: "Y"
|
13
|
+
user_name: [PayTrace.configuration.user_name],
|
14
|
+
password: [PayTrace.configuration.password],
|
15
|
+
terms: ["Y"]
|
14
16
|
}
|
15
17
|
|
16
18
|
@discretionary_data = {}
|
17
19
|
end
|
18
20
|
|
19
21
|
def to_parms_string()
|
20
|
-
raw_request = @params.map do |k,
|
21
|
-
|
22
|
+
raw_request = @params.map do |k,items|
|
23
|
+
items.map do |item|
|
24
|
+
"#{PayTrace::API.fields[k]}#{@value_delim}#{item}"
|
25
|
+
end
|
22
26
|
end.join(@field_delim) << @field_delim
|
23
27
|
|
24
28
|
if @discretionary_data.any?
|
@@ -38,10 +42,29 @@ module PayTrace
|
|
38
42
|
end
|
39
43
|
end
|
40
44
|
|
41
|
-
def
|
45
|
+
def validate_param(k, v)
|
42
46
|
raise PayTrace::Exceptions::ValidationError.new("Unknown field '#{k}'") unless PayTrace::API.fields.has_key?(k)
|
47
|
+
end
|
48
|
+
|
49
|
+
def set_param(k, v)
|
50
|
+
validate_param(k, v)
|
51
|
+
|
52
|
+
unless v.nil?
|
53
|
+
@params[k] ||= []
|
54
|
+
|
55
|
+
@params[k] << v
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def set_multivalue(param_name, items = {})
|
60
|
+
result = (items.map do |k,v|
|
61
|
+
validate_param(k, v)
|
62
|
+
"#{PayTrace::API.fields[k]}#{@multi_value_delim}#{v}"
|
63
|
+
end.join(@multi_field_delim))
|
64
|
+
|
65
|
+
set_param(param_name, result)
|
43
66
|
|
44
|
-
|
67
|
+
result
|
45
68
|
end
|
46
69
|
|
47
70
|
def set_params(keys, params)
|
@@ -2,12 +2,30 @@ module PayTrace
|
|
2
2
|
class Configuration
|
3
3
|
attr_accessor :user_name, :password, :connection, :domain, :path
|
4
4
|
|
5
|
+
RESET_PASSWORD_METHOD = "UpdatePassword"
|
6
|
+
|
5
7
|
def initialize
|
6
8
|
@domain = "paytrace.com"
|
7
9
|
@connection = Faraday.new
|
8
10
|
@path = "api/default.pay"
|
9
11
|
end
|
10
12
|
|
13
|
+
def update_password(params)
|
14
|
+
request = PayTrace::API::Request.new
|
15
|
+
request.set_param(:method, RESET_PASSWORD_METHOD)
|
16
|
+
request.set_params([:new_password, :new_password_confirmation], params)
|
17
|
+
gateway = PayTrace::API::Gateway.new
|
18
|
+
response = gateway.send_request(request)
|
19
|
+
|
20
|
+
unless response.has_errors?
|
21
|
+
PayTrace.configure do |config|
|
22
|
+
config.password = params[:new_password]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
response
|
27
|
+
end
|
28
|
+
|
11
29
|
def url
|
12
30
|
"https://#{@domain}/#{@path}"
|
13
31
|
end
|
data/lib/paytrace/debug.rb
CHANGED
@@ -29,17 +29,19 @@ module PayTrace
|
|
29
29
|
begin
|
30
30
|
yield
|
31
31
|
rescue Exception => e
|
32
|
+
puts "[REQUEST] #{PayTrace::API::Gateway.last_request}"
|
33
|
+
|
32
34
|
raise
|
33
35
|
else
|
34
36
|
dump_transaction
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
38
|
-
def self.configure_test
|
40
|
+
def self.configure_test(un = "demo123", pw = "demo123", domain = "stage.paytrace.com")
|
39
41
|
PayTrace.configure do |config|
|
40
|
-
config.user_name =
|
41
|
-
config.password =
|
42
|
-
config.domain =
|
42
|
+
config.user_name = un
|
43
|
+
config.password = pw
|
44
|
+
config.domain = domain
|
43
45
|
end
|
44
46
|
end
|
45
47
|
end
|
data/lib/paytrace/transaction.rb
CHANGED
@@ -90,6 +90,8 @@ module PayTrace
|
|
90
90
|
ATTACH_SIGNATURE_METHOD = "AttachSignature"
|
91
91
|
CALCULATE_SHIPPING_COST = "CalculateShipping"
|
92
92
|
CALCULATE_SHIPPING_COST_RESPONSE = "SHIPPINGRECORD"
|
93
|
+
LEVEL_3_VISA_METHOD = "Level3Visa"
|
94
|
+
LEVEL_3_MC_METHOD = "Level3MCRD"
|
93
95
|
|
94
96
|
def set_shipping_same_as_billing()
|
95
97
|
@shipping_address = @billing_address
|
@@ -167,6 +169,68 @@ module PayTrace
|
|
167
169
|
end
|
168
170
|
end
|
169
171
|
|
172
|
+
def self.add_level_three_visa(params = {})
|
173
|
+
line_items = params.delete(:line_items) || []
|
174
|
+
request = PayTrace::API::Request.new
|
175
|
+
request.set_param(:method, LEVEL_3_VISA_METHOD)
|
176
|
+
request.set_params([
|
177
|
+
:transaction_id,
|
178
|
+
:invoice,
|
179
|
+
:customer_reference_id,
|
180
|
+
:tax_amount,
|
181
|
+
:national_tax,
|
182
|
+
:merchant_tax_id,
|
183
|
+
:customer_tax_id,
|
184
|
+
:ccode,
|
185
|
+
:discount,
|
186
|
+
:freight,
|
187
|
+
:duty,
|
188
|
+
:source_zip,
|
189
|
+
:shipping_postal_code,
|
190
|
+
:shipping_country,
|
191
|
+
:add_tax,
|
192
|
+
:add_tax_rate
|
193
|
+
], params)
|
194
|
+
line_items.each do |li|
|
195
|
+
request.set_multivalue(:line_item, li)
|
196
|
+
end
|
197
|
+
|
198
|
+
gateway = PayTrace::API::Gateway.new
|
199
|
+
response = gateway.send_request(request)
|
200
|
+
unless response.has_errors?
|
201
|
+
response.values
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
def self.add_level_three_mc(params = {})
|
206
|
+
line_items = params.delete(:line_items) || []
|
207
|
+
request = PayTrace::API::Request.new
|
208
|
+
request.set_param(:method, LEVEL_3_MC_METHOD)
|
209
|
+
request.set_params([
|
210
|
+
:transaction_id,
|
211
|
+
:invoice,
|
212
|
+
:customer_reference_id,
|
213
|
+
:tax_amount,
|
214
|
+
:national_tax,
|
215
|
+
:freight,
|
216
|
+
:duty,
|
217
|
+
:source_zip,
|
218
|
+
:shipping_postal_code,
|
219
|
+
:shipping_country,
|
220
|
+
:add_tax,
|
221
|
+
:additional_tax_included
|
222
|
+
], params)
|
223
|
+
line_items.each do |li|
|
224
|
+
request.set_multivalue(:line_item, li)
|
225
|
+
end
|
226
|
+
|
227
|
+
gateway = PayTrace::API::Gateway.new
|
228
|
+
response = gateway.send_request(request)
|
229
|
+
unless response.has_errors?
|
230
|
+
response.values
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
170
234
|
private
|
171
235
|
def add_transaction_info(request)
|
172
236
|
request.set_param(:transaction_type, type)
|
data/lib/paytrace/version.rb
CHANGED
@@ -53,13 +53,13 @@ describe PayTrace::Address do
|
|
53
53
|
})
|
54
54
|
a.set_request(r)
|
55
55
|
|
56
|
-
r.params[:shipping_name].must_equal "John Doe"
|
57
|
-
r.params[:shipping_address].must_equal "1234 Main Street"
|
58
|
-
r.params[:shipping_address2].must_equal "Apt. B"
|
59
|
-
r.params[:shipping_city].must_equal "Shoreline"
|
60
|
-
r.params[:shipping_state].must_equal "WA"
|
61
|
-
r.params[:shipping_country].must_equal "USA"
|
62
|
-
r.params[:shipping_region].must_equal "region??"
|
63
|
-
r.params[:shipping_postal_code].must_equal "98133"
|
56
|
+
r.params[:shipping_name].must_equal ["John Doe"]
|
57
|
+
r.params[:shipping_address].must_equal ["1234 Main Street"]
|
58
|
+
r.params[:shipping_address2].must_equal ["Apt. B"]
|
59
|
+
r.params[:shipping_city].must_equal ["Shoreline"]
|
60
|
+
r.params[:shipping_state].must_equal ["WA"]
|
61
|
+
r.params[:shipping_country].must_equal ["USA"]
|
62
|
+
r.params[:shipping_region].must_equal ["region??"]
|
63
|
+
r.params[:shipping_postal_code].must_equal ["98133"]
|
64
64
|
end
|
65
65
|
end
|
@@ -17,9 +17,9 @@ describe PayTrace::API::Request do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
r = PayTrace::API::Request.new
|
20
|
-
r.params[:user_name].must_equal "request_test"
|
21
|
-
r.params[:password].must_equal "request_password"
|
22
|
-
r.params[:terms].must_equal "Y"
|
20
|
+
r.params[:user_name].must_equal ["request_test"]
|
21
|
+
r.params[:password].must_equal ["request_password"]
|
22
|
+
r.params[:terms].must_equal ["Y"]
|
23
23
|
to_url = r.to_parms_string
|
24
24
|
to_url.must_equal "UN~request_test|PSWD~request_password|TERMS~Y|"
|
25
25
|
end
|
@@ -27,15 +27,15 @@ describe PayTrace::API::Request do
|
|
27
27
|
it "can manually set params" do
|
28
28
|
r = PayTrace::API::Request.new
|
29
29
|
r.set_param(:billing_name, "Fred Jones")
|
30
|
-
r.params[:billing_name].must_equal "Fred Jones"
|
30
|
+
r.params[:billing_name].must_equal ["Fred Jones"]
|
31
31
|
end
|
32
32
|
|
33
33
|
it "can bulk set params" do
|
34
34
|
params = {billing_name: "Fred Jones", billing_postal_code: 98133}
|
35
35
|
r = PayTrace::API::Request.new
|
36
36
|
r.set_params([:billing_name, :billing_postal_code], params)
|
37
|
-
r.params[:billing_name].must_equal "Fred Jones"
|
38
|
-
r.params[:billing_postal_code].must_equal 98133
|
37
|
+
r.params[:billing_name].must_equal ["Fred Jones"]
|
38
|
+
r.params[:billing_postal_code].must_equal [98133]
|
39
39
|
end
|
40
40
|
|
41
41
|
it "raises a validation exception for unknown fields" do
|
@@ -33,4 +33,33 @@ describe PayTrace::Configuration do
|
|
33
33
|
end
|
34
34
|
PayTrace.configuration.url.must_equal "https://sandbox.paytrace.com/api/default.pay"
|
35
35
|
end
|
36
|
+
|
37
|
+
it "allows you to change your password" do
|
38
|
+
PayTrace::API::Gateway.debug = true
|
39
|
+
PayTrace::API::Gateway.next_response = "RESPONSE~100. Your password was successfully updated."
|
40
|
+
|
41
|
+
old_password = PayTrace.configuration.password
|
42
|
+
c = PayTrace::Configuration.new
|
43
|
+
c.update_password(new_password: 'foobar', new_password_confirmation: 'foobar')
|
44
|
+
|
45
|
+
PayTrace::API::Gateway.last_request.must_equal "UN~#{PayTrace.configuration.user_name}|PSWD~#{old_password}|TERMS~Y|" +
|
46
|
+
"METHOD~UpdatePassword|NEWPSWD~foobar|NEWPSWD2~foobar|"
|
47
|
+
|
48
|
+
PayTrace::API::Gateway.next_response = "RESPONSE~100. Your password was successfully updated."
|
49
|
+
c.update_password(new_password: old_password, new_password_confirmation: old_password)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "changes the config password when you successfully call update_password" do
|
53
|
+
PayTrace::API::Gateway.debug = true
|
54
|
+
PayTrace::API::Gateway.next_response = "RESPONSE~100. Your password was successfully updated."
|
55
|
+
|
56
|
+
old_password = PayTrace.configuration.password
|
57
|
+
c = PayTrace::Configuration.new
|
58
|
+
c.update_password(new_password: 'foobar', new_password_confirmation: 'foobar')
|
59
|
+
|
60
|
+
PayTrace.configuration.password.must_equal 'foobar'
|
61
|
+
|
62
|
+
PayTrace::API::Gateway.next_response = "RESPONSE~100. Your password was successfully updated."
|
63
|
+
c.update_password(new_password: old_password, new_password_confirmation: old_password)
|
64
|
+
end
|
36
65
|
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '../../test_helper.rb')
|
2
|
+
|
3
|
+
describe PayTrace::Transaction do
|
4
|
+
describe "add level 3 data" do
|
5
|
+
def base_url(method)
|
6
|
+
"UN~#{PayTrace.configuration.user_name}|PSWD~#{PayTrace.configuration.password}|TERMS~Y|METHOD~#{method}|"
|
7
|
+
end
|
8
|
+
|
9
|
+
before do
|
10
|
+
PayTrace::API::Gateway.debug = true
|
11
|
+
PayTrace::API::Gateway.next_response = "RESPONSE~ok|RECURID~12345|"
|
12
|
+
end
|
13
|
+
|
14
|
+
# see http://help.paytrace.com/api-adding-level-3-data-to-a-visa-sale
|
15
|
+
|
16
|
+
# Required Name Value Pairs
|
17
|
+
|
18
|
+
# UN, PSWD, TERMS, METHOD, TRANXID
|
19
|
+
|
20
|
+
# Optional Name Value Pairs For Add Level 3 Data to Visa Request
|
21
|
+
|
22
|
+
# INVOICE, CUSTREF, TAX, NTAX, MERCHANTTAXID, CUSTOMERTAXID, CCODE, DISCOUNT, FREIGHT, DUTY, SOURCEZIP, SZIP, SCOUNTRY, ADDTAX, ADDTAXRATE
|
23
|
+
|
24
|
+
# Optional Name Value Pairs For Line Item Detail to Visa Request
|
25
|
+
|
26
|
+
# CCODELI, PRODUCTID, DESCRIPTION, QUANTITY, MEASURE, UNITCOST, ADDTAXLI, ADDTAXRATELI, DISCOUNTLI, AMOUNTLI
|
27
|
+
|
28
|
+
# Please note that each name/value pair is separated by the traditional ~ and followed by a |. However, name/value pairs included in the LINEITEM parameter are separated by the = symbol and followed by a + symbol. So, no values in a Level3Visa request should contain a ~, |, +, or = symbols. The example request below contains 1 Line Item record.
|
29
|
+
it "works with visa" do
|
30
|
+
params = {
|
31
|
+
transaction_id: "1143",
|
32
|
+
invoice: "12346",
|
33
|
+
customer_reference_id: "1234578",
|
34
|
+
tax_amount: 31.76,
|
35
|
+
national_tax: "0.00",
|
36
|
+
merchant_tax_id: "13692468",
|
37
|
+
customer_tax_id: "12369240",
|
38
|
+
ccode: "1234abcd",
|
39
|
+
discount: 4.53,
|
40
|
+
freight: 7.99,
|
41
|
+
duty: 6.52,
|
42
|
+
source_zip: "94947",
|
43
|
+
shipping_postal_code: "98133",
|
44
|
+
shipping_country: "US",
|
45
|
+
add_tax: 4.78,
|
46
|
+
add_tax_rate: 0.43,
|
47
|
+
line_items:
|
48
|
+
[
|
49
|
+
{
|
50
|
+
ccode_li: "12345678",
|
51
|
+
product_id: "E123125",
|
52
|
+
description: "Widgets and wodgets",
|
53
|
+
quantity: 20,
|
54
|
+
measure: "foo",
|
55
|
+
unit_cost: 3.99,
|
56
|
+
add_tax_li: 3.82,
|
57
|
+
add_tax_rate_li: 0.44,
|
58
|
+
discount_li: 1.86,
|
59
|
+
amount_li: 5
|
60
|
+
},
|
61
|
+
{
|
62
|
+
ccode_li: "12345679",
|
63
|
+
product_id: "D987654",
|
64
|
+
description: "It's log!",
|
65
|
+
quantity: 42,
|
66
|
+
measure: "bar",
|
67
|
+
unit_cost: 3.98,
|
68
|
+
add_tax_li: 3.81,
|
69
|
+
add_tax_rate_li: 0.45,
|
70
|
+
discount_li: 1.87,
|
71
|
+
amount_li: 6
|
72
|
+
}
|
73
|
+
]
|
74
|
+
}
|
75
|
+
PayTrace::Transaction.add_level_three_visa(params)
|
76
|
+
|
77
|
+
PayTrace::API::Gateway.last_request.must_equal base_url(PayTrace::Transaction::LEVEL_3_VISA_METHOD) +
|
78
|
+
"TRANXID~1143|INVOICE~12346|CUSTREF~1234578|TAX~31.76|NTAX~0.00|MERCHANTTAXID~13692468|CUSTOMERTAXID~12369240|CCODE~1234abcd|DISCOUNT~4.53|FREIGHT~7.99|DUTY~6.52|SOURCEZIP~94947|SZIP~98133|SCOUNTRY~US|ADDTAX~4.78|ADDTAXRATE~0.43|LINEITEM~CCODELI=12345678+PRODUCTID=E123125+DESCRIPTION=Widgets and wodgets+QUANTITY=20+MEASURE=foo+UNITCOST=3.99+ADDTAXLI=3.82+ADDTAXRATELI=0.44+DISCOUNTLI=1.86+AMOUNTLI=5|LINEITEM~CCODELI=12345679+PRODUCTID=D987654+DESCRIPTION=It's log!+QUANTITY=42+MEASURE=bar+UNITCOST=3.98+ADDTAXLI=3.81+ADDTAXRATELI=0.45+DISCOUNTLI=1.87+AMOUNTLI=6|"
|
79
|
+
end
|
80
|
+
|
81
|
+
# Required Name Value Pairs
|
82
|
+
|
83
|
+
# UN, PSWD, TERMS, METHOD, TRANXID
|
84
|
+
|
85
|
+
# Optional Name Value Pairs For Add Level 3 Data to MasterCard Request
|
86
|
+
|
87
|
+
# INVOICE, CUSTREF, TAX, NTAX, FREIGHT, DUTY, SOURCEZIP, SZIP, SCOUNTRY, ADDTAX, ADDTAXIND
|
88
|
+
|
89
|
+
# Optional Name Value Pairs For Line Item Detail to MasterCard Request
|
90
|
+
|
91
|
+
# PRODUCTID, DESCRIPTION, QUANTITY, MEASURE, MERCHANTTAXID, UNITCOST, ADDTAXRATELI, ADDTAXINDLI, ADDTAXLI, AMOUNTLI, DISCOUNTIND, NETGROSSIND, DCIND, DISCOUNTLI, DICOUNTRATE
|
92
|
+
|
93
|
+
# see http://help.paytrace.com/api-adding-level-3-data-to-a-mastercard-sale
|
94
|
+
it "works with mastercard" do
|
95
|
+
params = {
|
96
|
+
transaction_id: "1143",
|
97
|
+
invoice: "12347",
|
98
|
+
customer_reference_id: "1234579",
|
99
|
+
tax_amount: 31.78,
|
100
|
+
national_tax: 0.01,
|
101
|
+
freight: 7.98,
|
102
|
+
duty: 6.51,
|
103
|
+
source_zip: "94948",
|
104
|
+
shipping_postal_code: "98134",
|
105
|
+
shipping_country: "US",
|
106
|
+
add_tax: 4.54,
|
107
|
+
additional_tax_included: 'Y',
|
108
|
+
line_items:
|
109
|
+
[
|
110
|
+
{
|
111
|
+
product_id: "E123126",
|
112
|
+
description: "Wadgets and wudgets",
|
113
|
+
quantity: 21,
|
114
|
+
measure: "food",
|
115
|
+
merchant_tax_id: "13699468",
|
116
|
+
unit_cost: 3.98,
|
117
|
+
add_tax_rate_li: 0.45,
|
118
|
+
additional_tax_included_li: 'Y',
|
119
|
+
add_tax_li: 3.82,
|
120
|
+
discount_included: 'Y',
|
121
|
+
amount_li: 6,
|
122
|
+
line_item_is_gross: 'Y',
|
123
|
+
is_debit_or_credit: 'D',
|
124
|
+
discount_li: 1.86,
|
125
|
+
discount_rate: '0.10'
|
126
|
+
}
|
127
|
+
]
|
128
|
+
}
|
129
|
+
|
130
|
+
PayTrace::Transaction.add_level_three_mc(params)
|
131
|
+
|
132
|
+
PayTrace::API::Gateway.last_request.must_equal base_url(PayTrace::Transaction::LEVEL_3_MC_METHOD) +
|
133
|
+
"TRANXID~1143|INVOICE~12347|CUSTREF~1234579|TAX~31.78|NTAX~0.01|FREIGHT~7.98|DUTY~6.51|SOURCEZIP~94948|SZIP~98134|SCOUNTRY~US|ADDTAX~4.54|ADDTAXIND~Y|LINEITEM~PRODUCTID=E123126+DESCRIPTION=Wadgets and wudgets+QUANTITY=21+MEASURE=food+MERCHANTTAXID=13699468+UNITCOST=3.98+ADDTAXRATELI=0.45+ADDTAXINDLI=Y+ADDTAXLI=3.82+DISCOUNTIND=Y+AMOUNTLI=6+NETGROSSIND=Y+DCIND=D+DISCOUNTLI=1.86+DISCOUNTRATE=0.10|"
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
@@ -243,12 +243,12 @@ describe PayTrace::Transaction do
|
|
243
243
|
r = PayTrace::API::Request.new
|
244
244
|
t.set_request(r)
|
245
245
|
|
246
|
-
r.params[:card_number].must_equal "1234123412341234"
|
247
|
-
r.params[:expiration_month].must_equal 10
|
248
|
-
r.params[:expiration_year].must_equal 24
|
249
|
-
r.params[:transaction_type].must_equal "SALE"
|
250
|
-
r.params[:method].must_equal "PROCESSTRANX"
|
251
|
-
r.params[:amount].must_equal "23.12"
|
246
|
+
r.params[:card_number].must_equal ["1234123412341234"]
|
247
|
+
r.params[:expiration_month].must_equal [10]
|
248
|
+
r.params[:expiration_year].must_equal [24]
|
249
|
+
r.params[:transaction_type].must_equal ["SALE"]
|
250
|
+
r.params[:method].must_equal ["PROCESSTRANX"]
|
251
|
+
r.params[:amount].must_equal ["23.12"]
|
252
252
|
|
253
253
|
url = r.to_parms_string
|
254
254
|
url.must_equal "UN~#{PayTrace.configuration.user_name}|PSWD~#{PayTrace.configuration.password}|TERMS~Y|CC~1234123412341234|EXPMNTH~10|EXPYR~24|TRANXTYPE~SALE|METHOD~PROCESSTRANX|AMOUNT~23.12|"
|
@@ -263,8 +263,8 @@ describe PayTrace::Transaction do
|
|
263
263
|
r = PayTrace::API::Request.new
|
264
264
|
t.set_request(r)
|
265
265
|
|
266
|
-
r.params[:customer_id].must_equal 1234
|
267
|
-
r.params[:amount].must_equal "12.34"
|
266
|
+
r.params[:customer_id].must_equal [1234]
|
267
|
+
r.params[:amount].must_equal ["12.34"]
|
268
268
|
|
269
269
|
url = r.to_parms_string
|
270
270
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "paytrace"
|
2
|
+
require "paytrace/debug"
|
3
|
+
|
4
|
+
# use a low-security user for this test, so we don't mess up the integration users :)
|
5
|
+
PayTrace::Debug.configure_test("tom_test_user", "password4", "dev2.paytrace.com")
|
6
|
+
|
7
|
+
# see: http://help.paytrace.com/api-updating-user-password for details
|
8
|
+
PayTrace::Debug.trace {
|
9
|
+
# change my demo user password...
|
10
|
+
# note, if you run this, it won't run again because the password has been changed :)
|
11
|
+
PayTrace.configuration.update_password(new_password: 'password5', new_password_confirmation: 'password4')
|
12
|
+
}
|
@@ -0,0 +1,97 @@
|
|
1
|
+
$:<< "./lib" # uncomment this to run against a Git clone instead of an installed gem
|
2
|
+
|
3
|
+
require "paytrace"
|
4
|
+
require "paytrace/debug"
|
5
|
+
|
6
|
+
PayTrace::Debug.configure_test
|
7
|
+
|
8
|
+
PayTrace::Debug.trace do
|
9
|
+
params = {
|
10
|
+
transaction_id: "1143",
|
11
|
+
invoice: "12346",
|
12
|
+
customer_reference_id: "1234578",
|
13
|
+
tax_amount: 31.76,
|
14
|
+
ntax: 0.00,
|
15
|
+
merchant_tax_id: "13692468",
|
16
|
+
customer_tax_id: "12369240",
|
17
|
+
ccode: "1234abcd",
|
18
|
+
discount: 4.53,
|
19
|
+
freight: 7.99,
|
20
|
+
duty: 6.52,
|
21
|
+
source_zip: "94947",
|
22
|
+
shipping_postal_code: "98133",
|
23
|
+
shipping_country: "US",
|
24
|
+
add_tax: 4.78,
|
25
|
+
add_tax_rate: 0.43,
|
26
|
+
line_items:
|
27
|
+
[
|
28
|
+
{
|
29
|
+
ccode_li: "12345678",
|
30
|
+
product_id: "E123125",
|
31
|
+
description: "Widgets and wodgets",
|
32
|
+
quantity: 20,
|
33
|
+
measure: "foo",
|
34
|
+
unit_cost: 3.99,
|
35
|
+
add_tax_li: 3.82,
|
36
|
+
add_tax_rate_li: 0.44,
|
37
|
+
discount_li: 1.86,
|
38
|
+
amount_li: 5
|
39
|
+
},
|
40
|
+
{
|
41
|
+
ccode_li: "12345679",
|
42
|
+
product_id: "D987654",
|
43
|
+
description: "It's log!",
|
44
|
+
quantity: 42,
|
45
|
+
measure: "bar",
|
46
|
+
unit_cost: 3.98,
|
47
|
+
add_tax_li: 3.81,
|
48
|
+
add_tax_rate_li: 0.45,
|
49
|
+
discount_li: 1.87,
|
50
|
+
amount_li: 6
|
51
|
+
}
|
52
|
+
]
|
53
|
+
}
|
54
|
+
PayTrace::Transaction.add_level_three_visa(params)
|
55
|
+
end
|
56
|
+
|
57
|
+
# https://stage.paytrace.com/api/default.pay?parmList=UN~NEWapiuser%7CPSWD~test456%7CTERMS~Y%7CMETHOD~Level3MCRD%7CTRANXID~1399%7CINVOICE~12347%7CCUSTREF~1234579%7CTAX~31.78%7CNTAX~0.01%7CFREIGHT~7.98%7CDUTY~6.51%7CSOURCEZIP~94948%7CSZIP~98134%7CSCOUNTRY~US%7CADDTAX~4.54%7CADDTAXIND~Y%7CLINEITEM~PRODUCTID=E123126+DESCRIPTION=Wadgets%20and%20wudgets+QUANTITY=21+MEASURE=food+MERCHANTTAXID=13699468+UNITCOST=3.98+ADDTAXRATELI=0.45+ADDTAXINDLI=Y+ADDTAXLI=3.82+DISCOUNTIND=Y+AMOUNTLI=6+NETGROSSIND=Y+DCIND=D+DISCOUNTLI=1.86+DISCOUNTRATE=0.10%7C
|
58
|
+
# [REQUEST] UN~demo123|PSWD~demo123|TERMS~Y|METHOD~Level3MCRD|TRANXID~1399|INVOICE~12347|CUSTREF~1234579|TAX~31.78|NTAX~0.01|FREIGHT~7.98|DUTY~6.51|SOURCEZIP~94948|SZIP~98134|SCOUNTRY~US|ADDTAX~4.54|ADDTAXIND~Y|LINEITEM~PRODUCTID=E123126+DESCRIPTION=Wadgets and wudgets+QUANTITY=21+MEASURE=food+MERCHANTTAXID=13699468+UNITCOST=3.98+ADDTAXRATELI=0.45+ADDTAXINDLI=Y+ADDTAXLI=3.82+DISCOUNTIND=Y+AMOUNTLI=6+NETGROSSIND=Y+DCIND=D+DISCOUNTLI=1.86+DISCOUNTRATE=0.10|
|
59
|
+
|
60
|
+
PayTrace::Debug.configure_test("NEWapiuser", "test456")
|
61
|
+
PayTrace::Debug.trace do
|
62
|
+
params = {
|
63
|
+
transaction_id: "1399",
|
64
|
+
invoice: "12347",
|
65
|
+
customer_reference_id: "1234579",
|
66
|
+
tax_amount: 31.78,
|
67
|
+
national_tax: 0.01,
|
68
|
+
freight: 7.98,
|
69
|
+
duty: 6.51,
|
70
|
+
source_zip: "94948",
|
71
|
+
shipping_postal_code: "98134",
|
72
|
+
shipping_country: "US",
|
73
|
+
add_tax: 4.54,
|
74
|
+
additional_tax_included: 'Y',
|
75
|
+
line_items:
|
76
|
+
[
|
77
|
+
{
|
78
|
+
product_id: "E123126",
|
79
|
+
description: "Wadgets and wudgets",
|
80
|
+
quantity: 21,
|
81
|
+
measure: "food",
|
82
|
+
merchant_tax_id: "13699468",
|
83
|
+
unit_cost: 3.98,
|
84
|
+
add_tax_rate_li: 0.45,
|
85
|
+
additional_tax_included_li: 'Y',
|
86
|
+
add_tax_li: 3.82,
|
87
|
+
discount_included: 'Y',
|
88
|
+
amount_li: 6,
|
89
|
+
line_item_is_gross: 'Y',
|
90
|
+
is_debit_or_credit: 'D',
|
91
|
+
discount_li: 1.86
|
92
|
+
}
|
93
|
+
]
|
94
|
+
}
|
95
|
+
|
96
|
+
PayTrace::Transaction.add_level_three_mc(params)
|
97
|
+
end
|
@@ -81,6 +81,25 @@ PayTrace::Debug.trace do
|
|
81
81
|
PayTrace::Debug.log "Recurrence ID: #{recur_id}"
|
82
82
|
end
|
83
83
|
|
84
|
+
PayTrace::Debug.log "Modify recurrence for john_doe..."
|
85
|
+
PayTrace::Debug.trace do
|
86
|
+
recur_id = PayTrace::RecurringTransaction.create(params)
|
87
|
+
PayTrace::Debug.log "Recurrence ID: #{recur_id}"
|
88
|
+
update_params = {
|
89
|
+
recur_id: recur_id,
|
90
|
+
description: "Updated recurring payment"
|
91
|
+
}
|
92
|
+
PayTrace::RecurringTransaction.update(update_params)
|
93
|
+
end
|
94
|
+
|
95
|
+
PayTrace::Debug.log "Delete a recurrence for john_doe..."
|
96
|
+
PayTrace::Debug.trace do
|
97
|
+
recur_id = PayTrace::RecurringTransaction.create(params)
|
98
|
+
PayTrace::Debug.log "Recurrence ID: #{recur_id}"
|
99
|
+
PayTrace::RecurringTransaction.delete({recur_id: recur_id})
|
100
|
+
end
|
101
|
+
|
102
|
+
|
84
103
|
begin
|
85
104
|
PayTrace::Debug.log "Exporting recurring transaction..."
|
86
105
|
PayTrace::Debug.trace do
|
@@ -101,4 +120,4 @@ PayTrace::Debug.trace { PayTrace::RecurringTransaction.delete({customer_id: "joh
|
|
101
120
|
PayTrace::Debug.log "Deleting customer 'john_doe'..."
|
102
121
|
################
|
103
122
|
# delete "john doe"
|
104
|
-
PayTrace::Debug.trace { c.delete() }
|
123
|
+
PayTrace::Debug.trace { c.delete() }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paytrace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Trevor Redfern
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -136,14 +136,17 @@ files:
|
|
136
136
|
- test/paytrace/customer_spec.rb
|
137
137
|
- test/paytrace/email_receipt_request_spec.rb
|
138
138
|
- test/paytrace/exceptions_spec.rb
|
139
|
+
- test/paytrace/level3_data_spec.rb
|
139
140
|
- test/paytrace/recurring_transaction_spec.rb
|
140
141
|
- test/paytrace/transaction_spec.rb
|
141
142
|
- test/scripts/run_attach_signature.rb
|
142
143
|
- test/scripts/run_calculate_shipping_costs.rb
|
144
|
+
- test/scripts/run_change_password.rb
|
143
145
|
- test/scripts/run_create_customer.rb
|
144
146
|
- test/scripts/run_email_request.rb
|
145
147
|
- test/scripts/run_export_customers.rb
|
146
148
|
- test/scripts/run_export_transactions.rb
|
149
|
+
- test/scripts/run_level3_data.rb
|
147
150
|
- test/scripts/run_recur_payments_integration.rb
|
148
151
|
- test/scripts/smiley_face.png
|
149
152
|
- test/test_helper.rb
|
@@ -183,14 +186,17 @@ test_files:
|
|
183
186
|
- test/paytrace/customer_spec.rb
|
184
187
|
- test/paytrace/email_receipt_request_spec.rb
|
185
188
|
- test/paytrace/exceptions_spec.rb
|
189
|
+
- test/paytrace/level3_data_spec.rb
|
186
190
|
- test/paytrace/recurring_transaction_spec.rb
|
187
191
|
- test/paytrace/transaction_spec.rb
|
188
192
|
- test/scripts/run_attach_signature.rb
|
189
193
|
- test/scripts/run_calculate_shipping_costs.rb
|
194
|
+
- test/scripts/run_change_password.rb
|
190
195
|
- test/scripts/run_create_customer.rb
|
191
196
|
- test/scripts/run_email_request.rb
|
192
197
|
- test/scripts/run_export_customers.rb
|
193
198
|
- test/scripts/run_export_transactions.rb
|
199
|
+
- test/scripts/run_level3_data.rb
|
194
200
|
- test/scripts/run_recur_payments_integration.rb
|
195
201
|
- test/scripts/smiley_face.png
|
196
202
|
- test/test_helper.rb
|