spree_stripe 1.8.0 → 6.0.0.beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +21 -0
  3. data/README.md +41 -104
  4. data/Rakefile +7 -19
  5. data/app/jobs/spree_stripe/base_job.rb +1 -1
  6. data/app/jobs/spree_stripe/create_webhook_endpoint_job.rb +17 -2
  7. data/app/models/spree/payment_sessions/stripe.rb +45 -11
  8. data/app/models/spree_stripe/gateway/connect.rb +327 -0
  9. data/app/models/spree_stripe/gateway/payment_sessions.rb +234 -88
  10. data/app/models/spree_stripe/gateway/payment_setup_sessions.rb +15 -9
  11. data/app/models/spree_stripe/gateway/webhooks.rb +107 -0
  12. data/app/models/spree_stripe/gateway.rb +197 -244
  13. data/app/models/spree_stripe/payment_sources/ideal.rb +1 -1
  14. data/app/models/spree_stripe/payment_sources/przelewy24.rb +1 -1
  15. data/app/models/spree_stripe/payout_provider.rb +348 -0
  16. data/app/presenters/spree_stripe/customer_presenter.rb +7 -6
  17. data/app/presenters/spree_stripe/statement_descriptor_suffix_presenter.rb +11 -10
  18. data/app/services/spree_stripe/create_gateway_webhooks.rb +57 -33
  19. data/app/services/spree_stripe/create_payment.rb +46 -31
  20. data/app/services/spree_stripe/create_source.rb +37 -17
  21. data/app/services/spree_stripe/update_customer.rb +5 -4
  22. data/app/subscribers/spree_stripe/customer_updated_subscriber.rb +18 -0
  23. data/config/initializers/stripe.rb +1 -13
  24. data/config/locales/en.yml +4 -0
  25. data/lib/generators/spree_stripe/install/install_generator.rb +12 -12
  26. data/lib/spree_stripe/engine.rb +7 -38
  27. data/lib/spree_stripe/factories.rb +1 -3
  28. data/lib/spree_stripe/testing_support/factories/gateway_factory.rb +10 -9
  29. data/lib/spree_stripe/testing_support/factories/payment_session_factory.rb +50 -0
  30. data/lib/spree_stripe.rb +7 -8
  31. data/lib/tasks/migrate_webhook_keys.rake +128 -0
  32. metadata +29 -167
  33. data/app/assets/config/spree_stripe_manifest.js +0 -4
  34. data/app/assets/images/payment_icons/banktransfer.svg +0 -3
  35. data/app/assets/images/payment_icons/link.svg +0 -1
  36. data/app/assets/images/payment_icons/sepadebit.svg +0 -22
  37. data/app/controllers/spree_stripe/apple_pay_domain_verification_controller.rb +0 -11
  38. data/app/controllers/spree_stripe/confirm_payments_controller.rb +0 -52
  39. data/app/controllers/spree_stripe/store_controller_decorator.rb +0 -11
  40. data/app/controllers/stripe_event/webhook_controller_decorator.rb +0 -21
  41. data/app/helpers/spree_stripe/base_helper.rb +0 -35
  42. data/app/helpers/spree_stripe/checkout_helper_decorator.rb +0 -17
  43. data/app/javascript/spree_stripe/application.js +0 -18
  44. data/app/javascript/spree_stripe/controllers/stripe_button_controller.js +0 -398
  45. data/app/javascript/spree_stripe/controllers/stripe_controller.js +0 -238
  46. data/app/jobs/spree_stripe/attach_customer_to_credit_card_job.rb +0 -18
  47. data/app/jobs/spree_stripe/complete_order_from_session_job.rb +0 -12
  48. data/app/jobs/spree_stripe/create_tax_transaction_job.rb +0 -10
  49. data/app/jobs/spree_stripe/register_domain_job.rb +0 -20
  50. data/app/jobs/spree_stripe/update_customer_job.rb +0 -10
  51. data/app/models/spree_stripe/base.rb +0 -6
  52. data/app/models/spree_stripe/calculators/stripe_tax.rb +0 -96
  53. data/app/models/spree_stripe/credit_card_decorator.rb +0 -13
  54. data/app/models/spree_stripe/custom_domain_decorator.rb +0 -20
  55. data/app/models/spree_stripe/gateway/payment_intents.rb +0 -149
  56. data/app/models/spree_stripe/gateway_customer_decorator.rb +0 -9
  57. data/app/models/spree_stripe/order_decorator.rb +0 -9
  58. data/app/models/spree_stripe/payment_decorator.rb +0 -46
  59. data/app/models/spree_stripe/payment_method_decorator.rb +0 -18
  60. data/app/models/spree_stripe/payment_methods_webhook_key.rb +0 -8
  61. data/app/models/spree_stripe/payment_source_decorator.rb +0 -9
  62. data/app/models/spree_stripe/shipment_decorator.rb +0 -21
  63. data/app/models/spree_stripe/store_decorator.rb +0 -24
  64. data/app/models/spree_stripe/user_decorator.rb +0 -21
  65. data/app/models/spree_stripe/webhook_key.rb +0 -14
  66. data/app/presenters/spree_stripe/payment_intent_presenter.rb +0 -101
  67. data/app/presenters/spree_stripe/tax_presenter.rb +0 -63
  68. data/app/services/spree_stripe/complete_order.rb +0 -105
  69. data/app/services/spree_stripe/create_payment_session.rb +0 -18
  70. data/app/services/spree_stripe/register_domain.rb +0 -22
  71. data/app/services/spree_stripe/webhook_handlers/base.rb +0 -19
  72. data/app/services/spree_stripe/webhook_handlers/payment_intent_amount_capturable_updated.rb +0 -13
  73. data/app/services/spree_stripe/webhook_handlers/payment_intent_payment_failed.rb +0 -16
  74. data/app/services/spree_stripe/webhook_handlers/payment_intent_succeeded.rb +0 -11
  75. data/app/services/spree_stripe/webhook_handlers/setup_intent_succeeded.rb +0 -34
  76. data/app/subscribers/spree_stripe/order_completed_subscriber.rb +0 -14
  77. data/app/views/spree/admin/payment_methods/configuration_guides/_spree_stripe.html.erb +0 -0
  78. data/app/views/spree/admin/payment_methods/custom_form_fields/_spree_stripe.html.erb +0 -47
  79. data/app/views/spree/admin/payment_methods/descriptions/_spree_stripe.html.erb +0 -15
  80. data/app/views/spree/checkout/payment/_spree_stripe.html.erb +0 -66
  81. data/app/views/spree_stripe/_head.html.erb +0 -2
  82. data/app/views/spree_stripe/_quick_checkout.html.erb +0 -34
  83. data/config/i18n-tasks.yml +0 -173
  84. data/config/importmap.rb +0 -8
  85. data/config/initializers/spree.rb +0 -9
  86. data/config/routes.rb +0 -11
  87. data/db/migrate/20250310152812_setup_spree_stripe_models.rb +0 -24
  88. data/lib/spree_stripe/configuration.rb +0 -11
  89. data/lib/spree_stripe/testing_support/factories/after_pay_payment_source_factory.rb +0 -6
  90. data/lib/spree_stripe/testing_support/factories/alipay_payment_source_factory.rb +0 -6
  91. data/lib/spree_stripe/testing_support/factories/ideal_payment_source_factory.rb +0 -6
  92. data/lib/spree_stripe/testing_support/factories/klarna_payment_source_factory.rb +0 -6
  93. data/lib/spree_stripe/testing_support/factories/link_payment_source_factory.rb +0 -6
  94. data/lib/spree_stripe/testing_support/factories/przelewy24_payment_source_factory.rb +0 -6
  95. data/lib/spree_stripe/testing_support/factories/sepa_debit_payment_source_factory.rb +0 -6
  96. data/lib/spree_stripe/testing_support/factories/stripe_payment_session_factory.rb +0 -33
  97. data/lib/spree_stripe/testing_support/factories/webhook_key_factory.rb +0 -23
  98. data/lib/spree_stripe/version.rb +0 -7
  99. data/vendor/javascript/@stripe--stripe-js--dist--pure.esm.js.js +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6ec2a5a3cd5e0a0b8e5160018ad055ff16dd27a2eea3e8404e4906e83b9e0758
