twocheckout 0.2.0 → 0.3.0

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: f1626c1aac085f25b351a2be715c38ea80e0d9fd
4
- data.tar.gz: c14dcf32498ac74d878f9712b6f3980035b42b4f
3
+ metadata.gz: dce977ca3179d64dbcaf3afef749b271d4154601
4
+ data.tar.gz: e1a3745495e261b8728e23313fe5211012d5cf7f
5
5
  SHA512:
6
- metadata.gz: f19c9b26078b7d32186394c81ebed1cfb6cbbfbef1ddcb5d73961f6f989a9e1497cf3bd860314100397bb01bcb1d08b61a24fa1158db9f20a9e7a529e04369be
7
- data.tar.gz: 232c8710c4b54d3a54acaadbef77e972cc35cba9895566739a2977d738c7aa93a2b57d4a5bae20f791196ee22dc39c24677068f5ef9b26b5e1d44ae5938015a0
6
+ metadata.gz: 0e4f9a886771ddb34aef7fdee4c9d14ea94b2e8a28fe23bcd8662aa8219d465b1531c14430db81471300be44a59fcf67c050b4741581bafa181b8793a39dd9c4
7
+ data.tar.gz: a28e08851d2d45b3c3be3cd2ed29f3b9e3045cb7457c609c49e81be941fe9ef8ae90ae39e47878c5d3396d143bd92f6a1e8f1aedf186c076533e262800ffcdd8
data/README.md CHANGED
@@ -15,7 +15,7 @@ Or import into your Gemfile.
15
15
  gem "twocheckout"
16
16
  ```
17
17
 
18
- Full documentation for each binding is provided in the **[Wiki](https://github.com/2checkout/2checkout-ruby/wiki)**.
18
+ Full documentation for each binding is provided in the **[2Checkout Documentation](https://github.com/2checkout/2checkout-ruby/wiki)**.
19
19
 
20
20
 
21
21
  Example Purchase API Usage
@@ -284,4 +284,4 @@ end
284
284
  "Lineitem is not scheduled to recur."
285
285
  ```
286
286
 
