twocheckout 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -2,4 +2,5 @@
2
2
  *.lock
3
3
  *.DS_Store
4
4
  *.swp
5
- *.out
5
+ *.out
6
+ *.idea
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2012 - Craig Christenson
3
+ Copyright (c) 2012 - 2Checkout.com, Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -12,10 +12,10 @@ gem install twocheckout
12
12
  Or import into your Gemfile.
13
13
 
14
14
  ```ruby
15
- gem "twocheckout", "~> 0.1.0"
15
+ gem "twocheckout", "~> 0.1.1"
16
16
  ```
17
17
 
18
- Full documentation for each binding is provided in the **[Wiki](https://github.com/craigchristenson/2checkout-ruby/wiki)**.
18
+ Full documentation for each binding is provided in the **[Wiki](https://github.com/2checkout/2checkout-ruby/wiki)**.
19
19
 
20
20
 
21
21
  Example API Usage
@@ -173,4 +173,29 @@ end
173
173
  }
174
174
  ```
175
175
 
176
- Full documentation for each binding is provided in the **[Wiki](https://github.com/craigchristenson/2checkout-ruby/wiki)**.
176
+ Exceptions:
177
+ ------------------
178
+
179
+ *Example Catch:*
180
+
181
+ Exceptions are thrown by if an error has returned. It is best to catch these exceptions so that they can be gracefully handled in your application.
182
+
183
+
184
+ ```ruby
185
+ begin
186
+ sale = Twocheckout::Sale.find(:sale_id => 4786293822)
187
+ last_invoice = sale.invoices.last
188
+ last_lineitem = last_invoice.lineitems.last
189
+ last_lineitem.stop_recurring!
190
+ rescue Exception => e
191
+ puts e.message
192
+ end
193
+ ```
194
+
195
+ *Example Exception:*
196
+
197
+ ```ruby
198
+ "Lineitem is not scheduled to recur."
199
+ ```
200
+
201
+ Full documentation for each binding is provided in the **[Wiki](https://github.com/2checkout/2checkout-ruby/wiki)**.
@@ -2,7 +2,7 @@ module Twocheckout
2
2
  class Checkout
3
3
 
4
4
  def self.form(params={})
5
- @form = "<form id=\"2checkout\" action=\"https://www.2checkout.com/checkout/spurchase\" method=\"post\">\n";
5
+ @form = "<form id=\"2checkout\" action=\"https://www.2checkout.com/checkout/purchase\" method=\"post\">\n";
6
6
  params.each do |k,v|
7
7
  @form = @form + "<input type=\"hidden\" name=\"" + k + "\" value=\"" + v.to_s + "\" />\n"
8
8
  end
@@ -10,7 +10,7 @@ module Twocheckout
10
10
  end
11
11
 
12
12
  def self.submit(params={})
13
- @form = "<form id=\"2checkout\" action=\"https://www.2checkout.com/checkout/spurchase\" method=\"post\">\n";
13
+ @form = "<form id=\"2checkout\" action=\"https://www.2checkout.com/checkout/purchase\" method=\"post\">\n";
14
14
  params.each do |k,v|
15
15
  @form = @form + "<input type=\"hidden\" name=\"" + k + "\" value=\"" + v.to_s + "\" />\n"
16
16
  end
@@ -18,7 +18,16 @@ module Twocheckout
18
18
  @form = @form + "<script type=\"text/javascript\">document.getElementById('2checkout').submit();</script>"
19
19
  end
20
20
 
21
- def self.link(params={}, url="https://www.2checkout.com/checkout/spurchase?")
21
+ def self.direct(params={})
22
+ @form = "<form id=\"2checkout\" action=\"https://www.2checkout.com/checkout/purchase\" method=\"post\">\n";
23
+ params.each do |k,v|
24
+ @form = @form + "<input type=\"hidden\" name=\"" + k + "\" value=\"" + v.to_s + "\" />\n"
25
+ end
26
+ @form = @form + "<input type=\"submit\" value=\"Proceed to Checkout\" />\n</form>\n"
27
+ @form = @form + "<script src=\"https://www.2checkout.com/static/checkout/javascript/direct.min.js\"></script>"
28
+ end
29
+
30
+ def self.link(params={}, url="https://www.2checkout.com/checkout/purchase?")
22
31
  @querystring = params.map{|k,v| "#{CGI.escape(k)}=#{CGI.escape(v)}"}.join("&")
23
32
  @purchase_url = url + @querystring
24
33
  end
@@ -0,0 +1,5 @@
1
+ require "minitest/spec"
2
+ require "minitest/autorun"
3
+ require "twocheckout"
4
+
5
+ Twocheckout::API.credentials = { :username => 'APIuser1817037', :password => 'APIpass1817037' }
@@ -1,252 +1,268 @@
1
- require "minitest/spec"
2
- require "minitest/autorun"
3
- require "twocheckout"
4
-
5
- #
6
- # Sales
7
- #
8
- describe Twocheckout::Sale do
9
- before do
10
- Twocheckout::API.credentials = { :username => 'APIuser1817037', :password => 'APIpass1817037' }
11
- end
12
-
13
- #retrieve sale
14
- it "Sale retrieve returns sale" do
15
- sale = Twocheckout::Sale.find(:sale_id => 4786293822)
16
- assert_equal('4786293822', sale.sale_id)
17
- end
18
-
19
- #retrieve invoice
20
- it "Sale retrieve returns invoice" do
21
- invoice = Twocheckout::Sale.find({:invoice_id => 4786293831})
22
- assert_equal('4786293831', invoice.invoice_id)
23
- end
24
-
25
- #retrieve sale list
26
- it "Sale list returns list" do
27
- sale_list = Twocheckout::Sale.list({:pagesize => 5})
28
- assert_equal(5, sale_list.size)
29
- end
30
-
31
- #refund sale
32
- it "Refunding a refunded sale returns exception" do
33
- begin
34
- sale = Twocheckout::Sale.find(:sale_id => 4786293822)
35
- sale.refund!({:comment => "test refund", :category => 1})
36
- rescue Exception => e
37
- assert_equal("Invoice was already refunded.", e.message)
38
- end
39
- end
40
-
41
- #refund invoice
42
- it "Refunding a refunded invoice returns exception" do
43
- begin
44
- sale = Twocheckout::Sale.find(:sale_id => 4786293822)
45
- invoice = sale.invoices.first
46
- invoice.refund!({:comment => "test refund", :category => 1})
47
- rescue Exception => e
48
- assert_equal("Invoice was already refunded.", e.message)
49
- end
50
- end
51
-
52
- #refund lineitem
53
- it "Refunding a refunded lineitem returns exception" do
54
- begin
55
- sale = Twocheckout::Sale.find(:sale_id => 4786293822)
56
- first_invoice = sale.invoices.first
57
- last_lineitem = first_invoice.lineitems.last
58
- last_lineitem.refund!({:comment => "test refund", :category => 1})
59
- rescue Exception => e
60
- assert_equal("This lineitem cannot be refunded.", e.message)
61
- end
62
- end
63
-
64
- #stop recurring lineitem
65
- it "Stopping a stopped recurring lineitem returns exception" do
66
- begin
67
- sale = Twocheckout::Sale.find(:sale_id => 4786293822)
68
- result = sale.stop_recurring!
69
- assert_equal(result, [])
70
- rescue Exception => e
71
- assert_equal("Lineitem is not scheduled to recur.", e.message)
72
- end
73
- end
74
-
75
- #stop recurring sale
76
- it "Stopping a stopped recurring sale returns exception" do
77
- begin
78
- sale = Twocheckout::Sale.find(:sale_id => 4786293822)
79
- last_invoice = sale.invoices.last
80
- last_lineitem = last_invoice.lineitems.last
81
- last_lineitem.stop_recurring!
82
- rescue Exception => e
83
- assert_equal("Lineitem is not scheduled to recur.", e.message)
84
- end
85
- end
86
-
87
- #create comment
88
- it "Creates a sale comment" do
89
- sale = Twocheckout::Sale.find(:sale_id => 4786293822)
90
- result = sale.comment({:sale_comment => "test"})
91
- assert_equal('Created comment successfully.', result['response_message'])
92
- end
93
-
94
- #mark shipped
95
- it "Shipping an intangible sale returns exception" do
96
- begin
97
- sale = Twocheckout::Sale.find(:sale_id => 4786293822)
98
- sale.ship({:tracking_number => "123"})
99
- rescue Exception => e
100
- assert_equal("Item not shippable.", e.message)
101
- end
102
- end
103
-
104
- #reauth
105
- it "Reauthorizing a pending sale returns exception" do
106
- begin
107
- sale = Twocheckout::Sale.find(:sale_id => 4786293822)
108
- sale.reauth
109
- rescue Exception => e
110
- assert_equal("Payment is already pending or deposited and cannot be reauthorized.", e.message)
111
- end
112
- end
113
- end
114
-
115
- #
116
- # Products
117
- #
118
-
119
- describe Twocheckout::Product do
120
- before do
121
- Twocheckout::API.credentials = { :username => 'APIuser1817037', :password => 'APIpass1817037' }
122
- end
123
-
124
- # Product list
125
- it "Product list returns array of products" do
126
- product_list = Twocheckout::Product.list({ :pagesize => 5 })
127
- assert_equal(product_list.size, 5)
128
- end
129
-
130
- # Product CRUD
131
- it "Product create, find, update, delete is successful" do
132
- # create
133
- new_product = Twocheckout::Product.create({:name => "test product", :price => 1.00})
134
- assert_equal("test product", new_product.name)
135
- # find
136
- product = Twocheckout::Product.find({:product_id => new_product.product_id})
137
- assert_equal(new_product.product_id, product.product_id)
138
- # update
139
- product = product.update({:name => "new name"})
140
- assert_equal("new name", product.name)
141
- # delete
142
- result = product.delete!
143
- assert_equal("Product successfully deleted.", result['response_message'])
144
- end
145
- end
146
-
147
- describe Twocheckout::Option do
148
- before do
149
- Twocheckout::API.credentials = { :username => 'APIuser1817037', :password => 'APIpass1817037' }
150
- end
151
-
152
- # Option list
153
- it "Option list returns array of options" do
154
- option_list = Twocheckout::Option.list({ :pagesize => 5 })
155
- assert_equal(5, option_list.size)
156
- end
157
-
158
- # Option CRUD
159
- it "Option create, find, update, delete is successful" do
160
- # create
161
- new_option = Twocheckout::Option.create({:option_name => "test option",
162
- :option_value_name => "test option value", :option_value_surcharge => 1.00})
163
- assert_equal("test option", new_option.option_name)
164
- # find
165
- option = Twocheckout::Option.find({:option_id => new_option.option_id})
166
- assert_equal(new_option.option_id, option.option_id)
167
- # update
168
- option = option.update({:option_name => "new name"})
169
- assert_equal("new name", option.option_name)
170
- # delete
171
- result = option.delete!
172
- assert_equal("Option deleted successfully", result['response_message'])
173
- end
174
- end
175
-
176
- describe Twocheckout::Coupon do
177
- before do
178
- Twocheckout::API.credentials = { :username => 'APIuser1817037', :password => 'APIpass1817037' }
179
- end
180
-
181
- # Coupon list
182
- it "Coupon list returns array of coupons" do
183
- coupon_list = Twocheckout::Coupon.list({ :pagesize => 4 })
184
- assert_equal(4, coupon_list.size)
185
- end
186
-
187
- # Coupon CRUD
188
- it "Coupon create, find, update, delete is successful" do
189
- # create
190
- new_coupon = Twocheckout::Coupon.create({:date_expire => "2020-01-01",
191
- :type => "shipping", :minimum_purchase => 1.00})
192
- assert_equal("2020-01-01", new_coupon.date_expire)
193
- # find
194
- coupon = Twocheckout::Coupon.find({:coupon_code => new_coupon.coupon_code})
195
- assert_equal(new_coupon.coupon_code, coupon.coupon_code)
196
- # update
197
- coupon = coupon.update({:date_expire => "2020-01-02"})
198
- assert_equal("2020-01-02", coupon.date_expire)
199
- # delete
200
- result = coupon.delete!
201
- assert_equal("Coupon successfully deleted.", result['response_message'])
202
- end
203
- end
204
-
205
- describe Twocheckout::ValidateResponse do
206
- #purchase
207
- it "Validates Purchase MD5 Hash" do
208
- result = Twocheckout::ValidateResponse.purchase({:sid => 1817037, :secret => "tango", :order_number => 4789848870, :total => 0.01,
209
- :key => 'CDF3E502AA1597DD4401760783432337'})
210
- assert_equal('PASS', result[:code])
211
- end
212
-
213
- #notification
214
- it "Validates Notification MD5 Hash" do
215
- result = Twocheckout::ValidateResponse.notification({:sale_id => 4789848870, :vendor_id => 1817037, :invoice_id => 4789848879, :secret => "tango",
216
- :md5_hash => '827220324C722873694758F38D8D3624'})
217
- assert_equal('PASS', result[:code])
218
- end
219
- end
220
-
221
- describe Twocheckout::Checkout do
222
- #submit
223
- it "Submit return a form + JS to submit" do
224
- form = Twocheckout::Checkout.submit({ 'sid' => '1817037', 'cart_order_id' => 'Example Sale', 'total' => '1.00'})
225
- @form = "<form id=\"2checkout\" action=\"https://www.2checkout.com/checkout/spurchase\" method=\"post\">\n" +
226
- "<input type=\"hidden\" name=\"sid\" value=\"1817037\" />\n" +
227
- "<input type=\"hidden\" name=\"cart_order_id\" value=\"Example Sale\" />\n" +
228
- "<input type=\"hidden\" name=\"total\" value=\"1.00\" />\n" +
229
- "</form>\n" +
230
- "<script type=\"text/javascript\">document.getElementById('2checkout').submit();</script>"
231
- assert_equal(form, @form)
232
- end
233
-
234
- #form
235
- it "Form returns a form" do
236
- form = Twocheckout::Checkout.form({ 'sid' => '1817037', 'cart_order_id' => 'Example Sale', 'total' => '1.00'})
237
- @form = "<form id=\"2checkout\" action=\"https://www.2checkout.com/checkout/spurchase\" method=\"post\">\n" +
238
- "<input type=\"hidden\" name=\"sid\" value=\"1817037\" />\n" +
239
- "<input type=\"hidden\" name=\"cart_order_id\" value=\"Example Sale\" />\n" +
240
- "<input type=\"hidden\" name=\"total\" value=\"1.00\" />\n" +
241
- "<input type=\"submit\" value=\"Proceed to Checkout\" />\n" +
242
- "</form>"
243
- assert_equal(form, @form)
244
- end
245
-
246
- #link
247
- it "Link returns a link" do
248
- link = Twocheckout::Checkout.link({ 'sid' => '1817037', 'cart_order_id' => 'Example Sale', 'total' => '1.00'})
249
- @link = "https://www.2checkout.com/checkout/spurchase?sid=1817037&cart_order_id=Example+Sale&total=1.00"
250
- assert_equal(link, @link)
251
- end
1
+ require_relative "minitest_helper"
2
+
3
+ #
4
+ # Sales
5
+ #
6
+ describe Twocheckout::Sale do
7
+
8
+ #retrieve sale
9
+ it "Sale retrieve returns sale" do
10
+ sale = Twocheckout::Sale.find(:sale_id => 4786293822)
11
+ assert_equal('4786293822', sale.sale_id)
12
+ end
13
+
14
+ #retrieve invoice
15
+ it "Sale retrieve returns invoice" do
16
+ invoice = Twocheckout::Sale.find({:invoice_id => 4786293831})
17
+ assert_equal('4786293831', invoice.invoice_id)
18
+ end
19
+
20
+ #retrieve sale list
21
+ it "Sale list returns list" do
22
+ sale_list = Twocheckout::Sale.list({:pagesize => 5})
23
+ assert_equal(5, sale_list.size)
24
+ end
25
+
26
+ #refund sale
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})
31
+ rescue Exception => e
32
+ assert_equal("Invoice too old to refund.", e.message)
33
+ end
34
+ end
35
+
36
+ #refund invoice
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})
42
+ rescue Exception => e
43
+ assert_equal("Invoice too old to refund.", e.message)
44
+ end
45
+ end
46
+
47
+ #refund lineitem
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})
54
+ rescue Exception => e
55
+ assert_equal("This lineitem cannot be refunded.", e.message)
56
+ end
57
+ end
58
+
59
+ #stop recurring lineitem
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, [])
65
+ rescue Exception => e
66
+ assert_equal("Lineitem is not scheduled to recur.", e.message)
67
+ end
68
+ end
69
+
70
+ #stop recurring sale
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!
77
+ rescue Exception => e
78
+ assert_equal("Lineitem is not scheduled to recur.", e.message)
79
+ end
80
+ end
81
+
82
+ #create comment
83
+ it "Creates a sale comment" do
84
+ sale = Twocheckout::Sale.find(:sale_id => 4786293822)
85
+ result = sale.comment({:sale_comment => "test"})
86
+ assert_equal('Created comment successfully.', result['response_message'])
87
+ end
88
+
89
+ #mark shipped
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"})
94
+ rescue Exception => e
95
+ assert_equal("Item not shippable.", e.message)
96
+ end
97
+ end
98
+
99
+ #reauth
100
+ it "Reauthorizing a pending sale returns exception" do
101
+ begin
102
+ sale = Twocheckout::Sale.find(:sale_id => 4786293822)
103
+ sale.reauth
104
+ rescue Exception => e
105
+ assert_equal("Payment is already pending or deposited and cannot be reauthorized.", e.message)
106
+ end
107
+ end
108
+ end
109
+
110
+ #
111
+ # Products
112
+ #
113
+
114
+ describe Twocheckout::Product do
115
+
116
+ # Product list
117
+ it "Product list returns array of products" do
118
+ product_list = Twocheckout::Product.list({ :pagesize => 5 })
119
+ assert_equal(product_list.size, 5)
120
+ end
121
+
122
+ # Product CRUD
123
+ it "Product create, find, update, delete is successful" do
124
+ # create
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'])
136
+ end
137
+ end
138
+
139
+ describe Twocheckout::Option do
140
+
141
+ # Option list
142
+ it "Option list returns array of options" do
143
+ option_list = Twocheckout::Option.list({ :pagesize => 5 })
144
+ assert_equal(5, option_list.size)
145
+ end
146
+
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'])
162
+ end
163
+ end
164
+
165
+ describe Twocheckout::Coupon do
166
+
167
+ # Coupon list
168
+ it "Coupon list returns array of coupons" do
169
+ coupon_list = Twocheckout::Coupon.list({ :pagesize => 4 })
170
+ assert_equal(4, coupon_list.size)
171
+ end
172
+
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'])
188
+ end
189
+ end
190
+
191
+ describe Twocheckout::ValidateResponse do
192
+ #purchase
193
+ it "Validates Purchase MD5 Hash" do
194
+ result = Twocheckout::ValidateResponse.purchase({:sid => 1817037, :secret => "tango", :order_number => 4789848870, :total => 0.01,
195
+ :key => 'CDF3E502AA1597DD4401760783432337'})
196
+ assert_equal('PASS', result[:code])
197
+ end
198
+
199
+ #notification
200
+ it "Validates Notification MD5 Hash" do
201
+ result = Twocheckout::ValidateResponse.notification({:sale_id => 4789848870, :vendor_id => 1817037, :invoice_id => 4789848879, :secret => "tango",
202
+ :md5_hash => '827220324C722873694758F38D8D3624'})
203
+ assert_equal('PASS', result[:code])
204
+ end
205
+ end
206
+
207
+ describe Twocheckout::Checkout do
208
+ #submit
209
+ it "Submit return a form + JS to submit" do
210
+ form = Twocheckout::Checkout.submit({ 'sid' => '1817037', 'cart_order_id' => 'Example Sale', 'total' => '1.00'})
211
+ @form = "<form id=\"2checkout\" action=\"https://www.2checkout.com/checkout/purchase\" method=\"post\">\n" +
212
+ "<input type=\"hidden\" name=\"sid\" value=\"1817037\" />\n" +
213
+ "<input type=\"hidden\" name=\"cart_order_id\" value=\"Example Sale\" />\n" +
214
+ "<input type=\"hidden\" name=\"total\" value=\"1.00\" />\n" +
215
+ "</form>\n" +
216
+ "<script type=\"text/javascript\">document.getElementById('2checkout').submit();</script>"
217
+ assert_equal(form, @form)
218
+ end
219
+
220
+ #form
221
+ it "Form returns a form" do
222
+ form = Twocheckout::Checkout.form({ 'sid' => '1817037', 'cart_order_id' => 'Example Sale', 'total' => '1.00'})
223
+ @form = "<form id=\"2checkout\" action=\"https://www.2checkout.com/checkout/purchase\" method=\"post\">\n" +
224
+ "<input type=\"hidden\" name=\"sid\" value=\"1817037\" />\n" +
225
+ "<input type=\"hidden\" name=\"cart_order_id\" value=\"Example Sale\" />\n" +
226
+ "<input type=\"hidden\" name=\"total\" value=\"1.00\" />\n" +
227
+ "<input type=\"submit\" value=\"Proceed to Checkout\" />\n" +
228
+ "</form>"
229
+ assert_equal(form, @form)
230
+ end
231
+
232
+ #direct
233
+ it "Direct returns a form and js" do
234
+ form = Twocheckout::Checkout.direct({ 'sid' => '1817037',
235
+ 'cart_order_id' => 'Example Sale',
236
+ 'total' => '1.00',
237
+ 'card_holder_name' => 'Testing Tester',
238
+ 'street_address' => '123 Test St',
239
+ 'city' => 'Columbus',
240
+ 'state' => 'Ohio',
241
+ 'zip' => '43123',
242
+ 'country' => 'USA',
243
+ 'email' => 'no-reply@2co.com'
244
+ })
245
+ @form = "<form id=\"2checkout\" action=\"https://www.2checkout.com/checkout/purchase\" method=\"post\">\n" +
246
+ "<input type=\"hidden\" name=\"sid\" value=\"1817037\" />\n" +
247
+ "<input type=\"hidden\" name=\"cart_order_id\" value=\"Example Sale\" />\n" +
248
+ "<input type=\"hidden\" name=\"total\" value=\"1.00\" />\n" +
249
+ "<input type=\"hidden\" name=\"card_holder_name\" value=\"Testing Tester\" />\n" +
250
+ "<input type=\"hidden\" name=\"street_address\" value=\"123 Test St\" />\n" +
251
+ "<input type=\"hidden\" name=\"city\" value=\"Columbus\" />\n" +
252
+ "<input type=\"hidden\" name=\"state\" value=\"Ohio\" />\n" +
253
+ "<input type=\"hidden\" name=\"zip\" value=\"43123\" />\n" +
254
+ "<input type=\"hidden\" name=\"country\" value=\"USA\" />\n" +
255
+ "<input type=\"hidden\" name=\"email\" value=\"no-reply@2co.com\" />\n" +
256
+ "<input type=\"submit\" value=\"Proceed to Checkout\" />\n" +
257
+ "</form>\n" +
258
+ "<script src=\"https://www.2checkout.com/static/checkout/javascript/direct.min.js\"></script>"
259
+ assert_equal(form, @form)
260
+ end
261
+
262
+ #link
263
+ it "Link returns a link" do
264
+ link = Twocheckout::Checkout.link({ 'sid' => '1817037', 'cart_order_id' => 'Example Sale', 'total' => '1.00'})
265
+ @link = "https://www.2checkout.com/checkout/purchase?sid=1817037&cart_order_id=Example+Sale&total=1.00"
266
+ assert_equal(link, @link)
267
+ end
252
268
  end
Binary file
data/twocheckout.gemspec CHANGED
@@ -4,9 +4,9 @@ $:.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.1.1'
7
+ s.version = '0.1.2'
8
8
  s.summary = '2Checkout Ruby Library'
9
- s.description = '0.1.1'
9
+ s.description = '0.1.2'
10
10
  s.summary = '2Checkout Ruby Library'
11
11
  s.author = "Craig Christenson", "Ernesto Garcia"
12
12
  s.email = 'christensoncraig@gmail.com'
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.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-10-24 00:00:00.000000000 Z
13
+ date: 2013-04-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rest-client
@@ -28,7 +28,7 @@ dependencies:
28
28
  - - ~>
29
29
  - !ruby/object:Gem::Version
30
30
  version: '1.4'
31
- description: 0.1.1
31
+ description: 0.1.2
32
32
  email: christensoncraig@gmail.com
33
33
  executables: []
34
34
  extensions: []
@@ -51,7 +51,9 @@ files:
51
51
  - lib/twocheckout/twocheckout_error.rb
52
52
  - lib/twocheckout/validate_response.rb
53
53
  - lib/twocheckout/version.rb
54
- - test/test_twocheckout.rb
54
+ - test/minitest_helper.rb
55
+ - test/twocheckout_test.rb
56
+ - twocheckout-0.1.1.gem
55
57
  - twocheckout.gemspec
56
58
  homepage: https://github.com/craigchristenson
57
59
  licenses: []
@@ -74,9 +76,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
76
  requirements:
75
77
  - none
76
78
  rubyforge_project:
77
- rubygems_version: 1.8.24
79
+ rubygems_version: 1.8.25
78
80
  signing_key:
79
81
  specification_version: 3
80
82
  summary: 2Checkout Ruby Library
81
- test_files:
82
- - test/test_twocheckout.rb
83
+ test_files: []