pay 2.3.1 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of pay might be problematic. Click here for more details.

Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -5
  3. data/app/controllers/pay/webhooks/braintree_controller.rb +7 -53
  4. data/app/controllers/pay/webhooks/paddle_controller.rb +19 -18
  5. data/app/controllers/pay/webhooks/stripe_controller.rb +47 -0
  6. data/app/mailers/pay/user_mailer.rb +14 -35
  7. data/app/models/pay/subscription.rb +12 -18
  8. data/app/views/pay/user_mailer/payment_action_required.html.erb +1 -1
  9. data/app/views/pay/user_mailer/receipt.html.erb +6 -6
  10. data/app/views/pay/user_mailer/refund.html.erb +6 -6
  11. data/app/views/pay/user_mailer/subscription_renewing.html.erb +1 -1
  12. data/config/locales/en.yml +137 -0
  13. data/config/routes.rb +1 -1
  14. data/db/migrate/20200603134434_add_data_to_pay_models.rb +6 -1
  15. data/lib/pay.rb +19 -50
  16. data/lib/pay/billable.rb +9 -9
  17. data/lib/pay/braintree.rb +1 -0
  18. data/lib/pay/braintree/billable.rb +11 -11
  19. data/lib/pay/braintree/charge.rb +3 -3
  20. data/lib/pay/braintree/subscription.rb +21 -13
  21. data/lib/pay/braintree/webhooks.rb +11 -0
  22. data/lib/pay/braintree/webhooks/subscription_canceled.rb +19 -0
  23. data/lib/pay/braintree/webhooks/subscription_charged_successfully.rb +24 -0
  24. data/lib/pay/braintree/webhooks/subscription_charged_unsuccessfully.rb +24 -0
  25. data/lib/pay/braintree/webhooks/subscription_expired.rb +19 -0
  26. data/lib/pay/braintree/webhooks/subscription_trial_ended.rb +19 -0
  27. data/lib/pay/braintree/webhooks/subscription_went_active.rb +19 -0
  28. data/lib/pay/braintree/webhooks/subscription_went_past_due.rb +19 -0
  29. data/lib/pay/engine.rb +0 -1
  30. data/lib/pay/errors.rb +73 -0
  31. data/lib/pay/paddle/billable.rb +34 -5
  32. data/lib/pay/paddle/charge.rb +2 -2
  33. data/lib/pay/paddle/subscription.rb +22 -13
  34. data/lib/pay/paddle/webhooks.rb +8 -0
  35. data/lib/pay/paddle/webhooks/subscription_cancelled.rb +3 -3
  36. data/lib/pay/paddle/webhooks/subscription_created.rb +15 -15
  37. data/lib/pay/paddle/webhooks/subscription_payment_refunded.rb +5 -5
  38. data/lib/pay/paddle/webhooks/subscription_payment_succeeded.rb +17 -38
  39. data/lib/pay/paddle/webhooks/subscription_updated.rb +20 -17
  40. data/lib/pay/receipts.rb +6 -6
  41. data/lib/pay/stripe.rb +3 -1
  42. data/lib/pay/stripe/billable.rb +4 -4
  43. data/lib/pay/stripe/charge.rb +2 -2
  44. data/lib/pay/stripe/subscription.rb +20 -12
  45. data/lib/pay/stripe/webhooks.rb +14 -15
  46. data/lib/pay/stripe/webhooks/charge_refunded.rb +2 -2
  47. data/lib/pay/stripe/webhooks/charge_succeeded.rb +1 -1
  48. data/lib/pay/stripe/webhooks/payment_action_required.rb +1 -1
  49. data/lib/pay/stripe/webhooks/subscription_created.rb +2 -1
  50. data/lib/pay/stripe/webhooks/subscription_renewing.rb +4 -3
  51. data/lib/pay/version.rb +1 -1
  52. data/lib/pay/webhooks/delegator.rb +61 -0
  53. metadata +21 -88
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 938efc72579bf8d24477a0e55060280a8e2d2df139860cdfe84dcc715f0eeb23
4
- data.tar.gz: 3f00c21f027beae9a68d9da5228d9fa0165eeb2153d62e48544702565e0834d7
3
+ metadata.gz: 8aa4f779f21c561b6e8b48df4908424198b09413c0e2b580d7d6d2610e4d7429
4
+ data.tar.gz: c62e136c8ae6ffed79028922aedfe59f14e77ca235ae407aa5acaed3299918d5
5
5
  SHA512:
6
- metadata.gz: 5d2ef6252a25049649fe460553766aa61122c2d3541b7eb6b4197ca4614c9110bcf9243fd5aa08ab90d32b2a224317dcf2e9275a8cd918bee4c0b8146703fd37
7
- data.tar.gz: '0992d392de15e633d5dcd190f9ed25bd356cf1a8da548e14b2560314aafa59593e5fcb64a68d70d16d5b58a6b6df0df55eba7259bb88c92166439bc61974af0e'
6
+ metadata.gz: 2154c6f3551b6089c470c71280c2ba9c810858954290fce62c67f2ca502822a4504447ebca822ac1b01f763c6c94095202693dc5b0d75e6dde4f89464530180e
7
+ data.tar.gz: 4d497228db1c45863ad0157bca179957f875705621b968eb1d4c0318c3e4f7ab35692260bb838a7f6c63aa39e704ac3398de535804d512461db1a8ac568239c8
data/README.md CHANGED
@@ -9,8 +9,8 @@ Pay is a payments engine for Ruby on Rails 4.2 and higher.
9
9
  **Current Payment Providers**
10
10
 
11
11
  - Stripe ([supports SCA](https://stripe.com/docs/strong-customer-authentication) using API version `2020-08-27`)
12
- - Braintree
13
- - Paddle
12
+ - Braintree (supports PayPal)
13
+ - Paddle (supports PayPal)
14
14
 
15
15
  Want to add a new payment provider? Contributions are welcome and the instructions [are here](https://github.com/jasoncharnes/pay/wiki/New-Payment-Provider).
16
16
 
@@ -31,7 +31,6 @@ gem 'pay', '~> 2.0'
31
31
 
32
32
  # To use Stripe, also include:
33
33
  gem 'stripe', '< 6.0', '>= 2.8'
34
- gem 'stripe_event', '~> 2.3'
35
34
 
36
35
  # To use Braintree + PayPal, also include:
37
36
  gem 'braintree', '< 3.0', '>= 2.92.0'
@@ -103,6 +102,9 @@ Pay.setup do |config|
103
102
 
104
103
  config.send_emails = true
105
104
 
105
+ config.default_product_name = "default"
106
+ config.default_plan_name = "default"
107
+
106
108
  config.automount_routes = true
107
109
  config.routes_path = "/pay" # Only when automount_routes is true
108
110
  end
@@ -260,7 +262,7 @@ A `card_token` must be provided as an attribute.
260
262
  The subscribe method has three optional arguments with default values.
261
263
 
262
264
  ```ruby
263
- def subscribe(name: 'default', plan: 'default', **options)
265
+ def subscribe(name: Pay.default_product_name, plan: Pay.default_plan_name, **options)
264
266
  ...
265
267
  end
266
268
  ```
@@ -269,7 +271,7 @@ For example, you can pass the `quantity` option to subscribe to a plan with for
269
271
 
270
272
  ```ruby
271
273
 
272
- user.subscribe(name: "default", plan: "default", quantity: 3)
274
+ user.subscribe(name: Pay.default_product_name, plan: Pay.default_plan_name, quantity: 3)
273
275
  ```
274
276
 
275
277
  ###### Name
@@ -6,66 +6,20 @@ module Pay
6
6
  end
7
7
 
8
8
  def create
9
- case webhook_notification.kind
10
- when "subscription_charged_successfully"
11
- subscription_charged_successfully(webhook_notification)
12
- when "subscription_canceled"
13
- subscription_canceled(webhook_notification)
14
- when "subscription_trial_ended"
15
- subscription_trial_ended(webhook_notification)
16
- end
17
-
18
- render json: {success: true}, status: :ok
19
- rescue ::Braintree::InvalidSignature
9
+ delegate_event(verified_event)
20
10
  head :ok
11
+ rescue ::Braintree::InvalidSignature
12
+ head :bad_request
21
13
  end
22
14
 
23
15
  private
24
16
 
25
- def subscription_charged_successfully(event)
26
- subscription = event.subscription
27
- return if subscription.nil?
28
-
29
- pay_subscription = Pay.subscription_model.find_by(processor: :braintree, processor_id: subscription.id)
30
- return unless pay_subscription.present?
31
-
32
- billable = pay_subscription.owner
33
- charge = billable.save_braintree_transaction(subscription.transactions.first)
34
-
35
- if Pay.send_emails
36
- Pay::UserMailer.receipt(billable, charge).deliver_later
37
- end
38
- end
39
-
40
- def subscription_canceled(event)
41
- subscription = event.subscription
42
- return if subscription.nil?
43
-
44
- pay_subscription = Pay.subscription_model.find_by(processor: :braintree, processor_id: subscription.id)
45
- return unless pay_subscription.present?
46
-
47
- billable = pay_subscription.owner
48
- return if billable.nil?
49
-
50
- # User canceled or failed to make payments
51
- billable.update(braintree_subscription_id: nil)
52
- end
53
-
54
- def subscription_trial_ended(event)
55
- subscription = event.subscription
56
- return if subscription.nil?
57
-
58
- pay_subscription = Pay.subscription_model.find_by(processor: :braintree, processor_id: subscription.id)
59
- return unless pay_subscription.present?
60
-
61
- pay_subscription.update(trial_ends_at: Time.zone.now)
17
+ def delegate_event(event)
18
+ Pay::Webhooks.instrument type: "braintree.#{event.kind}", event: event
62
19
  end
63
20
 
64
- def webhook_notification
65
- @webhook_notification ||= Pay.braintree_gateway.webhook_notification.parse(
66
- params[:bt_signature],
67
- params[:bt_payload]
68
- )
21
+ def verified_event
22
+ Pay.braintree_gateway.webhook_notification.parse(params[:bt_signature], params[:bt_payload])
69
23
  end
70
24
  end
71
25
  end
@@ -6,28 +6,29 @@ module Pay
6
6
  end
7
7
 
8
8
  def create
9
- verifier = Pay::Paddle::Webhooks::SignatureVerifier.new(check_params.as_json)
10
- if verifier.verify
11
- case params["alert_name"]
12
- when "subscription_created"
13
- Pay::Paddle::Webhooks::SubscriptionCreated.new(check_params.as_json)
14
- when "subscription_updated"
15
- Pay::Paddle::Webhooks::SubscriptionUpdated.new(check_params.as_json)
16
- when "subscription_cancelled"
17
- Pay::Paddle::Webhooks::SubscriptionCancelled.new(check_params.as_json)
18
- when "subscription_payment_succeeded"
19
- Pay::Paddle::Webhooks::SubscriptionPaymentSucceeded.new(check_params.as_json)
20
- when "subscription_payment_refunded"
21
- Pay::Paddle::Webhooks::SubscriptionPaymentRefunded.new(check_params.as_json)
22
- end
23
- render json: {success: true}, status: :ok
24
- else
25
- head :ok
26
- end
9
+ delegate_event(verified_event)
10
+ head :ok
11
+ rescue Pay::Paddle::Error
12
+ head :bad_request
27
13
  end
28
14
 
29
15
  private
30
16
 
17
+ def delegate_event(event)
18
+ Pay::Webhooks.instrument type: "paddle.#{type}", event: event
19
+ end
20
+
21
+ def type
22
+ params[:alert_name]
23
+ end
24
+
25
+ def verified_event
26
+ event = check_params.as_json
27
+ verifier = Pay::Paddle::Webhooks::SignatureVerifier.new(event)
28
+ return event if verifier.verify
29
+ raise Pay::Paddle::Error, "Unable to verify Paddle webhook event"
30
+ end
31
+
31
32
  def check_params
32
33
  params.except(:action, :controller).permit!
33
34
  end
@@ -0,0 +1,47 @@
1
+ module Pay
2
+ module Webhooks
3
+ class StripeController < Pay::ApplicationController
4
+ if Rails.application.config.action_controller.default_protect_from_forgery
5
+ skip_before_action :verify_authenticity_token
6
+ end
7
+
8
+ def create
9
+ delegate_event(verified_event)
10
+ head :ok
11
+ rescue ::Stripe::SignatureVerificationError => e
12
+ log_error(e)
13
+ head :bad_request
14
+ end
15
+
16
+ private
17
+
18
+ def delegate_event(event)
19
+ Pay::Webhooks.instrument type: "stripe.#{event.type}", event: event
20
+ end
21
+
22
+ def verified_event
23
+ payload = request.body.read
24
+ signature = request.headers["Stripe-Signature"]
25
+ possible_secrets = secrets(payload, signature)
26
+
27
+ possible_secrets.each_with_index do |secret, i|
28
+ return ::Stripe::Webhook.construct_event(payload, signature, secret.to_s)
29
+ rescue ::Stripe::SignatureVerificationError
30
+ raise if i == possible_secrets.length - 1
31
+ next
32
+ end
33
+ end
34
+
35
+ def secrets(payload, signature)
36
+ secret = Pay::Stripe.signing_secret
37
+ return Array.wrap(secret) if secret
38
+ raise ::Stripe::SignatureVerificationError.new("Cannot verify signature without a Stripe signing secret", signature, http_body: payload)
39
+ end
40
+
41
+ def log_error(e)
42
+ logger.error e.message
43
+ e.backtrace.each { |line| logger.error " #{line}" }
44
+ end
45
+ end
46
+ end
47
+ end
@@ -1,53 +1,32 @@
1
1
  module Pay
2
2
  class UserMailer < ApplicationMailer
3
- def receipt(user, charge)
4
- @user, @charge = user, charge
5
-
6
- if charge.respond_to? :receipt
7
- attachments[charge.filename] = charge.receipt
3
+ def receipt
4
+ if params[:charge].respond_to? :receipt
5
+ attachments[params[:charge].filename] = params[:charge].receipt
8
6
  end
9
7
 
10
- mail(
11
- to: to(user),
12
- subject: Pay.email_receipt_subject
13
- )
8
+ mail to: to
14
9
  end
15
10
 
16
- def refund(user, charge)
17
- @user, @charge = user, charge
18
-
19
- mail(
20
- to: to(user),
21
- subject: Pay.email_refund_subject
22
- )
11
+ def refund
12
+ mail to: to
23
13
  end
24
14
 
25
- def subscription_renewing(user, subscription)
26
- @user, @subscription = user, subscription
27
-
28
- mail(
29
- to: to(user),
30
- subject: Pay.email_renewing_subject
31
- )
15
+ def subscription_renewing
16
+ mail to: to
32
17
  end
33
18
 
34
- def payment_action_required(user, payment_intent_id, subscription)
35
- payment = Payment.from_id(payment_intent_id)
36
- @user, @payment, @subscription = user, payment, subscription
37
-
38
- mail(
39
- to: to(user),
40
- subject: Pay.email_action_required_subject
41
- )
19
+ def payment_action_required
20
+ mail to: to
42
21
  end
43
22
 
44
23
  private
45
24
 
46
- def to(user)
47
- if user.respond_to?(:customer_name)
48
- "#{user.customer_name} <#{user.email}>"
25
+ def to
26
+ if params[:billable].respond_to?(:customer_name)
27
+ "#{params[:billable].customer_name} <#{params[:billable].email}>"
49
28
  else
50
- user.email
29
+ params[:billable].email
51
30
  end
52
31
  end
53
32
  end
@@ -29,6 +29,15 @@ module Pay
29
29
 
30
30
  attribute :prorate, :boolean, default: true
31
31
 
32
+ # Helpers for payment processors
33
+ %w[braintree stripe paddle].each do |processor_name|
34
+ define_method "#{processor_name}?" do
35
+ processor == processor_name
36
+ end
37
+
38
+ scope processor_name, -> { where(processor: processor_name) }
39
+ end
40
+
32
41
  def no_prorate
33
42
  self.prorate = false
34
43
  end
@@ -50,7 +59,8 @@ module Pay
50
59
  end
51
60
 
52
61
  def on_grace_period?
53
- canceled? && Time.zone.now < ends_at
62
+ return unless processor?
63
+ send("#{processor}_on_grace_period?")
54
64
  end
55
65
 
56
66
  def active?
@@ -70,11 +80,10 @@ module Pay
70
80
  end
71
81
 
72
82
  def paused?
73
- status == "paused"
83
+ send("#{processor}_paused?")
74
84
  end
75
85
 
76
86
  def pause
77
- return unless paddle?
78
87
  send("#{processor}_pause")
79
88
  end
80
89
 
@@ -87,22 +96,7 @@ module Pay
87
96
  end
88
97
 
89
98
  def resume
90
- unless on_grace_period?
91
- unless paddle?
92
- raise StandardError,
93
- "You can only resume subscriptions within their grace period."
94
- end
95
- end
96
-
97
- unless paused?
98
- if paddle?
99
- raise StandardError,
100
- "You can only resume paused subscriptions."
101
- end
102
- end
103
-
104
99
  send("#{processor}_resume")
105
-
106
100
  update(ends_at: nil, status: "active")
107
101
  self
108
102
  end
@@ -1,6 +1,6 @@
1
1
  <h3>Extra confirmation is needed to process your payment</h3>
2
2
  <p>Your <%= Pay.business_name %> subscription requires confirmation to process your payment to continue access.</p>
3
3
 
4
- <p>You may confirm your payment via your account. If you have any questions, please hit reply and let us know.</p>
4
+ <p><%= link_to "Click here to confirm your payment", pay.payment_url(params[:payment_intent_id]) %>. If you have any questions, please hit reply and let us know.</p>
5
5
 
6
6
  <p>- The <%= Pay.business_name %> Team</p>
@@ -5,13 +5,13 @@ Questions? Please reply to this email.<br/>
5
5
  ------------------------------------<br/>
6
6
  RECEIPT - SUBSCRIPTION<br/>
7
7
  <br/>
8
- Amount: USD <%= ActionController::Base.helpers.number_to_currency(@charge.amount / 100.0) %><br/>
8
+ Amount: USD <%= ActionController::Base.helpers.number_to_currency(params[:charge].amount / 100.0) %><br/>
9
9
  <br/>
10
- Charged to: <%= @charge.charged_to %><br/>
11
- Transaction ID: <%= @charge.id %><br/>
12
- Date: <%= @charge.created_at %><br/>
13
- <% if @charge.owner.extra_billing_info? %>
14
- <%= @charge.owner.extra_billing_info %><br/>
10
+ Charged to: <%= params[:charge].charged_to %><br/>
11
+ Transaction ID: <%= params[:charge].id %><br/>
12
+ Date: <%= params[:charge].created_at %><br/>
13
+ <% if params[:charge].owner.extra_billing_info? %>
14
+ <%= params[:charge].owner.extra_billing_info %><br/>
15
15
  <% end %>
16
16
  <br/>
17
17
  <br/>
@@ -6,13 +6,13 @@ Questions? Please reply to this email.<br/>
6
6
  ------------------------------------<br/>
7
7
  RECEIPT - REFUND<br/>
8
8
  <br/>
9
- Amount: USD <%= ActionController::Base.helpers.number_to_currency(@charge.amount / 100.0) %><br/>
9
+ Amount: USD <%= ActionController::Base.helpers.number_to_currency(params[:charge].amount / 100.0) %><br/>
10
10
  <br/>
11
- Refunded to: <%= @charge.charged_to %><br/>
12
- Transaction ID: <%= @charge.id %><br/>
13
- Date: <%= @charge.created_at %><br/>
14
- <% if @charge.owner.extra_billing_info? %>
15
- <%= @charge.owner.extra_billing_info %><br/>
11
+ Refunded to: <%= params[:charge].charged_to %><br/>
12
+ Transaction ID: <%= params[:charge].id %><br/>
13
+ Date: <%= params[:charge].created_at %><br/>
14
+ <% if params[:charge].owner.extra_billing_info? %>
15
+ <%= params[:charge].owner.extra_billing_info %><br/>
16
16
  <% end %>
17
17
  <br/>
18
18
  <br/>
@@ -1,5 +1,5 @@
1
1
  <h3>Your upcoming subscription renewal</h3>
2
- <p>This is just a friendly reminder that your <%= Pay.business_name %> subscription will renew automatically on <%= @subscription %>.</p>
2
+ <p>This is just a friendly reminder that your <%= Pay.business_name %> subscription will renew automatically on <%= l params[:date].to_date, format: :long %>.</p>
3
3
 
4
4
  <p>You may manage your subscription via your account. If you have any questions, please hit reply and let us know.</p>
5
5
 
@@ -15,3 +15,140 @@ en:
15
15
  success: The payment was successful.
16
16
  all_rights_reserved: All rights reserved.
17
17
  back: Go back
18
+ receipt:
19
+ date: Date
20
+ account_billed: Account Billed
21
+ product: Product
22
+ amount: Amount
23
+ charged_to: Charged to
24
+ additional_info: Additional Info
25
+ errors:
26
+ action_required: "This payment attempt failed because additional action is required before it can be completed."
27
+ invalid_payment: "This payment attempt failed because of an invalid payment method."
28
+ email_required: "Email is required to create a customer"
29
+ no_processor: "No payment processor selected. Make sure to set the %{class_name}'s `processor` attribute to either 'stripe' or 'braintree'."
30
+ stripe:
31
+ errors:
32
+ account_already_exists: The email address provided for the creation of a deferred account already has an account associated with it. Use the OAuth flow to connect the existing account to your platform.
33
+ account_country_invalid_address: The country of the business address provided does not match the country of the account. Businesses must be located in the same country as the account.
34
+ account_invalid: The account ID provided as a value for the Stripe-Account header is invalid. Check that your requests are specifying a valid account ID.
35
+ account_number_invalid: The bank account number provided is invalid (e.g., missing digits). Bank account information varies from country to country. We recommend creating validations in your entry forms based on the bank account formats we provide.
36
+ alipay_upgrade_required: This method for creating Alipay payments is not supported anymore. Please upgrade your integration to use Sources instead.
37
+ amount_too_large: The specified amount is greater than the maximum amount allowed. Use a lower amount and try again.
38
+ amount_too_small: The specified amount is less than the minimum amount allowed. Use a higher amount and try again.
39
+ api_key_expired: The API key provided has expired. Obtain your current API keys from the Dashboard and update your integration to use them.
40
+ authentication_required: The payment requires authentication to proceed. If your customer is off session, notify your customer to return to your application and complete the payment. If you provided the error_on_requires_action parameter, then your customer should try another card that does not require authentication.
41
+ balance_insufficient: The transfer or payout could not be completed because the associated account does not have a sufficient balance available. Create a new transfer or payout using an amount less than or equal to the account’s available balance.
42
+ bank_account_declined: The bank account provided can not be used to charge, either because it is not verified yet or it is not supported.
43
+ bank_account_exists: The bank account provided already exists on the specified Customer object. If the bank account should also be attached to a different customer, include the correct customer ID when making the request again.
44
+ bank_account_unusable: The bank account provided cannot be used for payouts. A different bank account must be used.
45
+ bank_account_unverified: Your Connect platform is attempting to share an unverified bank account with a connected account.
46
+ bank_account_verification_failed: The bank account cannot be verified, either because the microdeposit amounts provided do not match the actual amounts, or because verification has failed too many times.
47
+ bitcoin_upgrade_required: This method for creating Bitcoin payments is not supported anymore. Please upgrade your integration to use Sources instead.
48
+ card_decline_rate_limit_exceeded: This card has been declined too many times. You can try to charge this card again after 24 hours. We suggest reaching out to your customer to make sure they have entered all of their information correctly and that there are no issues with their card.
49
+ card_declined: The card has been declined. When a card is declined, the error returned also includes the decline_code attribute with the reason why the card was declined. Refer to our decline codes documentation to learn more.
50
+ charge_already_captured: The charge you’re attempting to capture has already been captured. Update the request with an uncaptured charge ID.
51
+ charge_already_refunded: The charge you’re attempting to refund has already been refunded. Update the request to use the ID of a charge that has not been refunded.
52
+ charge_disputed: The charge you’re attempting to refund has been charged back. Check the disputes documentation to learn how to respond to the dispute.
53
+ charge_exceeds_source_limit: This charge would cause you to exceed your rolling-window processing limit for this source type. Please retry the charge later, or contact us to request a higher processing limit.
54
+ charge_expired_for_capture: The charge cannot be captured as the authorization has expired. Auth and capture charges must be captured within seven days.
55
+ charge_invalid_parameter: One or more provided parameters was not allowed for the given operation on the Charge. Check our API reference or the returned error message to see which values were not correct for that Charge.
56
+ clearing_code_unsupported: The clearing code provided is not supported.
57
+ country_code_invalid: The country code provided was invalid.
58
+ country_unsupported: Your platform attempted to create a custom account in a country that is not yet supported. Make sure that users can only sign up in countries supported by custom accounts.
59
+ coupon_expired: The coupon provided for a subscription or order has expired. Either create a new coupon, or use an existing one that is valid.
60
+ customer_max_payment_methods: The maximum number of PaymentMethods for this Customer has been reached. Either detach some PaymentMethods from this Customer or proceed with a different Customer.
61
+ customer_max_subscriptions: The maximum number of subscriptions for a customer has been reached. Contact us if you are receiving this error.
62
+ email_invalid: The email address is invalid (e.g., not properly formatted). Check that the email address is properly formatted and only includes allowed characters.
63
+ expired_card: The card has expired. Check the expiration date or use a different card.
64
+ idempotency_key_in_use: The idempotency key provided is currently being used in another request. This occurs if your integration is making duplicate requests simultaneously.
65
+ incorrect_address: The card’s address is incorrect. Check the card’s address or use a different card.
66
+ incorrect_cvc: The card’s security code is incorrect. Check the card’s security code or use a different card.
67
+ incorrect_number: The card number is incorrect. Check the card’s number or use a different card.
68
+ incorrect_zip: The card’s postal code is incorrect. Check the card’s postal code or use a different card.
69
+ instant_payouts_unsupported: This card is not eligible for Instant Payouts. Try a debit card from a supported bank.
70
+ intent_invalid_state: Intent is not the state that is rquired to perform the operation.
71
+ intent_verification_method_missing: Intent does not have verification method specified in its PaymentMethodOptions object.
72
+ invalid_card_type: The card provided as an external account is not supported for payouts. Provide a non-prepaid debit card instead.
73
+ invalid_characters: This value provided to the field contains characters that are unsupported by the field.
74
+ invalid_charge_amount: The specified amount is invalid. The charge amount must be a positive integer in the smallest currency unit, and not exceed the minimum or maximum amount.
75
+ invalid_cvc: The card’s security code is invalid. Check the card’s security code or use a different card.
76
+ invalid_expiry_month: The card’s expiration month is incorrect. Check the expiration date or use a different card.
77
+ invalid_expiry_year: The card’s expiration year is incorrect. Check the expiration date or use a different card.
78
+ invalid_number: The card number is invalid. Check the card details or use a different card.
79
+ invalid_source_usage: The source cannot be used because it is not in the correct state (e.g., a charge request is trying to use a source with a pending, failed, or consumed source). Check the status of the source you are attempting to use.
80
+ invoice_no_customer_line_items: An invoice cannot be generated for the specified customer as there are no pending invoice items. Check that the correct customer is being specified or create any necessary invoice items first.
81
+ invoice_no_payment_method_types: An invoice cannot be finalized because there are no payment method types available to process the payment. Your invoice template settings or the invoice’s payment_settings might be restricting which payment methods are available, or you might need to activate more payment methods in the Dashboard.
82
+ invoice_no_subscription_line_items: An invoice cannot be generated for the specified subscription as there are no pending invoice items. Check that the correct subscription is being specified or create any necessary invoice items first.
83
+ invoice_not_editable: The specified invoice can no longer be edited. Instead, consider creating additional invoice items that will be applied to the next invoice. You can either manually generate the next invoice or wait for it to be automatically generated at the end of the billing cycle.
84
+ invoice_payment_intent_requires_action: This payment requires additional user action before it can be completed successfully. Payment can be completed using the PaymentIntent associated with the invoice. See this page for more details.
85
+ invoice_upcoming_none: There is no upcoming invoice on the specified customer to preview. Only customers with active subscriptions or pending invoice items have invoices that can be previewed.
86
+ livemode_mismatch: Test and live mode API keys, requests, and objects are only available within the mode they are in.
87
+ lock_timeout: This object cannot be accessed right now because another API request or Stripe process is currently accessing it. If you see this error intermittently, retry the request. If you see this error frequently and are making multiple concurrent requests to a single object, make your requests serially or at a lower rate. See the rate limit documentation for more details.
88
+ missing: Both a customer and source ID have been provided, but the source has not been saved to the customer. To create a charge for a customer with a specified source, you must first save the card details.
89
+ not_allowed_on_standard_account: Transfers and payouts on behalf of a Standard connected account are not allowed.
90
+ order_creation_failed: The order could not be created. Check the order details and then try again.
91
+ order_required_settings: The order could not be processed as it is missing required information. Check the information provided and try again.
92
+ order_status_invalid: The order cannot be updated because the status provided is either invalid or does not follow the order lifecycle (e.g., an order cannot transition from created to fulfilled without first transitioning to paid).
93
+ order_upstream_timeout: The request timed out. Try again later.
94
+ out_of_inventory: The SKU is out of stock. If more stock is available, update the SKU’s inventory quantity and try again.
95
+ parameter_invalid_empty: One or more required values were not provided. Make sure requests include all required parameters.
96
+ parameter_invalid_integer: One or more of the parameters requires an integer, but the values provided were a different type. Make sure that only supported values are provided for each attribute. Refer to our API documentation to look up the type of data each attribute supports.
97
+ parameter_invalid_string_blank: One or more values provided only included whitespace. Check the values in your request and update any that contain only whitespace.
98
+ parameter_invalid_string_empty: One or more required string values is empty. Make sure that string values contain at least one character.
99
+ parameter_missing: One or more required values are missing. Check our API documentation to see which values are required to create or modify the specified resource.
100
+ parameter_unknown: The request contains one or more unexpected parameters. Remove these and try again.
101
+ parameters_exclusive: Two or more mutually exclusive parameters were provided. Check our API documentation or the returned error message to see which values are permitted when creating or modifying the specified resource.
102
+ payment_intent_action_required: The provided payment method requires customer actions to complete, but error_on_requires_action was set. If you’d like to add this payment method to your integration, we recommend that you first upgrade your integration to handle actions.
103
+ payment_intent_authentication_failure: The provided payment method has failed authentication. Provide a new payment method to attempt to fulfill this PaymentIntent again.
104
+ payment_intent_incompatible_payment_method: The PaymentIntent expected a payment method with different properties than what was provided.
105
+ payment_intent_invalid_parameter: One or more provided parameters was not allowed for the given operation on the PaymentIntent. Check our API reference or the returned error message to see which values were not correct for that PaymentIntent.
106
+ payment_intent_payment_attempt_failed: The latest payment attempt for the PaymentIntent has failed. Check the last_payment_error property on the PaymentIntent for more details, and provide a new payment method to attempt to fulfill this PaymentIntent again.
107
+ payment_intent_unexpected_state: The PaymentIntent’s state was incompatible with the operation you were trying to perform.
108
+ payment_method_invalid_parameter: Invalid parameter was provided in the payment method object. Check our API documentation or the returned error message for more context.
109
+ payment_method_provider_decline: The payment was declined by the issuer or customer. Check the last_payment_error property on the PaymentIntent for more details, and provide a new payment method to attempt to fulfill this PaymentIntent again.
110
+ payment_method_provider_timeout: The payment method failed due to a timeout. Check the last_payment_error property on the PaymentIntent for more details, and provide a new payment method to attempt to fulfill this PaymentIntent again.
111
+ payment_method_unactivated: The operation cannot be performed as the payment method used has not been activated. Activate the payment method in the Dashboard, then try again.
112
+ payment_method_unexpected_state: The provided payment method’s state was incompatible with the operation you were trying to perform. Confirm that the payment method is in an allowed state for the given operation before attempting to perform it.
113
+ payment_method_unsupported_type: The API only supports payment methods of certain types.
114
+ payouts_not_allowed: Payouts have been disabled on the connected account. Check the connected account’s status to see if any additional information needs to be provided, or if payouts have been disabled for another reason.
115
+ platform_api_key_expired: The API key provided by your Connect platform has expired. This occurs if your platform has either generated a new key or the connected account has been disconnected from the platform. Obtain your current API keys from the Dashboard and update your integration, or reach out to the user and reconnect the account.
116
+ postal_code_invalid: The postal code provided was incorrect.
117
+ processing_error: An error occurred while processing the card. Try again later or with a different payment method.
118
+ product_inactive: The product this SKU belongs to is no longer available for purchase.
119
+ rate_limit: Too many requests hit the API too quickly. We recommend an exponential backoff of your requests.
120
+ resource_already_exists: A resource with a user-specified ID (e.g., plan or coupon) already exists. Use a different, unique value for id and try again.
121
+ resource_missing: The ID provided is not valid. Either the resource does not exist, or an ID for a different resource has been provided.
122
+ routing_number_invalid: The bank routing number provided is invalid.
123
+ secret_key_required: The API key provided is a publishable key, but a secret key is required. Obtain your current API keys from the Dashboard and update your integration to use them.
124
+ sepa_unsupported_account: Your account does not support SEPA payments.
125
+ setup_attempt_failed: The latest setup attempt for the SetupIntent has failed. Check the last_setup_error property on the SetupIntent for more details, and provide a new payment method to attempt to set it up again.
126
+ setup_intent_authentication_failure: The provided payment method has failed authentication. Provide a new payment method to attempt to fulfill this SetupIntent again.
127
+ setup_intent_invalid_parameter: One or more provided parameters was not allowed for the given operation on the SetupIntent. Check our API reference or the returned error message to see which values were not correct for that SetupIntent.
128
+ setup_intent_unexpected_state: The SetupIntent’s state was incompatible with the operation you were trying to perform.
129
+ shipping_calculation_failed: Shipping calculation failed as the information provided was either incorrect or could not be verified.
130
+ sku_inactive: The SKU is inactive and no longer available for purchase. Use a different SKU, or make the current SKU active again.
131
+ state_unsupported: Occurs when providing the legal_entity information for a U.S. custom account, if the provided state is not supported. (This is mostly associated states and territories.)
132
+ tax_id_invalid: The tax ID number provided is invalid (e.g., missing digits). Tax ID information varies from country to country, but must be at least nine digits.
133
+ taxes_calculation_failed: Tax calculation for the order failed.
134
+ terminal_location_country_unsupported: Terminal is currently only available in some countries. Locations in your country cannot be created in livemode.
135
+ testmode_charges_only: Your account has not been activated and can only make test charges. Activate your account in the Dashboard to begin processing live charges.
136
+ tls_version_unsupported: Your integration is using an older version of TLS that is unsupported. You must be using TLS 1.2 or above.
137
+ token_already_used: The token provided has already been used. You must create a new token before you can retry this request.
138
+ token_in_use: The token provided is currently being used in another request. This occurs if your integration is making duplicate requests simultaneously.
139
+ transfers_not_allowed: The requested transfer cannot be created. Contact us if you are receiving this error.
140
+ upstream_order_creation_failed: The order could not be created. Check the order details and then try again.
141
+ url_invalid: The URL provided is invalid.
142
+ braintree:
143
+ authorization: "Either the data you submitted is malformed and does not match the API or the API key you used may not be authorized to perform this action."
144
+
145
+ pay:
146
+ user_mailer:
147
+ receipt:
148
+ subject: "Payment receipt"
149
+ refund:
150
+ subject: "Payment refunded"
151
+ subscription_renewing:
152
+ subject: "Your upcoming subscription renewal"
153
+ payment_action_required:
154
+ subject: "Confirm your payment"