287
- Full documentation for each binding is provided in the **[Wiki](https://github.com/2checkout/2checkout-ruby/wiki)**.
287
+ Full documentation for each binding is provided in the **[2Checkout Documentation](https://github.com/2checkout/2checkout-ruby/wiki)**.
data/lib/twocheckout.rb CHANGED
File without changes
@@ -3,9 +3,8 @@ require 'json'
3
3
 
4
4
  module Twocheckout
5
5
  class API
6
- API_BASE = 'https://www.2checkout.com/api/'
7
- CHECKOUT_BASE = 'https://www.2checkout.com/checkout/api/'
8
- SANDBOX_BASE = 'https://sandbox.2checkout.com/checkout/api/'
6
+ PROD_BASE = 'https://www.2checkout.com'
7
+ SANDBOX_BASE = 'https://sandbox.2checkout.com'
9
8
  API_VERSION = '1'
10
9
 
11
10
  def self.credentials=(opts)
@@ -34,9 +33,9 @@ module Twocheckout
34
33
  private
35
34
 
36
35
  def self.set_opts(http_method, api_call, params = null)
36
+ url = @@sandbox ? SANDBOX_BASE : PROD_BASE
37
37
  if api_call == 'authService'
38
- url = @@sandbox? SANDBOX_BASE : CHECKOUT_BASE
39
- url += API_VERSION + '/' + @@seller_id + '/rs/' + api_call
38
+ url += '/checkout/api/' + API_VERSION + '/' + @@seller_id + '/rs/' + api_call
40
39
  params['sellerId'] = @@seller_id
41
40
  params['privateKey'] = @@private_key
42
41
  opts = {
@@ -50,7 +49,7 @@ module Twocheckout
50
49
  :payload => params.to_json,
51
50
  }
52
51
  else
53
- url = API_BASE + api_call
52
+ url += '/api/' + api_call
54
53
  if http_method == :get
55
54
  url += hash_to_querystring(params)
56
55
  params = nil
@@ -1,8 +1,14 @@
1
1
  module Twocheckout
2
2
  class Checkout < HashObject
3
3
 
4
+ @checkout_url = 'https://www.2checkout.com/checkout/purchase'
5
+
6
+ def self.sandbox(sandbox)
7
+ @checkout_url = sandbox ? 'https://sandbox.2checkout.com/checkout/purchase' : @checkout_url;
8
+ end
9
+
4
10
  def self.form(params={}, button_text='Proceed to Checkout')
5
- @form = "<form id=\"2checkout\" action=\"https://www.2checkout.com/checkout/purchase\" method=\"post\">\n";
11
+ @form = "<form id=\"2checkout\" action=\"#{@checkout_url}\" method=\"post\">\n";
6
12
  params.each do |k,v|
7
13
  @form = @form + "<input type=\"hidden\" name=\"" + k + "\" value=\"" + v.to_s + "\" />\n"
8
14
  end
@@ -10,7 +16,7 @@ module Twocheckout
10
16
  end
11
17
 
12
18
  def self.submit(params={})
13
- @form = "<form id=\"2checkout\" action=\"https://www.2checkout.com/checkout/purchase\" method=\"post\">\n";
19
+ @form = "<form id=\"2checkout\" action=\"#{@checkout_url}\" method=\"post\">\n";
14
20
  params.each do |k,v|
15
21
  @form = @form + "<input type=\"hidden\" name=\"" + k + "\" value=\"" + v.to_s + "\" />\n"
16
22
  end
@@ -19,7 +25,7 @@ module Twocheckout
19
25
  end
20
26
 
21
27
  def self.direct(params={}, button_text='Proceed to Checkout')
22
- @form = "<form id=\"2checkout\" action=\"https://www.2checkout.com/checkout/purchase\" method=\"post\">\n";
28
+ @form = "<form id=\"2checkout\" action=\"#{@checkout_url}\" method=\"post\">\n";
23
29
  params.each do |k,v|
24
30
  @form = @form + "<input type=\"hidden\" name=\"" + k + "\" value=\"" + v.to_s + "\" />\n"
25
31
  end
@@ -27,9 +33,9 @@ module Twocheckout
27
33
  @form = @form + "<script src=\"https://www.2checkout.com/static/checkout/javascript/direct.min.js\"></script>"
28
34
  end
29
35
 
30
- def self.link(params={}, url="https://www.2checkout.com/checkout/purchase?")
36
+ def self.link(params={})
31
37
  @querystring = params.map{|k,v| "#{CGI.escape(k)}=#{CGI.escape(v)}"}.join("&")
32
- @purchase_url = url + @querystring
38
+ @purchase_url = @checkout_url + '?' + @querystring
33
39
  end
34
40
 
35
41
  def self.authorize(params={})
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,3 +1,3 @@
1
1
  module Twocheckout
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -1,10 +1,12 @@
1
- require "minitest/spec"
2
1
  require "minitest/autorun"
3
2
  require "twocheckout"
4
3
 
5
4
  Twocheckout::API.credentials = {
6
- :username => 'APIuser1817037',
7
- :password => 'APIpass1817037',
8
- :seller_id => '532001',
9
- :private_key => '9999999'
10
- }
5
+ :username => 'testlibraryapi901248204',
6
+ :password => 'testlibraryapi901248204PASS',
7
+ :seller_id => '901248204',
8
+ :private_key => 'BE632CB0-BB29-11E3-AFB6-D99C28100996',
9
+ :sandbox => true
10
+ }
11
+
12
+ Twocheckout::Checkout.sandbox(true);
@@ -7,14 +7,14 @@ describe Twocheckout::Sale do
7
7
 
8
8
  #retrieve sale
9
9
  it "Sale retrieve returns sale" do
10
- sale = Twocheckout::Sale.find(:sale_id => 4786293822)
11
- assert_equal('4786293822', sale.sale_id)
10
+ sale = Twocheckout::Sale.find(:sale_id => 9093717691800)
11
+ assert_equal('9093717691800', sale.sale_id)
12
12
  end
13
13
 
14
14
  #retrieve invoice
15
15
  it "Sale retrieve returns invoice" do
16
- invoice = Twocheckout::Sale.find({:invoice_id => 4786293831})
17
- assert_equal('4786293831', invoice.invoice_id)
16
+ invoice = Twocheckout::Sale.find({:invoice_id => 9093717691821})
17
+ assert_equal('9093717691821', invoice.invoice_id)
18
18
  end
19
19
 
20
20
  #retrieve sale list
@@ -25,84 +25,84 @@ describe Twocheckout::Sale do
25
25
 
26
26
  #refund sale
27
27
  it "Refunding a refunded sale returns exception" do
28
- begin
29
- sale = Twocheckout::Sale.find(:sale_id => 4786293822)
30
- sale.refund!({:comment => "test refund", :category => 1})
28
+ begin
29
+ sale = Twocheckout::Sale.find(:sale_id => 9093717691800)
30
+ sale.refund!({:comment => "test refund", :category => 1})
31
31
  rescue Exception => e
32
- assert_equal("Invoice too old to refund.", e.message)
32
+ assert_equal("Invoice was already refunded.", e.message)
33
33
  end
34
34
  end
35
35
 
36
36
  #refund invoice
37
37
  it "Refunding a refunded invoice returns exception" do
38
- begin
39
- sale = Twocheckout::Sale.find(:sale_id => 4786293822)
40
- invoice = sale.invoices.first
41
- invoice.refund!({:comment => "test refund", :category => 1})
38
+ begin
39
+ sale = Twocheckout::Sale.find(:sale_id => 9093717691800)
40
+ invoice = sale.invoices.first
41
+ invoice.refund!({:comment => "test refund", :category => 1})
42
42
  rescue Exception => e
43
- assert_equal("Invoice too old to refund.", e.message)
43
+ assert_equal("Invoice was already refunded.", e.message)
44
44
  end
45
45
  end
46
46
 
47
47
  #refund lineitem
48
48
  it "Refunding a refunded lineitem returns exception" do
49
- begin
50
- sale = Twocheckout::Sale.find(:sale_id => 4786293822)
51
- first_invoice = sale.invoices.first
52
- last_lineitem = first_invoice.lineitems.last
53
- last_lineitem.refund!({:comment => "test refund", :category => 1})
49
+ begin
50
+ sale = Twocheckout::Sale.find(:sale_id => 9093717691800)
51
+ first_invoice = sale.invoices.first
52
+ last_lineitem = first_invoice.lineitems.last
53
+ last_lineitem.refund!({:comment => "test refund", :category => 1})
54
54
  rescue Exception => e
55
- assert_equal("This lineitem cannot be refunded.", e.message)
55
+ assert_equal("This lineitem cannot be refunded.", e.message)
56
56
  end
57
57
  end
58
58
 
59
59
  #stop recurring lineitem
60
60
  it "Stopping a stopped recurring lineitem returns exception" do
61
- begin
62
- sale = Twocheckout::Sale.find(:sale_id => 4786293822)
63
- result = sale.stop_recurring!
64
- assert_equal(result, [])
61
+ begin
62
+ sale = Twocheckout::Sale.find(:sale_id => 9093717691800)
63
+ result = sale.stop_recurring!
64
+ assert_equal(result, [])
65
65
  rescue Exception => e
66
- assert_equal("Lineitem is not scheduled to recur.", e.message)
66
+ assert_equal("Lineitem is not scheduled to recur.", e.message)
67
67
  end
68
68
  end
69
69
 
70
70
  #stop recurring sale
71
71
  it "Stopping a stopped recurring sale returns exception" do
72
- begin
73
- sale = Twocheckout::Sale.find(:sale_id => 4786293822)
74
- last_invoice = sale.invoices.last
75
- last_lineitem = last_invoice.lineitems.last
76
- last_lineitem.stop_recurring!
72
+ begin
73
+ sale = Twocheckout::Sale.find(:sale_id => 9093717691800)
74
+ last_invoice = sale.invoices.last
75
+ last_lineitem = last_invoice.lineitems.last
76
+ last_lineitem.stop_recurring!
77
77
  rescue Exception => e
78
- assert_equal("Lineitem is not scheduled to recur.", e.message)
78
+ assert_equal("Lineitem is not scheduled to recur.", e.message)
79
79
  end
80
80
  end
81
81
 
82
82
  #create comment
83
83
  it "Creates a sale comment" do
84
- sale = Twocheckout::Sale.find(:sale_id => 4786293822)
84
+ sale = Twocheckout::Sale.find(:sale_id => 9093717691800)
85
85
  result = sale.comment({:sale_comment => "test"})
86
86
  assert_equal('Created comment successfully.', result['response_message'])
87
87
  end
88
88
 
89
89
  #mark shipped
90
90
  it "Shipping an intangible sale returns exception" do
91
- begin
92
- sale = Twocheckout::Sale.find(:sale_id => 4786293822)
93
- sale.ship({:tracking_number => "123"})
91
+ begin
92
+ sale = Twocheckout::Sale.find(:sale_id => 9093717691800)
93
+ sale.ship({:tracking_number => "123"})
94
94
  rescue Exception => e
95
- assert_equal("Item not shippable.", e.message)
95
+ assert_equal("Sale already marked shipped.", e.message)
96
96
  end
97
97
  end
98
98
 
99
99
  #reauth
100
100
  it "Reauthorizing a pending sale returns exception" do
101
- begin
102
- sale = Twocheckout::Sale.find(:sale_id => 4786293822)
103
- sale.reauth
101
+ begin
102
+ sale = Twocheckout::Sale.find(:sale_id => 9093717691800)
103
+ sale.reauth
104
104
  rescue Exception => e
105
- assert_equal("Payment is already pending or deposited and cannot be reauthorized.", e.message)
105
+ assert_equal("Payment is already pending or deposited and cannot be reauthorized.", e.message)
106
106
  end
107
107
  end
108
108
  end
@@ -115,24 +115,24 @@ describe Twocheckout::Product do
115
115
 
116
116
  # Product list
117
117
  it "Product list returns array of products" do
118
- product_list = Twocheckout::Product.list({ :pagesize => 5 })
119
- assert_equal(product_list.size, 5)
118
+ product_list = Twocheckout::Product.list({ :pagesize => 3 })
119
+ assert_equal(product_list.size, 3)
120
120
  end
121
121
 
122
122
  # Product CRUD
123
- it "Product create, find, update, delete is successful" do
124
- # create
123
+ it "Product create, find, update, delete is successful" do
124
+ # create
125
125
  new_product = Twocheckout::Product.create({:name => "test product", :price => 1.00})
126
- assert_equal("test product", new_product.name)
127
- # find
128
- product = Twocheckout::Product.find({:product_id => new_product.product_id})
129
- assert_equal(new_product.product_id, product.product_id)
130
- # update
131
- product = product.update({:name => "new name"})
132
- assert_equal("new name", product.name)
133
- # delete
134
- result = product.delete!
135
- assert_equal("Product successfully deleted.", result['response_message'])
126
+ assert_equal("test product", new_product.name)
127
+ # find
128
+ product = Twocheckout::Product.find({:product_id => new_product.product_id})
129
+ assert_equal(new_product.product_id, product.product_id)
130
+ # update
131
+ product = product.update({:name => "new name"})
132
+ assert_equal("new name", product.name)
133
+ # delete
134
+ result = product.delete!
135
+ assert_equal("Product successfully deleted.", result['response_message'])
136
136
  end
137
137
  end
138
138
 
@@ -140,25 +140,25 @@ describe Twocheckout::Option do
140
140
 
141
141
  # Option list
142
142
  it "Option list returns array of options" do
143
- option_list = Twocheckout::Option.list({ :pagesize => 5 })
144
- assert_equal(5, option_list.size)
143
+ option_list = Twocheckout::Option.list({ :pagesize => 3 })
144
+ assert_equal(3, option_list.size)
145
145
  end
146
146
 
147
147
  # Option CRUD
148
- it "Option create, find, update, delete is successful" do
149
- # create
150
- new_option = Twocheckout::Option.create({:option_name => "test option",
151
- :option_value_name => "test option value", :option_value_surcharge => 1.00})
152
- assert_equal("test option", new_option.option_name)
153
- # find
154
- option = Twocheckout::Option.find({:option_id => new_option.option_id})
155
- assert_equal(new_option.option_id, option.option_id)
156
- # update
157
- option = option.update({:option_name => "new name"})
158
- assert_equal("new name", option.option_name)
159
- # delete
160
- result = option.delete!
161
- assert_equal("Option deleted successfully", result['response_message'])
148
+ it "Option create, find, update, delete is successful" do
149
+ # create
150
+ new_option = Twocheckout::Option.create({:option_name => "test option",
151
+ :option_value_name => "test option value", :option_value_surcharge => 1.00})
152
+ assert_equal("test option", new_option.option_name)
153
+ # find
154
+ option = Twocheckout::Option.find({:option_id => new_option.option_id})
155
+ assert_equal(new_option.option_id, option.option_id)
156
+ # update
157
+ option = option.update({:option_name => "new name"})
158
+ assert_equal("new name", option.option_name)
159
+ # delete
160
+ result = option.delete!
161
+ assert_equal("Option deleted successfully", result['response_message'])
162
162
  end
163
163
  end
164
164
 
@@ -167,24 +167,24 @@ describe Twocheckout::Coupon do
167
167
  # Coupon list
168
168
  it "Coupon list returns array of coupons" do
169
169
  coupon_list = Twocheckout::Coupon.list({ :pagesize => 4 })
170
- assert_equal(4, coupon_list.size)
170
+ assert_equal(4, coupon_list.size)
171
171
  end
172
172
 
173
173
  # Coupon CRUD
174
- it "Coupon create, find, update, delete is successful" do
175
- # create
176
- new_coupon = Twocheckout::Coupon.create({:date_expire => "2020-01-01",
177
- :type => "shipping", :minimum_purchase => 1.00})
178
- assert_equal("2020-01-01", new_coupon.date_expire)
179
- # find
180
- coupon = Twocheckout::Coupon.find({:coupon_code => new_coupon.coupon_code})
181
- assert_equal(new_coupon.coupon_code, coupon.coupon_code)
182
- # update
183
- coupon = coupon.update({:date_expire => "2020-01-02"})
184
- assert_equal("2020-01-02", coupon.date_expire)
185
- # delete
186
- result = coupon.delete!
187
- assert_equal("Coupon successfully deleted.", result['response_message'])
174
+ it "Coupon create, find, update, delete is successful" do
175
+ # create
176
+ new_coupon = Twocheckout::Coupon.create({:date_expire => "2020-01-01",
177
+ :type => "shipping", :minimum_purchase => 1.00})
178
+ assert_equal("2020-01-01", new_coupon.date_expire)
179
+ # find
180
+ coupon = Twocheckout::Coupon.find({:coupon_code => new_coupon.coupon_code})
181
+ assert_equal(new_coupon.coupon_code, coupon.coupon_code)
182
+ # update
183
+ coupon = coupon.update({:date_expire => "2020-01-02"})
184
+ assert_equal("2020-01-02", coupon.date_expire)
185
+ # delete
186
+ result = coupon.delete!
187
+ assert_equal("Coupon successfully deleted.", result['response_message'])
188
188
  end
189
189
  end
190
190
 
@@ -192,21 +192,21 @@ describe Twocheckout::ValidateResponse do
192
192
  #demo
193
193
  it "Validates Purchase MD5 Hash" do
194
194
  result = Twocheckout::ValidateResponse.purchase({:sid => 1817037, :secret => "tango", :order_number => 1, :total => 0.01,
195
- :key => '1BC47EA0D63EB76496E294F434138AD3'})
195
+ :key => '1BC47EA0D63EB76496E294F434138AD3'})
196
196
  assert_equal('PASS', result[:code])
