bongloy 4.21.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +76 -0
- data/.editorconfig +10 -0
- data/.gitattributes +4 -0
- data/.github/ISSUE_TEMPLATE.md +5 -0
- data/.github/README.md +79 -0
- data/.github/pull.yml +5 -0
- data/.gitignore +8 -0
- data/.rubocop.yml +43 -0
- data/.rubocop_todo.yml +38 -0
- data/.travis.yml +43 -0
- data/.vscode/extensions.json +7 -0
- data/.vscode/settings.json +8 -0
- data/CHANGELOG.md +770 -0
- data/CONTRIBUTORS +3 -0
- data/Gemfile +39 -0
- data/History.txt +1 -0
- data/LICENSE +21 -0
- data/README.md +282 -0
- data/Rakefile +36 -0
- data/VERSION +1 -0
- data/bin/stripe-console +16 -0
- data/bongloy.gemspec +37 -0
- data/lib/bongloy.rb +7 -0
- data/lib/data/ca-certificates.crt +4043 -0
- data/lib/stripe.rb +208 -0
- data/lib/stripe/api_operations/create.rb +12 -0
- data/lib/stripe/api_operations/delete.rb +35 -0
- data/lib/stripe/api_operations/list.rb +30 -0
- data/lib/stripe/api_operations/nested_resource.rb +70 -0
- data/lib/stripe/api_operations/request.rb +53 -0
- data/lib/stripe/api_operations/save.rb +94 -0
- data/lib/stripe/api_resource.rb +107 -0
- data/lib/stripe/errors.rb +156 -0
- data/lib/stripe/list_object.rb +110 -0
- data/lib/stripe/oauth.rb +63 -0
- data/lib/stripe/object_types.rb +98 -0
- data/lib/stripe/resources.rb +79 -0
- data/lib/stripe/resources/account.rb +174 -0
- data/lib/stripe/resources/account_link.rb +9 -0
- data/lib/stripe/resources/alipay_account.rb +34 -0
- data/lib/stripe/resources/apple_pay_domain.rb +16 -0
- data/lib/stripe/resources/application_fee.rb +24 -0
- data/lib/stripe/resources/application_fee_refund.rb +30 -0
- data/lib/stripe/resources/balance.rb +7 -0
- data/lib/stripe/resources/balance_transaction.rb +13 -0
- data/lib/stripe/resources/bank_account.rb +42 -0
- data/lib/stripe/resources/bitcoin_receiver.rb +23 -0
- data/lib/stripe/resources/bitcoin_transaction.rb +15 -0
- data/lib/stripe/resources/capability.rb +33 -0
- data/lib/stripe/resources/card.rb +37 -0
- data/lib/stripe/resources/charge.rb +84 -0
- data/lib/stripe/resources/checkout/session.rb +11 -0
- data/lib/stripe/resources/country_spec.rb +9 -0
- data/lib/stripe/resources/coupon.rb +12 -0
- data/lib/stripe/resources/credit_note.rb +18 -0
- data/lib/stripe/resources/customer.rb +95 -0
- data/lib/stripe/resources/customer_balance_transaction.rb +30 -0
- data/lib/stripe/resources/discount.rb +7 -0
- data/lib/stripe/resources/dispute.rb +23 -0
- data/lib/stripe/resources/ephemeral_key.rb +19 -0
- data/lib/stripe/resources/event.rb +9 -0
- data/lib/stripe/resources/exchange_rate.rb +9 -0
- data/lib/stripe/resources/file.rb +44 -0
- data/lib/stripe/resources/file_link.rb +11 -0
- data/lib/stripe/resources/invoice.rb +48 -0
- data/lib/stripe/resources/invoice_item.rb +12 -0
- data/lib/stripe/resources/invoice_line_item.rb +7 -0
- data/lib/stripe/resources/issuer_fraud_record.rb +9 -0
- data/lib/stripe/resources/issuing/authorization.rb +25 -0
- data/lib/stripe/resources/issuing/card.rb +20 -0
- data/lib/stripe/resources/issuing/card_details.rb +9 -0
- data/lib/stripe/resources/issuing/cardholder.rb +13 -0
- data/lib/stripe/resources/issuing/dispute.rb +13 -0
- data/lib/stripe/resources/issuing/transaction.rb +12 -0
- data/lib/stripe/resources/login_link.rb +14 -0
- data/lib/stripe/resources/order.rb +32 -0
- data/lib/stripe/resources/order_return.rb +9 -0
- data/lib/stripe/resources/payment_intent.rb +30 -0
- data/lib/stripe/resources/payment_method.rb +24 -0
- data/lib/stripe/resources/payout.rb +24 -0
- data/lib/stripe/resources/person.rb +31 -0
- data/lib/stripe/resources/plan.rb +12 -0
- data/lib/stripe/resources/product.rb +12 -0
- data/lib/stripe/resources/radar/early_fraud_warning.rb +11 -0
- data/lib/stripe/resources/radar/value_list.rb +14 -0
- data/lib/stripe/resources/radar/value_list_item.rb +13 -0
- data/lib/stripe/resources/recipient.rb +17 -0
- data/lib/stripe/resources/recipient_transfer.rb +7 -0
- data/lib/stripe/resources/refund.rb +11 -0
- data/lib/stripe/resources/reporting/report_run.rb +12 -0
- data/lib/stripe/resources/reporting/report_type.rb +12 -0
- data/lib/stripe/resources/reversal.rb +29 -0
- data/lib/stripe/resources/review.rb +16 -0
- data/lib/stripe/resources/setup_intent.rb +24 -0
- data/lib/stripe/resources/sigma/scheduled_query_run.rb +15 -0
- data/lib/stripe/resources/sku.rb +12 -0
- data/lib/stripe/resources/source.rb +42 -0
- data/lib/stripe/resources/source_transaction.rb +7 -0
- data/lib/stripe/resources/subscription.rb +25 -0
- data/lib/stripe/resources/subscription_item.rb +17 -0
- data/lib/stripe/resources/subscription_schedule.rb +32 -0
- data/lib/stripe/resources/subscription_schedule_revision.rb +34 -0
- data/lib/stripe/resources/tax_id.rb +26 -0
- data/lib/stripe/resources/tax_rate.rb +11 -0
- data/lib/stripe/resources/terminal/connection_token.rb +11 -0
- data/lib/stripe/resources/terminal/location.rb +14 -0
- data/lib/stripe/resources/terminal/reader.rb +14 -0
- data/lib/stripe/resources/three_d_secure.rb +13 -0
- data/lib/stripe/resources/token.rb +9 -0
- data/lib/stripe/resources/topup.rb +18 -0
- data/lib/stripe/resources/transfer.rb +27 -0
- data/lib/stripe/resources/usage_record.rb +23 -0
- data/lib/stripe/resources/usage_record_summary.rb +7 -0
- data/lib/stripe/resources/webhook_endpoint.rb +12 -0
- data/lib/stripe/singleton_api_resource.rb +26 -0
- data/lib/stripe/stripe_client.rb +686 -0
- data/lib/stripe/stripe_object.rb +583 -0
- data/lib/stripe/stripe_response.rb +50 -0
- data/lib/stripe/util.rb +336 -0
- data/lib/stripe/version.rb +5 -0
- data/lib/stripe/webhook.rb +90 -0
- data/stripe.gemspec +37 -0
- data/test/api_stub_helpers.rb +1 -0
- data/test/openapi/README.md +9 -0
- data/test/stripe/account_link_test.rb +18 -0
- data/test/stripe/account_test.rb +428 -0
- data/test/stripe/alipay_account_test.rb +37 -0
- data/test/stripe/api_operations_test.rb +80 -0
- data/test/stripe/api_resource_test.rb +544 -0
- data/test/stripe/apple_pay_domain_test.rb +46 -0
- data/test/stripe/application_fee_refund_test.rb +37 -0
- data/test/stripe/application_fee_test.rb +58 -0
- data/test/stripe/balance_test.rb +13 -0
- data/test/stripe/bank_account_test.rb +36 -0
- data/test/stripe/capability_test.rb +45 -0
- data/test/stripe/charge_test.rb +80 -0
- data/test/stripe/checkout/session_test.rb +41 -0
- data/test/stripe/country_spec_test.rb +20 -0
- data/test/stripe/coupon_test.rb +61 -0
- data/test/stripe/credit_note_test.rb +61 -0
- data/test/stripe/customer_balance_transaction_test.rb +37 -0
- data/test/stripe/customer_card_test.rb +42 -0
- data/test/stripe/customer_test.rb +269 -0
- data/test/stripe/dispute_test.rb +51 -0
- data/test/stripe/ephemeral_key_test.rb +93 -0
- data/test/stripe/errors_test.rb +20 -0
- data/test/stripe/exchange_rate_test.rb +20 -0
- data/test/stripe/file_link_test.rb +41 -0
- data/test/stripe/file_test.rb +97 -0
- data/test/stripe/file_upload_test.rb +79 -0
- data/test/stripe/invoice_item_test.rb +66 -0
- data/test/stripe/invoice_line_item_test.rb +8 -0
- data/test/stripe/invoice_test.rb +213 -0
- data/test/stripe/issuer_fraud_record_test.rb +20 -0
- data/test/stripe/issuing/authorization_test.rb +72 -0
- data/test/stripe/issuing/card_test.rb +62 -0
- data/test/stripe/issuing/cardholder_test.rb +53 -0
- data/test/stripe/issuing/dispute_test.rb +45 -0
- data/test/stripe/issuing/transaction_test.rb +48 -0
- data/test/stripe/list_object_test.rb +156 -0
- data/test/stripe/login_link_test.rb +37 -0
- data/test/stripe/oauth_test.rb +88 -0
- data/test/stripe/order_return_test.rb +21 -0
- data/test/stripe/order_test.rb +82 -0
- data/test/stripe/payment_intent_test.rb +107 -0
- data/test/stripe/payment_method_test.rb +84 -0
- data/test/stripe/payout_test.rb +57 -0
- data/test/stripe/person_test.rb +46 -0
- data/test/stripe/plan_test.rb +98 -0
- data/test/stripe/product_test.rb +59 -0
- data/test/stripe/radar/early_fraud_warning_test.rb +22 -0
- data/test/stripe/radar/value_list_item_test.rb +48 -0
- data/test/stripe/radar/value_list_test.rb +61 -0
- data/test/stripe/recipient_test.rb +62 -0
- data/test/stripe/refund_test.rb +39 -0
- data/test/stripe/reporting/report_run_test.rb +33 -0
- data/test/stripe/reporting/report_type_test.rb +22 -0
- data/test/stripe/reversal_test.rb +43 -0
- data/test/stripe/review_test.rb +27 -0
- data/test/stripe/setup_intent_test.rb +84 -0
- data/test/stripe/sigma/scheduled_query_run_test.rb +22 -0
- data/test/stripe/sku_test.rb +60 -0
- data/test/stripe/source_test.rb +99 -0
- data/test/stripe/source_transaction_test.rb +19 -0
- data/test/stripe/stripe_client_test.rb +842 -0
- data/test/stripe/stripe_object_test.rb +525 -0
- data/test/stripe/stripe_response_test.rb +49 -0
- data/test/stripe/subscription_item_test.rb +63 -0
- data/test/stripe/subscription_schedule_revision_test.rb +37 -0
- data/test/stripe/subscription_schedule_test.rb +116 -0
- data/test/stripe/subscription_test.rb +80 -0
- data/test/stripe/tax_id_test.rb +31 -0
- data/test/stripe/tax_rate_test.rb +43 -0
- data/test/stripe/terminal/connection_token_test.rb +16 -0
- data/test/stripe/terminal/location_test.rb +68 -0
- data/test/stripe/terminal/reader_test.rb +62 -0
- data/test/stripe/three_d_secure_test.rb +23 -0
- data/test/stripe/topup_test.rb +62 -0
- data/test/stripe/transfer_test.rb +88 -0
- data/test/stripe/usage_record_summary_test.rb +19 -0
- data/test/stripe/usage_record_test.rb +28 -0
- data/test/stripe/util_test.rb +402 -0
- data/test/stripe/webhook_endpoint_test.rb +59 -0
- data/test/stripe/webhook_test.rb +96 -0
- data/test/stripe_mock.rb +77 -0
- data/test/stripe_test.rb +63 -0
- data/test/test_data.rb +61 -0
- data/test/test_helper.rb +71 -0
- metadata +372 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
class BitcoinTransaction < APIResource
|
5
|
+
# Directly retrieving BitcoinTransactions is deprecated. Please use the
|
6
|
+
# Sources API instead: https://stripe.com/docs/sources/bitcoin
|
7
|
+
extend Stripe::APIOperations::List
|
8
|
+
|
9
|
+
OBJECT_NAME = "bitcoin_transaction".freeze
|
10
|
+
|
11
|
+
def self.resource_url
|
12
|
+
"/v1/bitcoin/transactions"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
class Capability < APIResource
|
5
|
+
extend Stripe::APIOperations::List
|
6
|
+
include Stripe::APIOperations::Save
|
7
|
+
|
8
|
+
OBJECT_NAME = "capability".freeze
|
9
|
+
|
10
|
+
def resource_url
|
11
|
+
if !respond_to?(:account) || account.nil?
|
12
|
+
raise NotImplementedError,
|
13
|
+
"Capabilities cannot be accessed without an account ID."
|
14
|
+
end
|
15
|
+
"#{Account.resource_url}/#{CGI.escape(account)}/capabilities" \
|
16
|
+
"/#{CGI.escape(id)}"
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.retrieve(_id, _opts = {})
|
20
|
+
raise NotImplementedError,
|
21
|
+
"Capabilities cannot be retrieve without an account ID. " \
|
22
|
+
"Retrieve a capability using Account.retrieve_capability(" \
|
23
|
+
"'account_id', 'capability_id')`"
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.update(_id, _params = nil, _opts = nil)
|
27
|
+
raise NotImplementedError,
|
28
|
+
"Capabilities cannot be updated without an account ID. Update a " \
|
29
|
+
"capability using Account.update_capability('account_id', " \
|
30
|
+
"'capability_id', update_params)`"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
class Card < APIResource
|
5
|
+
include Stripe::APIOperations::Delete
|
6
|
+
extend Stripe::APIOperations::List
|
7
|
+
include Stripe::APIOperations::Save
|
8
|
+
|
9
|
+
OBJECT_NAME = "card".freeze
|
10
|
+
|
11
|
+
def resource_url
|
12
|
+
if respond_to?(:recipient) && !recipient.nil? && !recipient.empty?
|
13
|
+
"#{Recipient.resource_url}/#{CGI.escape(recipient)}/cards/#{CGI.escape(id)}"
|
14
|
+
elsif respond_to?(:customer) && !customer.nil? && !customer.empty?
|
15
|
+
"#{Customer.resource_url}/#{CGI.escape(customer)}/sources/#{CGI.escape(id)}"
|
16
|
+
elsif respond_to?(:account) && !account.nil? && !account.empty?
|
17
|
+
"#{Account.resource_url}/#{CGI.escape(account)}/external_accounts/#{CGI.escape(id)}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.update(_id, _params = nil, _opts = nil)
|
22
|
+
raise NotImplementedError,
|
23
|
+
"Card cannot be updated without a customer ID or an account ID. " \
|
24
|
+
"Update a card using `Customer.update_source('customer_id', " \
|
25
|
+
"'card_id', update_params)` or `Account.update_external_account(" \
|
26
|
+
"'account_id', 'card_id', update_params)`"
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.retrieve(_id, _opts = nil)
|
30
|
+
raise NotImplementedError,
|
31
|
+
"Card cannot be retrieved without a customer ID or an account " \
|
32
|
+
"ID. Retrieve a card using `Customer.retrieve_source(" \
|
33
|
+
"'customer_id', 'card_id')` or " \
|
34
|
+
"`Account.retrieve_external_account('account_id', 'card_id')`"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
class Charge < APIResource
|
5
|
+
extend Stripe::APIOperations::Create
|
6
|
+
extend Stripe::APIOperations::List
|
7
|
+
include Stripe::APIOperations::Save
|
8
|
+
|
9
|
+
OBJECT_NAME = "charge".freeze
|
10
|
+
|
11
|
+
custom_method :capture, http_verb: :post
|
12
|
+
|
13
|
+
def refund(params = {}, opts = {})
|
14
|
+
# Old versions of charge objects included a `refunds` field that was just
|
15
|
+
# a vanilla array instead of a Stripe list object.
|
16
|
+
#
|
17
|
+
# Where possible, we'd still like to use the new refund endpoint (thus
|
18
|
+
# `self.refunds.create`), but detect the old API version by looking for
|
19
|
+
# an `Array` and fall back to the old refund URL if necessary so as to
|
20
|
+
# maintain internal compatibility.
|
21
|
+
if refunds.is_a?(Array)
|
22
|
+
resp, opts = request(:post, refund_url, params, opts)
|
23
|
+
initialize_from(resp.data, opts)
|
24
|
+
else
|
25
|
+
refunds.create(params, opts)
|
26
|
+
|
27
|
+
# now that a refund has been created, we expect the state of this object
|
28
|
+
# to change as well (i.e. `refunded` will now be `true`) so refresh it
|
29
|
+
# from the server
|
30
|
+
refresh
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def capture(params = {}, opts = {})
|
35
|
+
resp, opts = request(:post, capture_url, params, opts)
|
36
|
+
initialize_from(resp.data, opts)
|
37
|
+
end
|
38
|
+
|
39
|
+
def update_dispute(params = {}, opts = {})
|
40
|
+
resp, opts = request(:post, dispute_url, params, opts)
|
41
|
+
initialize_from({ dispute: resp.data }, opts, true)
|
42
|
+
dispute
|
43
|
+
end
|
44
|
+
|
45
|
+
def close_dispute(params = {}, opts = {})
|
46
|
+
resp, opts = request(:post, close_dispute_url, params, opts)
|
47
|
+
initialize_from(resp.data, opts)
|
48
|
+
end
|
49
|
+
|
50
|
+
def mark_as_fraudulent
|
51
|
+
params = {
|
52
|
+
fraud_details: { user_report: "fraudulent" },
|
53
|
+
}
|
54
|
+
resp, opts = request(:post, resource_url, params)
|
55
|
+
initialize_from(resp.data, opts)
|
56
|
+
end
|
57
|
+
|
58
|
+
def mark_as_safe
|
59
|
+
params = {
|
60
|
+
fraud_details: { user_report: "safe" },
|
61
|
+
}
|
62
|
+
resp, opts = request(:post, resource_url, params)
|
63
|
+
initialize_from(resp.data, opts)
|
64
|
+
end
|
65
|
+
|
66
|
+
private def capture_url
|
67
|
+
resource_url + "/capture"
|
68
|
+
end
|
69
|
+
|
70
|
+
private def dispute_url
|
71
|
+
resource_url + "/dispute"
|
72
|
+
end
|
73
|
+
|
74
|
+
private def close_dispute_url
|
75
|
+
resource_url + "/dispute/close"
|
76
|
+
end
|
77
|
+
|
78
|
+
# Note that this is actually the *old* refund URL and its use is no longer
|
79
|
+
# preferred.
|
80
|
+
private def refund_url
|
81
|
+
resource_url + "/refund"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
class Coupon < APIResource
|
5
|
+
extend Stripe::APIOperations::Create
|
6
|
+
include Stripe::APIOperations::Delete
|
7
|
+
extend Stripe::APIOperations::List
|
8
|
+
include Stripe::APIOperations::Save
|
9
|
+
|
10
|
+
OBJECT_NAME = "coupon".freeze
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
class CreditNote < APIResource
|
5
|
+
extend Stripe::APIOperations::Create
|
6
|
+
extend Stripe::APIOperations::List
|
7
|
+
include Stripe::APIOperations::Save
|
8
|
+
|
9
|
+
OBJECT_NAME = "credit_note".freeze
|
10
|
+
|
11
|
+
custom_method :void_credit_note, http_verb: :post, http_path: "void"
|
12
|
+
|
13
|
+
def void_credit_note(params = {}, opts = {})
|
14
|
+
resp, opts = request(:post, resource_url + "/void", params, opts)
|
15
|
+
initialize_from(resp.data, opts)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
class Customer < APIResource
|
5
|
+
extend Stripe::APIOperations::Create
|
6
|
+
include Stripe::APIOperations::Delete
|
7
|
+
extend Stripe::APIOperations::List
|
8
|
+
include Stripe::APIOperations::Save
|
9
|
+
extend Stripe::APIOperations::NestedResource
|
10
|
+
|
11
|
+
OBJECT_NAME = "customer".freeze
|
12
|
+
|
13
|
+
nested_resource_class_methods :balance_transaction,
|
14
|
+
operations: %i[create retrieve update list]
|
15
|
+
nested_resource_class_methods :tax_id,
|
16
|
+
operations: %i[create retrieve delete list]
|
17
|
+
|
18
|
+
custom_method :delete_discount, http_verb: :delete, http_path: "discount"
|
19
|
+
|
20
|
+
save_nested_resource :source
|
21
|
+
nested_resource_class_methods :source,
|
22
|
+
operations: %i[create retrieve update delete list]
|
23
|
+
|
24
|
+
# The API request for deleting a card or bank account and for detaching a
|
25
|
+
# source object are the same.
|
26
|
+
class << self
|
27
|
+
alias detach_source delete_source
|
28
|
+
end
|
29
|
+
|
30
|
+
def add_invoice_item(params, opts = {})
|
31
|
+
opts = @opts.merge(Util.normalize_opts(opts))
|
32
|
+
InvoiceItem.create(params.merge(customer: id), opts)
|
33
|
+
end
|
34
|
+
|
35
|
+
def invoices(params = {}, opts = {})
|
36
|
+
opts = @opts.merge(Util.normalize_opts(opts))
|
37
|
+
Invoice.all(params.merge(customer: id), opts)
|
38
|
+
end
|
39
|
+
|
40
|
+
def invoice_items(params = {}, opts = {})
|
41
|
+
opts = @opts.merge(Util.normalize_opts(opts))
|
42
|
+
InvoiceItem.all(params.merge(customer: id), opts)
|
43
|
+
end
|
44
|
+
|
45
|
+
def upcoming_invoice(params = {}, opts = {})
|
46
|
+
opts = @opts.merge(Util.normalize_opts(opts))
|
47
|
+
Invoice.upcoming(params.merge(customer: id), opts)
|
48
|
+
end
|
49
|
+
|
50
|
+
def charges(params = {}, opts = {})
|
51
|
+
opts = @opts.merge(Util.normalize_opts(opts))
|
52
|
+
Charge.all(params.merge(customer: id), opts)
|
53
|
+
end
|
54
|
+
|
55
|
+
def create_upcoming_invoice(params = {}, opts = {})
|
56
|
+
opts = @opts.merge(Util.normalize_opts(opts))
|
57
|
+
Invoice.create(params.merge(customer: id), opts)
|
58
|
+
end
|
59
|
+
|
60
|
+
def cancel_subscription(params = {}, opts = {})
|
61
|
+
resp, opts = request(:delete, subscription_url, params, opts)
|
62
|
+
initialize_from({ subscription: resp.data }, opts, true)
|
63
|
+
subscription
|
64
|
+
end
|
65
|
+
|
66
|
+
def update_subscription(params = {}, opts = {})
|
67
|
+
resp, opts = request(:post, subscription_url, params, opts)
|
68
|
+
initialize_from({ subscription: resp.data }, opts, true)
|
69
|
+
subscription
|
70
|
+
end
|
71
|
+
|
72
|
+
def create_subscription(params = {}, opts = {})
|
73
|
+
resp, opts = request(:post, subscriptions_url, params, opts)
|
74
|
+
initialize_from({ subscription: resp.data }, opts, true)
|
75
|
+
subscription
|
76
|
+
end
|
77
|
+
|
78
|
+
def delete_discount
|
79
|
+
_, opts = request(:delete, discount_url)
|
80
|
+
initialize_from({ discount: nil }, opts, true)
|
81
|
+
end
|
82
|
+
|
83
|
+
private def discount_url
|
84
|
+
resource_url + "/discount"
|
85
|
+
end
|
86
|
+
|
87
|
+
private def subscription_url
|
88
|
+
resource_url + "/subscription"
|
89
|
+
end
|
90
|
+
|
91
|
+
private def subscriptions_url
|
92
|
+
resource_url + "/subscriptions"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
class CustomerBalanceTransaction < APIResource
|
5
|
+
extend Stripe::APIOperations::List
|
6
|
+
include Stripe::APIOperations::Save
|
7
|
+
|
8
|
+
OBJECT_NAME = "customer_balance_transaction".freeze
|
9
|
+
|
10
|
+
def resource_url
|
11
|
+
if !respond_to?(:customer) || customer.nil?
|
12
|
+
raise NotImplementedError,
|
13
|
+
"Customer Balance Transactions cannot be accessed without a customer ID."
|
14
|
+
end
|
15
|
+
"#{Customer.resource_url}/#{CGI.escape(customer)}/balance_transactions/#{CGI.escape(id)}"
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.retrieve(_id, _opts = {})
|
19
|
+
raise NotImplementedError,
|
20
|
+
"Customer Balance Transactions cannot be retrieved without a customer ID. " \
|
21
|
+
"Retrieve a Customer Balance Transaction using Customer.retrieve_balance_transaction('cus_123', 'cbtxn_123')"
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.update(_id, _params = nil, _opts = nil)
|
25
|
+
raise NotImplementedError,
|
26
|
+
"Customer Balance Transactions cannot be retrieved without a customer ID. " \
|
27
|
+
"Update a Customer Balance Transaction using Customer.update_balance_transaction('cus_123', 'cbtxn_123', params)"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
class Dispute < APIResource
|
5
|
+
extend Stripe::APIOperations::List
|
6
|
+
include Stripe::APIOperations::Save
|
7
|
+
|
8
|
+
OBJECT_NAME = "dispute".freeze
|
9
|
+
|
10
|
+
custom_method :close, http_verb: :post
|
11
|
+
|
12
|
+
def close(params = {}, opts = {})
|
13
|
+
resp, opts = request(:post, resource_url + "/close", params, opts)
|
14
|
+
initialize_from(resp.data, opts)
|
15
|
+
end
|
16
|
+
|
17
|
+
def close_url
|
18
|
+
resource_url + "/close"
|
19
|
+
end
|
20
|
+
extend Gem::Deprecate
|
21
|
+
deprecate :close_url, :none, 2019, 11
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
class EphemeralKey < APIResource
|
5
|
+
extend Stripe::APIOperations::Create
|
6
|
+
include Stripe::APIOperations::Delete
|
7
|
+
|
8
|
+
OBJECT_NAME = "ephemeral_key".freeze
|
9
|
+
|
10
|
+
def self.create(params = {}, opts = {})
|
11
|
+
opts = Util.normalize_opts(opts)
|
12
|
+
unless opts[:stripe_version]
|
13
|
+
raise ArgumentError,
|
14
|
+
"stripe_version must be specified to create an ephemeral key"
|
15
|
+
end
|
16
|
+
super
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
class File < APIResource
|
5
|
+
extend Stripe::APIOperations::Create
|
6
|
+
extend Stripe::APIOperations::List
|
7
|
+
|
8
|
+
OBJECT_NAME = "file".freeze
|
9
|
+
|
10
|
+
# This resource can have two different object names. In latter API
|
11
|
+
# versions, only `file` is used, but since stripe-ruby may be used with
|
12
|
+
# any API version, we need to support deserializing the older
|
13
|
+
# `file_upload` object into the same class.
|
14
|
+
OBJECT_NAME_ALT = "file_upload".freeze
|
15
|
+
|
16
|
+
def self.resource_url
|
17
|
+
"/v1/files"
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.create(params = {}, opts = {})
|
21
|
+
# rest-client would accept a vanilla `File` for upload, but Faraday does
|
22
|
+
# not. Support the old API by wrapping a `File`-like object with an
|
23
|
+
# `UploadIO` object if we're given one.
|
24
|
+
if params[:file] && !params[:file].is_a?(String)
|
25
|
+
unless params[:file].respond_to?(:read)
|
26
|
+
raise ArgumentError, "file must respond to `#read`"
|
27
|
+
end
|
28
|
+
|
29
|
+
params[:file] = Faraday::UploadIO.new(params[:file], nil)
|
30
|
+
end
|
31
|
+
|
32
|
+
opts = {
|
33
|
+
api_base: Stripe.uploads_base,
|
34
|
+
content_type: "multipart/form-data",
|
35
|
+
}.merge(Util.normalize_opts(opts))
|
36
|
+
super
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
module Stripe
|
42
|
+
# For backwards compatibility, the `File` class is aliased to `FileUpload`.
|
43
|
+
FileUpload = File
|
44
|
+
end
|