activemerchant-paymentech-orbital 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. data/.gitignore +3 -1
  2. data/Rakefile +8 -2
  3. data/VERSION +1 -1
  4. data/activemerchant-paymentech-orbital.gemspec +38 -19
  5. data/config/gateway.yml.example +6 -0
  6. data/lib/active_merchant/billing/{paymentech_orbital.rb → paymentech_orbital/gateway.rb} +5 -2
  7. data/lib/active_merchant/billing/paymentech_orbital/request.rb +12 -5
  8. data/lib/active_merchant/billing/paymentech_orbital/request/end_of_day.rb +4 -0
  9. data/lib/active_merchant/billing/paymentech_orbital/request/new_order.rb +20 -1
  10. data/lib/active_merchant/billing/paymentech_orbital/request/profile_management.rb +29 -2
  11. data/lib/active_merchant/billing/paymentech_orbital/request/void.rb +6 -0
  12. data/lib/active_merchant/billing/paymentech_orbital/response.rb +57 -4
  13. data/lib/activemerchant-paymentech-orbital.rb +1 -1
  14. data/test/factories.rb +55 -4
  15. data/test/remote/auth_capture_test.rb +101 -0
  16. data/test/remote/auth_test.rb +42 -0
  17. data/test/remote/existing_profile_test.rb +137 -0
  18. data/test/remote/profile_test.rb +72 -0
  19. data/test/remote/recurring_test.rb +160 -0
  20. data/test/remote/refund_test.rb +87 -0
  21. data/test/remote/retry_test.rb +51 -0
  22. data/test/remote_helper.rb +28 -0
  23. data/test/test_helper.rb +0 -1
  24. data/test/unit_helper.rb +2 -0
  25. data/test/{payment_orbital → units/paymentech_orbital}/gateway_test.rb +1 -1
  26. data/test/{payment_orbital → units/paymentech_orbital}/request/end_of_day_test.rb +1 -1
  27. data/test/{payment_orbital → units/paymentech_orbital}/request/new_order_test.rb +1 -1
  28. data/test/{payment_orbital → units/paymentech_orbital}/request/profile_management_test.rb +6 -2
  29. data/test/{payment_orbital → units/paymentech_orbital}/request/void_test.rb +1 -1
  30. data/test/{payment_orbital → units/paymentech_orbital}/request_test.rb +1 -1
  31. metadata +53 -23