197
197
  end
198
198
 
199
199
  #purchase
200
200
  it "Validates Purchase MD5 Hash" do
201
201
  result = Twocheckout::ValidateResponse.purchase({:sid => 1817037, :secret => "tango", :order_number => 4789848870, :total => 0.01,
202
- :key => 'CDF3E502AA1597DD4401760783432337'})
202
+ :key => 'CDF3E502AA1597DD4401760783432337'})
203
203
  assert_equal('PASS', result[:code])
204
204
  end
205
205
 
206
206
  #notification
207
207
  it "Validates Notification MD5 Hash" do
208
208
  result = Twocheckout::ValidateResponse.notification({:sale_id => 4789848870, :vendor_id => 1817037, :invoice_id => 4789848879, :secret => "tango",
209
- :md5_hash => '827220324C722873694758F38D8D3624'})
209
+ :md5_hash => '827220324C722873694758F38D8D3624'})
210
210
  assert_equal('PASS', result[:code])
211
211
  end
212
212
  end
@@ -215,24 +215,24 @@ describe Twocheckout::Checkout do
215
215
  #submit
216
216
  it "Submit return a form + JS to submit" do
217
217
  form = Twocheckout::Checkout.submit({ 'sid' => '1817037', 'cart_order_id' => 'Example Sale', 'total' => '1.00'})
