stripe 1.26.0 → 1.27.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +4 -0
- data/VERSION +1 -1
- data/lib/stripe.rb +3 -0
- data/lib/stripe/api_operations/update.rb +3 -1
- data/lib/stripe/order.rb +19 -0
- data/lib/stripe/product.rb +16 -0
- data/lib/stripe/sku.rb +8 -0
- data/lib/stripe/stripe_object.rb +1 -1
- data/lib/stripe/util.rb +4 -1
- data/lib/stripe/version.rb +1 -1
- data/test/stripe/metadata_test.rb +16 -1
- data/test/stripe/order_test.rb +52 -0
- data/test/stripe/product_test.rb +41 -0
- data/test/stripe/sku_test.rb +24 -0
- data/test/test_data.rb +129 -0
- metadata +11 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 760f0f55706fd57c28bd816239bce54e737af027
|
4
|
+
data.tar.gz: f130be8395aa8171a34281613132a4810f4a6933
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 811530350758ac6aa6eee05ce63591ac77272e2d0dc66b503d86e3897d79060237352dd3fa1f4b0997b1387e8360dd672e3c82fc9293e644b86636fc31bbdec6
|
7
|
+
data.tar.gz: daa6cad45b40d685193cc63b90fbcbf5f51967d34d8f5b63e095200958ff9902d0b99edc7ea40b19bcab26697aff6517a75e26c90f768083c04ebc04215b0538
|
data/History.txt
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.27.0
|
data/lib/stripe.rb
CHANGED
@@ -49,6 +49,9 @@ require 'stripe/application_fee_refund'
|
|
49
49
|
require 'stripe/bitcoin_receiver'
|
50
50
|
require 'stripe/bitcoin_transaction'
|
51
51
|
require 'stripe/dispute'
|
52
|
+
require 'stripe/product'
|
53
|
+
require 'stripe/sku'
|
54
|
+
require 'stripe/order'
|
52
55
|
|
53
56
|
# Errors
|
54
57
|
require 'stripe/errors/stripe_error'
|
@@ -2,12 +2,14 @@ module Stripe
|
|
2
2
|
module APIOperations
|
3
3
|
module Update
|
4
4
|
def save(params={})
|
5
|
+
# Let the caller override the URL but avoid serializing it.
|
6
|
+
req_url = params.delete(:req_url) || url
|
5
7
|
values = self.class.serialize_params(self).merge(params)
|
6
8
|
|
7
9
|
if values.length > 0
|
8
10
|
values.delete(:id)
|
9
11
|
|
10
|
-
response, opts = request(:post,
|
12
|
+
response, opts = request(:post, req_url, values)
|
11
13
|
refresh_from(response, opts)
|
12
14
|
end
|
13
15
|
self
|
data/lib/stripe/order.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Stripe
|
2
|
+
class Order < APIResource
|
3
|
+
include Stripe::APIOperations::List
|
4
|
+
include Stripe::APIOperations::Create
|
5
|
+
include Stripe::APIOperations::Update
|
6
|
+
|
7
|
+
def pay(params, opts={})
|
8
|
+
response, opts = request(:post, pay_url, params, opts)
|
9
|
+
refresh_from(response, opts)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def pay_url
|
15
|
+
url + "/pay"
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Stripe
|
2
|
+
class Product < APIResource
|
3
|
+
include Stripe::APIOperations::List
|
4
|
+
include Stripe::APIOperations::Create
|
5
|
+
include Stripe::APIOperations::Update
|
6
|
+
|
7
|
+
# Keep APIResource#url as `api_url` to avoid letting the external URL
|
8
|
+
# replace the Stripe URL.
|
9
|
+
alias_method :api_url, :url
|
10
|
+
|
11
|
+
# Override Stripe::APIOperations::Update#save to explicitly pass URL.
|
12
|
+
def save
|
13
|
+
super(req_url: api_url)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/stripe/sku.rb
ADDED
data/lib/stripe/stripe_object.rb
CHANGED
@@ -123,7 +123,7 @@ module Stripe
|
|
123
123
|
new_keys = update.keys.map(&:to_sym)
|
124
124
|
|
125
125
|
# remove keys at the server, but not known locally
|
126
|
-
if @original_values
|
126
|
+
if @original_values[key]
|
127
127
|
keys_to_unset = @original_values[key].keys - new_keys
|
128
128
|
keys_to_unset.each {|key| update[key] = ''}
|
129
129
|
end
|
data/lib/stripe/util.rb
CHANGED
@@ -44,7 +44,10 @@ module Stripe
|
|
44
44
|
'transfer_reversal' => Reversal,
|
45
45
|
'bitcoin_receiver' => BitcoinReceiver,
|
46
46
|
'bitcoin_transaction' => BitcoinTransaction,
|
47
|
-
'dispute' => Dispute
|
47
|
+
'dispute' => Dispute,
|
48
|
+
'product' => Product,
|
49
|
+
'sku' => SKU,
|
50
|
+
'order' => Order,
|
48
51
|
}
|
49
52
|
end
|
50
53
|
|
data/lib/stripe/version.rb
CHANGED
@@ -23,7 +23,22 @@ module Stripe
|
|
23
23
|
:new => Stripe::Transfer.method(:new),
|
24
24
|
:test => method(:make_transfer),
|
25
25
|
:url => "/v1/transfers/#{make_transfer()[:id]}"
|
26
|
-
}
|
26
|
+
},
|
27
|
+
:product => {
|
28
|
+
:new => Stripe::Product.method(:new),
|
29
|
+
:test => method(:make_product),
|
30
|
+
:url => "/v1/products/#{make_product()[:id]}"
|
31
|
+
},
|
32
|
+
:order => {
|
33
|
+
:new => Stripe::Order.method(:new),
|
34
|
+
:test => method(:make_order),
|
35
|
+
:url => "/v1/orders/#{make_order()[:id]}"
|
36
|
+
},
|
37
|
+
:sku => {
|
38
|
+
:new => Stripe::SKU.method(:new),
|
39
|
+
:test => method(:make_sku),
|
40
|
+
:url => "/v1/skus/#{make_sku()[:id]}"
|
41
|
+
},
|
27
42
|
}
|
28
43
|
|
29
44
|
@base_url = 'https://api.stripe.com'
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
class OrderTest < Test::Unit::TestCase
|
5
|
+
should "orders should be listable" do
|
6
|
+
@mock.expects(:get).once.returns(make_response(make_order_array))
|
7
|
+
orders = Stripe::Order.all
|
8
|
+
assert orders.data.kind_of?(Array)
|
9
|
+
orders.each do |order|
|
10
|
+
assert order.kind_of?(Stripe::Order)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
should "orders should not be deletable" do
|
15
|
+
assert_raises NoMethodError do
|
16
|
+
@mock.expects(:get).once.returns(make_response(make_order))
|
17
|
+
p = Stripe::Order.retrieve("test_order")
|
18
|
+
p.delete
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
should "orders should be updateable" do
|
23
|
+
@mock.expects(:get).once.returns(make_response(make_order))
|
24
|
+
@mock.expects(:post).once.returns(make_response(make_order))
|
25
|
+
p = Stripe::Order.new("test_order")
|
26
|
+
p.refresh
|
27
|
+
p.status = "fulfilled"
|
28
|
+
p.save
|
29
|
+
end
|
30
|
+
|
31
|
+
should "orders should allow metadata updates" do
|
32
|
+
@mock.expects(:get).once.returns(make_response(make_order))
|
33
|
+
@mock.expects(:post).once.returns(make_response(make_order))
|
34
|
+
p = Stripe::Order.new("test_order")
|
35
|
+
p.refresh
|
36
|
+
p.metadata['key'] = 'value'
|
37
|
+
p.save
|
38
|
+
end
|
39
|
+
|
40
|
+
should "pay should pay an order" do
|
41
|
+
@mock.expects(:get).once.
|
42
|
+
returns(make_response(make_order(:id => 'or_test_order')))
|
43
|
+
order = Stripe::Order.retrieve('or_test_order')
|
44
|
+
|
45
|
+
@mock.expects(:post).once.
|
46
|
+
with('https://api.stripe.com/v1/orders/or_test_order/pay', nil, 'token=test_token').
|
47
|
+
returns(make_response(make_paid_order))
|
48
|
+
order.pay(token: 'test_token')
|
49
|
+
assert_equal "paid", order.status
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
class ProductTest < Test::Unit::TestCase
|
5
|
+
should "products should be listable" do
|
6
|
+
@mock.expects(:get).once.returns(make_response(make_product_array))
|
7
|
+
products = Stripe::Product.all
|
8
|
+
assert products.data.kind_of?(Array)
|
9
|
+
products.each do |product|
|
10
|
+
assert product.kind_of?(Stripe::Product)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
should "products should not be deletable" do
|
15
|
+
assert_raises NoMethodError do
|
16
|
+
@mock.expects(:get).once.returns(make_response(make_product))
|
17
|
+
p = Stripe::Product.retrieve("test_product")
|
18
|
+
p.delete
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
should "products should be updateable" do
|
23
|
+
@mock.expects(:get).once.returns(make_response(make_product))
|
24
|
+
@mock.expects(:post).once.returns(make_response(make_product))
|
25
|
+
p = Stripe::Product.new("test_product")
|
26
|
+
p.refresh
|
27
|
+
p.description = "New product description"
|
28
|
+
p.save
|
29
|
+
end
|
30
|
+
|
31
|
+
should "products should allow metadata updates" do
|
32
|
+
@mock.expects(:get).once.returns(make_response(make_product))
|
33
|
+
@mock.expects(:post).once.returns(make_response(make_product))
|
34
|
+
p = Stripe::Product.new("test_product")
|
35
|
+
p.refresh
|
36
|
+
p.metadata['key'] = 'value'
|
37
|
+
p.save
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
class SKUTest < Test::Unit::TestCase
|
5
|
+
should "SKUs should be listable" do
|
6
|
+
@mock.expects(:get).once.
|
7
|
+
returns(make_response(make_sku_array("test_product")))
|
8
|
+
skus = Stripe::SKU.all
|
9
|
+
assert skus.data.kind_of? Array
|
10
|
+
skus.each do |sku|
|
11
|
+
assert sku.kind_of?(Stripe::SKU)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
should "SKUs should not be deletable" do
|
16
|
+
assert_raises NoMethodError do
|
17
|
+
@mock.expects(:get).once.returns(make_response(make_sku))
|
18
|
+
p = Stripe::SKU.retrieve("test_product")
|
19
|
+
p.delete
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
data/test/test_data.rb
CHANGED
@@ -533,5 +533,134 @@ module Stripe
|
|
533
533
|
:id => "di_test_coupon"
|
534
534
|
}
|
535
535
|
end
|
536
|
+
|
537
|
+
def make_product(params={})
|
538
|
+
{
|
539
|
+
:id => "pr_test_product",
|
540
|
+
:created => 1441992477,
|
541
|
+
:updated => 1441992477,
|
542
|
+
:object => "product",
|
543
|
+
:livemode => false,
|
544
|
+
:name => "Test Product",
|
545
|
+
:caption => "Comfy comfu",
|
546
|
+
:description => "Testing",
|
547
|
+
:active => true,
|
548
|
+
:attributes => [],
|
549
|
+
:shippable => true,
|
550
|
+
:metadata => {},
|
551
|
+
:url => "http://example.com/product",
|
552
|
+
:package_dimensions => nil,
|
553
|
+
:images => [],
|
554
|
+
:skus => make_sku_array("pr_test_product")
|
555
|
+
}.merge(params)
|
556
|
+
end
|
557
|
+
|
558
|
+
def make_product_array
|
559
|
+
{
|
560
|
+
:object => "list",
|
561
|
+
:url => "/v1/products",
|
562
|
+
:data => [
|
563
|
+
make_product,
|
564
|
+
make_product,
|
565
|
+
make_product,
|
566
|
+
],
|
567
|
+
}
|
568
|
+
end
|
569
|
+
|
570
|
+
def make_sku(params={})
|
571
|
+
{
|
572
|
+
:id => "12345",
|
573
|
+
:created => 1441992494,
|
574
|
+
:updated => 1441992494,
|
575
|
+
:object => "sku",
|
576
|
+
:livemode => false,
|
577
|
+
:product => "pr_test_product",
|
578
|
+
:image => nil,
|
579
|
+
:active => true,
|
580
|
+
:price => 999,
|
581
|
+
:currency => "usd",
|
582
|
+
:inventory => {
|
583
|
+
:type => "infinite",
|
584
|
+
:quantity => nil,
|
585
|
+
:value => nil,
|
586
|
+
},
|
587
|
+
:attributes => {},
|
588
|
+
:metadata => {},
|
589
|
+
:package_dimensions => nil,
|
590
|
+
}.merge(params)
|
591
|
+
end
|
592
|
+
|
593
|
+
def make_sku_array(product_id, params={})
|
594
|
+
{
|
595
|
+
:object => "list",
|
596
|
+
:url => "/v1/skus",
|
597
|
+
:data => [
|
598
|
+
make_sku(:product => product_id),
|
599
|
+
make_sku(:product => product_id),
|
600
|
+
make_sku(:product => product_id),
|
601
|
+
]
|
602
|
+
}
|
603
|
+
end
|
604
|
+
|
605
|
+
def make_order(params={})
|
606
|
+
{
|
607
|
+
:id => "or_16kg0uDAu10Yox5RReNVCthv",
|
608
|
+
:created => 1442171988,
|
609
|
+
:updated => nil,
|
610
|
+
:object => "order",
|
611
|
+
:livemode => false,
|
612
|
+
:status => "created",
|
613
|
+
:metadata => {},
|
614
|
+
:customer => nil,
|
615
|
+
:shipping => {
|
616
|
+
:name => "Jenny Rosen",
|
617
|
+
:address => {
|
618
|
+
:line1 => "1234 Main street",
|
619
|
+
:line2 => nil,
|
620
|
+
:city => "Anytown",
|
621
|
+
:state => nil,
|
622
|
+
:postal_code => "123456",
|
623
|
+
:country => "US"
|
624
|
+
},
|
625
|
+
:phone => nil,
|
626
|
+
},
|
627
|
+
:email => nil,
|
628
|
+
:items => [
|
629
|
+
{
|
630
|
+
:parent => "sk_16bHXrDAu10Yox5RU2007dpU",
|
631
|
+
:object => "order_item",
|
632
|
+
:type => "sku",
|
633
|
+
:description => "T-shirt",
|
634
|
+
:amount => 1500,
|
635
|
+
:currency => "usd",
|
636
|
+
:quantity => nil,
|
637
|
+
}
|
638
|
+
],
|
639
|
+
:shipping_methods => nil,
|
640
|
+
:selected_shipping_method => nil,
|
641
|
+
:amount => 1500,
|
642
|
+
:currency => "usd",
|
643
|
+
:charge => nil,
|
644
|
+
}.merge(params)
|
645
|
+
end
|
646
|
+
|
647
|
+
def make_order_array(params={})
|
648
|
+
{
|
649
|
+
:object => "list",
|
650
|
+
:url => "/v1/orders",
|
651
|
+
:data => [
|
652
|
+
make_order,
|
653
|
+
make_order,
|
654
|
+
make_order,
|
655
|
+
]
|
656
|
+
}
|
657
|
+
end
|
658
|
+
|
659
|
+
def make_paid_order(params={})
|
660
|
+
make_order.merge({
|
661
|
+
:status => "paid",
|
662
|
+
:charge => make_charge,
|
663
|
+
}).merge(params)
|
664
|
+
end
|
536
665
|
end
|
537
666
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stripe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.27.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ross Boucher
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-09-
|
12
|
+
date: 2015-09-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
@@ -151,11 +151,14 @@ files:
|
|
151
151
|
- lib/stripe/invoice.rb
|
152
152
|
- lib/stripe/invoice_item.rb
|
153
153
|
- lib/stripe/list_object.rb
|
154
|
+
- lib/stripe/order.rb
|
154
155
|
- lib/stripe/plan.rb
|
156
|
+
- lib/stripe/product.rb
|
155
157
|
- lib/stripe/recipient.rb
|
156
158
|
- lib/stripe/refund.rb
|
157
159
|
- lib/stripe/reversal.rb
|
158
160
|
- lib/stripe/singleton_api_resource.rb
|
161
|
+
- lib/stripe/sku.rb
|
159
162
|
- lib/stripe/stripe_object.rb
|
160
163
|
- lib/stripe/subscription.rb
|
161
164
|
- lib/stripe/token.rb
|
@@ -179,9 +182,12 @@ files:
|
|
179
182
|
- test/stripe/invoice_test.rb
|
180
183
|
- test/stripe/list_object_test.rb
|
181
184
|
- test/stripe/metadata_test.rb
|
185
|
+
- test/stripe/order_test.rb
|
186
|
+
- test/stripe/product_test.rb
|
182
187
|
- test/stripe/recipient_card_test.rb
|
183
188
|
- test/stripe/refund_test.rb
|
184
189
|
- test/stripe/reversal_test.rb
|
190
|
+
- test/stripe/sku_test.rb
|
185
191
|
- test/stripe/stripe_object_test.rb
|
186
192
|
- test/stripe/subscription_test.rb
|
187
193
|
- test/stripe/transfer_test.rb
|
@@ -229,9 +235,12 @@ test_files:
|
|
229
235
|
- test/stripe/invoice_test.rb
|
230
236
|
- test/stripe/list_object_test.rb
|
231
237
|
- test/stripe/metadata_test.rb
|
238
|
+
- test/stripe/order_test.rb
|
239
|
+
- test/stripe/product_test.rb
|
232
240
|
- test/stripe/recipient_card_test.rb
|
233
241
|
- test/stripe/refund_test.rb
|
234
242
|
- test/stripe/reversal_test.rb
|
243
|
+
- test/stripe/sku_test.rb
|
235
244
|
- test/stripe/stripe_object_test.rb
|
236
245
|
- test/stripe/subscription_test.rb
|
237
246
|
- test/stripe/transfer_test.rb
|