@@ -0,0 +1,101 @@
1
+ require 'remote_helper'
2
+
3
+ # Auth/capture
4
+ # # without profile
5
+ # # with profile
6
+ # Auth
7
+ # # without profile
8
+ # # with profile
9
+ # Void
10
+ # Refund
11
+
12
+ # Retry logic
13
+
14
+ class AuthCaptureTest < Test::Unit::TestCase
15
+ context "Auth/Capture" do
16
+ setup do
17
+ @gateway = remote_gateway
18
+ @address = Options(:billing_address)
19
+ end
20
+
21
+ context "with amex" do
22
+ setup do
23
+ @credit_card = Factory(:amex)
24
+ @response = @gateway.purchase(100, @credit_card, {
25
+ :address => @address,
26
+ :order_id => @@order_id,
27
+ :soft_descriptors => {
28
+ :merchant_name => 'Bitbop',
29
+ :merchant_url => 'bitbop.com'
30
+ }
31
+ })
32
+ end
33
+
34
+ should "be successful" do
35
+ assert @response.success?, "should be successful overall"
36
+ assert @response.approved?, "should be approved"
37
+ assert @response.profile_proc_success?, "should save profile"
38
+ end
39
+ end
40
+
41
+ context "with discover" do
42
+ setup do
43
+ @credit_card = Factory(:discover)
44
+ @response = @gateway.purchase(100, @credit_card, {
45
+ :address => @address,
46
+ :order_id => @@order_id,
47
+ :soft_descriptors => {
48
+ :merchant_name => 'Bitbop',
49
+ :merchant_url => 'bitbop.com'
50
+ }
51
+ })
52
+ end
53
+
54
+ should "be successful" do
55
+ assert @response.success?, "should be successful overall"
56
+ assert @response.approved?, "should be approved"
57
+ assert @response.profile_proc_success?, "should save profile"
58
+ end
59
+ end
60
+
61
+ context "with mastercard" do
62
+ setup do
63
+ @credit_card = Factory(:master_card)
64
+ @response = @gateway.purchase(100, @credit_card, {
65
+ :address => @address,
66
+ :order_id => @@order_id,
67
+ :soft_descriptors => {
68
+ :merchant_name => 'Bitbop',
69
+ :merchant_url => 'bitbop.com'
70
+ }
71
+ })
72
+ end
73
+
74
+ should "be successful" do
75
+ assert @response.success?, "should be successful overall"
76
+ assert @response.approved?, "should be approved"
77
+ assert @response.profile_proc_success?, "should save profile"
78
+ end
79
+ end
80
+
81
+ context "with visa" do
82
+ setup do
83
+ @credit_card = Factory(:visa)
84
+ @response = @gateway.purchase(100, @credit_card, {
85
+ :address => @address,
86
+ :order_id => @@order_id,
87
+ :soft_descriptors => {
88
+ :merchant_name => 'Bitbop',
89
+ :merchant_url => 'bitbop.com'
90
+ }
91
+ })
92
+ end
93
+
94
+ should "be successful" do
95
+ assert @response.success?, "should be successful overall"
96
+ assert @response.approved?, "should be approved"
97
+ assert @response.profile_proc_success?, "should save profile"
98
+ end
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,42 @@
1
+ require 'remote_helper'
2
+
3
+ class AuthTest < Test::Unit::TestCase
4
+ context "Auth" do
5
+ setup do
6
+ @gateway = remote_gateway
7
+ @address = Options(:billing_address)
8
+ end
9
+
10
+ context "with mastercard" do
11
+ setup do
12
+ @credit_card = Factory(:master_card)
13
+ @response = @gateway.authorize(000, @credit_card, {
14
+ :address => @address,
15
+ :order_id => @@order_id
16
+ })
17
+ end
18
+
19
+ should "be successful" do
20
+ assert @response.success?, "should be successful overall"
21
+ assert @response.approved?, "should be approved"
22
+ assert @response.profile_proc_success?, "should save profile"
23
+ end
24
+ end
25
+
26
+ context "with visa" do
27
+ setup do
28
+ @credit_card = Factory(:visa)
29
+ @response = @gateway.authorize(000, @credit_card, {
30
+ :address => @address,
31
+ :order_id => @@order_id
32
+ })
33
+ end
34
+
35
+ should "be successful" do
36
+ assert @response.success?, "should be successful overall"
37
+ assert @response.approved?, "should be approved"
38
+ assert @response.profile_proc_success?, "should save profile"
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,137 @@
1
+ require 'remote_helper'
2
+
3
+ # With existing profile:
4
+ # Auth/Capture: AX
5
+ # Void the above
6
+ # Auth/Capture: MC
7
+ # Void the above
8
+ # Auth/Capture: DI
9
+ # Void the above
10
+ # Auth/Capture: VI
11
+ # Void the above
12
+
13
+ class ProfileTest < Test::Unit::TestCase
14
+ context "With an amex" do
15
+ setup do
16
+ @gateway = remote_gateway
17
+ @address = Options(:billing_address)
18
+ @credit_card = Factory(:amex)
19
+ @create_response = @gateway.profile(:create, @credit_card, {
20
+ :address => @address
21
+ })
22
+ @customer_ref_num = @create_response.customer_ref_num
23
+ end
24
+
25
+ should "perform an auth/capture then void it" do
26
+ @purchase_response = @gateway.purchase(100, nil, {
27
+ :customer_ref_num => @customer_ref_num,
28
+ :order_id => @@order_id
29
+ })
30
+
31
+ assert @purchase_response.success?, "should be successful overall"
32
+ assert @purchase_response.approved?, "should be approved"
33
+ assert @purchase_response.profile_proc_success?, "should save profile"
34
+
35
+ @@csv << @gateway.to_a
36
+
37
+ @void_response = @gateway.void(@purchase_response.tx_ref_num, @purchase_response.tx_ref_idx, nil, {
38
+ :order_id => @@order_id
39
+ })
40
+
41
+ assert @void_response.success?, "should be successful overall"
42
+ end
43
+ end
44
+
45
+ context "With a discover" do
46
+ setup do
47
+ @gateway = remote_gateway
48
+ @address = Options(:billing_address)
49
+ @credit_card = Factory(:discover)
50
+ @create_response = @gateway.profile(:create, @credit_card, {
51
+ :address => @address
52
+ })
53
+ @customer_ref_num = @create_response.customer_ref_num
54
+ end
55
+
56
+ should "perform an auth/capture then void it" do
57
+ @purchase_response = @gateway.purchase(100, nil, {
58
+ :customer_ref_num => @customer_ref_num,
59
+ :order_id => @@order_id
60
+ })
61
+
62
+ assert @purchase_response.success?, "should be successful overall"
63
+ assert @purchase_response.approved?, "should be approved"
64
+ assert @purchase_response.profile_proc_success?, "should save profile"
65
+
66
+ @@csv << @gateway.to_a
67
+
68
+ @void_response = @gateway.void(@purchase_response.tx_ref_num, @purchase_response.tx_ref_idx, nil, {
69
+ :order_id => @@order_id
70
+ })
71
+
72
+ assert @void_response.success?, "should be successful overall"
73
+ end
74
+ end
75
+
76
+ context "With a master_card" do
77
+ setup do
78
+ @gateway = remote_gateway
79
+ @address = Options(:billing_address)
80
+ @credit_card = Factory(:master_card)
81
+ @create_response = @gateway.profile(:create, @credit_card, {
82
+ :address => @address
83
+ })
84
+ @customer_ref_num = @create_response.customer_ref_num
85
+ end
86
+
87
+ should "perform an auth/capture then void it" do
88
+ @purchase_response = @gateway.purchase(100, nil, {
89
+ :customer_ref_num => @customer_ref_num,
90
+ :order_id => @@order_id
91
+ })
92
+
93
+ assert @purchase_response.success?, "should be successful overall"
94
+ assert @purchase_response.approved?, "should be approved"
95
+ assert @purchase_response.profile_proc_success?, "should save profile"
96
+
97
+ @@csv << @gateway.to_a
98
+
99
+ @void_response = @gateway.void(@purchase_response.tx_ref_num, @purchase_response.tx_ref_idx, nil, {
100
+ :order_id => @@order_id
101
+ })
102
+
103
+ assert @void_response.success?, "should be successful overall"
104
+ end
105
+ end
106
+
107
+ context "With a visa" do
108
+ setup do
109
+ @gateway = remote_gateway
110
+ @address = Options(:billing_address)
111
+ @credit_card = Factory(:visa)
112
+ @create_response = @gateway.profile(:create, @credit_card, {
113
+ :address => @address
114
+ })
115
+ @customer_ref_num = @create_response.customer_ref_num
116
+ end
117
+
118
+ should "perform an auth/capture then void it" do
119
+ @purchase_response = @gateway.purchase(100, nil, {
120
+ :customer_ref_num => @customer_ref_num,
121
+ :order_id => @@order_id
122
+ })
123
+
124
+ assert @purchase_response.success?, "should be successful overall"
125
+ assert @purchase_response.approved?, "should be approved"
126
+ assert @purchase_response.profile_proc_success?, "should save profile"
127
+
128
+ @@csv << @gateway.to_a
129
+
130
+ @void_response = @gateway.void(@purchase_response.tx_ref_num, @purchase_response.tx_ref_idx, nil, {
131
+ :order_id => @@order_id
132
+ })
133
+
134
+ assert @void_response.success?, "should be successful overall"
135
+ end
136
+ end
137
+ end
@@ -0,0 +1,72 @@
1
+ require 'remote_helper'
2
+
3
+ # Profile CRUD
4
+
5
+ class ProfileTest < Test::Unit::TestCase
6
+ context "Profile CRUD" do
7
+ setup do
8
+ @gateway = remote_gateway
9
+ @address = Options(:billing_address)
10
+ @credit_card = Factory(:visa)
11
+ end
12
+
13
+ should "create a profile" do
14
+ @create_response = @gateway.profile(:create, @credit_card, {
15
+ :address => @address
16
+ })
17
+
18
+ assert @create_response.success?, "should be successful overall"
19
+ assert @create_response.profile_proc_success?, "should save profile"
20
+ end
21
+
22
+ should "read a profile" do
23
+ @create_response = @gateway.profile(:create, @credit_card, {
24
+ :address => @address
25
+ })
26
+ @customer_ref_num = @create_response.customer_ref_num
27
+
28
+ @read_response = @gateway.profile(:retrieve, nil, {
29
+ :customer_ref_num => @customer_ref_num
30
+ })
31
+
32
+ assert_equal @customer_ref_num, @read_response.customer_ref_num
33
+ assert @read_response.success?, "should be successful overall"
34
+ assert @read_response.profile_proc_success?, "should save profile"
35
+ end
36
+
37
+ should "update a profile" do
38
+ @create_response = @gateway.profile(:create, @credit_card, {
39
+ :address => @address
40
+ })
41
+ @customer_ref_num = @create_response.customer_ref_num
42
+
43
+ @new_name = "Smith Joe"
44
+
45
+ assert_not_equal @new_name, @create_response.customer_name
46
+
47
+ @update_response = @gateway.profile(:update, nil, {
48
+ :address => {
49
+ :name => @new_name
50
+ },
51
+ :customer_ref_num => @customer_ref_num
52
+ })
53
+
54
+ assert @update_response.success?, "should be successful overall"
55
+ assert @update_response.profile_proc_success?, "should save profile"
56
+ end
57
+
58
+ should "delete a profile" do
59
+ @create_response = @gateway.profile(:create, @credit_card, {
60
+ :address => @address
61
+ })
62
+ @customer_ref_num = @create_response.customer_ref_num
63
+
64
+ @delete_response = @gateway.profile(:delete, nil, {
65
+ :customer_ref_num => @customer_ref_num
66
+ })
67
+
68
+ assert @delete_response.success?, "should be successful overall"
69
+ assert @delete_response.profile_proc_success?, "should save profile"
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,160 @@
1
+ require 'remote_helper'
2
+
3
+ # Recurring:
4
+ # Auth/Capture
5
+ # x Update MBCancelDate
6
+ # Update MBRestoreBillingDate / restore a canceled billing date
7
+ # x Update MBRecurringEndDate
8
+ # x Update MBRemoveFlag / entirely remove mb info
9
+ # x Start late
10
+
11
+ class RecurringTest < Test::Unit::TestCase
12
+ def teardown; end
13
+
14
+ context "Recurring" do
15
+ setup do
16
+ @gateway = remote_gateway
17
+ @address = Options(:billing_address)
18
+ @credit_card = Factory(:visa)
19
+ end
20
+
21
+ should "set start date to future" do
22
+ @@csv << []
23
+ @@csv << ["Starting a recurring payment in the future."]
24
+ @recurring_start_date = (Date.today + 7).strftime("%m%d%Y")
25
+ @purchase = @gateway.purchase(999, @credit_card, {
26
+ :address => @address,
27
+ :mb_type => "R",
28
+ :industry_type => "RC",
29
+ :order_id => @@order_id,
30
+ :recurring_end_date_flag => "N",
31
+ :recurring_frequency => "#{(Date.today + 7).strftime("%d")} * ?",
32
+ :recurring_start_date => @recurring_start_date,
33
+ :mb_type => "R"
34
+ })
35
+ assert @purchase.success?
36
+ @@csv << @gateway.to_a
37
+
38
+ @read_response = @gateway.profile(:retrieve, nil, {
39
+ :customer_ref_num => @purchase.customer_ref_num
40
+ })
41
+
42
+ assert_equal @recurring_start_date, @read_response.mb_recurring_start_date
43
+ end
44
+
45
+ should "remove mb info from a profile" do
46
+ @@csv << []
47
+ @@csv << ["Removing mb info from a profile."]
48
+ @recurring_start_date = (Date.today + 7).strftime("%m%d%Y")
49
+ @purchase = @gateway.purchase(999, @credit_card, {
50
+ :address => @address,
51
+ :mb_type => "R",
52
+ :industry_type => "RC",
53
+ :order_id => @@order_id,
54
+ :recurring_end_date_flag => "N",
55
+ :recurring_frequency => "#{(Date.today + 7).strftime("%d")} * ?",
56
+ :recurring_start_date => @recurring_start_date,
57
+ :mb_type => "R"
58
+ })
59
+ assert @purchase.success?
60
+ @@csv << @gateway.to_a
61
+ @customer_ref_num = @purchase.customer_ref_num
62
+
63
+ @read_response = @gateway.profile(:retrieve, nil, {
64
+ :customer_ref_num => @customer_ref_num
65
+ })
66
+ assert @read_response.success?
67
+ assert_equal @recurring_start_date, @read_response.mb_recurring_start_date
68
+
69
+ @update_response = @gateway.profile(:update, nil, {
70
+ :customer_ref_num => @customer_ref_num,
71
+ :mb_remove_flag => "Y",
72
+ :mb_type => "R"
73
+ })
74
+ @@csv << @gateway.to_a
75
+ assert @update_response.success?
76
+
77
+ @updated_response = @gateway.profile(:retrieve, nil, {
78
+ :customer_ref_num => @customer_ref_num
79
+ })
80
+ assert @updated_response.success?
81
+ assert_nil @updated_response.mb_recurring_start_date
82
+ end
83
+
84
+ should "add a recurring end date" do
85
+ @@csv << []
86
+ @@csv << ["Adding a recurring end date"]
87
+ @purchase = @gateway.purchase(999, @credit_card, {
88
+ :address => @address,
89
+ :mb_type => "R",
90
+ :industry_type => "RC",
91
+ :order_id => @@order_id,
92
+ :recurring_end_date_flag => "Y",
93
+ :recurring_frequency => "#{(Date.today + 7).strftime("%d")} * ?",
94
+ :recurring_start_date => (Date.today + 7).strftime("%m%d%Y"),
95
+ :mb_type => "R"
96
+ })
97
+ @@csv << @gateway.to_a
98
+ assert @purchase.success?
99
+ @customer_ref_num = @purchase.customer_ref_num
100
+
101
+ @read_response = @gateway.profile(:retrieve, nil, {
102
+ :customer_ref_num => @customer_ref_num
103
+ })
104
+ assert @read_response.success?
105
+
106
+ assert_nil @read_response.mb_recurring_end_date
107
+
108
+ # Remove mb info
109
+ @remove_response = @gateway.profile(:update, nil, {
110
+ :customer_ref_num => @customer_ref_num,
111
+ :mb_remove_flag => "Y",
112
+ :mb_type => "R"
113
+ })
114
+ @@csv << @gateway.to_a
115
+ assert @remove_response.success?
116
+
117
+ @recurring_end_date = "12#{(Date.today + 7).strftime("%d")}2010"
118
+ @update_response = @gateway.profile(:update, nil, {
119
+ :customer_ref_num => @customer_ref_num,
120
+ :mb_recurring_end_date => @recurring_end_date,
121
+ :mb_recurring_frequency => "#{(Date.today + 7).strftime("%d")} * ?",
122
+ :mb_recurring_start_date => (Date.today + 7).strftime("%m%d%Y"),
123
+ :mb_type => "R"
124
+ })
125
+
126
+ @@csv << @gateway.to_a
127
+ assert @update_response.success?
128
+
129
+ @updated_response = @gateway.profile(:retrieve, nil, {
130
+ :customer_ref_num => @customer_ref_num
131
+ })
132
+
133
+ assert_equal @recurring_end_date, @updated_response.mb_recurring_end_date
134
+ end
135
+
136
+ should "update cancel date" do
137
+ @@csv << []
138
+ @@csv << ["Cancelling a future, scheduled payment."]
139
+
140
+ @customer_ref_num = "3461056"
141
+ @read_response = @gateway.profile(:retrieve, nil, {
142
+ :customer_ref_num => @customer_ref_num,
143
+ :mb_type => "R"
144
+ })
145
+
146
+ @update_response = @gateway.profile(:update, nil, {
147
+ :customer_ref_num => @customer_ref_num,
148
+ :mb_cancel_date => "09132011",
149
+ :mb_type => "R"
150
+ })
151
+ @@csv << @gateway.to_a
152
+ assert @update_response.success?
153
+
154
+ @updated_profile = @gateway.profile(:retrieve, nil, {
155
+ :customer_ref_num => @customer_ref_num
156
+ })
157
+ assert @updated_profile.success?
158
+ end
159
+ end
160
+ end