218
- @form = "<form id=\"2checkout\" action=\"https://www.2checkout.com/checkout/purchase\" method=\"post\">\n" +
219
- "<input type=\"hidden\" name=\"sid\" value=\"1817037\" />\n" +
220
- "<input type=\"hidden\" name=\"cart_order_id\" value=\"Example Sale\" />\n" +
221
- "<input type=\"hidden\" name=\"total\" value=\"1.00\" />\n" +
222
- "</form>\n" +
223
- "<script type=\"text/javascript\">document.getElementById('2checkout').submit();</script>"
218
+ @form = "<form id=\"2checkout\" action=\"https://sandbox.2checkout.com/checkout/purchase\" method=\"post\">\n" +
219
+ "<input type=\"hidden\" name=\"sid\" value=\"1817037\" />\n" +
220
+ "<input type=\"hidden\" name=\"cart_order_id\" value=\"Example Sale\" />\n" +
221
+ "<input type=\"hidden\" name=\"total\" value=\"1.00\" />\n" +
222
+ "</form>\n" +
223
+ "<script type=\"text/javascript\">document.getElementById('2checkout').submit();</script>"
224
224
  assert_equal(form, @form)
225
225
  end
226
226
 
227
227
  #form
228
228
  it "Form returns a form" do
229
229
  form = Twocheckout::Checkout.form({ 'sid' => '1817037', 'cart_order_id' => 'Example Sale', 'total' => '1.00'}, "Proceed")