4
- data.tar.gz: b51ad1b1e21337ad780f5e2269c1850b0fd1dfb39ac778db187ae0629c933944
3
+ metadata.gz: 6b19b020b414085c822cac14eb0e6eb3b9477e00db8133f5922cf442c597cccf
4
+ data.tar.gz: 7ee74de9899f55a6a6d61a6122c6e6639e5cb9913cd705b7852fe0f11939b6b1
5
5
  SHA512:
6
- metadata.gz: f3f47966c0982f865f7dfa55074f4df6c2f8c90e2c5bdb656012266eb7c46ed690260b47fab15d7fabf0889fbaef8d22fbd153548d23f4316bcc6cdca4353d64
7
- data.tar.gz: 4c9696c085fa47b26f0eb6c6dd06f4b855e0de02dd7ec583efea2c552e8be03c9d9f2952500001357ae04c06e0315a65374846a833d2267a7b6ed89b4b25e325
6
+ metadata.gz: 2c274dfb225afb9fbd665bed8af493eafbec5a24bfeddf16b3e11f0c075743778ce8cfb52de7e9f034e40f9f6d33d7c349237282946ce016595e0f0e16475dda
7
+ data.tar.gz: 58d8dc69605f5ddbf228233f114d36f071f79afbf336bb40b6a2d62c77a15b64e096d31ebc7133273863ddea15a65c8da4b6e9bff9672e1967981c49009d1132
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026-present, Vendo Sp. z o.o., Vendo Connect Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,126 +1,63 @@
1
- <p align="center">
2
- <a href="https://spreecommerce.org">
3
- <img alt="Spree Commerce x Stripe integration" src="https://vendo-production-res.cloudinary.com/image/upload/w_2000/q_auto/v1742930549/docs/github/Spree_Commerce_open-source_eCommerce_Stripe_payments_integration_-_Github_xlrcn8.jpg">
4
- </a>
5
-
6
1
  # Spree Stripe
