paytrace 0.1.16 → 0.1.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7c24369bccca3d21f97f62554d1d04382bb300dc
4
- data.tar.gz: 87a67ae201eaec2984fecf87669f39ce94243f98
3
+ metadata.gz: 84816713c530841342b09d6e6c0ad0ab9a3c76d9
4
+ data.tar.gz: 630093f3288af7c1a4c65d910e653e71aea91681
5
5
  SHA512:
6
- metadata.gz: 522c094a24fc50f1806f2de2ad09535f0039f91f5d72a59d04e034c97202631d0100655a1bdf7d432eff4ac0e609ecd8c36d5ae0e005b564b1335bcc7ff03381
7
- data.tar.gz: 9ce05c2a29b8283364361e7b0dffa6f901af27249a645f415824d9b752562a83648452afdfd3ef5ad36d4c5d87b2da45ba1966fa1238c19a3dbc3ae8294b66b5
6
+ metadata.gz: 6ad0fbbb6664dbcb5823bdd805df339c3df2c8727880debe19d5ef0d4b3a3bb75081f17536f08914c2c1afba3ed10976fcb2176e890f6187df4c8a0ee40cee06
7
+ data.tar.gz: 03ae07044bfded8fa0c63a55ec23cbeaacf04f43198543093e0c2fa7a4b62f6fa4eb34d1c060ccd4e94a36e2945be345c3c8ee4588ef4770998c6315587a776a
@@ -10,6 +10,7 @@ require 'paytrace/api/request'
10
10
  require 'paytrace/api/response'
11
11
  require 'paytrace/exceptions'
12
12
  require 'paytrace/recurring_transaction'
13
+ require 'paytrace/check_transaction'
13
14
 
14
15
  module PayTrace
15
16
  end
@@ -89,9 +89,10 @@ module PayTrace
89
89
  id_number:"PHOTOID",
90
90
  id_expiration:"IDEXP",
91
91
  cc_last_4:"LAST4",
92
- #bank accounts
92
+ #bank accounts/checks
93
93
  account_number:"DDA",
94
94
  routing_number:"TR",
95
+ check_type: "CHECKTYPE",
95
96
  #recurring transactions
96
97
  recur_id: "RECURID",
97
98
  recur_frequency: "FREQUENCY",
@@ -21,6 +21,13 @@ module PayTrace
21
21
  @@debug = enable
22
22
  end
23
23
 
24
+ def self.reset_trace
25
+ @@last_request = nil
26
+ @@last_response = nil
27
+ @@last_response_object = nil
28
+ @@next_response = nil
29
+ end
30
+
24
31
  def self.last_request
25
32
  @@last_request
26
33
  end
@@ -93,6 +93,7 @@ module PayTrace
93
93
  LEVEL_3_VISA_METHOD = "Level3Visa"
94
94
  LEVEL_3_MC_METHOD = "Level3MCRD"
95
95
  SETTLE_TRANSACTION_METHOD = "SettleTranx"
96
+ ADJUST_AMOUNT_METHOD = "AdjustAmount"
96
97
 
97
98
  def set_shipping_same_as_billing()
98
99
  @shipping_address = @billing_address
@@ -240,6 +241,15 @@ module PayTrace
240
241
  gateway.send_request(request)
241
242
  end
242
243
 
244
+ def self.adjust_amount(params = {})
245
+ request = PayTrace::API::Request.new
246
+ request.set_param(:method, ADJUST_AMOUNT_METHOD)
247
+ request.set_param(:transaction_id, params[:transaction_id])
248
+ request.set_param(:amount, params[:amount])
249
+ gateway = PayTrace::API::Gateway.new
250
+ gateway.send_request(request)
251
+ end
252
+
243
253
  private
244
254
  def add_transaction_info(request)
245
255
  request.set_param(:transaction_type, type)
@@ -1,3 +1,3 @@
1
1
  module PayTrace
2
- VERSION = "0.1.16"
2
+ VERSION = "0.1.17"
3
3
  end
@@ -5,8 +5,12 @@ describe PayTrace::Transaction do
5
5
  "UN~#{PayTrace.configuration.user_name}|PSWD~#{PayTrace.configuration.password}|TERMS~Y|"
6
6
  end
7
7
 
8
- it "exports transaction(s)" do
8
+ before do
9
9
  PayTrace::API::Gateway.debug = true
10
+ PayTrace::API::Gateway.reset_trace()
11
+ end
12
+
13
+ it "exports transaction(s)" do
10
14
  PayTrace::API::Gateway.next_response = "TRANSACTIONRECORD~TRANXID=1143"
11
15
  records = PayTrace::Transaction.export({transaction_id: 1143})
12
16
  records.must_be_instance_of Array
@@ -16,21 +20,18 @@ describe PayTrace::Transaction do
16
20
  end
17
21
 
18
22
  it "successfully attaches base-64 encoded signatures to transactions" do
19
- PayTrace::API::Gateway.debug = true
20
23
  PayTrace::API::Gateway.next_response = "RESPONSE~172. The signature image was successfully attached to Transaction ID 13192003.|"