230
- @form = "<form id=\"2checkout\" action=\"https://www.2checkout.com/checkout/purchase\" method=\"post\">\n" +
231
- "<input type=\"hidden\" name=\"sid\" value=\"1817037\" />\n" +
232
- "<input type=\"hidden\" name=\"cart_order_id\" value=\"Example Sale\" />\n" +
233
- "<input type=\"hidden\" name=\"total\" value=\"1.00\" />\n" +
234
- "<input type=\"submit\" value=\"Proceed\" />\n" +
235
- "</form>"
230
+ @form = "<form id=\"2checkout\" action=\"https://sandbox.2checkout.com/checkout/purchase\" method=\"post\">\n" +
231
+ "<input type=\"hidden\" name=\"sid\" value=\"1817037\" />\n" +
232
+ "<input type=\"hidden\" name=\"cart_order_id\" value=\"Example Sale\" />\n" +
233
+ "<input type=\"hidden\" name=\"total\" value=\"1.00\" />\n" +
234
+ "<input type=\"submit\" value=\"Proceed\" />\n" +
235
+ "</form>"
236
236
  assert_equal(form, @form)
237
237
  end
238
238
 
@@ -248,48 +248,48 @@ describe Twocheckout::Checkout do
248
248
  'zip' => '43123',
249
249
  'country' => 'USA',