7
2
 
8
- This is the official Stripe payment gateway extension for [Spree Commerce](https://spreecommerce.org) [open-source eCommerce platform](https://spreecommerce.org/).
9
-
10
- This Stripe integration is bundled in the [Spree Starter](https://github.com/spree/spree_starter/) for your development convenience.
11
-
12
- Or you could follow the [installation instructions](https://spreecommerce.org/docs/integrations/payments/stripe).
13
-
14
- If you like what you see, consider giving this repo a GitHub star :star:
15
-
16
- Thank you for supporting Spree open-source :heart:
17
-
18
- > [!TIP]
19
- > Looking for a [Stripe Connect integration](#looking-for-a-stripe-connect-integration-for-spree) for Spree? It's available with the [Enterprise Edition](https://spreecommerce.org/spree-commerce-version-comparison-community-edition-vs-enterprise-edition/).
20
-
21
- ## Features
22
-
23
- - Support for quick checkout using Apple Pay, Google Pay, Stripe Link
24
- - Support for 3D Secure and other security standards
25
- - Support for off-session payments
26
- - Support for Storefront API integration (see the API docs [here](https://spreecommerce.org/docs/api-reference/storefront/stripe)).
27
- - Accept payments in over 130 currencies
28
- - Accept Credit Cards, Apple Pay, Google Pay, and more
29
- - Accept SEPA Direct Debit payments
30
- - Accept iDEAL payments
31
- - Accept SOFORT payments
32
- - Accept Bancontact payments
33
- - Accept Alipay payments
34
- - Accept WeChat Pay payments
35
- - Accept Afterpay, Klarna, Affirm, and more
36
-
37
- ## What's new?
38
-
39
- ### Installment (BNPL) payments indicator on PDP (Product Detail Page)
40
-
41
- ![Spree_x_Stripe_-_BNPL_Installment_payments_Product_Card_PDP_Product_Detail_Page](https://vendo-production-res.cloudinary.com/image/upload/w_2000/q_auto/v1742983146/docs/github/Spree_x_Stripe_-_BNPL_Installment_payments_Product_Card_PDP_Product_Detail_Page_amhfkw.jpg)
42
-
43
- ### Quick payment options on the cart (Apple Pay, Google Pay, Link)
44
-
45
- ![Apple_Pay_Google_Pay_Link_-_Quick_payment_options_on_the_cart](https://vendo-production-res.cloudinary.com/image/upload/w_2000/q_auto/v1742930027/docs/github/Spree_x_Stripe_-_Apple_Pay_Google_Pay_Link_-_Quick_payment_options_on_the_cart_aw45x9.jpg)
46
-
47
- ### Quick payments bypassing checkout 1st step (Apple Pay, Google Pay, Link)
48
-
49
- ![Apple_Pay_Google_Pay_Link_-_Quick_payments_bypassing_checkout](https://vendo-production-res.cloudinary.com/image/upload/w_2000/q_auto/v1742930027/docs/github/Spree_x_Stripe_-_Apple_Pay_Google_Pay_Link_-_Quick_payments_bypassing_checkout_on_Cart_n6gbh6.jpg)
3
+ Official [Stripe](https://stripe.com) payment gateway for
4
+ [Spree Commerce](https://spreecommerce.org), built on Spree's payment session
5
+ API.
50
6
 
51
- ### Various payment options on the payment step (cards, BNPL, Apple Pay, Google Pay, Link)
52
-
53
- ![Quick payments bypassing checkout 1st step (Apple Pay, Google_Pay, Link)](https://vendo-production-res.cloudinary.com/image/upload/w_2000/q_auto/v1742930027/docs/github/Spree_x_Stripe_-_Apple_Pay_Google_Pay_Link_-_Checkout_payment_step_rxxnr9.jpg)
7
+ Supports card payments plus Klarna, Affirm, Afterpay, Alipay, iDEAL, Link,
8
+ SEPA Direct Debit, Przelewy24 and bank transfers, along with Apple Pay and
9
+ Google Pay quick checkout. Customers can save payment methods for later use
10
+ through setup sessions.
54
11
 
55
12
  ## Installation
56
13
 
57
- 1. Add this extension to your Gemfile with this line:
58
-
59
- ```ruby
60
- bundle add spree_stripe
61
- ```
62
-
63
- 2. Run the install generator
64
-
65
- ```ruby
66
- bundle exec rails g spree_stripe:install
67
- ```
68
-
69
- 3. Restart your server
70
-
71
- If your server was running, restart it so that it can find the assets properly.
72
-
73
- This Stripe integration is also bundled in the [Spree Starter](https://github.com/spree/spree_starter/) for your development convenience.
14
+ Add the gem to your `Gemfile`:
74
15
 
75
- ## Developing
16
+ ```ruby
17
+ gem 'spree_stripe'
18
+ ```
76
19
 
77
- 1. Create a dummy app
20
+ Then run `bundle install`. The gateway registers itself — there is nothing to
21
+ generate and no migrations to run.
78
22
 
79
- ```bash
80
- bundle update
81
- bundle exec rake test_app
82
- ```
23
+ ## Configuration
83
24
 
84
- 2. Add your new code
85
- 3. Run tests
25
+ Create a Stripe payment method in the admin dashboard and enter your
26
+ publishable and secret keys. Everything else is automatic:
86
27
 
87
- ```bash
88
- bundle exec rspec
89
- ```
28
+ - The webhook endpoint is registered with Stripe on save, and its signing
29
+ secret is stored on the payment method.
30
+ - Your storefront domains are registered with Stripe so Apple Pay and Google
31
+ Pay can offer themselves at checkout.
90
32
 
91
- When testing your applications integration with this extension you may use it's factories.
92
- Simply add this require statement to your spec_helper:
33
+ Set `STRIPE_SIGNING_SECRET` to verify webhooks forwarded by the Stripe CLI
34
+ during local development.
93
35
 
94
- ```ruby
95
- require 'spree_stripe/factories'
96
- ```
36
+ ## Upgrading from spree_stripe 1.x
97
37
 
98
- ## Releasing a new version
38
+ Signing secrets used to live in their own tables. Move them onto the payment
39
+ method with:
99
40
 
100
- ```shell
101
- bundle exec gem bump -p -t
102
- bundle exec gem release
41
+ ```bash
42
+ bundle exec rake spree:upgrade:migrate_stripe_webhook_keys
103
43
  ```
104
44
 
105
- For more options please see [gem-release README](https://github.com/svenfuchs/gem-release)
45
+ This runs as part of `rake spree:upgrade`. Until it does, gateways carrying a
46
+ pre-6.0 webhook endpoint will reject incoming webhooks.
106
47
 
107
- ## Contributing
48
+ Applications still using the Rails storefront checkout, the legacy
49
+ `stripe_event` webhook path, or Stripe Tax should complete the payment session
50
+ migration before upgrading — those paths ship only in the 1.x series.
108
51
 
109
- If you'd like to contribute, please take a look at the
110
- [instructions](CONTRIBUTING.md) for installing dependencies and crafting a good
111
- pull request.
52
+ ## Testing
112
53
 
113
- Copyright (c) 2026 [Vendo Connect Inc.](https://getvendo.com), released under [MIT](https://github.com/spree/spree_stripe/blob/main/LICENSE).
54
+ The suite runs offline against recorded VCR cassettes:
114
55
 
115
- ## Looking for a Stripe Connect integration for Spree?
116
-
117
- Spree Commerce [Enterprise Edition](https://spreecommerce.org/spree-commerce-version-comparison-community-edition-vs-enterprise-edition/) comes with a fully automated Stripe Connect integration for a [multi-vendor marketplace use case](https://spreecommerce.org/marketplace-ecommerce/):
118
-
119
- - Automated split payments between marketplace and vendors
120
- - Support for multiple payment methods including cards and digital wallets
121
- - Configurable marketplace fees and commission structures
122
- - Automated payouts to vendors
123
- - Comprehensive transaction reporting
124
- - Built-in fraud prevention tools
56
+ ```bash
57
+ bundle exec rake test_app # once
58
+ bundle exec rspec
59
+ ```
125
60
 
126
- Feel free to [reach out](https://spreecommerce.org/get-started/) to learn more.
61
+ Set `RECORD_VCR=1` with real Stripe test credentials to record new
62
+ interactions. Note that renaming a `:vcr`-tagged example changes its cassette
63
+ path, so it will re-record rather than reuse the old file.
data/Rakefile CHANGED
@@ -1,27 +1,15 @@
1
- require 'bundler'
2
- Bundler::GemHelper.install_tasks
3
-
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/testtask'
4
4
  require 'rspec/core/rake_task'
5
- require 'spree/testing_support/extension_rake'
5
+ require 'spree/testing_support/common_rake'
6
6
 
7
7
  RSpec::Core::RakeTask.new
8
8
 
9
- task :default do
10
- if Dir['spec/dummy'].empty?
11
- Rake::Task[:test_app].invoke
12
- Dir.chdir('../../')
13
- end
14
- Rake::Task[:spec].invoke
15
- end
9
+ task default: :spec
16
10
 
17
- desc 'Generates a dummy app for testing'
11
+ desc "Generates a dummy app for testing"
18
12
  task :test_app do
19
13
  ENV['LIB_NAME'] = 'spree_stripe'
20
- Rake::Task['extension:test_app'].execute(
21
- install_storefront: true,
22
- install_admin: true
23
- )
24
- system({ 'BUNDLE_GEMFILE' => File.expand_path('Gemfile', __dir__) }, 'rails g spree_posts:install')
25
- system({ 'BUNDLE_GEMFILE' => File.expand_path('Gemfile', __dir__) }, 'rails g spree_legacy_api_v2:install')
26
- system({ 'BUNDLE_GEMFILE' => File.expand_path('Gemfile', __dir__) }, 'rails g spree_legacy_product_properties:install')
14
+ Rake::Task['common:test_app'].invoke
27
15
  end
@@ -1,5 +1,5 @@
1
1
  module SpreeStripe
2
2
  class BaseJob < Spree::BaseJob
3
- queue_as SpreeStripe.queue
3
+ queue_as { SpreeStripe.queue }
4
4
  end
5
5
  end
@@ -1,7 +1,22 @@
1
1
  module SpreeStripe
2
2
  class CreateWebhookEndpointJob < BaseJob
3
- def perform(payment_method_id)
4
- Spree::PaymentMethod.find(payment_method_id).create_webhook_endpoint
3
+ # @param connect [Boolean] true registers the connected-accounts endpoint,
4
+ # which a marketplace holds alongside its payment one
5
+ def perform(payment_method_id, connect: false)
6
+ # Both endpoints store their credentials in the one serialised
7
+ # `preferences` column, so concurrent jobs would drop each other's
8
+ # signing secret. Locked on load because `with_lock` refuses a record
9
+ # with unsaved changes, and reading a preference populates its default.
10
+ Spree::PaymentMethod.transaction do
11
+ payment_method = Spree::PaymentMethod.lock.find_by(id: payment_method_id)
12
+ next if payment_method.blank?
13
+
14
+ if connect
15
+ payment_method.create_connect_webhook_endpoint
16
+ else
17
+ payment_method.create_webhook_endpoint
18
+ end
19
+ end
5
20
  end
6
21
  end
7
22
  end
@@ -2,7 +2,6 @@ module Spree
2
2
  class PaymentSessions::Stripe < PaymentSession
3
3
  delegate :api_options, to: :payment_method
4
4
 
5
- # Duck-type interface consumed by the CompleteOrder and CreatePayment services
6
5
  def stripe_id
7
6
  external_id
8
7
  end
@@ -31,23 +30,58 @@ module Spree
31
30
  end
32
31
 
33
32
  def successful?
34
- stripe_payment_intent.status == 'succeeded'
33
+ payment_method.payment_intent_successful?(stripe_payment_intent)
35
34
  end
36
35
 
37
36
  def charge_not_required?
38
37
  payment_method.payment_intent_charge_not_required?(stripe_payment_intent)
39
38
  end
40
39
 
41
- def find_or_create_payment!(metadata = {})
42
- return unless persisted?
43
- return payment if payment.present?
40
+ # Warms everything settlement reads from Stripe — the intent, its charge,
41
+ # and the gateway customer a card source needs — so the webhook path's
42
+ # locked settlement does no Stripe I/O.
43
+ def prepare_for_settlement!
44
+ stripe_charge
45
+ payment_method.fetch_or_create_customer(order: owner) if owner&.customer
46
+ self
47
+ end
48
+
49
+ # Core creates the payment; Stripe only says what instrument it was paid
50
+ # with. The charge and customer are already warmed by
51
+ # +prepare_for_settlement!+, so this does no Stripe I/O inside the lock.
52
+ #
53
+ # @return [Spree::PaymentSource, nil]
54
+ def payment_source_for_settlement
55
+ charge = stripe_charge
56
+
57
+ if charge.present?
58
+ SpreeStripe::CreateSource.new(
59
+ owner: owner,
60
+ stripe_payment_method_details: charge.payment_method_details,
61
+ stripe_payment_method_id: charge.payment_method,
62
+ stripe_billing_details: charge.billing_details,
63
+ gateway: payment_method
64
+ ).call
65
+ elsif charge_not_required?
66
+ # Bank transfers settle with no charge object, so the instrument has
67
+ # to come off the intent instead.
68
+ intent = stripe_payment_intent
69
+
70
+ SpreeStripe::CreateSource.new(
71
+ owner: owner,
72
+ stripe_payment_method_details: intent.payment_method,
73
+ stripe_payment_method_id: intent.payment_method.id,
74
+ stripe_billing_details: nil,
75
+ gateway: payment_method
76
+ ).call
77
+ end
78
+ end
44
79
 
45
- SpreeStripe::CreatePayment.new(
46
- order: order,
47
- payment_intent: self,
48
- gateway: payment_method,
49
- amount: amount
50
- ).call
80
+ # Keeps the charge reference alongside whatever the caller passed.
81
+ def apply_settlement_metadata(payment, metadata)
82
+ super
83
+ charge = stripe_charge
84
+ payment.metadata['stripe_charge_id'] = charge.id if charge.present?
51
85
  end
52
86
  end
53
87
  end