paytrace 0.1.8 → 0.1.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e13cfd13c9fa4d9c8ec7b4fc6e950bd3b2923a3f
4
- data.tar.gz: d407555a86e3e4193e9fb38a66eecd47701350c1
3
+ metadata.gz: 44c650779abac381f8aa795ef2fdb9318ef846eb
4
+ data.tar.gz: 148eeb0bddda9f331afabbc97ad2991e91a70599
5
5
  SHA512:
6
- metadata.gz: f3e0613a8cdddcfa3800e120ce48da58353cc6886af2100e5db2922f3cc2503ade41ca24f380e294530d6deb50f5ccce1121c32782056b4916e8a973a1cc07b3
7
- data.tar.gz: f74214c1513e428e24a7b245693a441d536d4f1ffd24990f7c8f0c473ce9ffe3199818fa0c10b965fbbe60c4f5473eee902715cd92a8ff9d83686973ac8eaf43
6
+ metadata.gz: 19e53a00575c838678e7951a38f7b0051eef92df6dc1500d3220fcc107c626fd6ff4f0405978e3fd8120ce8928f1605c4de5b3c39a675c738f2afc71ca1b60ea
7
+ data.tar.gz: f86a1e5fb3714839854f7ba55bcca993ed8cdaacd0dbcea34fcf94033003b5314676d3e431d22213b86b2df6a30384a130d4a903367645316841ab0f51fec365
@@ -5,6 +5,8 @@ module PayTrace
5
5
  CREATE_CUSTOMER = "CreateCustomer"
6
6
  UPDATE_CUSTOMER = "UpdateCustomer"
7
7
  DELETE_CUSTOMER = "DeleteCustomer"
8
+ EXPORT_CUSTOMERS = "ExportCustomers"
9
+ EXPORT_CUSTOMERS_RESPONSE = "CUSTOMERRECORD"
8
10
 
9
11
  def initialize(customer_id = nil)
10
12
  @customer_id = customer_id
@@ -22,6 +24,22 @@ module PayTrace
22
24
  gateway.send_request(request)
23
25
  end
24
26
 
27
+ def self.export(params = {})
28
+ # CUSTID, EMAIL, USER, RETURNBIN
29
+ request = PayTrace::API::Request.new
30
+ request.set_param(:method, EXPORT_CUSTOMERS)
31
+ request.set_param(:customer_id, params[:customer_id])
32
+ request.set_param(:email, params[:email])
33
+ request.set_param(:transaction_user, params[:transaction_user])
34
+ request.set_param(:return_bin, params[:return_bin])
35
+ gateway = PayTrace::API::Gateway.new
36
+ response = gateway.send_request(request, [EXPORT_CUSTOMERS_RESPONSE])
37
+
38
+ unless response.has_errors?
39
+ response.values[EXPORT_CUSTOMERS_RESPONSE]
40
+ end
41
+ end
42
+
25
43
  def self.delete(customer_id)
26
44
  Customer.new(customer_id).delete
27
45
  end
@@ -1,3 +1,3 @@
1
1
  module PayTrace
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
@@ -10,6 +10,19 @@ describe PayTrace::Customer do
10
10
  PayTrace::API::Gateway.next_response = "RESPONSE~ok|CUSTOMERID~12345|CUSTID~john_doe"
11
11
  end
12
12
 
13
+ describe "export customers" do
14
+ it "works" do
15
+ PayTrace::API::Gateway.next_response = "CUSTOMERRECORD~CUSTID=741356+CUSTOMERID=741356+CC=************5454+EXPMNTH=12+EXPYR=17+SNAME=+SADDRESS=+SADDRESS2=+SCITY=+SCOUNTY=+SSTATE=+SZIP=+SCOUNTRY=US+BNAME=DUMMY1+BADDRESS=+BADDRESS2=+BCITY=+BSTATE=+BZIP=+BCOUNTRY=US+EMAIL=+PHONE=+FAX=+WHEN=2/7/2014 5:02:08 PM+USER=demo123+IP=131.191.89.5+DDA=123412341234+TR=051000017+hair_color=+|"
16
+ records = PayTrace::Customer.export()
17
+
18
+ PayTrace::API::Gateway.last_request.must_equal base_url + "METHOD~ExportCustomers|"
19
+ records.count.must_equal 1
20
+ records.must_be_instance_of Array
21
+ records[0].must_be_instance_of Hash
22
+ records[0].keys.count.must_equal 29
23
+ end
24
+ end
25
+
13
26
  describe "create customer profile" do
14
27
  # first call path: create from credit card information
15
28
  it "can be created from credit card information" do
@@ -1,4 +1,4 @@
1
- $:<< "./lib"
1
+ # $:<< "./lib" # uncomment this to run against a Git clone instead of an installed gem
2
2
 
3
3
  require "paytrace"
4
4
 
@@ -0,0 +1,49 @@
1
+ # $:<< "./lib" # uncomment this to run against a Git clone instead of an installed gem
2
+
3
+ require "paytrace"
4
+
5
+ # see: http://help.paytrace.com/api-exporting-customer-profiles for details
6
+
7
+ #
8
+ # Helper that loops through the response values and dumps them out
9
+ #
10
+ def dump_transaction
11
+ puts "[REQUEST] #{PayTrace::API::Gateway.last_request}"
12
+ response = PayTrace::API::Gateway.last_response_object
13
+ if(response.has_errors?)
14
+ response.errors.each do |key, value|
15
+ puts "[RESPONSE] ERROR: #{key.ljust(20)}#{value}"
16
+ end
17
+ else
18
+ response.values.each do |key, value|
19
+ puts "[RESPONSE] #{key.ljust(20)}#{value}"
20
+ end
21
+ end
22
+ end
23
+
24
+ def log(msg)
25
+ puts ">>>>>> #{msg}"
26
+ end
27
+
28
+ def trace(&block)
29
+ PayTrace::API::Gateway.debug = true
30
+
31
+ begin
32
+ yield
33
+ rescue Exception => e
34
+ raise
35
+ else
36
+ dump_transaction
37
+ end
38
+ end
39
+
40
+ PayTrace.configure do |config|
41
+ config.user_name = "demo123"
42
+ config.password = "demo123"
43
+ config.domain = "stage.paytrace.com"
44
+ end
45
+
46
+ PayTrace::API::Gateway.debug = true
47
+
48
+ # this should dump out a wall of text...
49
+ trace { puts PayTrace::Customer.export() }
@@ -1,4 +1,4 @@
1
- $:<< "./lib"
1
+ # $:<< "./lib" # uncomment this to run against a Git clone instead of an installed gem
2
2
 
3
3
  require "paytrace"
4
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paytrace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trevor Redfern
@@ -140,6 +140,7 @@ files:
140
140
  - test/scripts/run_attach_signature.rb
141
141
  - test/scripts/run_create_customer.rb
142
142
  - test/scripts/run_email_request.rb
143
+ - test/scripts/run_export_customers.rb
143
144
  - test/scripts/run_export_transactions.rb
144
145
  - test/scripts/run_recur_payments_integration.rb
145
146
  - test/scripts/smiley_face.png
@@ -185,6 +186,7 @@ test_files:
185
186
  - test/scripts/run_attach_signature.rb
186
187
  - test/scripts/run_create_customer.rb
187
188
  - test/scripts/run_email_request.rb
189
+ - test/scripts/run_export_customers.rb
188
190
  - test/scripts/run_export_transactions.rb
189
191
  - test/scripts/run_recur_payments_integration.rb
190
192
  - test/scripts/smiley_face.png