250
250
  'email' => 'no-reply@2co.com'
251
- })
252
- @form = "<form id=\"2checkout\" action=\"https://www.2checkout.com/checkout/purchase\" method=\"post\">\n" +
253
- "<input type=\"hidden\" name=\"sid\" value=\"1817037\" />\n" +
254
- "<input type=\"hidden\" name=\"cart_order_id\" value=\"Example Sale\" />\n" +
255
- "<input type=\"hidden\" name=\"total\" value=\"1.00\" />\n" +
256
- "<input type=\"hidden\" name=\"card_holder_name\" value=\"Testing Tester\" />\n" +
257
- "<input type=\"hidden\" name=\"street_address\" value=\"123 Test St\" />\n" +
258
- "<input type=\"hidden\" name=\"city\" value=\"Columbus\" />\n" +
259
- "<input type=\"hidden\" name=\"state\" value=\"Ohio\" />\n" +
260
- "<input type=\"hidden\" name=\"zip\" value=\"43123\" />\n" +
261
- "<input type=\"hidden\" name=\"country\" value=\"USA\" />\n" +
262
- "<input type=\"hidden\" name=\"email\" value=\"no-reply@2co.com\" />\n" +
263
- "<input type=\"submit\" value=\"Proceed to Checkout\" />\n" +
264
- "</form>\n" +
265
- "<script src=\"https://www.2checkout.com/static/checkout/javascript/direct.min.js\"></script>"
251
+ })
252
+ @form = "<form id=\"2checkout\" action=\"https://sandbox.2checkout.com/checkout/purchase\" method=\"post\">\n" +
253
+ "<input type=\"hidden\" name=\"sid\" value=\"1817037\" />\n" +
254
+ "<input type=\"hidden\" name=\"cart_order_id\" value=\"Example Sale\" />\n" +
255
+ "<input type=\"hidden\" name=\"total\" value=\"1.00\" />\n" +
256
+ "<input type=\"hidden\" name=\"card_holder_name\" value=\"Testing Tester\" />\n" +
257
+ "<input type=\"hidden\" name=\"street_address\" value=\"123 Test St\" />\n" +
258
+ "<input type=\"hidden\" name=\"city\" value=\"Columbus\" />\n" +
259
+ "<input type=\"hidden\" name=\"state\" value=\"Ohio\" />\n" +
260
+ "<input type=\"hidden\" name=\"zip\" value=\"43123\" />\n" +
261
+ "<input type=\"hidden\" name=\"country\" value=\"USA\" />\n" +
262
+ "<input type=\"hidden\" name=\"email\" value=\"no-reply@2co.com\" />\n" +
263
+ "<input type=\"submit\" value=\"Proceed to Checkout\" />\n" +
264
+ "</form>\n" +
265
+ "<script src=\"https://www.2checkout.com/static/checkout/javascript/direct.min.js\"></script>"
266
266
  assert_equal(form, @form)