21
24
  result = PayTrace::Transaction.attach_signature({transaction_id: 13192003, image_data: "foo", image_type: "png"})
22
25
  result.has_errors?.must_equal false
23
26
  end
24
27
 
25
28
  it "successfully attaches image files to transactions" do
26
- PayTrace::API::Gateway.debug = true
27
29
  PayTrace::API::Gateway.next_response = "RESPONSE~172. The signature image was successfully attached to Transaction ID 13192003.|"
28
30
  result = PayTrace::Transaction.attach_signature({transaction_id: 13192003, image_file: __FILE__, image_type: "png"})
29
31
  result.has_errors?.must_equal false
30
32
  end
31
33
 
32
34
  it "calculates shipping costs" do
33
- PayTrace::API::Gateway.debug = true
34
35
  PayTrace::API::Gateway.next_response = "SHIPPINGRECORD~SHIPPINGCOMPANY=USPS+SHIPPINGMETHOD=STANDARD POST+SHIPPINGRATE=12.72|"
35
36
  params = {
36
37
  #UN, PSWD, TERMS, METHOD, SOURCEZIP, SOURCESTATE, SZIP, WEIGHT, SHIPPERS, SSTATE
@@ -46,9 +47,17 @@ describe PayTrace::Transaction do
46
47
  result[0]['SHIPPINGCOMPANY'].must_equal "USPS"
47
48
  end
48
49
 
50
+ it "can adjust a transaction" do
51
+ PayTrace::API::Gateway.next_response = "SHIPPINGRECORD~SHIPPINGCOMPANY=USPS+SHIPPINGMETHOD=STANDARD POST+SHIPPINGRATE=12.72|"
52
+ params = {
53
+ transaction_id: 1234,
54
+ amount: 9.87
55
+ }
56
+ result = PayTrace::Transaction.adjust_amount(params)
57
+ PayTrace::API::Gateway.last_request.must_equal base_url + "METHOD~AdjustAmount|TRANXID~1234|AMOUNT~9.87|"
58
+ end
49
59
 
50
60
  it "can settle a transaction by recurrence ID" do
51
- PayTrace::API::Gateway.debug = true
52
61
  PayTrace::API::Gateway.next_response = "SHIPPINGRECORD~SHIPPINGCOMPANY=USPS+SHIPPINGMETHOD=STANDARD POST+SHIPPINGRATE=12.72|"
53
62
  params = {
54
63
  # UN, PSWD, TERMS, METHOD, RECURID
@@ -59,7 +68,6 @@ describe PayTrace::Transaction do
59
68
  end
60
69
 
61
70
  it "can settle a transaction by customer ID" do
62
- PayTrace::API::Gateway.debug = true
63
71
  PayTrace::API::Gateway.next_response = "SHIPPINGRECORD~SHIPPINGCOMPANY=USPS+SHIPPINGMETHOD=STANDARD POST+SHIPPINGRATE=12.72|"
64
72
  params = {
65
73
  # UN, PSWD, TERMS, METHOD, RECURID
@@ -0,0 +1,16 @@
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
+ # change this as needed to reflect the username, password, and test host you're testing against
7
+ PayTrace::Debug.configure_test("demo123", "demo123", "stage.paytrace.com")
8
+
9
+ PayTrace::Debug.trace do
10
+ params = {
11
+ # this must be a valid transaction ID for the credentials supplied
12
+ transaction_id: 1131,
13
+ amount: 4.01
14
+ }
15
+ PayTrace::Transaction::adjust_amount(params)
16
+ end
@@ -3,7 +3,8 @@
3
3
  require "paytrace"
4
4
  require "paytrace/debug"
5
5
 
6
- PayTrace::Debug.configure_test
6
+ # change this as needed to reflect the username, password, and test host you're testing against
7
+ PayTrace::Debug.configure_test("demo123", "demo123", "stage.paytrace.com")
7
8
 
8
9
  # see: http://help.paytrace.com/api-email-receipt for details
9
10
 
@@ -3,7 +3,8 @@
3
3
  require "paytrace"
4
4
  require "paytrace/debug"
5
5
 
6
- PayTrace::Debug.configure_test
6
+ # change this as needed to reflect the username, password, and test host you're testing against
7
+ PayTrace::Debug.configure_test("demo123", "demo123", "stage.paytrace.com")
7
8
 
8
9
  PayTrace::Debug.trace do
9
10
  params = {
@@ -3,7 +3,8 @@
3
3
  require "paytrace"
4
4
  require "paytrace/debug"
5
5
 
6
- PayTrace::Debug.configure_test
6
+ # change this as needed to reflect the username, password, and test host you're testing against
7
+ PayTrace::Debug.configure_test("demo123", "demo123", "stage.paytrace.com")
7
8
 
8
9
  # this should be a valid credit card number (it can be a "sandbox" number, however)
9
10
  cc = PayTrace::CreditCard.new({
@@ -3,7 +3,8 @@
3
3
  require "paytrace"
4
4
  require "paytrace/debug"
5
5
 
6
- PayTrace::Debug.configure_test
6
+ # change this as needed to reflect the username, password, and test host you're testing against
7
+ PayTrace::Debug.configure_test("demo123", "demo123", "stage.paytrace.com")
7
8
 
8
9
  PayTrace::Debug.trace do
9
10
  e = PayTrace::EmailReceiptRequest.new({email: "support@paytrace.com", check_id: "62" })
@@ -3,7 +3,8 @@
3
3
  require "paytrace"
4
4
  require "paytrace/debug"
5
5
 
6
- PayTrace::Debug.configure_test
6
+ # change this as needed to reflect the username, password, and test host you're testing against
7
+ PayTrace::Debug.configure_test("demo123", "demo123", "stage.paytrace.com")
7
8
 
8
9
  # this should dump out a wall of text...
9
10
  PayTrace::Debug.trace { puts PayTrace::Customer.export() }
@@ -3,7 +3,8 @@
3
3
  require "paytrace"
4
4
  require "paytrace/debug"
5
5
 
6
- PayTrace::Debug.configure_test
6
+ # change this as needed to reflect the username, password, and test host you're testing against
7
+ PayTrace::Debug.configure_test("demo123", "demo123", "stage.paytrace.com")
7
8
 
8
9
  PayTrace::API::Gateway.debug = true
9
10
 
@@ -3,11 +3,13 @@ $:<< "./lib" # uncomment this to run against a Git clone instead of an installed
3
3
  require "paytrace"
4
4
  require "paytrace/debug"
5
5
 
6
- PayTrace::Debug.configure_test
6
+ # change this as needed to reflect the username, password, and test host you're testing against
7
+ PayTrace::Debug.configure_test("demo123", "demo123", "stage.paytrace.com")
7
8
 
9
+ # This is testing the Level 3 data addition for Visa transactions
8
10
  PayTrace::Debug.trace do
9
11
  params = {
10
- transaction_id: "1143",
12
+ transaction_id: "1448",
11
13
  invoice: "12346",
12
14
  customer_reference_id: "1234578",
13
15
  tax_amount: 31.76,
@@ -54,19 +56,17 @@ PayTrace::Debug.trace do
54
56
  PayTrace::Transaction.add_level_three_visa(params)
55
57
  end
56
58
 
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
+ # This is testing the Level 3 data addition for Mastercard transactions
59
60
 
60
- PayTrace::Debug.configure_test("NEWapiuser", "test456")
61
61
  PayTrace::Debug.trace do
62
62
  params = {
63
- transaction_id: "1399",
63
+ transaction_id: "1448",
64
64
  invoice: "12347",
65
65
  customer_reference_id: "1234579",
66
66
  tax_amount: 31.78,
67
67
  national_tax: 0.01,
68
68
  freight: 7.98,
69
- duty: 6.51,
69
+ # duty: 6.51,
70
70
  source_zip: "94948",
71
71
  shipping_postal_code: "98134",
72
72
  shipping_country: "US",
@@ -3,7 +3,8 @@
3
3
  require "paytrace"
4
4
  require "paytrace/debug"
5
5
 
6
- PayTrace::Debug.configure_test
6
+ # change this as needed to reflect the username, password, and test host you're testing against
7
+ PayTrace::Debug.configure_test("demo123", "demo123", "stage.paytrace.com")
7
8
 
8
9
  # this should be a valid credit card number (it can be a "sandbox" number, however)
9
10
  cc = PayTrace::CreditCard.new({
@@ -3,7 +3,8 @@ $:<< "./lib" # uncomment this to run against a Git clone instead of an installed
3
3
  require "paytrace"
4
4
  require "paytrace/debug"
5
5
 
6
- PayTrace::Debug.configure_test
6
+ # change this as needed to reflect the username, password, and test host you're testing against
7
+ PayTrace::Debug.configure_test("demo123", "demo123", "stage.paytrace.com")
7
8
 
8
9
  # settle a transaction via a recurrence ID
9
10
  PayTrace::Debug.trace do
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.16
4
+ version: 0.1.17
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-28 00:00:00.000000000 Z
11
+ date: 2014-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -139,6 +139,7 @@ files:
139
139
  - test/paytrace/level3_data_spec.rb
140
140
  - test/paytrace/recurring_transaction_spec.rb
141
141
  - test/paytrace/transaction_spec.rb
142
+ - test/scripts/run_adjust_amount.rb
142
143
  - test/scripts/run_attach_signature.rb
143
144
  - test/scripts/run_calculate_shipping_costs.rb
144
145
  - test/scripts/run_change_password.rb
@@ -190,6 +191,7 @@ test_files:
190
191
  - test/paytrace/level3_data_spec.rb
191
192
  - test/paytrace/recurring_transaction_spec.rb
192
193
  - test/paytrace/transaction_spec.rb
194
+ - test/scripts/run_adjust_amount.rb
193
195
  - test/scripts/run_attach_signature.rb
194
196
  - test/scripts/run_calculate_shipping_costs.rb
195
197
  - test/scripts/run_change_password.rb