267
267
  end
268
268
 
269
269
  #link
270
270
  it "Link returns a link" do
271
271
  link = Twocheckout::Checkout.link({ 'sid' => '1817037', 'cart_order_id' => 'Example Sale', 'total' => '1.00'})
272
- @link = "https://www.2checkout.com/checkout/purchase?sid=1817037&cart_order_id=Example+Sale&total=1.00"
272
+ @link = "https://sandbox.2checkout.com/checkout/purchase?sid=1817037&cart_order_id=Example+Sale&total=1.00"
273
273
  assert_equal(link, @link)
274
274
  end
275
275
 
276
276
  #authorize
277
277
  it "Authorize creates authorization" do
278
278
  params = {
279
- :merchantOrderId => '123',
280
- :token => 'ZThjM2U3ZjMtMjViYy00ZTAwLWJiY2MtMDgzNTEzODZhZTFh',
281
- :currency => 'USD',
282
- :total => '1.00',
283
- :billingAddr => {
284
- :name => 'Testing Tester',
285
- :addrLine1 => '123 Test St',
286
- :city => 'Columbus',
287
- :state => 'OH',
288
- :zipCode => '43123',
289
- :country => 'USA',
290
- :email => 'cchristenson@2co.com',
291
- :phoneNumber => '555-555-5555'
292
- }
279
+ :merchantOrderId => '123',
280
+ :token => 'MjQ3YTM2NDEtMmNiNC00ZGM3LTljZDItZjIxMzllYWE5ZmNl',
281
+ :currency => 'USD',
282
+ :total => '1.00',
283
+ :billingAddr => {
284
+ :name => 'Testing Tester',
285
+ :addrLine1 => '123 Test St',
286
+ :city => 'Columbus',
287
+ :state => 'OH',
288
+ :zipCode => '43123',
289
+ :country => 'USA',
290
+ :email => 'cchristenson@2co.com',
291
+ :phoneNumber => '555-555-5555'
292
+ }
293
293
  }
294
294
  begin
295
295
  result = Twocheckout::Checkout.authorize(params)
@@ -298,4 +298,4 @@ describe Twocheckout::Checkout do
298
298
  assert_equal("Unauthorized", e.message)
299
299
  end
300
300
  end
301
- end
301
+ end
data/twocheckout.gemspec CHANGED
@@ -4,13 +4,13 @@ $:.unshift(File.join(File.dirname(__FILE__), 'lib'))
4
4
  Gem::Specification.new do |s|
5
5
  s.platform = Gem::Platform::RUBY
6
6
  s.name = 'twocheckout'
7
- s.version = '0.2.0'
7
+ s.version = '0.3.0'
8
8
  s.summary = '2Checkout Ruby Library'
9
- s.description = '0.2.0'
9
+ s.description = '0.3.0'
10
10
  s.summary = '2Checkout Ruby Library'
11
11
  s.author = "Craig Christenson", "Ernesto Garcia"
12
12
  s.email = 'christensoncraig@gmail.com'
13
- s.homepage = 'https://github.com/craigchristenson'
13
+ s.homepage = 'https://github.com/2Checkout/2checkout-ruby'
14
14
  s.files = `git ls-files`.split("\n")
15
15
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
16
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twocheckout
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig Christenson
@@ -9,29 +9,29 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-17 00:00:00.000000000 Z
12
+ date: 2014-05-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ~>
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
20
  version: '1.4'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ~>
25
+ - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '1.4'
28
- description: 0.2.0
28
+ description: 0.3.0
29
29
  email: christensoncraig@gmail.com
30
30
  executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
- - .gitignore
34
+ - ".gitignore"
35
35
  - LICENSE
36
36
  - README.md
37
37
  - lib/twocheckout.rb
@@ -51,7 +51,7 @@ files:
51
51
  - test/minitest_helper.rb
52
52
  - test/twocheckout_test.rb
53
53
  - twocheckout.gemspec
54
- homepage: https://github.com/craigchristenson
54
+ homepage: https://github.com/2Checkout/2checkout-ruby
55
55
  licenses:
56
56
  - MIT
57
57
  metadata: {}
@@ -61,18 +61,18 @@ require_paths:
61
61
  - lib
62
62
  required_ruby_version: !ruby/object:Gem::Requirement
63
63
  requirements:
64
- - - '>='
64
+ - - ">="
65
65
  - !ruby/object:Gem::Version
66
66
  version: '0'
67
67
  required_rubygems_version: !ruby/object:Gem::Requirement
68
68
  requirements:
69
- - - '>='
69
+ - - ">="
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0'
72
72
  requirements:
73
73
  - none
74
74
  rubyforge_project:
75
- rubygems_version: 2.2.1
75
+ rubygems_version: 2.2.2
76
76
  signing_key:
77
77
  specification_version: 4
78
78
  summary: 2Checkout Ruby Library