Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Move Stripe into the monorepo as a payment-session gem
Damian Legawiec8bf2ad9f4b7a
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.ymlindex bc732c8ceb..a7f44b9d33 100644--- a/.github/workflows/tests.yml+++ b/.github/workflows/tests.yml@@ -56,7 +56,7 @@ jobs:- name: Install all project dependenciesrun: |- for project in core api emails providers/easypost providers/meilisearch dashboard opentelemetry; do+ for project in core api emails providers/easypost providers/meilisearch providers/stripe dashboard opentelemetry; doecho "--- Installing gems for $project ---"cd spree/$projectbundle config set --local path ${{ github.workspace }}/vendor/bundle@@ -101,7 +101,7 @@ jobs:- name: Install all project dependenciesrun: |- for project in core api emails providers/easypost providers/meilisearch dashboard opentelemetry; do+ for project in core api emails providers/easypost providers/meilisearch providers/stripe dashboard opentelemetry; doecho "--- Installing gems for $project ---"cd spree/$projectbundle config set --local path ${{ github.workspace }}/vendor/bundle@@ -133,7 +133,7 @@ jobs:# The suites are small, so a runner each cost more in queue time than# they saved. This is also the only job with the Meilisearch service,# so spree_meilisearch's integration spec runs here.- - { project: providers, dirs: "providers/easypost providers/meilisearch", shard: 1, total_shards: 1, procs: 2 }+ - { project: providers, dirs: "providers/easypost providers/meilisearch providers/stripe", shard: 1, total_shards: 1, procs: 2 }# dashboard: 1 runner × 2 procs (tiny suite — SPA host)- { project: dashboard, shard: 1, total_shards: 1, procs: 2 }# opentelemetry: 1 runner × 2 procs (tiny suite — optional tracing gem)@@ -293,7 +293,7 @@ jobs:# providers: 1 runner × 2 procs — every provider gem shares a lane.# No Meilisearch service here, so spree_meilisearch's integration spec# skips itself; its unit specs still run against MySQL.- - { project: providers, dirs: "providers/easypost providers/meilisearch", shard: 1, total_shards: 1, procs: 2 }+ - { project: providers, dirs: "providers/easypost providers/meilisearch providers/stripe", shard: 1, total_shards: 1, procs: 2 }# dashboard: 1 runner × 2 procs (tiny suite — SPA host)- { project: dashboard, shard: 1, total_shards: 1, procs: 2 }# opentelemetry: 1 runner × 2 procs (tiny suite — optional tracing gem)diff --git a/docs/plans/6.0-payment-gateways-monorepo.md b/docs/plans/6.0-payment-gateways-monorepo.mdindex a0ffe12671..f42095bcbe 100644--- a/docs/plans/6.0-payment-gateways-monorepo.md+++ b/docs/plans/6.0-payment-gateways-monorepo.md@@ -1,10 +1,10 @@# Payment Gateways in the Monorepo-**Status:** Design Finalized+**Status:** Stripe shipped; Adyen pending**Target:** Spree 6.0**Depends on:** Payment sessions infrastructure (shipped in core), `6.0-multi-vendor-marketplace.md` (Phase 3b consumes the Stripe gem)**Author:** Damian Legawiec-**Last updated:** 2026-07-20+**Last updated:** 2026-08-09## Summary@@ -99,13 +99,20 @@ dedicated gems, not core.```spree/- core/ spree_core- api/ spree_api- emails/ spree_emails (optional, depends on spree)- stripe/ spree_stripe (optional, depends on spree + stripe SDK)- adyen/ spree_adyen (optional, depends on spree + adyen-ruby-api-library)+ core/ spree_core+ api/ spree_api+ emails/ spree_emails (optional, depends on spree)+ providers/+ easypost/ spree_easypost (delivery rates + fulfillment)+ stripe/ spree_stripe (optional, depends on spree_core + stripe SDK)+ adyen/ spree_adyen (optional, depends on spree_core + adyen-ruby-api-library)```+Gateways live under `spree/providers/` alongside the other third-party+integrations, following the shape `spree_easypost` established: gem-name+`LIB_NAME`, a flat `lib/<gem_name>/` tree, and a `spree_core` dependency rather+than the `spree` meta gem.+Each gateway gem is a Rails engine following the existing optional-gem shape:version from `spree/core/lib/spree/core/version.rb`, engine initializerregistering the gateway (`config.spree.payment_methods << SpreeStripe::Gateway`),@@ -117,22 +124,50 @@ migrations installable via `spree:install:migrations`, its own RSpec suiteBoth source repos already ship the v3 path alongside the legacy one; the portkeeps the v3 half.-**Stripe (~37 files, ~1,700 LOC):**+**Scope narrowed at implementation (2026-08-09): payment-session API only.**+The keep-set below is what actually shipped for Stripe — 45 files, ~1,650 LOC+of source and ~2,800 lines of spec. Everything serving the classic+ActiveMerchant-style checkout came out with the storefront (see Drop-set).++The six gateway money verbs — `authorize`, `purchase`, `capture`, `credit`,+`void`, `cancel` — stay, because core's payment lifecycle calls them *after* a+session completes (`Payment#process!` → `gateway_action`). Core's own reference+session gateway, `Spree::Gateway::Bogus`, implements the same six. What left is+the machinery *around* them: creating intents for payments that never had a+session, off-session confirmation, and the storefront's redirect/confirm flow.++**Stripe (45 files, ~1,650 LOC):**- `SpreeStripe::Gateway` + `Gateway::PaymentSessions`,- `Gateway::PaymentSetupSessions`, `Gateway::PaymentIntents` concerns- (intents are Stripe-side API objects wrapped by the session flow — no- intent AR model exists)+ `Gateway::PaymentSetupSessions`, `Gateway::PaymentIntents`,+ `Gateway::Webhooks` concerns (intents are Stripe-side API objects wrapped by+ the session flow — no intent AR model exists)- `Spree::PaymentSessions::Stripe`, `Spree::PaymentSetupSessions::Stripe`(core-table STI subclasses)-- `SpreeStripe::WebhookKey` + `PaymentMethodsWebhookKey` models and their- migration (`spree_stripe_webhook_keys`, join table) — encrypted signing- secrets- Payment sources (Klarna, Affirm, Alipay, iDEAL, Link, SEPA, bank transfer,Przelewy24, AfterPay), services (CreatePayment, CreateSource,CreatePaymentSession, CreateGatewayWebhooks, RegisterDomain,- UpdateCustomer, CompleteOrder), presenters, jobs, the `.stripe` scopes on+ UpdateCustomer), presenters, jobs, the `.stripe` scopes on`PaymentMethod`/`GatewayCustomer`+Apple Pay / Google Pay domain **registration** with Stripe stays — quick+checkout in the session flow depends on it. Serving the domain-association+**file** was a Rails-storefront route and left with the storefront.++### Core adaptations the port required++6.0 core moved under the gem in four ways; every one of them touched the+keep-set:++| 6.0 core change | Effect on the gateway |+|---|---|+| `PaymentMethod belongs_to :store` | `stores.first` / `stores.ids` collapse to `store`; one webhook endpoint per gateway |+| `private_metadata` + `public_metadata` → one `metadata` column | every `store_accessor`, plus the credit-card source params |+| `user` → `customer` (`Spree.customer_class`) | `fetch_or_create_customer`, `CreateSource`, `UpdateCustomer`, wallet-address patching; `Customer#full_name`, not `#name` |+| Cart/Order split | sessions take an `owner` (cart or order); `Carts::Complete` owns completion, so the gateway never completes an order |++Core's fingerprint-dedup backport (`CreditCardDecorator`) is dropped outright —+the column, scope and validation are all in 6.0 core.+**Adyen (~98 files, ~3,400 LOC, of which 60 are one-per-method paymentsources):**- `SpreeAdyen::Gateway` + session/setup-session concerns, HMAC-validating@@ -151,7 +186,9 @@ sources):**controllers, Apple Pay domain-verification file routes- Legacy webhook paths: the `stripe_event` engine mount + subscriber block andits handler services; Adyen's `POST /adyen/webhooks` controller and the- `config.spree_adyen` event-code → handler registry+ `config.spree_adyen` event-code → handler registry. The `stripe_event` gem+ leaves the gemspec entirely; webhooks arrive at core's+ `/api/v3/webhooks/payments/:id` and route through `#parse_webhook_event`.- `SpreeAdyen::PaymentSession` standalone model and its`spree_adyen_payment_sessions` table + migrations (superseded by thecore-table `Spree::PaymentSessions::Adyen`)@@ -159,9 +196,12 @@ sources):**- Assorted AR decorators (order/payment/store/custom_domain/user) tied to thelegacy flows- All `use_legacy_*` preferences and both branches of their conditionals--The Stripe Tax calculator (`SpreeStripe::Calculators::StripeTax`) is ported-only if it fits the `6.0-tax-provider.md` direction (see Open Questions).+- **Classic-checkout payment machinery** (2026-08-09): Stripe Tax+ (`Calculators::StripeTax`, `TaxPresenter`, `CreateTaxTransactionJob`, the+ shipment decorator that fired it), `SpreeStripe::CompleteOrder` ++ `CompleteOrderFromSessionJob` (`Carts::Complete` owns completion),+ `ensure_payment_intent_exists_for_payment` and off-session intents,+ `AttachCustomerToCreditCardJob`### Registration and admin surface@@ -174,10 +214,13 @@ admin" with no conditional-SDK logic. Webhook endpoints are the core v3 ones## Migration Path-1. **Port Stripe** into `spree/providers/stripe` (smaller keep-set; sequenced first- because marketplace Phase 3b builds `PayoutProvider::StripeConnect` on- it). Bring the spec suite + cassettes; wire the gem into monorepo CI and- the release train; add it to the starter/dev-server path mounts.+1. ~~**Port Stripe** into `spree/providers/stripe`~~ — **done 2026-08-09.** Gem+ builds and loads in a full Rails app alongside dashboard/api/emails;+ registers as `api_type: "stripe"` with no registry collision; the suite+ passes offline, single-process and under `parallel_shard`. Wired into both+ CI matrices (PostgreSQL + MySQL) and the bundle-install loops. The starter+ Gemfile change lives in the `spree-starter` repo — `server/` is gitignored+ here, so **that edit still has to be made upstream.**2. **Port Adyen** into `spree/providers/adyen` the same way.3. **Marketplace Phase 3b** adds `Spree::PayoutProvider::StripeConnect`inside `spree/providers/stripe`.@@ -204,19 +247,51 @@ admin" with no conditional-SDK logic. Webhook endpoints are the core v3 onesshape: own `spree/<provider>` gem, existing name kept if published, lockstepversion, exact `spree` pin, SDK as the gem's own dependency.- The `spree` meta gem must not gain a dependency on any gateway gem.+- **An upgrade step contributed by an optional gem must be marked+ `optional: true` in the manifest.** The runner resolves steps through+ `Rake::Task[…]`, which raises when the gem isn't installed; the flag makes it+ skip with a note instead (added for the Stripe webhook-key backfill, and the+ pattern every future gateway gem uses). `invoke` returns whether the step+ ran, so a skipped step doesn't print a completion line.+- Gateway configuration lives in payment-method preferences, never in new+ tables. The Stripe gem ships no migrations at all — a gateway that thinks it+ needs a table should first check whether single-store ownership has removed+ the reason.++## Resolved Questions++- **Webhook-key tables → preferences: YES** (2026-08-09). The two tables held+ per-endpoint signing secrets in a many-to-many join, which only existed+ because a payment method could be shared across stores. With+ `belongs_to :store` there is one endpoint per gateway, so the secret is just+ `preference :webhook_signing_secret, :password` (plus+ `webhook_endpoint_id`). **The gem now ships zero migrations and owns no+ tables.** Note this is not an encryption upgrade: `spree_payment_methods.preferences`+ is a serialized YAML text column with no encryption at rest, whereas+ `WebhookKey` declared `encrypts … deterministic: true`. It is not a *new*+ exposure either — the Stripe secret key, a strictly more powerful+ credential, has always lived in that same column. Encrypting the+ preferences column is a separate, core-wide question.+ Existing secrets move via `spree:upgrade:migrate_stripe_webhook_keys`.+- **Stripe Tax: dropped** (2026-08-09). Out of scope for the port; revisit as+ a `TaxProvider` under `6.0-tax-provider.md`.+- **CI secrets: none needed** (2026-08-09). The suite is fully VCR-backed and+ runs offline. Two hardening changes were made during the port: cassettes now+ default to `record: :none` (opt in with `RECORD_VCR=1`), because+ record-by-default turns any rename of a `:vcr` example into a live API call;+ and the `before_record` filter now scrubs `whsec_` values from **response+ bodies**, which the request-side key filters never saw — two committed+ cassettes had real signing secrets in them and were redacted.## Open Questions-- **Webhook-key tables → encrypted preferences?** Stripe's two custom tables- exist to hold per-endpoint signing secrets; they may collapse into encrypted- preferences on the payment method. Decide during the port — default is to- keep the tables (smaller diff, proven).-- **Stripe Tax calculator**: port into `spree/providers/stripe`, or drop and revisit as- a `TaxProvider` under `6.0-tax-provider.md`? Leaning drop-and-revisit.+- **`spree_paypal_checkout` timing**: same treatment, but in-scope for 6.0 orafter? Not blocking this plan.-- **CI secrets for gateway suites**: the source repos use VCR cassettes- (offline-safe); confirm no live-credential jobs are needed in monorepo CI.+- **Wallet billing-name precedence**: for a signed-in customer, core's+ `Address#set_default_values` fills the name before the Stripe billing name is+ applied, so the wallet name never wins. Defensible (saved name beats+ wallet-supplied), but it is currently incidental rather than chosen.## Referencesdiff --git a/docs/plans/decisions.md b/docs/plans/decisions.mdindex fb3818e3b2..d21ee2be2d 100644--- a/docs/plans/decisions.md+++ b/docs/plans/decisions.md@@ -705,6 +705,54 @@ means splitting first, and split-then-ship inside an `after_transition` callbackis exactly the shape `6.0-service-workflows.md` prohibits. The workflow wraps themachine as a low-level mechanic, mirroring how `Fulfillments::Create` alreadywraps `mark_shipped`.+## 2026-08-09 — Stripe moves into the monorepo as a payment-session-only gem, with no tables++`spree_stripe` ships from `spree/providers/stripe` in the monorepo, per+`6.0-payment-gateways-monorepo.md`. Three things were decided during the port+that the plan had left open or assumed differently.++**Scope is the payment-session API, not the whole gateway.** The plan's+keep-set was "the v3 half of the repo"; the sharper line is the session flow.+The six money verbs (`authorize`/`purchase`/`capture`/`credit`/`void`/`cancel`)+stay, because core's payment lifecycle calls them after a session completes —+`Spree::Gateway::Bogus`, core's own reference session gateway, implements the+same six. What left is the machinery around them: creating intents for payments+that never had a session, off-session confirmation, the storefront+redirect/confirm controllers, `SpreeStripe::CompleteOrder` (`Carts::Complete`+owns completion now), and the `stripe_event` engine with its four webhook+handlers — webhooks arrive at core's v3 endpoint and route through+`#parse_webhook_event`. Stripe Tax is dropped outright and revisits as a+`TaxProvider`.++**The webhook-key tables collapse into preferences, and the gem ends up with no+schema at all.** `spree_stripe_webhook_keys` plus its join table existed to map+signing secrets to payment methods many-to-many — a shape that only made sense+while a payment method could be shared across stores. `belongs_to :store` means+one endpoint per gateway, so the secret is a `:password` preference. Worth+stating plainly, because the plan called this an "encrypted preferences" move+and it is not: `spree_payment_methods.preferences` is serialized YAML with no+encryption at rest, while the dropped model declared+`encrypts … deterministic: true`. It is not a new exposure — the Stripe secret+key, a more powerful credential, has always sat in that same column — but+encrypting the preferences column is now a live core-wide question rather than+something this port solved. `spree:upgrade:migrate_stripe_webhook_keys` carries+existing secrets across.++**Manifest steps from optional gems need an `optional: true` flag.** The+upgrade runner resolves each step with `Rake::Task[…]`, which raises when the+task isn't defined — so an unconditional Stripe step in core's 5.6→6.0 manifest+would break `rake spree:upgrade` for every install without the gem. The flag+makes the runner skip with a note. Every future gateway gem contributing a+backfill uses it.++**Consequences:** gateway configuration lives in payment-method preferences,+never in new tables — a gateway that thinks it needs one should first check+whether single-store ownership removed the reason. Gem-contributed upgrade+steps are always `optional: true`. Two committed VCR cassettes were found+carrying real webhook signing secrets (the sensitive-data filters covered+request keys but not response bodies) and were redacted; cassettes now default+to `record: :none`, since record-by-default turns renaming a `:vcr` example+into a live API call.## 2026-08-09: Metadata consolidated to one column — `public_metadata` dropped, `private_metadata` renameddiff --git a/spree/core/lib/spree/upgrades/5_6_to_6_0/manifest.yml b/spree/core/lib/spree/upgrades/5_6_to_6_0/manifest.ymlindex 0319ac7c1e..62d8b8aa56 100644--- a/spree/core/lib/spree/upgrades/5_6_to_6_0/manifest.yml+++ b/spree/core/lib/spree/upgrades/5_6_to_6_0/manifest.yml@@ -412,3 +412,21 @@ steps:nothing until the index is rebuilt.Safe to run at any time and safe to repeat; it re-enqueues every product.++ - id: migrate_stripe_webhook_keys+ name: "Move Stripe webhook signing secrets onto the gateway"+ task: "spree:upgrade:migrate_stripe_webhook_keys"+ optional: true+ notes: |+ Only runs when spree_stripe is installed; skipped otherwise.++ Signing secrets used to live in spree_stripe_webhook_keys, joined to+ payment methods many-to-many because a payment method could be shared+ across stores. A payment method belongs to exactly one store in 6.0, so+ there is a single endpoint per gateway and the secret moves onto the+ gateway's own preferences.++ Until this runs, a gateway carrying a pre-6.0 endpoint has no signing+ secret and rejects incoming webhooks. Idempotent — gateways that already+ hold a secret are skipped, and the legacy tables stay in place as a+ rollback path until they are dropped in 6.1.diff --git a/spree/core/lib/tasks/upgrade.rake b/spree/core/lib/tasks/upgrade.rakeindex c23bc4445a..5305e4acf3 100644--- a/spree/core/lib/tasks/upgrade.rake+++ b/spree/core/lib/tasks/upgrade.rake@@ -133,10 +133,7 @@ module Spreeprint_manifest_header(manifest)manifest['steps'].each_with_index do |step, i|print_step(step, i + 1, manifest['steps'].size)- unless dry_run- invoke(step)- print_step_complete(step)- end+ print_step_complete(step) if !dry_run && invoke(step)endend@@ -164,10 +161,7 @@ module Spreemanifest, step = matches.firstprint_manifest_header(manifest)print_step(step, 1, 1)- unless dry_run- invoke(step)- print_step_complete(step)- end+ print_step_complete(step) if !dry_run && invoke(step)putsputs dry_run ? ' (dry run — nothing executed)' : " Step '#{step_id}' complete."@@ -195,6 +189,16 @@ module Spreedef invoke(step)task = step.fetch('task')++ # Steps contributed by optional gems (payment gateways, for instance)+ # are absent unless that gem is installed. Skipping keeps the upgrade+ # runnable on installs that never had the gem, while an install that+ # does have it still gets the backfill.+ if step['optional'] && !Rake::Task.task_defined?(task)+ puts " Skipping #{task} — not installed."+ return false+ end+puts " Running #{task}..."# Rake caches invoked tasks in-process; explicit reenable lets a@@ -205,6 +209,7 @@ module Spreerake_task = Rake::Task[task]rake_task.reenablerake_task.invoke+ trueendendenddiff --git a/spree/providers/stripe/.rspec b/spree/providers/stripe/.rspecnew file mode 100644index 0000000000..83e16f8044--- /dev/null+++ b/spree/providers/stripe/.rspec@@ -0,0 +1,2 @@+--color+--require spec_helperdiff --git a/spree/providers/stripe/Gemfile b/spree/providers/stripe/Gemfilenew file mode 100644index 0000000000..304a564012--- /dev/null+++ b/spree/providers/stripe/Gemfile@@ -0,0 +1,5 @@+eval_gemfile('../../common_spree_dependencies.rb')++gem 'spree', path: '../../'++gemspecdiff --git a/spree/providers/stripe/README.md b/spree/providers/stripe/README.mdnew file mode 100644index 0000000000..f6459d8901--- /dev/null+++ b/spree/providers/stripe/README.md@@ -0,0 +1,63 @@+# Spree Stripe++Official [Stripe](https://stripe.com) payment gateway for+[Spree Commerce](https://spreecommerce.org), built on Spree's payment session+API.++Supports card payments plus Klarna, Affirm, Afterpay, Alipay, iDEAL, Link,+SEPA Direct Debit, Przelewy24 and bank transfers, along with Apple Pay and+Google Pay quick checkout. Customers can save payment methods for later use+through setup sessions.++## Installation++Add the gem to your `Gemfile`:++```ruby+gem 'spree_stripe'+```++Then run `bundle install`. The gateway registers itself — there is nothing to+generate and no migrations to run.++## Configuration++Create a Stripe payment method in the admin dashboard and enter your+publishable and secret keys. Everything else is automatic:++- The webhook endpoint is registered with Stripe on save, and its signing+ secret is stored on the payment method.+- Your storefront domains are registered with Stripe so Apple Pay and Google+ Pay can offer themselves at checkout.++Set `STRIPE_SIGNING_SECRET` to verify webhooks forwarded by the Stripe CLI+during local development.++## Upgrading from spree_stripe 1.x++Signing secrets used to live in their own tables. Move them onto the payment+method with:++```bash+bundle exec rake spree:upgrade:migrate_stripe_webhook_keys+```++This runs as part of `rake spree:upgrade`. Until it does, gateways carrying a+pre-6.0 webhook endpoint will reject incoming webhooks.++Applications still using the Rails storefront checkout, the legacy+`stripe_event` webhook path, or Stripe Tax should complete the payment session+migration before upgrading — those paths ship only in the 1.x series.++## Testing++The suite runs offline against recorded VCR cassettes:++```bash+bundle exec rake test_app # once+bundle exec rspec+```++Set `RECORD_VCR=1` with real Stripe test credentials to record new+interactions. Note that renaming a `:vcr`-tagged example changes its cassette+path, so it will re-record rather than reuse the old file.diff --git a/spree/providers/stripe/Rakefile b/spree/providers/stripe/Rakefilenew file mode 100644index 0000000000..3ed1eeeb0b--- /dev/null+++ b/spree/providers/stripe/Rakefile@@ -0,0 +1,15 @@+require 'rubygems'+require 'rake'+require 'rake/testtask'+require 'rspec/core/rake_task'+require 'spree/testing_support/common_rake'++RSpec::Core::RakeTask.new++task default: :spec++desc "Generates a dummy app for testing"+task :test_app do+ ENV['LIB_NAME'] = 'spree_stripe'+ Rake::Task['common:test_app'].invoke+enddiff --git a/spree/providers/stripe/app/jobs/spree_stripe/base_job.rb b/spree/providers/stripe/app/jobs/spree_stripe/base_job.rbnew file mode 100644index 0000000000..e991463e5f--- /dev/null+++ b/spree/providers/stripe/app/jobs/spree_stripe/base_job.rb@@ -0,0 +1,5 @@+module SpreeStripe+ class BaseJob < Spree::BaseJob+ queue_as { SpreeStripe.queue }+ end+enddiff --git a/spree/providers/stripe/app/jobs/spree_stripe/create_webhook_endpoint_job.rb b/spree/providers/stripe/app/jobs/spree_stripe/create_webhook_endpoint_job.rbnew file mode 100644index 0000000000..c222d08015--- /dev/null+++ b/spree/providers/stripe/app/jobs/spree_stripe/create_webhook_endpoint_job.rb@@ -0,0 +1,10 @@+module SpreeStripe+ class CreateWebhookEndpointJob < BaseJob+ def perform(payment_method_id)+ payment_method = Spree::PaymentMethod.find_by(id: payment_method_id)+ return if payment_method.blank?++ payment_method.create_webhook_endpoint+ end+ end+enddiff --git a/spree/providers/stripe/app/jobs/spree_stripe/register_domain_job.rb b/spree/providers/stripe/app/jobs/spree_stripe/register_domain_job.rbnew file mode 100644index 0000000000..2a9a05d9c4--- /dev/null+++ b/spree/providers/stripe/app/jobs/spree_stripe/register_domain_job.rb@@ -0,0 +1,19 @@+module SpreeStripe+ class RegisterDomainJob < BaseJob+ def perform(model_id, klass_type = 'store')+ model = model_class(klass_type)&.find_by(id: model_id)+ return if model.blank?++ RegisterDomain.new.call(model: model)+ end++ private++ def model_class(klass_type)+ case klass_type+ when 'store' then Spree::Store+ when 'custom_domain' then Spree::CustomDomain if defined?(Spree::CustomDomain)+ end+ end+ end+enddiff --git a/spree/providers/stripe/app/jobs/spree_stripe/update_customer_job.rb b/spree/providers/stripe/app/jobs/spree_stripe/update_customer_job.rbnew file mode 100644index 0000000000..02d1e47fef--- /dev/null+++ b/spree/providers/stripe/app/jobs/spree_stripe/update_customer_job.rb@@ -0,0 +1,10 @@+module SpreeStripe+ class UpdateCustomerJob < BaseJob+ def perform(customer_id)+ customer = Spree.customer_class.find_by(id: customer_id)+ return if customer.blank?++ SpreeStripe::UpdateCustomer.new.call(customer: customer)+ end+ end+enddiff --git a/spree/providers/stripe/app/models/spree/payment_sessions/stripe.rb b/spree/providers/stripe/app/models/spree/payment_sessions/stripe.rbnew file mode 100644index 0000000000..d08b9f0aae--- /dev/null+++ b/spree/providers/stripe/app/models/spree/payment_sessions/stripe.rb@@ -0,0 +1,54 @@+module Spree+ class PaymentSessions::Stripe < PaymentSession+ delegate :api_options, to: :payment_method++ def stripe_id+ external_id+ end++ def client_secret+ external_data&.dig('client_secret')+ end++ def ephemeral_key_secret+ external_data&.dig('ephemeral_key_secret')+ end++ def stripe_payment_intent+ @stripe_payment_intent ||= payment_method.retrieve_payment_intent(external_id)+ end++ def stripe_charge+ @stripe_charge ||= begin+ latest_charge = stripe_payment_intent.latest_charge+ latest_charge.present? ? payment_method.retrieve_charge(latest_charge) : nil+ end+ end++ def accepted?+ payment_method.payment_intent_accepted?(stripe_payment_intent)+ end++ def successful?+ payment_method.payment_intent_successful?(stripe_payment_intent)+ end++ def charge_not_required?+ payment_method.payment_intent_charge_not_required?(stripe_payment_intent)+ end++ # Builds the payment together with a Stripe-specific source (card, Klarna,+ # SEPA, …), which core's generic implementation cannot do.+ def find_or_create_payment!(metadata = {})+ return unless persisted?+ return payment if payment.present?++ SpreeStripe::CreatePayment.new(+ owner: owner,+ payment_session: self,+ gateway: payment_method,+ amount: amount+ ).call+ end+ end+enddiff --git a/spree/providers/stripe/app/models/spree/payment_setup_sessions/stripe.rb b/spree/providers/stripe/app/models/spree/payment_setup_sessions/stripe.rbnew file mode 100644index 0000000000..b9d4d4df73--- /dev/null+++ b/spree/providers/stripe/app/models/spree/payment_setup_sessions/stripe.rb@@ -0,0 +1,21 @@+module Spree+ class PaymentSetupSessions::Stripe < PaymentSetupSession+ delegate :api_options, to: :payment_method++ def stripe_id+ external_id+ end++ def client_secret+ external_client_secret+ end++ def stripe_setup_intent+ @stripe_setup_intent ||= payment_method.retrieve_setup_intent(external_id)+ end++ def successful?+ stripe_setup_intent.status == 'succeeded'+ end+ end+enddiff --git a/spree/providers/stripe/app/models/spree_stripe/custom_domain_decorator.rb b/spree/providers/stripe/app/models/spree_stripe/custom_domain_decorator.rbnew file mode 100644index 0000000000..0fd567b638--- /dev/null+++ b/spree/providers/stripe/app/models/spree_stripe/custom_domain_decorator.rb@@ -0,0 +1,18 @@+module SpreeStripe+ module CustomDomainDecorator+ def self.prepended(base)+ base.store_accessor :metadata, :stripe_apple_pay_domain_id+ base.store_accessor :metadata, :stripe_top_level_domain_id++ base.after_create :register_stripe_domain+ end++ def register_stripe_domain+ return if store.stripe_gateway.blank?++ SpreeStripe::RegisterDomainJob.perform_later(id, 'custom_domain')+ end+ end+end++Spree::CustomDomain.prepend(SpreeStripe::CustomDomainDecorator) if defined?(Spree::CustomDomain)diff --git a/spree/providers/stripe/app/models/spree_stripe/customer_decorator.rb b/spree/providers/stripe/app/models/spree_stripe/customer_decorator.rbnew file mode 100644index 0000000000..a726d11f28--- /dev/null+++ b/spree/providers/stripe/app/models/spree_stripe/customer_decorator.rb@@ -0,0 +1,21 @@+module SpreeStripe+ module CustomerDecorator+ def self.prepended(base)+ base.after_update :update_stripe_customer, if: :should_update_stripe_customer?+ end++ def update_stripe_customer+ SpreeStripe::UpdateCustomerJob.perform_later(id)+ end++ private++ def should_update_stripe_customer?+ ship_address_previously_changed? || bill_address_previously_changed? ||+ first_name_previously_changed? || last_name_previously_changed? ||+ email_previously_changed?+ end+ end+end++Spree.customer_class.prepend(SpreeStripe::CustomerDecorator) if Spree.customer_class.present?diff --git a/spree/providers/stripe/app/models/spree_stripe/gateway.rb b/spree/providers/stripe/app/models/spree_stripe/gateway.rbnew file mode 100644index 0000000000..46d01e8a4a--- /dev/null+++ b/spree/providers/stripe/app/models/spree_stripe/gateway.rb@@ -0,0 +1,269 @@+module SpreeStripe+ # Stripe payment gateway built on the payment session API. Payment intents are+ # created and confirmed through sessions; core's payment lifecycle then drives+ # capture, refund and cancellation against the resulting intent.+ class Gateway < ::Spree::Gateway+ include SpreeStripe::Gateway::PaymentIntents+ include SpreeStripe::Gateway::PaymentSessions+ include SpreeStripe::Gateway::PaymentSetupSessions+ include SpreeStripe::Gateway::Webhooks++ preference :publishable_key, :password+ preference :secret_key, :password++ validates :preferred_secret_key, :preferred_publishable_key, presence: true+ validate :validate_secret_key, unless: -> { Rails.env.test? }, if: -> { preferred_secret_key.present? }++ after_commit :register_domains, on: :create++ def provider_class+ self.class+ end++ def default_name+ 'Stripe'+ end++ def method_type+ 'spree_stripe'+ end++ def payment_icon_name+ 'stripe'+ end++ def payment_profiles_supported?+ true+ end++ def gateway_dashboard_payment_url(payment)+ return if payment.transaction_id.blank?++ "https://dashboard.stripe.com/payments/#{payment.transaction_id}"+ end++ # Called by core when a session-created payment moves to pending. The intent+ # is already confirmed client-side in the session flow, so this reads back the+ # intent rather than initiating a charge.+ #+ # @param amount_in_cents [Integer]+ # @param payment_source [Spree::PaymentSource, Spree::CreditCard]+ # @param gateway_options [Hash] Spree::Payment::GatewayOptions#to_hash+ # @return [Spree::PaymentResponse]+ def authorize(amount_in_cents, payment_source, gateway_options = {})+ handle_authorize_or_purchase(amount_in_cents, payment_source, gateway_options)+ end++ # @see #authorize — capture vs authorize is decided by the intent's capture+ # method, so both resolve the same way.+ def purchase(amount_in_cents, payment_source, gateway_options = {})+ handle_authorize_or_purchase(amount_in_cents, payment_source, gateway_options)+ end++ def capture(amount_in_cents, payment_intent_id, _gateway_options = {})+ protect_from_error do+ stripe_payment_intent = retrieve_payment_intent(payment_intent_id)++ response = if payment_intent_requires_capture?(stripe_payment_intent)+ capture_payment_intent(payment_intent_id, amount_in_cents)+ elsif stripe_payment_intent.status == 'succeeded'+ stripe_payment_intent+ else+ raise Spree::Core::GatewayError, "Payment intent status is #{stripe_payment_intent.status}"+ end++ success(response.id, response)+ end+ end++ def credit(amount_in_cents, _source, payment_intent_id, _gateway_options = {})+ protect_from_error do+ response = send_request do |opts|+ Stripe::Refund.create({ amount: amount_in_cents, payment_intent: payment_intent_id }, opts)+ end++ success(response.id, response)+ end+ end++ def void(response_code, _source, _gateway_options)+ return failure('Response code is blank') if response_code.blank?++ protect_from_error do+ response = cancel_payment_intent(response_code)+ success(response.id, response)+ end+ end++ # A completed payment can no longer be voided, so cancellation refunds it+ # instead. Refunds for a fulfillment are skipped — the delivery cost is+ # refunded as a whole elsewhere.+ def cancel(payment_intent_id, payment = nil)+ protect_from_error do+ if payment&.completed?+ amount = payment.credit_allowed+ return success(payment_intent_id, {}) if amount.zero?+ return success(payment_intent_id, {}) if payment.respond_to?(:for_shipment?) && payment.for_shipment?++ refund = payment.refunds.create!(+ amount: amount,+ reason: Spree::RefundReason.order_canceled_reason,+ refunder_id: payment.order.canceler_id+ )++ # Spree::Refund#response holds the `credit` response. The authorization+ # must stay the payment intent id, or the refund id would overwrite it.+ success(payment.response_code, refund.response.params)+ else+ response = cancel_payment_intent(payment_intent_id)+ success(response.id, response)+ end+ end+ end++ # @param customer [Spree::Customer]+ # @return [Spree::GatewayCustomer, nil]+ def fetch_or_create_customer(order: nil, customer: nil)+ customer ||= order&.customer+ return nil if customer.blank?++ gateway_customers.find_by(customer: customer) || create_customer(order: order, customer: customer)+ end++ # @return [Spree::GatewayCustomer]+ def create_customer(order: nil, customer: nil)+ customer ||= order&.customer+ payload = build_customer_payload(order: order, customer: customer)+ response = send_request { |opts| Stripe::Customer.create(payload, opts) }++ gateway_customer = gateway_customers.build(customer: customer, profile_id: response.id)+ gateway_customer.save! if customer.present?+ gateway_customer+ end++ def update_customer(order: nil, customer: nil)+ customer ||= order&.customer+ return if customer.blank?++ gateway_customer = gateway_customers.find_by(customer: customer)+ return if gateway_customer.blank?++ payload = build_customer_payload(order: order, customer: customer)+ send_request { |opts| Stripe::Customer.update(gateway_customer.profile_id, payload, opts) }+ end++ def retrieve_charge(charge_id)+ send_request { |opts| Stripe::Charge.retrieve(charge_id, opts) }+ end++ def create_ephemeral_key(customer_profile_id)+ protect_from_error do+ response = send_request do |opts|+ Stripe::EphemeralKey.create({ customer: customer_profile_id }, opts.merge(stripe_version: Stripe.api_version))+ end++ success(response.secret, response)+ end+ end++ def create_setup_intent(customer_profile_id)+ protect_from_error do+ response = send_request do |opts|+ Stripe::SetupIntent.create({ customer: customer_profile_id, automatic_payment_methods: { enabled: true } }, opts)+ end++ success(response.client_secret, response)+ end+ end++ def create_profile(payment)+ gateway_customer = fetch_or_create_customer(order: payment.order)+ return if payment.source.blank? || gateway_customer.blank?++ payment.source.update(gateway_customer_profile_id: gateway_customer.profile_id)+ end++ def api_options+ { api_key: preferred_secret_key }+ end++ def send_request+ yield(api_options)+ end++ private++ def handle_authorize_or_purchase(amount_in_cents, _payment_source, gateway_options)+ order_number, payment_number = gateway_options[:order_id].to_s.split('-')++ return failure('Order number is invalid') if order_number.blank?+ return failure('Payment number is invalid') if payment_number.blank?++ order = store.orders.find_by(number: order_number)+ return failure('Order not found') if order.blank?++ payment = order.payments.find_by(number: payment_number)+ return failure('Payment not found') if payment.blank?+ return failure('Payment is missing a payment intent') if payment.response_code.blank?++ protect_from_error do+ stripe_payment_intent = retrieve_payment_intent(payment.response_code)++ response = if payment_intent_accepted?(stripe_payment_intent)+ # already confirmed via the session flow+ stripe_payment_intent+ else+ confirm_payment_intent(stripe_payment_intent.id)+ end++ success(response.id, response)+ end+ end++ # Apple Pay and Google Pay only appear on domains registered with Stripe.+ def register_domains+ return if store.blank?++ SpreeStripe::RegisterDomainJob.perform_later(store.id, 'store')++ return unless defined?(Spree::CustomDomain)++ store.custom_domains.each do |custom_domain|+ SpreeStripe::RegisterDomainJob.perform_later(custom_domain.id, 'custom_domain')+ end+ end++ def validate_secret_key+ Stripe::Refund.list({ limit: 0 }, api_options)+ rescue Stripe::AuthenticationError+ errors.add(:base, 'Secret key is invalid')+ rescue Stripe::PermissionError => e+ errors.add(:base, 'You have provided your publishable key instead of your secret key') if e.error&.code == 'secret_key_required'+ rescue Stripe::StripeError+ errors.add(:base, 'Something went wrong with Stripe. Try again later.')+ end++ def build_customer_payload(order: nil, customer: nil)+ customer ||= order&.customer+ address = order&.bill_address || customer&.bill_address+ name = order&.name || customer&.full_name+ email = order&.email || customer&.email++ SpreeStripe::CustomerPresenter.new(name: name, email: email, address: address).call+ end++ def success(authorization, full_response)+ Spree::PaymentResponse.new(true, nil, full_response.as_json, authorization: authorization)+ end++ def failure(error = nil)+ Spree::PaymentResponse.new(false, error)+ end++ def protect_from_error+ yield+ rescue Stripe::StripeError => e+ raise Spree::Core::GatewayError, e.message+ end+ end+enddiff --git a/spree/providers/stripe/app/models/spree_stripe/gateway/payment_intents.rb b/spree/providers/stripe/app/models/spree_stripe/gateway/payment_intents.rbnew file mode 100644index 0000000000..8414982d67--- /dev/null+++ b/spree/providers/stripe/app/models/spree_stripe/gateway/payment_intents.rb@@ -0,0 +1,117 @@+module SpreeStripe+ class Gateway < ::Spree::Gateway+ # Stripe payment intents are API objects rather than Spree records — the+ # payment session owns their lifecycle and stores the intent id as its+ # external id.+ module PaymentIntents+ extend ActiveSupport::Concern++ # Banks confirm these asynchronously, so `processing` is as good as accepted.+ DELAYED_NOTIFICATION_PAYMENT_METHOD_TYPES = %w[sepa_debit us_bank_account].freeze+ # Funds arrive out of band, leaving the intent in `requires_action`.+ BANK_PAYMENT_METHOD_TYPES = %w[customer_balance us_bank_account].freeze+ MANUAL_CAPTURE_METHOD = 'manual'.freeze++ def payment_intent_accepted?(payment_intent)+ payment_intent.status.in?(payment_intent_accepted_statuses(payment_intent))+ end++ def payment_intent_successful?(payment_intent)+ payment_intent.status == 'succeeded'+ end++ def payment_intent_requires_capture?(payment_intent)+ payment_intent.status == 'requires_capture'+ end++ def payment_intent_delayed_notification?(payment_intent)+ payment_intent_type_in?(payment_intent, DELAYED_NOTIFICATION_PAYMENT_METHOD_TYPES)+ end++ # Bank transfers settle without a charge object, so the source has to be+ # built from the intent instead.+ def payment_intent_charge_not_required?(payment_intent)+ payment_intent_type_in?(payment_intent, BANK_PAYMENT_METHOD_TYPES)+ end++ def payment_intent_manual_capture?(payment_intent)+ payment_intent.respond_to?(:capture_method) && payment_intent.capture_method == MANUAL_CAPTURE_METHOD+ end++ # @param amount_in_cents [Integer]+ # @param order [Spree::Order, Spree::Cart]+ # @param payment_method_id [String, nil] Stripe payment method id, eg. pm_123+ # @param customer_profile_id [String, nil] Stripe customer id, eg. cus_123+ # @return [Spree::PaymentResponse]+ def create_payment_intent(amount_in_cents, order, payment_method_id: nil, customer_profile_id: nil)+ payload = SpreeStripe::PaymentIntentPresenter.new(+ amount: amount_in_cents,+ order: order,+ customer: customer_profile_id,+ payment_method_id: payment_method_id,+ capture_method: stripe_capture_method+ ).call++ protect_from_error do+ response = send_request { |opts| Stripe::PaymentIntent.create(payload, opts) }++ success(response.id, response)+ end+ end++ # @param payment_intent_id [String] eg. pi_123+ # @return [Spree::PaymentResponse]+ def update_payment_intent(payment_intent_id, amount_in_cents, order, payment_method_id = nil)+ protect_from_error do+ payload = SpreeStripe::PaymentIntentPresenter.new(+ amount: amount_in_cents,+ order: order,+ customer: fetch_or_create_customer(order: order)&.profile_id,+ payment_method_id: payment_method_id+ ).call.slice(:amount, :currency, :payment_method, :shipping, :customer)++ response = send_request { |opts| Stripe::PaymentIntent.update(payment_intent_id, payload, opts) }++ success(response.id, response)+ end+ end++ def retrieve_payment_intent(payment_intent_id)+ send_request { |opts| Stripe::PaymentIntent.retrieve({ id: payment_intent_id, expand: ['payment_method'] }, opts) }+ end++ def confirm_payment_intent(payment_intent_id)+ send_request { |opts| Stripe::PaymentIntent.confirm(payment_intent_id, {}, opts) }+ end++ def capture_payment_intent(payment_intent_id, amount_in_cents)+ send_request { |opts| Stripe::PaymentIntent.capture(payment_intent_id, { amount_to_capture: amount_in_cents }, opts) }+ end++ def cancel_payment_intent(payment_intent_id)+ send_request { |opts| Stripe::PaymentIntent.cancel(payment_intent_id, {}, opts) }+ end++ private++ def payment_intent_type_in?(payment_intent, types)+ payment_method = payment_intent.payment_method+ return false unless payment_method.respond_to?(:type)++ payment_method.type.in?(types)+ end++ def stripe_capture_method+ auto_capture? ? nil : MANUAL_CAPTURE_METHOD+ end++ def payment_intent_accepted_statuses(payment_intent)+ statuses = %w[succeeded]+ statuses << 'requires_capture' if payment_intent_manual_capture?(payment_intent)+ statuses << 'processing' if payment_intent_delayed_notification?(payment_intent)+ statuses << 'requires_action' if payment_intent_charge_not_required?(payment_intent)+ statuses+ end+ end+ end+enddiff --git a/spree/providers/stripe/app/models/spree_stripe/gateway/payment_sessions.rb b/spree/providers/stripe/app/models/spree_stripe/gateway/payment_sessions.rbnew file mode 100644index 0000000000..91f301c000--- /dev/null+++ b/spree/providers/stripe/app/models/spree_stripe/gateway/payment_sessions.rb@@ -0,0 +1,175 @@+module SpreeStripe+ class Gateway < ::Spree::Gateway+ module PaymentSessions+ extend ActiveSupport::Concern++ def session_required?+ true+ end++ def payment_session_class+ Spree::PaymentSessions::Stripe+ end++ # @param order [Spree::Cart, Spree::Order]+ # @return [Spree::PaymentSessions::Stripe]+ def create_payment_session(order:, amount: nil, external_data: {})+ total = amount.presence || order.total_minus_store_credits+ amount_in_cents = Spree::Money.new(total, currency: order.currency).cents++ raise Spree::Core::GatewayError, I18n.t('spree.stripe.payment_session_errors.zero_amount') if amount_in_cents.zero?++ gateway_customer = fetch_or_create_customer(order: order)+ stripe_payment_method_id = external_data[:stripe_payment_method_id] || external_data['stripe_payment_method_id']++ response = create_payment_intent(+ amount_in_cents, order,+ payment_method_id: stripe_payment_method_id,+ customer_profile_id: gateway_customer&.profile_id+ )++ ephemeral_key_response = create_ephemeral_key(gateway_customer.profile_id) if gateway_customer.present?++ payment_session_class.create!(+ owner: order,+ payment_method: self,+ amount: total,+ currency: order.currency,+ status: 'pending',+ external_id: response.authorization,+ customer: order.customer,+ customer_external_id: gateway_customer&.profile_id,+ external_data: {+ 'client_secret' => response.params['client_secret'],+ 'ephemeral_key_secret' => ephemeral_key_response&.params&.dig('secret'),+ 'stripe_payment_method_id' => stripe_payment_method_id+ }.compact+ )+ end++ def update_payment_session(payment_session:, amount: nil, external_data: {})+ attrs = {}+ amount_in_cents = nil++ if amount.present?+ attrs[:amount] = amount+ amount_in_cents = Spree::Money.new(amount, currency: payment_session.currency).cents+ end++ stripe_payment_method_id = external_data[:stripe_payment_method_id] || external_data['stripe_payment_method_id']++ update_payment_intent(+ payment_session.external_id,+ amount_in_cents || payment_session.amount_in_cents,+ payment_session.owner,+ stripe_payment_method_id+ )++ attrs[:external_data] = (payment_session.external_data || {}).merge(external_data.stringify_keys) if external_data.present?++ payment_session.update!(attrs) if attrs.any?+ end++ # Verifies the intent with Stripe, creates the Payment record and patches+ # wallet address data.+ #+ # Does NOT complete the order — Carts::Complete owns that.+ def complete_payment_session(payment_session:, params: {})+ stripe_payment_intent = retrieve_payment_intent(payment_session.external_id)++ unless payment_intent_accepted?(stripe_payment_intent)+ payment_session.fail if payment_session.can_fail?+ return payment_session+ end++ payment_session.process if payment_session.can_process?++ charge = payment_session.stripe_charge+ patch_wallet_address(payment_session.owner, charge) if charge.present?++ payment_session.find_or_create_payment!++ payment = payment_session.payment+ if payment.present? && !payment.completed?+ # The `else` covers requires_capture (manual capture), processing+ # (delayed-notification banks) and requires_action (bank transfer+ # awaiting funds) — all authorization-only states.+ if payment_intent_successful?(stripe_payment_intent)+ payment.process!+ else+ payment.authorize!+ end+ end++ payment_session.complete unless payment_session.completed?+ payment_session+ end++ private++ # Quick checkout (Apple Pay / Google Pay) confirms payment before the+ # storefront has a billing address, so it arrives on the Stripe charge.+ #+ # @param owner [Spree::Cart, Spree::Order]+ def patch_wallet_address(owner, charge)+ return if charge.blank?++ billing_details = charge.billing_details+ address = billing_details.address++ owner.email ||= billing_details.email+ owner.save! if owner.email_changed?++ return if owner.bill_address.present? && owner.bill_address.valid?++ country_iso = address.country+ country = (country_iso.present? && Spree::Country.by_iso(country_iso)) ||+ owner.store.default_market&.default_country ||+ Spree::Country.by_iso('US')++ owner.bill_address ||= Spree::Address.new(country: country, customer: owner.customer)+ owner.bill_address.quick_checkout = true++ # Google Pay sometimes omits the name entirely.+ first_name = billing_details.name&.split(' ')&.first || owner.ship_address&.first_name || owner.customer&.first_name+ last_name = billing_details.name&.split(' ')&.last || owner.ship_address&.last_name || owner.customer&.last_name++ owner.bill_address.first_name ||= first_name+ owner.bill_address.last_name ||= last_name+ owner.bill_address.phone ||= billing_details.phone+ owner.bill_address.address1 ||= address.line1+ owner.bill_address.address2 ||= address.line2+ owner.bill_address.city ||= address.city+ owner.bill_address.zipcode ||= address.postal_code++ state_name = address.state+ if country.states_required?+ owner.bill_address.state = country.states.find_all_by_name_or_abbr(state_name)&.first+ else+ owner.bill_address.state_name = state_name+ end+ owner.bill_address.state_name ||= state_name++ if owner.bill_address.invalid?+ return if owner.ship_address.blank?++ owner.bill_address = owner.ship_address+ end++ owner.bill_address.save! if owner.bill_address&.changed?+ owner.save!++ copy_bill_info_to_customer(owner) if owner.customer.present?+ end++ def copy_bill_info_to_customer(owner)+ customer = owner.customer+ customer.first_name ||= owner.bill_address.first_name+ customer.last_name ||= owner.bill_address.last_name+ customer.phone ||= owner.bill_address.phone+ customer.bill_address_id ||= owner.bill_address.id+ customer.save! if customer.changed?+ end+ end+ end+enddiff --git a/spree/providers/stripe/app/models/spree_stripe/gateway/payment_setup_sessions.rb b/spree/providers/stripe/app/models/spree_stripe/gateway/payment_setup_sessions.rbnew file mode 100644index 0000000000..caedb27ee8--- /dev/null+++ b/spree/providers/stripe/app/models/spree_stripe/gateway/payment_setup_sessions.rb@@ -0,0 +1,65 @@+module SpreeStripe+ class Gateway < ::Spree::Gateway+ # Saving a payment method for later use, without taking a payment.+ module PaymentSetupSessions+ extend ActiveSupport::Concern++ def setup_session_supported?+ true+ end++ def payment_setup_session_class+ Spree::PaymentSetupSessions::Stripe+ end++ # @param customer [Spree::Customer]+ # @return [Spree::PaymentSetupSessions::Stripe]+ def create_payment_setup_session(customer:, external_data: {})+ gateway_customer = fetch_or_create_customer(customer: customer)++ setup_intent_response = create_setup_intent(gateway_customer.profile_id)+ ephemeral_key_response = create_ephemeral_key(gateway_customer.profile_id)++ payment_setup_session_class.create!(+ customer: customer,+ payment_method: self,+ status: 'pending',+ external_id: setup_intent_response.params['id'],+ external_client_secret: setup_intent_response.authorization,+ external_data: external_data.to_h.stringify_keys.merge(+ 'customer_id' => gateway_customer.profile_id,+ 'ephemeral_key_secret' => ephemeral_key_response&.params&.dig('secret')+ ).compact+ )+ end++ def complete_payment_setup_session(setup_session:, params: {})+ stripe_setup_intent = retrieve_setup_intent(setup_session.external_id)++ if stripe_setup_intent.status == 'succeeded'+ setup_session.process if setup_session.can_process?++ stripe_payment_method = stripe_setup_intent.payment_method++ setup_session.payment_source = SpreeStripe::CreateSource.new(+ stripe_payment_method_details: stripe_payment_method,+ stripe_payment_method_id: stripe_payment_method.id,+ stripe_billing_details: stripe_payment_method.billing_details,+ gateway: self,+ customer: setup_session.customer+ ).call++ setup_session.complete unless setup_session.completed?+ else+ setup_session.fail if setup_session.can_fail?+ end++ setup_session+ end++ def retrieve_setup_intent(setup_intent_id)+ send_request { |opts| Stripe::SetupIntent.retrieve({ id: setup_intent_id, expand: ['payment_method'] }, opts) }+ end+ end+ end+enddiff --git a/spree/providers/stripe/app/models/spree_stripe/gateway/webhooks.rb b/spree/providers/stripe/app/models/spree_stripe/gateway/webhooks.rbnew file mode 100644index 0000000000..3564647993--- /dev/null+++ b/spree/providers/stripe/app/models/spree_stripe/gateway/webhooks.rb@@ -0,0 +1,86 @@+module SpreeStripe+ class Gateway < ::Spree::Gateway+ # Webhook signature verification and endpoint registration.+ #+ # Signing secrets live in the gateway's own preferences. Before 6.0 they were+ # rows in spree_stripe_webhook_keys joined to payment methods many-to-many;+ # with a payment method now owned by exactly one store there is a single+ # endpoint per gateway, so a preference carries the same data. Existing+ # secrets are carried over by `spree:upgrade:migrate_stripe_webhook_keys`.+ module Webhooks+ extend ActiveSupport::Concern++ SUPPORTED_EVENTS = %w[+ payment_intent.amount_capturable_updated+ payment_intent.payment_failed+ payment_intent.succeeded+ setup_intent.succeeded+ ].freeze++ WEBHOOK_EVENT_ACTIONS = {+ 'payment_intent.succeeded' => :captured,+ 'payment_intent.amount_capturable_updated' => :authorized,+ 'payment_intent.payment_failed' => :failed+ }.freeze++ included do+ preference :webhook_signing_secret, :password+ preference :webhook_endpoint_id, :string++ after_commit :create_webhook_endpoint_async, on: %i[create update]+ end++ # @param raw_body [String]+ # @param headers [Hash]+ # @return [Hash, nil] nil for events this gateway does not act on+ # @raise [Spree::PaymentMethod::WebhookSignatureError]+ def parse_webhook_event(raw_body, headers)+ event = verify_webhook_signature(raw_body, headers)++ action = WEBHOOK_EVENT_ACTIONS[event.type]+ return nil unless action++ payment_session = Spree::PaymentSessions::Stripe.find_by(+ payment_method: self,+ external_id: event.data.object[:id]+ )+ return nil unless payment_session++ { action: action, payment_session: payment_session, metadata: { stripe_event: event } }+ end++ def create_webhook_endpoint+ SpreeStripe::CreateGatewayWebhooks.new.call(payment_method: self)+ end++ private++ def verify_webhook_signature(raw_body, headers)+ signature = headers['HTTP_STRIPE_SIGNATURE']++ webhook_signing_secrets.each do |secret|+ return Stripe::Webhook.construct_event(raw_body, signature, secret)+ rescue Stripe::SignatureVerificationError+ next+ end++ raise Spree::PaymentMethod::WebhookSignatureError, 'Invalid webhook signature'+ end++ # The ENV fallback supports local development against the Stripe CLI, whose+ # secret is not the one registered for this endpoint.+ def webhook_signing_secrets+ [preferred_webhook_signing_secret, ENV['STRIPE_SIGNING_SECRET']].select(&:present?)+ end++ # Also the loop guard: registration writes the secret back through+ # `update!`, which re-runs this callback. A stored secret means the+ # endpoint is already registered, so the second pass stops here.+ def create_webhook_endpoint_async+ return if preferred_webhook_signing_secret.present?++ SpreeStripe::CreateWebhookEndpointJob.perform_later(id)+ end+ end+ end+enddiff --git a/spree/providers/stripe/app/models/spree_stripe/gateway_customer_decorator.rb b/spree/providers/stripe/app/models/spree_stripe/gateway_customer_decorator.rbnew file mode 100644index 0000000000..5b83295e92--- /dev/null+++ b/spree/providers/stripe/app/models/spree_stripe/gateway_customer_decorator.rb@@ -0,0 +1,11 @@+module SpreeStripe+ module GatewayCustomerDecorator+ def self.prepended(base)+ base.scope :stripe, lambda {+ joins(:payment_method).where(Spree::PaymentMethod.table_name => { type: SpreeStripe::Gateway.to_s })+ }+ end+ end+end++Spree::GatewayCustomer.prepend(SpreeStripe::GatewayCustomerDecorator)diff --git a/spree/providers/stripe/app/models/spree_stripe/payment_decorator.rb b/spree/providers/stripe/app/models/spree_stripe/payment_decorator.rbnew file mode 100644index 0000000000..1bdf637cbf--- /dev/null+++ b/spree/providers/stripe/app/models/spree_stripe/payment_decorator.rb@@ -0,0 +1,33 @@+module SpreeStripe+ module PaymentDecorator+ # Stripe reports address/CVC checks as pass/fail/unchecked; Spree stores the+ # equivalent AVS and CVV response codes.+ AVS_CODES = {+ 'pass' => { 'pass' => 'Y', 'fail' => 'A', 'unchecked' => 'B' },+ 'fail' => { 'pass' => 'Z', 'fail' => 'N' },+ 'unchecked' => { 'pass' => 'P', 'unchecked' => 'I' }+ }.freeze unless defined?(AVS_CODES)++ CVV_CODES = { 'pass' => 'M', 'fail' => 'N', 'unchecked' => 'P' }.freeze unless defined?(CVV_CODES)++ def self.prepended(base)+ base.store_accessor :metadata, :stripe_charge_id++ base.before_save :set_cvv_and_avs_response_from_metadata, if: :credit_card_source?+ end++ def set_cvv_and_avs_response_from_metadata+ checks = source.metadata[:checks]+ return if checks.blank?++ self.avs_response ||= AVS_CODES.dig(checks[:address_line1_check], checks[:address_postal_code_check])+ self.cvv_response_code ||= CVV_CODES[checks[:cvc_check]]+ end++ def credit_card_source?+ source.is_a?(Spree::CreditCard)+ end+ end+end++Spree::Payment.prepend(SpreeStripe::PaymentDecorator)diff --git a/spree/providers/stripe/app/models/spree_stripe/payment_method_decorator.rb b/spree/providers/stripe/app/models/spree_stripe/payment_method_decorator.rbnew file mode 100644index 0000000000..4fd0dab4b0--- /dev/null+++ b/spree/providers/stripe/app/models/spree_stripe/payment_method_decorator.rb@@ -0,0 +1,15 @@+module SpreeStripe+ module PaymentMethodDecorator+ STRIPE_TYPE = 'SpreeStripe::Gateway'.freeze unless defined?(STRIPE_TYPE)++ def self.prepended(base)+ base.scope :stripe, -> { where(type: STRIPE_TYPE) }+ end++ def stripe?+ type == STRIPE_TYPE+ end+ end+end++Spree::PaymentMethod.prepend(SpreeStripe::PaymentMethodDecorator)diff --git a/spree/providers/stripe/app/models/spree_stripe/payment_sources/affirm.rb b/spree/providers/stripe/app/models/spree_stripe/payment_sources/affirm.rbnew file mode 100644index 0000000000..e86cabdea5--- /dev/null+++ b/spree/providers/stripe/app/models/spree_stripe/payment_sources/affirm.rb@@ -0,0 +1,9 @@+module SpreeStripe+ module PaymentSources+ class Affirm < ::Spree::PaymentSource+ def actions+ %w[credit]+ end+ end+ end+enddiff --git a/spree/providers/stripe/app/models/spree_stripe/payment_sources/after_pay.rb b/spree/providers/stripe/app/models/spree_stripe/payment_sources/after_pay.rbnew file mode 100644index 0000000000..4cb5b345a3--- /dev/null+++ b/spree/providers/stripe/app/models/spree_stripe/payment_sources/after_pay.rb@@ -0,0 +1,13 @@+module SpreeStripe+ module PaymentSources+ class AfterPay < ::Spree::PaymentSource+ def actions+ %w[credit]+ end++ def self.display_name+ 'Afterpay'+ end+ end+ end+enddiff --git a/spree/providers/stripe/app/models/spree_stripe/payment_sources/alipay.rb b/spree/providers/stripe/app/models/spree_stripe/payment_sources/alipay.rbnew file mode 100644index 0000000000..6314ac0eb1--- /dev/null+++ b/spree/providers/stripe/app/models/spree_stripe/payment_sources/alipay.rb@@ -0,0 +1,9 @@+module SpreeStripe+ module PaymentSources+ class Alipay < ::Spree::PaymentSource+ def actions+ %w[credit]+ end+ end+ end+enddiff --git a/spree/providers/stripe/app/models/spree_stripe/payment_sources/bank_transfer.rb b/spree/providers/stripe/app/models/spree_stripe/payment_sources/bank_transfer.rbnew file mode 100644index 0000000000..fddf9f4d7f--- /dev/null+++ b/spree/providers/stripe/app/models/spree_stripe/payment_sources/bank_transfer.rb@@ -0,0 +1,17 @@+module SpreeStripe+ module PaymentSources+ class BankTransfer < ::Spree::PaymentSource+ def actions+ %w[credit]+ end++ def self.display_name+ Spree.t(:bank_transfer)+ end++ def name+ Spree.t(:bank_transfer)+ end+ end+ end+enddiff --git a/spree/providers/stripe/app/models/spree_stripe/payment_sources/ideal.rb b/spree/providers/stripe/app/models/spree_stripe/payment_sources/ideal.rbnew file mode 100644index 0000000000..04cd1a23b2--- /dev/null+++ b/spree/providers/stripe/app/models/spree_stripe/payment_sources/ideal.rb@@ -0,0 +1,15 @@+module SpreeStripe+ module PaymentSources+ class Ideal < ::Spree::PaymentSource+ store_accessor :metadata, :bank, :last4++ def actions+ %w[credit]+ end++ def self.display_name+ 'iDEAL'+ end+ end+ end+enddiff --git a/spree/providers/stripe/app/models/spree_stripe/payment_sources/klarna.rb b/spree/providers/stripe/app/models/spree_stripe/payment_sources/klarna.rbnew file mode 100644index 0000000000..c345832a56--- /dev/null+++ b/spree/providers/stripe/app/models/spree_stripe/payment_sources/klarna.rb@@ -0,0 +1,9 @@+module SpreeStripe+ module PaymentSources+ class Klarna < ::Spree::PaymentSource+ def actions+ %w[credit]+ end+ end+ end+enddiff --git a/spree/providers/stripe/app/models/spree_stripe/payment_sources/link.rb b/spree/providers/stripe/app/models/spree_stripe/payment_sources/link.rbnew file mode 100644index 0000000000..5883847e45--- /dev/null+++ b/spree/providers/stripe/app/models/spree_stripe/payment_sources/link.rb@@ -0,0 +1,13 @@+module SpreeStripe+ module PaymentSources+ class Link < ::Spree::PaymentSource+ def actions+ %w[credit]+ end++ def self.display_name+ 'Link'+ end+ end+ end+enddiff --git a/spree/providers/stripe/app/models/spree_stripe/payment_sources/przelewy24.rb b/spree/providers/stripe/app/models/spree_stripe/payment_sources/przelewy24.rbnew file mode 100644index 0000000000..4d0d6f78c5--- /dev/null+++ b/spree/providers/stripe/app/models/spree_stripe/payment_sources/przelewy24.rb@@ -0,0 +1,11 @@+module SpreeStripe+ module PaymentSources+ class Przelewy24 < ::Spree::PaymentSource+ store_accessor :metadata, :bank++ def actions+ %w[credit]+ end+ end+ end+enddiff --git a/spree/providers/stripe/app/models/spree_stripe/payment_sources/sepa_debit.rb b/spree/providers/stripe/app/models/spree_stripe/payment_sources/sepa_debit.rbnew file mode 100644index 0000000000..85ab6bd6d2--- /dev/null+++ b/spree/providers/stripe/app/models/spree_stripe/payment_sources/sepa_debit.rb@@ -0,0 +1,17 @@+module SpreeStripe+ module PaymentSources+ class SepaDebit < ::Spree::PaymentSource+ def actions+ %w[credit]+ end++ def self.display_name+ 'SEPA Debit'+ end++ def name+ 'SEPA Debit'+ end+ end+ end+enddiff --git a/spree/providers/stripe/app/models/spree_stripe/store_decorator.rb b/spree/providers/stripe/app/models/spree_stripe/store_decorator.rbnew file mode 100644index 0000000000..1474461d98--- /dev/null+++ b/spree/providers/stripe/app/models/spree_stripe/store_decorator.rb@@ -0,0 +1,25 @@+module SpreeStripe+ module StoreDecorator+ def self.prepended(base)+ base.store_accessor :metadata, :stripe_apple_pay_domain_id+ base.store_accessor :metadata, :stripe_top_level_domain_id++ base.after_commit :register_stripe_domain, on: :update, if: -> { code_previously_changed? }+ end++ # @return [SpreeStripe::Gateway, nil]+ def stripe_gateway+ @stripe_gateway ||= payment_methods.stripe.active.last+ end++ private++ def register_stripe_domain+ return if stripe_gateway.blank?++ SpreeStripe::RegisterDomainJob.perform_later(id)+ end+ end+end++Spree::Store.prepend(SpreeStripe::StoreDecorator)diff --git a/spree/providers/stripe/app/presenters/spree_stripe/customer_presenter.rb b/spree/providers/stripe/app/presenters/spree_stripe/customer_presenter.rbnew file mode 100644index 0000000000..a0879d76db--- /dev/null+++ b/spree/providers/stripe/app/presenters/spree_stripe/customer_presenter.rb@@ -0,0 +1,33 @@+module SpreeStripe+ class CustomerPresenter+ def initialize(address: nil, email: nil, name: nil)+ @email = email+ @name = name+ @address = address+ end++ # @return [Hash]+ def call+ hash = {}+ hash[:address] = address_payload if address.present?+ hash[:email] = email if email.present?+ hash[:name] = name if name.present?+ hash+ end++ private++ attr_reader :email, :name, :address++ def address_payload+ {+ city: address.city,+ line1: address.address1,+ line2: address.address2,+ postal_code: address.zipcode,+ country: address.country_name,+ state: address.state_name_text+ }+ end+ end+enddiff --git a/spree/providers/stripe/app/presenters/spree_stripe/payment_intent_presenter.rb b/spree/providers/stripe/app/presenters/spree_stripe/payment_intent_presenter.rbnew file mode 100644index 0000000000..bbe333b4e7--- /dev/null+++ b/spree/providers/stripe/app/presenters/spree_stripe/payment_intent_presenter.rb@@ -0,0 +1,87 @@+module SpreeStripe+ class PaymentIntentPresenter+ SETUP_FUTURE_USAGE = 'off_session'.freeze++ # @param order [Spree::Cart, Spree::Order]+ # @param customer [String, nil] Stripe customer id, eg. cus_123+ # @param payment_method_id [String, nil] Stripe payment method id, eg. pm_123+ def initialize(amount:, order:, customer: nil, payment_method_id: nil, capture_method: nil)+ @amount = amount+ @order = order+ @customer = customer+ @ship_address = order.ship_address+ @payment_method_id = payment_method_id+ @capture_method = capture_method+ end++ # @return [Hash]+ def call+ payload = payment_method_id.present? ? saved_payment_method_payload : new_payment_method_payload+ payload = payload.deep_merge(basic_payload)+ payload = payload.merge(capture_method: Gateway::PaymentIntents::MANUAL_CAPTURE_METHOD) if manual_capture?++ return payload unless ship_address++ # Stripe requires address1, which Spree does not always demand.+ if ship_address.invalid? || ship_address.address1.blank?+ ship_address.errors.clear+ return payload+ end++ payload.merge(ship_address_payload)+ end++ def ship_address_payload+ {+ shipping: {+ address: {+ city: ship_address.city,+ country: ship_address.country_iso,+ line1: ship_address.address1,+ line2: ship_address.address2,+ postal_code: ship_address.zipcode,+ state: ship_address.state_abbr+ },+ name: ship_address.full_name+ }+ }+ end++ private++ attr_reader :order, :amount, :customer, :ship_address, :payment_method_id, :capture_method++ def manual_capture?+ capture_method.to_s == Gateway::PaymentIntents::MANUAL_CAPTURE_METHOD+ end++ def basic_payload+ {+ amount: amount,+ customer: customer,+ currency: order.currency,+ statement_descriptor_suffix: statement_descriptor_suffix,+ automatic_payment_methods: { enabled: true },+ transfer_group: order.number,+ metadata: { spree_order_id: order.id }+ }+ end++ def statement_descriptor_suffix+ SpreeStripe::StatementDescriptorSuffixPresenter.new(order_description: order.number).call+ end++ def new_payment_method_payload+ {+ payment_method_options: {+ card: { setup_future_usage: SETUP_FUTURE_USAGE },+ sepa_debit: { setup_future_usage: SETUP_FUTURE_USAGE }+ }+ }+ end++ def saved_payment_method_payload+ { payment_method: payment_method_id }+ end+ end+enddiff --git a/spree/providers/stripe/app/presenters/spree_stripe/statement_descriptor_suffix_presenter.rb b/spree/providers/stripe/app/presenters/spree_stripe/statement_descriptor_suffix_presenter.rbnew file mode 100644index 0000000000..fae0fe56c9--- /dev/null+++ b/spree/providers/stripe/app/presenters/spree_stripe/statement_descriptor_suffix_presenter.rb@@ -0,0 +1,36 @@+module SpreeStripe+ # Builds the suffix shown on the customer's bank statement. Stripe rejects a+ # suffix with no letters, so a purely numeric order number gets an "O#" prefix.+ class StatementDescriptorSuffixPresenter+ STATEMENT_DESCRIPTOR_MAX_CHARS = 10+ STATEMENT_DESCRIPTOR_NOT_ALLOWED_CHARS = /[<>'"*\\]/.freeze+ STATEMENT_PREFIX = 'O#'.freeze++ def initialize(order_description:)+ @order_description = order_description.to_s+ end++ # @return [String, nil]+ def call+ return if stripped_order_description.blank?++ if stripped_order_description.count('A-Z').positive?+ stripped_order_description+ else+ "#{STATEMENT_PREFIX}#{stripped_order_description}"[0...STATEMENT_DESCRIPTOR_MAX_CHARS].strip+ end+ end++ private++ attr_reader :order_description++ def stripped_order_description+ @stripped_order_description ||= I18n.transliterate(order_description).+ gsub(STATEMENT_DESCRIPTOR_NOT_ALLOWED_CHARS, '').+ strip.+ upcase[0...STATEMENT_DESCRIPTOR_MAX_CHARS].+ strip+ end+ end+enddiff --git a/spree/providers/stripe/app/services/spree_stripe/create_gateway_webhooks.rb b/spree/providers/stripe/app/services/spree_stripe/create_gateway_webhooks.rbnew file mode 100644index 0000000000..183e47048a--- /dev/null+++ b/spree/providers/stripe/app/services/spree_stripe/create_gateway_webhooks.rb@@ -0,0 +1,48 @@+module SpreeStripe+ # Registers the gateway's webhook endpoint with Stripe and stores the signing+ # secret on the payment method.+ class CreateGatewayWebhooks+ # @param payment_method [SpreeStripe::Gateway]+ # @return [Stripe::WebhookEndpoint, nil]+ def call(payment_method:, events: SpreeStripe::Gateway::Webhooks::SUPPORTED_EVENTS, connect: false)+ webhook_url = payment_method.webhook_url+ return if webhook_url.blank?++ api_options = { api_key: payment_method.preferred_secret_key }+ existing = find_webhook(Stripe::WebhookEndpoint.list({}, api_options)[:data], webhook_url, events)++ # Stripe only returns the signing secret when the endpoint is created, so a+ # pre-existing endpoint whose secret we do not hold has to be replaced.+ if existing.present? && payment_method.preferred_webhook_endpoint_id == existing[:id] &&+ payment_method.preferred_webhook_signing_secret.present?+ return existing+ end++ Stripe::WebhookEndpoint.delete(existing[:id], {}, api_options) if existing.present?++ create_webhook_endpoint(payment_method, webhook_url, events, connect, api_options)+ end++ private++ def find_webhook(webhooks_data, webhook_url, enabled_events)+ webhooks_data.find do |webhook|+ webhook[:url] == webhook_url && webhook[:enabled_events].sort == enabled_events.sort+ end+ end++ def create_webhook_endpoint(payment_method, webhook_url, events, connect, api_options)+ stripe_webhook = Stripe::WebhookEndpoint.create(+ { url: webhook_url, enabled_events: events, connect: connect },+ api_options+ )++ payment_method.update!(+ preferred_webhook_endpoint_id: stripe_webhook[:id],+ preferred_webhook_signing_secret: stripe_webhook[:secret]+ )++ stripe_webhook+ end+ end+enddiff --git a/spree/providers/stripe/app/services/spree_stripe/create_payment.rb b/spree/providers/stripe/app/services/spree_stripe/create_payment.rbnew file mode 100644index 0000000000..b58fef8cd3--- /dev/null+++ b/spree/providers/stripe/app/services/spree_stripe/create_payment.rb@@ -0,0 +1,59 @@+module SpreeStripe+ # Builds the Spree::Payment for a completed payment session, together with the+ # Stripe-specific payment source.+ class CreatePayment+ # @param owner [Spree::Cart, Spree::Order]+ # @param payment_session [Spree::PaymentSessions::Stripe]+ # @param gateway [SpreeStripe::Gateway]+ def initialize(owner:, payment_session:, gateway: nil, amount: nil)+ @owner = owner+ @gateway = gateway || owner.store.stripe_gateway+ @payment_session = payment_session+ @amount = amount || owner.total_minus_store_credits+ end++ # @return [Spree::Payment]+ def call+ stripe_charge = payment_session.stripe_charge+ source = build_source(stripe_charge)++ # A retried job must not produce a second payment for the same intent.+ payment = owner.payments.find_or_initialize_by(+ payment_method_id: gateway.id,+ response_code: payment_session.stripe_id,+ amount: amount+ )++ payment.source = source if source.present?+ payment.stripe_charge_id = stripe_charge&.id+ payment.save!+ payment+ end++ private++ attr_reader :owner, :gateway, :payment_session, :amount++ def build_source(stripe_charge)+ if stripe_charge.present?+ SpreeStripe::CreateSource.new(+ owner: owner,+ stripe_payment_method_details: stripe_charge.payment_method_details,+ stripe_payment_method_id: stripe_charge.payment_method,+ stripe_billing_details: stripe_charge.billing_details,+ gateway: gateway+ ).call+ elsif payment_session.charge_not_required?+ stripe_payment_intent = payment_session.stripe_payment_intent++ SpreeStripe::CreateSource.new(+ owner: owner,+ stripe_payment_method_details: stripe_payment_intent.payment_method,+ stripe_payment_method_id: stripe_payment_intent.payment_method.id,+ stripe_billing_details: nil,+ gateway: gateway+ ).call+ end+ end+ end+enddiff --git a/spree/providers/stripe/app/services/spree_stripe/create_payment_session.rb b/spree/providers/stripe/app/services/spree_stripe/create_payment_session.rbnew file mode 100644index 0000000000..660cc06ef2--- /dev/null+++ b/spree/providers/stripe/app/services/spree_stripe/create_payment_session.rb@@ -0,0 +1,20 @@+module SpreeStripe+ # Reuses the pending Stripe payment session (keeping its amount in sync with+ # the total) or creates a new one.+ class CreatePaymentSession+ # @param owner [Spree::Cart, Spree::Order]+ # @param gateway [SpreeStripe::Gateway]+ # @return [Spree::PaymentSessions::Stripe, nil]+ def call(owner, gateway)+ amount = owner.total_minus_store_credits+ return if Spree::Money.new(amount, currency: owner.currency).cents.zero?++ session = owner.payment_sessions.where(payment_method: gateway, status: 'pending').order(:created_at).last++ return gateway.create_payment_session(order: owner) unless session++ gateway.update_payment_session(payment_session: session, amount: amount) if session.amount != amount+ session+ end+ end+enddiff --git a/spree/providers/stripe/app/services/spree_stripe/create_source.rb b/spree/providers/stripe/app/services/spree_stripe/create_source.rbnew file mode 100644index 0000000000..19eedaba74--- /dev/null+++ b/spree/providers/stripe/app/services/spree_stripe/create_source.rb@@ -0,0 +1,109 @@+module SpreeStripe+ # Maps a Stripe payment method onto the matching Spree payment source.+ class CreateSource+ def initialize(stripe_payment_method_details:, stripe_payment_method_id:, gateway:, stripe_billing_details:, owner: nil, customer: nil)+ @stripe_payment_method_details = stripe_payment_method_details+ @stripe_payment_method_id = stripe_payment_method_id+ @gateway = gateway+ @customer = customer || owner&.customer+ @stripe_billing_details = stripe_billing_details+ @owner = owner+ end++ # @return [Spree::PaymentSource]+ def call+ case stripe_payment_method_details.type+ when 'card'+ find_or_create_credit_card+ when 'klarna'+ SpreeStripe::PaymentSources::Klarna.create!(source_params)+ when 'afterpay_clearpay'+ SpreeStripe::PaymentSources::AfterPay.create!(source_params)+ when 'sepa_debit'+ SpreeStripe::PaymentSources::SepaDebit.create!(source_params)+ when 'p24'+ SpreeStripe::PaymentSources::Przelewy24.create!(source_params.merge(bank: stripe_payment_method_details.p24.bank))+ when 'ideal'+ SpreeStripe::PaymentSources::Ideal.create!(+ source_params.merge(+ bank: stripe_payment_method_details.ideal.bank,+ last4: stripe_payment_method_details.ideal.iban_last4+ )+ )+ when 'alipay'+ SpreeStripe::PaymentSources::Alipay.create!(source_params)+ when 'link'+ SpreeStripe::PaymentSources::Link.create!(source_params)+ when 'affirm'+ SpreeStripe::PaymentSources::Affirm.create!(source_params)+ when 'customer_balance', 'us_bank_account'+ SpreeStripe::PaymentSources::BankTransfer.create!(source_params)+ else+ Spree::PaymentSource.create!(source_params)+ end+ end++ private++ attr_reader :gateway, :customer, :stripe_payment_method_details, :stripe_payment_method_id,+ :stripe_billing_details, :owner++ def find_or_create_credit_card+ if customer+ exact_source = customer.credit_cards.find_by(gateway_payment_profile_id: stripe_payment_method_id)+ return exact_source if exact_source++ matching_source = match_credit_card_by_fingerprint+ return matching_source if matching_source+ end++ Spree::CreditCard.create!(credit_card_params)+ end++ # Stripe issues a fresh PaymentMethod id every time a card is entered, even+ # for the same physical card, so matching on the profile id alone would save+ # a duplicate. The card fingerprint is stable, so match on it plus expiry.+ #+ # @return [Spree::CreditCard, nil]+ def match_credit_card_by_fingerprint+ card = stripe_payment_method_details.card+ return if card.fingerprint.blank?++ customer.credit_cards.+ where(payment_method: gateway).+ by_fingerprint(card.fingerprint, card.exp_month, card.exp_year).+ order(created_at: :desc).+ first+ end++ def credit_card_params+ card_details = stripe_payment_method_details.card+ gateway_customer = gateway.fetch_or_create_customer(customer: customer, order: owner)++ {+ customer: customer,+ gateway_customer: gateway_customer,+ payment_method: gateway,+ gateway_customer_profile_id: gateway_customer&.profile_id,+ gateway_payment_profile_id: stripe_payment_method_id,+ fingerprint: card_details.fingerprint,+ name: stripe_billing_details&.name,+ month: card_details.exp_month,+ year: card_details.exp_year,+ last_digits: card_details.last4,+ brand: card_details.brand,+ metadata: {+ checks: card_details&.checks,+ wallet: { type: card_details&.wallet&.type }+ }+ }+ end++ def source_params+ {+ gateway_payment_profile_id: stripe_payment_method_id,+ payment_method: gateway+ }+ end+ end+enddiff --git a/spree/providers/stripe/app/services/spree_stripe/register_domain.rb b/spree/providers/stripe/app/services/spree_stripe/register_domain.rbnew file mode 100644index 0000000000..34bc7c63ee--- /dev/null+++ b/spree/providers/stripe/app/services/spree_stripe/register_domain.rb@@ -0,0 +1,34 @@+module SpreeStripe+ # Registers a storefront domain with Stripe. Apple Pay and Google Pay only+ # offer themselves on domains Stripe has verified, so quick checkout depends+ # on this having run.+ class RegisterDomain+ # @param model [Spree::Store, Spree::CustomDomain]+ # @return [Stripe::PaymentMethodDomain, nil]+ def call(model:)+ gateway = model.is_a?(Spree::Store) ? model.stripe_gateway : model.store.stripe_gateway+ return if gateway.blank?++ payment_method_domain = gateway.send_request do |opts|+ Stripe::PaymentMethodDomain.create({ domain_name: model.url }, opts)+ end++ attributes_to_update = { stripe_apple_pay_domain_id: payment_method_domain.id }++ # A custom domain on a subdomain needs its apex registered too, or Apple Pay+ # refuses to render there.+ tld_length = model.url.split('.').length+ if tld_length > 2 && defined?(Spree::CustomDomain) && model.is_a?(Spree::CustomDomain)+ top_level_domain_name = model.url.split('.').last(tld_length - 1).join('.')+ top_level_domain = gateway.send_request do |opts|+ Stripe::PaymentMethodDomain.create({ domain_name: top_level_domain_name }, opts)+ end+ attributes_to_update[:stripe_top_level_domain_id] = top_level_domain.id+ end++ model.update!(**attributes_to_update)++ payment_method_domain+ end+ end+enddiff --git a/spree/providers/stripe/app/services/spree_stripe/update_customer.rb b/spree/providers/stripe/app/services/spree_stripe/update_customer.rbnew file mode 100644index 0000000000..96fb5d2c7a--- /dev/null+++ b/spree/providers/stripe/app/services/spree_stripe/update_customer.rb@@ -0,0 +1,14 @@+module SpreeStripe+ # Pushes Spree-side customer changes (name, email, address) to Stripe.+ class UpdateCustomer+ # @param customer [Spree::Customer]+ def call(customer:)+ gateway_customers = customer.gateway_customers.stripe+ return if gateway_customers.empty?++ gateway_customers.each do |gateway_customer|+ gateway_customer.payment_method.update_customer(customer: customer)+ end+ end+ end+enddiff --git a/spree/providers/stripe/config/initializers/stripe.rb b/spree/providers/stripe/config/initializers/stripe.rbnew file mode 100644index 0000000000..e0e4e2ff9a--- /dev/null+++ b/spree/providers/stripe/config/initializers/stripe.rb@@ -0,0 +1,3 @@+Stripe.log_level = ENV.fetch('STRIPE_LOG_LEVEL', 'info')+Stripe.api_version = '2023-10-16'+Stripe.set_app_info('Spree Stripe', version: Spree.version, url: 'https://spreecommerce.org')diff --git a/spree/providers/stripe/config/locales/en.yml b/spree/providers/stripe/config/locales/en.ymlnew file mode 100644index 0000000000..0f7b1cae04--- /dev/null+++ b/spree/providers/stripe/config/locales/en.yml@@ -0,0 +1,8 @@+---+en:+ spree:+ bank_transfer: Bank Transfer+ stripe:+ payment_could_not_be_processed: Your payment could not be processed. Please try again.+ payment_session_errors:+ zero_amount: Payment session amount must be greater than zerodiff --git a/spree/providers/stripe/lib/generators/spree_stripe/install/install_generator.rb b/spree/providers/stripe/lib/generators/spree_stripe/install/install_generator.rbnew file mode 100644index 0000000000..da9bf3570b--- /dev/null+++ b/spree/providers/stripe/lib/generators/spree_stripe/install/install_generator.rb@@ -0,0 +1,20 @@+require 'rails/generators'+require 'spree/core'++module SpreeStripe+ module Generators+ # Kept as a no-op so `rake test_app` and any existing+ # `rails g spree_stripe:install` invocations keep working. The gateway+ # registers itself from the engine and stores its configuration in payment+ # method preferences, so it owns no tables and has nothing to copy into the+ # host app.+ class InstallGenerator < Rails::Generators::Base+ desc 'No-op. spree_stripe registers its gateway automatically and ships no migrations.'++ def notify_nothing_to_install+ say 'spree_stripe registers its gateway automatically — nothing to install. ' \+ 'Add a Stripe payment method in the admin to configure your API keys.'+ end+ end+ end+enddiff --git a/spree/providers/stripe/lib/spree_stripe.rb b/spree/providers/stripe/lib/spree_stripe.rbnew file mode 100644index 0000000000..e0a6468360--- /dev/null+++ b/spree/providers/stripe/lib/spree_stripe.rb@@ -0,0 +1,14 @@+require 'stripe'+require 'spree_core'+require 'spree_stripe/engine'++module SpreeStripe+ # Background queue for the gem's jobs. Defaults to Spree's default queue.+ def self.queue+ @queue ||= Spree.queues.default+ end++ class << self+ attr_writer :queue+ end+enddiff --git a/spree/providers/stripe/lib/spree_stripe/engine.rb b/spree/providers/stripe/lib/spree_stripe/engine.rbnew file mode 100644index 0000000000..db0dfbbe33--- /dev/null+++ b/spree/providers/stripe/lib/spree_stripe/engine.rb@@ -0,0 +1,27 @@+require 'rails/engine'++module SpreeStripe+ class Engine < Rails::Engine+ isolate_namespace Spree+ engine_name 'spree_stripe'++ config.paths.add 'app/subscribers', eager_load: true++ config.generators do |g|+ g.test_framework :rspec+ end++ # Core assigns the payment method registry in its own after_initialize, so+ # appending has to happen in a later one — engine callbacks run in load order.+ config.after_initialize do+ Rails.application.config.spree.payment_methods << SpreeStripe::Gateway+ Spree.subscribers << SpreeStripe::CustomerUpdatedSubscriber+ end++ config.to_prepare do+ Dir.glob(Engine.root.join('app/**/*_decorator*.rb')) do |decorator|+ require_dependency(decorator)+ end+ end+ end+enddiff --git a/spree/providers/stripe/lib/spree_stripe/factories.rb b/spree/providers/stripe/lib/spree_stripe/factories.rbnew file mode 100644index 0000000000..841b96bfea--- /dev/null+++ b/spree/providers/stripe/lib/spree_stripe/factories.rb@@ -0,0 +1 @@+Dir["#{File.dirname(__FILE__)}/testing_support/factories/**/*.rb"].sort.each { |f| load File.expand_path(f) }diff --git a/spree/providers/stripe/lib/spree_stripe/testing_support/factories/gateway_factory.rb b/spree/providers/stripe/lib/spree_stripe/testing_support/factories/gateway_factory.rbnew file mode 100644index 0000000000..64b2cdddd1--- /dev/null+++ b/spree/providers/stripe/lib/spree_stripe/testing_support/factories/gateway_factory.rb@@ -0,0 +1,24 @@+FactoryBot.define do+ factory :stripe_gateway, parent: :payment_method, class: 'SpreeStripe::Gateway' do+ name { 'Stripe' }+ type { 'SpreeStripe::Gateway' }++ preferences do+ {+ publishable_key: ENV.fetch('STRIPE_PUBLISHABLE_KEY', 'pk_test_1234567890'),+ secret_key: ENV.fetch('STRIPE_SECRET_KEY', 'sk_test_1234567890')+ }+ end++ trait :with_webhook_signing_secret do+ preferences do+ {+ publishable_key: ENV.fetch('STRIPE_PUBLISHABLE_KEY', 'pk_test_1234567890'),+ secret_key: ENV.fetch('STRIPE_SECRET_KEY', 'sk_test_1234567890'),+ webhook_endpoint_id: 'we_test_1234567890',+ webhook_signing_secret: 'whsec_test_1234567890'+ }+ end+ end+ end+enddiff --git a/spree/providers/stripe/lib/spree_stripe/testing_support/factories/payment_session_factory.rb b/spree/providers/stripe/lib/spree_stripe/testing_support/factories/payment_session_factory.rbnew file mode 100644index 0000000000..5d575c6afc--- /dev/null+++ b/spree/providers/stripe/lib/spree_stripe/testing_support/factories/payment_session_factory.rb@@ -0,0 +1,50 @@+FactoryBot.define do+ factory :stripe_payment_session, class: 'Spree::PaymentSessions::Stripe' do+ transient do+ owner { create(:order_with_line_items) }+ end++ cart { owner if owner.is_a?(Spree::Cart) }+ order { owner unless owner.is_a?(Spree::Cart) }+ payment_method { create(:stripe_gateway, store: owner.store) }+ amount { owner.total }+ currency { owner.currency }+ status { 'pending' }+ external_id { "pi_test_#{SecureRandom.hex(12)}" }+ external_data { { 'client_secret' => "pi_secret_#{SecureRandom.hex(8)}" } }++ trait :with_customer do+ customer { owner.customer || create(:customer) }+ customer_external_id { "cus_#{SecureRandom.hex(8)}" }+ end++ trait :with_ephemeral_key do+ external_data do+ {+ 'client_secret' => "pi_secret_#{SecureRandom.hex(8)}",+ 'ephemeral_key_secret' => "ek_test_#{SecureRandom.hex(8)}"+ }+ end+ end++ trait :processing do+ status { 'processing' }+ end++ trait :completed do+ status { 'completed' }+ end++ trait :failed do+ status { 'failed' }+ end+ end++ factory :stripe_payment_setup_session, class: 'Spree::PaymentSetupSessions::Stripe' do+ customer { create(:customer) }+ payment_method { create(:stripe_gateway) }+ status { 'pending' }+ external_id { "seti_test_#{SecureRandom.hex(12)}" }+ external_client_secret { "seti_secret_#{SecureRandom.hex(8)}" }+ end+enddiff --git a/spree/providers/stripe/lib/tasks/migrate_webhook_keys.rake b/spree/providers/stripe/lib/tasks/migrate_webhook_keys.rakenew file mode 100644index 0000000000..952169c0e6--- /dev/null+++ b/spree/providers/stripe/lib/tasks/migrate_webhook_keys.rake@@ -0,0 +1,124 @@+# Defined here rather than in lib/spree/stripe/ — this is a one-release upgrade+# step that dies with the legacy tables, not engine infrastructure.+module SpreeStripe+ # Copies Stripe webhook signing secrets out of the legacy+ # spree_stripe_webhook_keys tables onto the gateway's own preferences.+ #+ # Before 6.0 a signing secret was a row joined to payment methods+ # many-to-many, because a payment method could be shared across stores. A+ # payment method now belongs to exactly one store, so there is a single+ # endpoint per gateway and the secret is just another gateway preference.+ #+ # Reads the legacy tables through throwaway model classes — the legacy models+ # are gone in 6.0. The secret columns were written with deterministic Active+ # Record encryption, so the reader declares it too; installs that never+ # configured encryption keys stored them in plaintext and are read as-is.+ #+ # Idempotent: gateways that already hold a signing secret are skipped, and the+ # legacy tables are left in place as a rollback path.+ class WebhookKeysMigrator+ LEGACY_KEYS_TABLE = 'spree_stripe_webhook_keys'.freeze+ LEGACY_JOIN_TABLE = 'spree_stripe_payment_methods_webhook_keys'.freeze++ # @return [Hash, nil] counts, or nil when the legacy tables are absent+ def call+ return nil unless connection.table_exists?(LEGACY_KEYS_TABLE) && connection.table_exists?(LEGACY_JOIN_TABLE)++ migrated = 0+ skipped = 0+ failed = []++ SpreeStripe::Gateway.with_deleted.find_each do |gateway|+ if gateway.preferred_webhook_signing_secret.present?+ skipped += 1+ next+ end++ key = legacy_key_for(gateway)+ if key.blank?+ skipped += 1+ next+ end++ gateway.update_columns(+ preferences: gateway.preferences.merge(+ webhook_endpoint_id: key.stripe_id,+ webhook_signing_secret: key.signing_secret+ ),+ updated_at: Time.current+ )+ migrated += 1+ rescue StandardError => e+ failed << { gateway_id: gateway.id, error: e.message }+ end++ { migrated: migrated, skipped: skipped, failed: failed }+ end++ private++ def connection+ ActiveRecord::Base.connection+ end++ # A payment method could be joined to several keys historically; the most+ # recent one is the endpoint Stripe would be signing with today.+ def legacy_key_for(gateway)+ key_ids = join_model.where(payment_method_id: gateway.id).order(:created_at).pluck(:webhook_key_id)+ return if key_ids.empty?++ key_model.where(id: key_ids).order(:created_at).last+ end++ def key_model+ @key_model ||= Class.new(ActiveRecord::Base) do+ self.table_name = LEGACY_KEYS_TABLE+ self.inheritance_column = nil++ if Rails.configuration.active_record.encryption.include?(:primary_key)+ encrypts :stripe_id, deterministic: true+ encrypts :signing_secret, deterministic: true+ end+ end+ end++ def join_model+ @join_model ||= Class.new(ActiveRecord::Base) do+ self.table_name = LEGACY_JOIN_TABLE+ self.inheritance_column = nil+ end+ end+ end+end++namespace :spree do+ namespace :upgrade do+ desc <<~DESC+ Moves Stripe webhook signing secrets from the legacy+ spree_stripe_webhook_keys tables onto each gateway's preferences.++ Run once after upgrading to Spree 6.0. Without it, gateways carrying a+ pre-6.0 endpoint have no signing secret and reject incoming webhooks+ until a new endpoint is registered.++ Idempotent. The legacy tables are left in place as a rollback path and+ are dropped in 6.1.+ DESC+ task migrate_stripe_webhook_keys: :environment do+ result = SpreeStripe::WebhookKeysMigrator.new.call++ if result.nil?+ puts 'Legacy Stripe webhook key tables not found — nothing to migrate.'+ next+ end++ puts "Migrated #{result[:migrated]} signing secret(s), skipped #{result[:skipped]}."++ next if result[:failed].empty?++ puts "Failed for #{result[:failed].size} gateway(s):"+ result[:failed].each { |failure| puts " gateway #{failure[:gateway_id]}: #{failure[:error]}" }+ abort 'Some gateways could not be migrated. Re-run after resolving the errors above.'+ end+ end+enddiff --git a/spree/providers/stripe/spec/jobs/spree_stripe/update_customer_job_spec.rb b/spree/providers/stripe/spec/jobs/spree_stripe/update_customer_job_spec.rbnew file mode 100644index 0000000000..aa72306485--- /dev/null+++ b/spree/providers/stripe/spec/jobs/spree_stripe/update_customer_job_spec.rb@@ -0,0 +1,22 @@+require 'spec_helper'++RSpec.describe SpreeStripe::UpdateCustomerJob do+ subject { described_class.new.perform(customer_id) }++ let(:customer) { create(:customer) }+ let(:customer_id) { customer.id }++ it 'calls the SpreeStripe::UpdateCustomer service' do+ expect(SpreeStripe::UpdateCustomer).to receive_message_chain(:new, :call).with(customer: customer)+ subject+ end++ context 'when the customer is not found' do+ let(:customer_id) { 'missing' }++ it 'does nothing' do+ expect(SpreeStripe::UpdateCustomer).not_to receive(:new)+ subject+ end+ end+enddiff --git a/spree/providers/stripe/spec/models/spree/payment_sessions/stripe_spec.rb b/spree/providers/stripe/spec/models/spree/payment_sessions/stripe_spec.rbnew file mode 100644index 0000000000..b433623b18--- /dev/null+++ b/spree/providers/stripe/spec/models/spree/payment_sessions/stripe_spec.rb@@ -0,0 +1,181 @@+require 'spec_helper'++RSpec.describe Spree::PaymentSessions::Stripe, type: :model do+ let(:store) { @default_store }+ let(:customer) { create(:customer) }+ let(:order) { create(:order_with_line_items, store: store, customer: customer) }+ let(:gateway) { create(:stripe_gateway, store: store) }+ let(:payment_session) do+ create(:stripe_payment_session,+ owner: order,+ payment_method: gateway,+ external_id: 'pi_test_abc123',+ external_data: {+ 'client_secret' => 'pi_secret_xyz',+ 'ephemeral_key_secret' => 'ek_test_key',+ 'stripe_payment_method_id' => 'pm_card_visa'+ },+ customer_external_id: 'cus_test_123')+ end++ describe 'STI' do+ it 'uses the correct type' do+ expect(payment_session.type).to eq('Spree::PaymentSessions::Stripe')+ end++ it 'is a PaymentSession' do+ expect(payment_session).to be_a(Spree::PaymentSession)+ end+ end++ describe '#owner' do+ it 'returns the order when the session belongs to an order' do+ expect(payment_session.owner).to eq(order)+ expect(payment_session.cart).to be_nil+ end++ context 'when the owner is a cart' do+ let(:cart) { create(:cart_with_line_items, store: store, customer: customer) }+ let(:payment_session) { create(:stripe_payment_session, owner: cart, payment_method: gateway) }++ it 'returns the cart' do+ expect(payment_session.owner).to eq(cart)+ expect(payment_session.order).to be_nil+ end+ end+ end++ describe '#stripe_id' do+ it 'aliases external_id' do+ expect(payment_session.stripe_id).to eq('pi_test_abc123')+ end+ end++ describe '#client_secret' do+ it 'reads from external_data' do+ expect(payment_session.client_secret).to eq('pi_secret_xyz')+ end++ it 'returns nil when external_data is nil' do+ payment_session.external_data = nil+ expect(payment_session.client_secret).to be_nil+ end+ end++ describe '#ephemeral_key_secret' do+ it 'reads from external_data' do+ expect(payment_session.ephemeral_key_secret).to eq('ek_test_key')+ end+ end++ describe '#stripe_payment_intent' do+ let(:stripe_pi) { Stripe::StripeObject.construct_from(id: 'pi_test_abc123', status: 'succeeded') }++ it 'retrieves from Stripe via payment_method' do+ expect(gateway).to receive(:retrieve_payment_intent).with('pi_test_abc123').and_return(stripe_pi)+ expect(payment_session.stripe_payment_intent).to eq(stripe_pi)+ end++ it 'caches the result' do+ expect(gateway).to receive(:retrieve_payment_intent).once.and_return(stripe_pi)+ 2.times { payment_session.stripe_payment_intent }+ end+ end++ describe '#stripe_charge' do+ let(:stripe_pi) { Stripe::StripeObject.construct_from(id: 'pi_test_abc123', status: 'succeeded', latest_charge: 'ch_123') }+ let(:stripe_charge) { Stripe::StripeObject.construct_from(id: 'ch_123') }++ before do+ allow(gateway).to receive(:retrieve_payment_intent).and_return(stripe_pi)+ end++ it 'retrieves charge from Stripe' do+ expect(gateway).to receive(:retrieve_charge).with('ch_123').and_return(stripe_charge)+ expect(payment_session.stripe_charge).to eq(stripe_charge)+ end++ it 'returns nil when no latest_charge' do+ allow(stripe_pi).to receive(:latest_charge).and_return(nil)+ expect(payment_session.stripe_charge).to be_nil+ end+ end++ describe '#accepted?' do+ let(:stripe_pi) { Stripe::StripeObject.construct_from(id: 'pi_test_abc123', status: 'succeeded', payment_method: { type: 'card' }) }++ it 'delegates to payment_method' do+ allow(gateway).to receive(:retrieve_payment_intent).and_return(stripe_pi)+ expect(payment_session.accepted?).to be true+ end+ end++ describe '#successful?' do+ it 'returns true when stripe status is succeeded' do+ stripe_pi = Stripe::StripeObject.construct_from(id: 'pi_test_abc123', status: 'succeeded')+ allow(gateway).to receive(:retrieve_payment_intent).and_return(stripe_pi)+ expect(payment_session.successful?).to be true+ end++ it 'returns false when stripe status is not succeeded' do+ stripe_pi = Stripe::StripeObject.construct_from(id: 'pi_test_abc123', status: 'requires_payment_method')+ allow(gateway).to receive(:retrieve_payment_intent).and_return(stripe_pi)+ expect(payment_session.successful?).to be false+ end+ end++ describe '#find_or_create_payment!' do+ before do+ allow(gateway).to receive(:create_profile)+ end++ it 'returns nil when not persisted' do+ session = build(:stripe_payment_session, owner: order, payment_method: gateway)+ expect(session.find_or_create_payment!).to be_nil+ end++ it 'returns existing payment if present' do+ payment = create(:payment, order: order, payment_method: gateway, response_code: payment_session.external_id, amount: payment_session.amount)+ expect(payment_session.reload.find_or_create_payment!).to eq(payment)+ end++ it 'creates payment via CreatePayment service' do+ mock_payment = build(:payment, order: order, payment_method: gateway)+ service = instance_double(SpreeStripe::CreatePayment, call: mock_payment)+ expect(SpreeStripe::CreatePayment).to receive(:new).with(+ owner: order,+ payment_session: payment_session,+ gateway: gateway,+ amount: payment_session.amount+ ).and_return(service)++ expect(payment_session.find_or_create_payment!).to eq(mock_payment)+ end++ it 'accepts metadata argument without error' do+ mock_payment = build(:payment, order: order, payment_method: gateway)+ service = instance_double(SpreeStripe::CreatePayment, call: mock_payment)+ allow(SpreeStripe::CreatePayment).to receive(:new).and_return(service)++ expect(payment_session.find_or_create_payment!(charge_id: 'ch_123')).to eq(mock_payment)+ end+ end++ describe 'state machine' do+ it 'starts as pending' do+ expect(payment_session.status).to eq('pending')+ end++ it 'can transition through the full lifecycle' do+ expect(payment_session.process).to be true+ expect(payment_session.complete).to be true+ expect(payment_session.status).to eq('completed')+ end+ end++ describe '#api_options' do+ it 'delegates to payment_method' do+ expect(payment_session.api_options).to eq(gateway.api_options)+ end+ end+enddiff --git a/spree/providers/stripe/spec/models/spree/payment_setup_sessions/stripe_spec.rb b/spree/providers/stripe/spec/models/spree/payment_setup_sessions/stripe_spec.rbnew file mode 100644index 0000000000..820d415c9f--- /dev/null+++ b/spree/providers/stripe/spec/models/spree/payment_setup_sessions/stripe_spec.rb@@ -0,0 +1,71 @@+require 'spec_helper'++RSpec.describe Spree::PaymentSetupSessions::Stripe, type: :model do+ let(:store) { @default_store }+ let(:customer) { create(:customer) }+ let(:gateway) { create(:stripe_gateway, store: store) }+ let(:setup_session) do+ create(:stripe_payment_setup_session,+ customer: customer,+ payment_method: gateway,+ external_id: 'seti_test_abc123',+ external_client_secret: 'seti_test_abc123_secret_xyz',+ external_data: { 'customer_id' => 'cus_test_123' })+ end++ describe 'STI' do+ it 'uses the correct type' do+ expect(setup_session.type).to eq('Spree::PaymentSetupSessions::Stripe')+ end++ it 'is a PaymentSetupSession' do+ expect(setup_session).to be_a(Spree::PaymentSetupSession)+ end+ end++ describe '#stripe_id' do+ it 'aliases external_id' do+ expect(setup_session.stripe_id).to eq('seti_test_abc123')+ end+ end++ describe '#client_secret' do+ it 'aliases external_client_secret' do+ expect(setup_session.client_secret).to eq('seti_test_abc123_secret_xyz')+ end+ end++ describe '#stripe_setup_intent' do+ let(:stripe_setup_intent) { Stripe::StripeObject.construct_from(id: 'seti_test_abc123', status: 'succeeded') }++ it 'retrieves the SetupIntent from Stripe via payment_method' do+ expect(gateway).to receive(:retrieve_setup_intent).with('seti_test_abc123').and_return(stripe_setup_intent)+ expect(setup_session.stripe_setup_intent).to eq(stripe_setup_intent)+ end++ it 'caches the result' do+ expect(gateway).to receive(:retrieve_setup_intent).once.and_return(stripe_setup_intent)+ 2.times { setup_session.stripe_setup_intent }+ end+ end++ describe '#successful?' do+ it 'returns true when stripe status is succeeded' do+ stripe_setup_intent = Stripe::StripeObject.construct_from(id: 'seti_test_abc123', status: 'succeeded')+ allow(gateway).to receive(:retrieve_setup_intent).and_return(stripe_setup_intent)+ expect(setup_session.successful?).to be true+ end++ it 'returns false when stripe status is not succeeded' do+ stripe_setup_intent = Stripe::StripeObject.construct_from(id: 'seti_test_abc123', status: 'requires_payment_method')+ allow(gateway).to receive(:retrieve_setup_intent).and_return(stripe_setup_intent)+ expect(setup_session.successful?).to be false+ end+ end++ describe '#api_options' do+ it 'delegates to payment_method' do+ expect(setup_session.api_options).to eq(gateway.api_options)+ end+ end+enddiff --git a/spree/providers/stripe/spec/models/spree_stripe/gateway/payment_sessions_spec.rb b/spree/providers/stripe/spec/models/spree_stripe/gateway/payment_sessions_spec.rbnew file mode 100644index 0000000000..6dae39f9e9--- /dev/null+++ b/spree/providers/stripe/spec/models/spree_stripe/gateway/payment_sessions_spec.rb@@ -0,0 +1,576 @@+require 'spec_helper'++RSpec.describe SpreeStripe::Gateway::PaymentSessions do+ let(:store) { @default_store }+ let(:customer) { create(:customer) }+ let(:order) { create(:order_with_line_items, store: store, customer: customer) }+ let(:gateway) { create(:stripe_gateway, store: store) }++ let(:gateway_customer) { instance_double(Spree::GatewayCustomer, profile_id: 'cus_test_123') }+ let(:pi_response) do+ Spree::PaymentResponse.new(+ true, nil,+ { 'client_secret' => 'pi_secret_abc' },+ authorization: 'pi_new_intent_123'+ )+ end+ let(:ephemeral_key_response) do+ Spree::PaymentResponse.new(+ true, nil,+ { 'secret' => 'ek_test_secret' },+ authorization: 'ek_test_secret'+ )+ end++ before do+ allow(gateway).to receive(:fetch_or_create_customer).and_return(gateway_customer)+ allow(gateway).to receive(:create_payment_intent).and_return(pi_response)+ allow(gateway).to receive(:create_ephemeral_key).and_return(ephemeral_key_response)+ end++ describe '#session_required?' do+ it 'returns true' do+ expect(gateway.session_required?).to be true+ end+ end++ describe '#payment_session_class' do+ it 'returns Spree::PaymentSessions::Stripe' do+ expect(gateway.payment_session_class).to eq(Spree::PaymentSessions::Stripe)+ end+ end++ describe '#create_payment_session' do+ subject { gateway.create_payment_session(order: order) }++ it 'creates a Stripe PaymentIntent' do+ expect(gateway).to receive(:create_payment_intent).with(+ order.display_total.cents, order,+ payment_method_id: nil,+ customer_profile_id: 'cus_test_123'+ ).and_return(pi_response)+ subject+ end++ it 'creates an ephemeral key' do+ expect(gateway).to receive(:create_ephemeral_key).with('cus_test_123')+ subject+ end++ it 'persists a PaymentSessions::Stripe record' do+ session = subject+ expect(session).to be_a(Spree::PaymentSessions::Stripe)+ expect(session).to be_persisted+ expect(session.external_id).to eq('pi_new_intent_123')+ expect(session.status).to eq('pending')+ expect(session.owner).to eq(order)+ expect(session.payment_method).to eq(gateway)+ end++ it 'stores client_secret and ephemeral_key_secret in external_data' do+ session = subject+ expect(session.external_data['client_secret']).to eq('pi_secret_abc')+ expect(session.external_data['ephemeral_key_secret']).to eq('ek_test_secret')+ end++ it 'stores customer_external_id' do+ session = subject+ expect(session.customer_external_id).to eq('cus_test_123')+ end++ it 'raises a GatewayError when amount is zero' do+ allow(order).to receive(:total_minus_store_credits).and_return(0)+ expect { subject }.to raise_error(Spree::Core::GatewayError, I18n.t('spree.stripe.payment_session_errors.zero_amount'))+ end++ context 'when the owner is a cart' do+ subject { gateway.create_payment_session(order: cart) }++ let(:cart) { create(:cart_with_line_items, store: store, customer: customer) }++ it 'assigns the cart as the owner' do+ session = subject+ expect(session.owner).to eq(cart)+ expect(session.cart).to eq(cart)+ expect(session.order).to be_nil+ end+ end++ context 'with a custom amount' do+ subject { gateway.create_payment_session(order: order, amount: 50.0) }++ it 'uses the provided amount' do+ expect(gateway).to receive(:create_payment_intent).with(+ 5000, order,+ payment_method_id: nil,+ customer_profile_id: 'cus_test_123'+ ).and_return(pi_response)+ session = subject+ expect(session.amount).to eq(50.0)+ end+ end++ context 'with external_data containing stripe_payment_method_id' do+ subject { gateway.create_payment_session(order: order, external_data: { stripe_payment_method_id: 'pm_card_visa' }) }++ it 'passes payment_method_id to create_payment_intent' do+ expect(gateway).to receive(:create_payment_intent).with(+ anything, order,+ payment_method_id: 'pm_card_visa',+ customer_profile_id: 'cus_test_123'+ ).and_return(pi_response)+ subject+ end++ it 'stores stripe_payment_method_id in external_data' do+ session = subject+ expect(session.external_data['stripe_payment_method_id']).to eq('pm_card_visa')+ end+ end++ context 'without a customer' do+ before do+ allow(gateway).to receive(:fetch_or_create_customer).and_return(nil)+ end++ it 'does not create an ephemeral key' do+ expect(gateway).not_to receive(:create_ephemeral_key)+ subject+ end++ it 'creates the session without customer data' do+ session = subject+ expect(session.customer_external_id).to be_nil+ end+ end+ end++ describe '#update_payment_session' do+ let(:payment_session) do+ create(:stripe_payment_session,+ owner: order,+ payment_method: gateway,+ amount: 20.0,+ external_id: 'pi_existing_123',+ external_data: { 'client_secret' => 'pi_secret_old' })+ end++ before do+ allow(gateway).to receive(:update_payment_intent)+ end++ it 'calls update_payment_intent on Stripe' do+ expect(gateway).to receive(:update_payment_intent).with(+ 'pi_existing_123', 3000, order, nil+ )+ gateway.update_payment_session(payment_session: payment_session, amount: 30.0)+ end++ it 'updates the session amount' do+ gateway.update_payment_session(payment_session: payment_session, amount: 30.0)+ expect(payment_session.reload.amount).to eq(30.0)+ end++ it 'merges new external_data' do+ gateway.update_payment_session(+ payment_session: payment_session,+ external_data: { stripe_payment_method_id: 'pm_new' }+ )+ expect(payment_session.reload.external_data['stripe_payment_method_id']).to eq('pm_new')+ expect(payment_session.external_data['client_secret']).to eq('pi_secret_old')+ end+ end++ describe '#complete_payment_session' do+ let(:payment_session) do+ create(:stripe_payment_session,+ owner: order,+ payment_method: gateway,+ amount: order.total,+ external_id: 'pi_complete_123')+ end++ # Wallet charges carry a full billing address; the fields the storefront+ # never collected are what patch_wallet_address fills in.+ def build_charge(billing_overrides = {}, address_overrides = {})+ default_address = {+ line1: '100 California Street', line2: nil, city: 'San Francisco',+ state: 'CA', postal_code: '94111', country: 'US'+ }+ default_billing = { name: 'John Doe', email: '[email protected]', phone: nil }++ Stripe::StripeObject.construct_from(+ id: 'ch_test_123',+ payment_method: 'pm_test_123',+ billing_details: default_billing.merge(billing_overrides).merge(+ address: default_address.merge(address_overrides)+ ),+ payment_method_details: { type: 'card', card: { brand: 'visa', last4: '4242', exp_month: 12, exp_year: 2025 } }+ )+ end++ let(:stripe_charge) { build_charge }++ context 'when the payment intent is accepted and succeeded' do+ let(:stripe_pi) { Stripe::StripeObject.construct_from(id: 'pi_complete_123', status: 'succeeded', latest_charge: 'ch_test_123', payment_method: { type: 'card' }) }++ before do+ allow(gateway).to receive(:retrieve_payment_intent).and_return(stripe_pi)+ allow(gateway).to receive(:retrieve_charge).and_return(stripe_charge)+ allow(payment_session).to receive(:find_or_create_payment!).and_return(+ create(:payment, order: order, payment_method: gateway, amount: order.total, state: 'checkout')+ )+ end++ it 'completes the session' do+ gateway.complete_payment_session(payment_session: payment_session)+ expect(payment_session.reload.status).to eq('completed')+ end++ it 'creates a payment record' do+ expect(payment_session).to receive(:find_or_create_payment!)+ gateway.complete_payment_session(payment_session: payment_session)+ end++ describe 'wallet billing address patching' do+ context 'when the charge billing address has a known country ISO' do+ let!(:california) do+ usa = Spree::Country.by_iso('US')+ usa.states.find_by(abbr: 'CA') || create(:state, name: 'California', abbr: 'CA', country: usa)+ end++ it 'builds the bill_address from the charge billing details' do+ order.update!(bill_address: nil)++ gateway.complete_payment_session(payment_session: payment_session)++ order.reload+ expect(order.bill_address).to be_present+ expect(order.bill_address.country.iso).to eq('US')+ expect(order.bill_address.address1).to eq('100 California Street')+ expect(order.bill_address.city).to eq('San Francisco')+ expect(order.bill_address.zipcode).to eq('94111')+ expect(order.bill_address.state).to eq(california)+ expect(order.bill_address).to be_quick_checkout+ end++ context 'for a guest order' do+ let(:order) { create(:order_with_line_items, store: store, customer: nil) }++ it 'takes the name from the charge billing details' do+ order.update!(bill_address: nil)++ gateway.complete_payment_session(payment_session: payment_session)++ order.reload+ expect(order.bill_address.first_name).to eq('John')+ expect(order.bill_address.last_name).to eq('Doe')+ end+ end+ end++ context 'when the charge billing address country is nil' do+ let(:stripe_charge) { build_charge({}, country: nil) }++ context 'and the store has a default_market with a default_country' do+ let(:default_country) { create(:country, iso: 'CA', name: 'Canada') }++ before do+ allow_any_instance_of(Spree::Store).to receive(:default_market).and_return(+ instance_double(Spree::Market, default_country: default_country)+ )+ end++ it 'falls back to the store default_market default_country' do+ order.update!(bill_address: nil)++ gateway.complete_payment_session(payment_session: payment_session)++ order.reload+ expect(order.bill_address).to be_present+ expect(order.bill_address.country).to eq(default_country)+ end+ end++ context 'and the store has no default_market' do+ before do+ allow_any_instance_of(Spree::Store).to receive(:default_market).and_return(nil)+ end++ it 'falls back to the US country as last resort' do+ order.update!(bill_address: nil)++ gateway.complete_payment_session(payment_session: payment_session)++ order.reload+ expect(order.bill_address).to be_present+ expect(order.bill_address.country.iso).to eq('US')+ end+ end+ end++ context 'when the charge billing address country is an unknown ISO' do+ let(:stripe_charge) { build_charge({}, country: 'ZZ') }++ it 'ignores the unknown ISO and falls back through the chain' do+ order.update!(bill_address: nil)++ gateway.complete_payment_session(payment_session: payment_session)++ order.reload+ expect(order.bill_address).to be_present+ expect(order.bill_address.country.iso).to eq('US')+ end+ end++ context 'when the order already has a valid bill_address' do+ it 'does not modify the bill_address' do+ original_address = order.bill_address+ expect(original_address).to be_present+ expect(original_address).to be_valid++ gateway.complete_payment_session(payment_session: payment_session)++ expect(order.reload.bill_address_id).to eq(original_address.id)+ end+ end++ context 'when billing_details email fills a missing order email' do+ it 'sets the order email from billing_details' do+ order.update_column(:email, nil)++ gateway.complete_payment_session(payment_session: payment_session)++ expect(order.reload.email).to eq('[email protected]')+ end+ end++ context 'when the latest_charge is missing (no charge to patch from)' do+ let(:stripe_pi) do+ Stripe::StripeObject.construct_from(+ id: 'pi_complete_123',+ status: 'succeeded',+ latest_charge: nil,+ payment_method: { type: 'card' }+ )+ end++ it 'does not raise and still completes the session' do+ order.update!(bill_address: nil)++ expect {+ gateway.complete_payment_session(payment_session: payment_session)+ }.not_to raise_error++ expect(payment_session.reload.status).to eq('completed')+ end+ end+ end+ end++ context 'when the payment intent is accepted but not succeeded (requires_action with charge_not_required)' do+ let(:stripe_pi) do+ Stripe::StripeObject.construct_from(+ id: 'pi_complete_123',+ status: 'requires_action',+ latest_charge: 'ch_test_123',+ payment_method: { type: 'card' },+ next_action: { type: 'setup_future_usage' }+ )+ end+ let(:payment) { create(:payment, order: order, payment_method: gateway, amount: order.total, state: 'checkout') }++ before do+ allow(gateway).to receive(:retrieve_payment_intent).and_return(stripe_pi)+ allow(gateway).to receive(:retrieve_charge).and_return(stripe_charge)+ allow(gateway).to receive(:payment_intent_accepted?).and_return(true)+ allow(payment_session).to receive(:find_or_create_payment!).and_return(payment)+ allow(payment_session).to receive(:payment).and_return(payment)+ end++ it 'authorizes the payment instead of processing' do+ expect(payment).to receive(:authorize!)+ gateway.complete_payment_session(payment_session: payment_session)+ end+ end++ context 'when the payment intent is not accepted' do+ let(:stripe_pi) { Stripe::StripeObject.construct_from(id: 'pi_complete_123', status: 'requires_payment_method', payment_method: { type: 'card' }) }++ before do+ allow(gateway).to receive(:retrieve_payment_intent).and_return(stripe_pi)+ end++ it 'fails the session' do+ gateway.complete_payment_session(payment_session: payment_session)+ expect(payment_session.reload.status).to eq('failed')+ end++ it 'does not create a payment' do+ expect(payment_session).not_to receive(:find_or_create_payment!)+ gateway.complete_payment_session(payment_session: payment_session)+ end+ end++ context 'when the payment intent is in requires_capture (manual capture)' do+ let(:stripe_pi) do+ Stripe::StripeObject.construct_from(+ id: 'pi_complete_123',+ status: 'requires_capture',+ capture_method: 'manual',+ latest_charge: nil,+ payment_method: { type: 'card' }+ )+ end+ let(:payment) { create(:payment, order: order, payment_method: gateway, amount: order.total, state: 'checkout') }++ before do+ allow(gateway).to receive(:retrieve_payment_intent).and_return(stripe_pi)+ allow(payment_session).to receive(:find_or_create_payment!).and_return(payment)+ allow(payment_session).to receive(:payment).and_return(payment)+ end++ it 'completes the session and authorizes the payment without capturing' do+ expect(payment).to receive(:authorize!)+ expect(payment).not_to receive(:process!)+ gateway.complete_payment_session(payment_session: payment_session)+ expect(payment_session.reload.status).to eq('completed')+ end+ end++ context 'when the session is already completed' do+ let(:stripe_pi) { Stripe::StripeObject.construct_from(id: 'pi_complete_123', status: 'requires_payment_method', payment_method: { type: 'card' }) }++ before do+ payment_session.update_column(:status, 'completed')+ allow(gateway).to receive(:retrieve_payment_intent).and_return(stripe_pi)+ end++ it 'does not fail a completed session' do+ gateway.complete_payment_session(payment_session: payment_session)+ expect(payment_session.reload.status).to eq('completed')+ end+ end+ end++ describe '#parse_webhook_event' do+ let(:raw_body) { '{"id": "evt_test"}' }+ let(:headers) { { 'HTTP_STRIPE_SIGNATURE' => 'sig_test' } }++ context 'with payment_intent.succeeded event' do+ let(:stripe_event) do+ Stripe::StripeObject.construct_from(+ type: 'payment_intent.succeeded',+ data: { object: { id: 'pi_webhook_123' } }+ )+ end+ let!(:payment_session) do+ create(:stripe_payment_session, owner: order, payment_method: gateway, external_id: 'pi_webhook_123')+ end++ before do+ allow(gateway).to receive(:verify_webhook_signature).and_return(stripe_event)+ end++ it 'returns captured action with payment session' do+ result = gateway.parse_webhook_event(raw_body, headers)++ expect(result[:action]).to eq(:captured)+ expect(result[:payment_session]).to eq(payment_session)+ end+ end++ context 'with payment_intent.payment_failed event' do+ let(:stripe_event) do+ Stripe::StripeObject.construct_from(+ type: 'payment_intent.payment_failed',+ data: { object: { id: 'pi_failed_123' } }+ )+ end+ let!(:payment_session) do+ create(:stripe_payment_session, owner: order, payment_method: gateway, external_id: 'pi_failed_123')+ end++ before do+ allow(gateway).to receive(:verify_webhook_signature).and_return(stripe_event)+ end++ it 'returns failed action' do+ result = gateway.parse_webhook_event(raw_body, headers)++ expect(result[:action]).to eq(:failed)+ expect(result[:payment_session]).to eq(payment_session)+ end+ end++ context 'with payment_intent.amount_capturable_updated event' do+ let(:stripe_event) do+ Stripe::StripeObject.construct_from(+ type: 'payment_intent.amount_capturable_updated',+ data: { object: { id: 'pi_authorized_123' } }+ )+ end+ let!(:payment_session) do+ create(:stripe_payment_session, owner: order, payment_method: gateway, external_id: 'pi_authorized_123')+ end++ before do+ allow(gateway).to receive(:verify_webhook_signature).and_return(stripe_event)+ end++ it 'returns authorized action' do+ result = gateway.parse_webhook_event(raw_body, headers)++ expect(result[:action]).to eq(:authorized)+ expect(result[:payment_session]).to eq(payment_session)+ end+ end++ context 'with unsupported event type' do+ let(:stripe_event) do+ Stripe::StripeObject.construct_from(+ type: 'customer.created',+ data: { object: { id: 'cus_123' } }+ )+ end++ before do+ allow(gateway).to receive(:verify_webhook_signature).and_return(stripe_event)+ end++ it 'returns nil' do+ expect(gateway.parse_webhook_event(raw_body, headers)).to be_nil+ end+ end++ context 'when payment session is not found' do+ let(:stripe_event) do+ Stripe::StripeObject.construct_from(+ type: 'payment_intent.succeeded',+ data: { object: { id: 'pi_unknown_123' } }+ )+ end++ before do+ allow(gateway).to receive(:verify_webhook_signature).and_return(stripe_event)+ end++ it 'returns nil' do+ expect(gateway.parse_webhook_event(raw_body, headers)).to be_nil+ end+ end++ context 'with invalid signature' do+ before do+ allow(gateway).to receive(:verify_webhook_signature)+ .and_raise(Spree::PaymentMethod::WebhookSignatureError)+ end++ it 'raises WebhookSignatureError' do+ expect {+ gateway.parse_webhook_event(raw_body, headers)+ }.to raise_error(Spree::PaymentMethod::WebhookSignatureError)+ end+ end+ end+enddiff --git a/spree/providers/stripe/spec/models/spree_stripe/gateway_spec.rb b/spree/providers/stripe/spec/models/spree_stripe/gateway_spec.rbnew file mode 100644index 0000000000..f55e34c79f--- /dev/null+++ b/spree/providers/stripe/spec/models/spree_stripe/gateway_spec.rb@@ -0,0 +1,1081 @@+require 'spec_helper'++RSpec.describe SpreeStripe::Gateway do+ let(:store) { @default_store }+ let(:gateway) { create(:stripe_gateway, store: store) }+ let(:amount) { 100 }++ describe '#payment_intent_accepted?' do+ subject { gateway.payment_intent_accepted?(stripe_payment_intent) }++ let(:stripe_payment_intent) do+ Stripe::StripeObject.construct_from(+ id: 'pi_123',+ status: payment_intent_status,+ capture_method: capture_method,+ payment_method: {+ type: payment_method_type+ }+ )+ end+ let(:capture_method) { 'automatic' }++ context 'for a card payment method' do+ let(:payment_method_type) { 'card' }++ context 'when the payment intent is succeeded' do+ let(:payment_intent_status) { 'succeeded' }++ it { is_expected.to be(true) }+ end++ context 'when the payment intent is processing' do+ let(:payment_intent_status) { 'processing' }++ it { is_expected.to be(false) }+ end++ context 'when the payment intent status is requires_action' do+ let(:payment_intent_status) { 'requires_action' }++ it { is_expected.to be(false) }+ end++ context 'when the payment intent is failed' do+ let(:payment_intent_status) { 'failed' }++ it { is_expected.to be(false) }+ end++ context 'when the payment intent status is requires_capture' do+ let(:payment_intent_status) { 'requires_capture' }++ context 'when capture_method is manual' do+ let(:capture_method) { 'manual' }++ it { is_expected.to be(true) }+ end++ context 'when capture_method is automatic' do+ let(:capture_method) { 'automatic' }++ it { is_expected.to be(false) }+ end+ end+ end++ context 'for a sepa debit payment method' do+ let(:payment_method_type) { 'sepa_debit' }++ context 'when the payment intent is succeeded' do+ let(:payment_intent_status) { 'succeeded' }++ it { is_expected.to be(true) }+ end++ context 'when the payment intent is processing' do+ let(:payment_intent_status) { 'processing' }++ it { is_expected.to be(true) }+ end++ context 'when the payment intent status is requires_action' do+ let(:payment_intent_status) { 'requires_action' }++ it { is_expected.to be(false) }+ end++ context 'when the payment intent is failed' do+ let(:payment_intent_status) { 'failed' }++ it { is_expected.to be(false) }+ end+ end++ context 'for a bank transfer payment method' do+ let(:payment_method_type) { 'customer_balance' }++ context 'when the payment intent is succeeded' do+ let(:payment_intent_status) { 'succeeded' }++ it { is_expected.to be(true) }+ end++ context 'when the payment intent is processing' do+ let(:payment_intent_status) { 'processing' }++ it { is_expected.to be(false) }+ end++ context 'when the payment intent status is requires_action' do+ let(:payment_intent_status) { 'requires_action' }++ it { is_expected.to be(true) }+ end++ context 'when the payment intent is failed' do+ let(:payment_intent_status) { 'failed' }++ it { is_expected.to be(false) }+ end+ end++ context 'for a us bank account payment method' do+ let(:payment_method_type) { 'us_bank_account' }++ context 'when the payment intent is succeeded' do+ let(:payment_intent_status) { 'succeeded' }++ it { is_expected.to be(true) }+ end++ context 'when the payment intent is processing' do+ let(:payment_intent_status) { 'processing' }++ it { is_expected.to be(true) }+ end++ context 'when the payment intent status is requires_action' do+ let(:payment_intent_status) { 'requires_action' }++ it { is_expected.to be(true) }+ end++ context 'when the payment intent is failed' do+ let(:payment_intent_status) { 'failed' }++ it { is_expected.to be(false) }+ end+ end+ end++ describe '#payment_intent_delayed_notification?' do+ subject { gateway.payment_intent_delayed_notification?(stripe_payment_intent) }++ let(:stripe_payment_intent) do+ Stripe::StripeObject.construct_from(+ id: 'pi_123',+ status: 'succeeded',+ payment_method: stripe_payment_method+ )+ end++ let(:stripe_payment_method) do+ { type: payment_method_type }+ end++ context 'for a card payment method' do+ let(:payment_method_type) { 'card' }++ it { is_expected.to be(false) }+ end++ context 'for a sepa debit payment method' do+ let(:payment_method_type) { 'sepa_debit' }++ it { is_expected.to be(true) }+ end++ context 'when the payment method is not expanded' do+ let(:stripe_payment_method) { 'pm_1234567890' }++ it { is_expected.to be(false) }+ end++ context 'when the payment method type is not provided' do+ let(:stripe_payment_method) { nil }++ it { is_expected.to be(false) }+ end+ end++ describe '#payment_intent_charge_not_required?' do+ subject { gateway.payment_intent_charge_not_required?(stripe_payment_intent) }++ let(:stripe_payment_intent) do+ Stripe::StripeObject.construct_from(+ id: 'pi_123',+ status: 'succeeded',+ payment_method: stripe_payment_method+ )+ end++ let(:stripe_payment_method) do+ { type: payment_method_type }+ end++ context 'for a card payment method' do+ let(:payment_method_type) { 'card' }++ it { is_expected.to be(false) }+ end++ context 'for a customer_balance payment method' do+ let(:payment_method_type) { 'customer_balance' }++ it { is_expected.to be(true) }+ end++ context 'for a us_bank_account payment method' do+ let(:payment_method_type) { 'us_bank_account' }++ it { is_expected.to be(true) }+ end++ context 'when the payment method is not expanded' do+ let(:stripe_payment_method) { 'pm_1234567890' }++ it { is_expected.to be(false) }+ end++ context 'when the payment method type is not provided' do+ let(:stripe_payment_method) { nil }++ it { is_expected.to be(false) }+ end+ end++ describe '#payment_intent_manual_capture?' do+ subject { gateway.payment_intent_manual_capture?(stripe_pi) }++ let(:stripe_pi) { Stripe::StripeObject.construct_from(id: 'pi_x', capture_method: capture_method) }++ context 'when capture_method is manual' do+ let(:capture_method) { 'manual' }++ it { is_expected.to be(true) }+ end++ context 'when capture_method is automatic' do+ let(:capture_method) { 'automatic' }++ it { is_expected.to be(false) }+ end++ context 'when capture_method is missing' do+ let(:stripe_pi) { Stripe::StripeObject.construct_from(id: 'pi_x') }++ it { is_expected.to be(false) }+ end+ end++ describe '#payment_intent_requires_capture?' do+ subject { gateway.payment_intent_requires_capture?(stripe_pi) }++ let(:stripe_pi) { Stripe::StripeObject.construct_from(id: 'pi_x', status: status) }++ context 'when status is requires_capture' do+ let(:status) { 'requires_capture' }++ it { is_expected.to be(true) }+ end++ context 'when status is succeeded' do+ let(:status) { 'succeeded' }++ it { is_expected.to be(false) }+ end+ end++ describe '#webhook_url' do+ subject { gateway.webhook_url }++ it 'returns the core payment webhook url' do+ expect(subject).to eq("#{store.url_or_custom_domain}/api/v3/webhooks/payments/#{gateway.prefixed_id}")+ end+ end++ describe '#after_commit :register_domains' do+ subject(:create_gateway) { gateway }++ it 'schedules a job to register the Apple Pay store domain' do+ expect { create_gateway }.to have_enqueued_job(SpreeStripe::RegisterDomainJob).once.with(store.id, 'store')+ end++ context 'on update' do+ before { create_gateway }++ it 'does nothing' do+ expect { gateway.update!(name: 'test') }.not_to have_enqueued_job(SpreeStripe::RegisterDomainJob)+ end+ end+ end++ describe '#create_payment_intent' do+ subject { gateway.create_payment_intent(amount, order) }++ let(:order) { create(:order_with_line_items, store: store) }++ let(:payment_intent_id) { 'pi_3QXmfC2ESifGlJez0qSmz8Vf' }++ it 'creates a payment intent' do+ VCR.use_cassette('create_payment_intent') do+ expect(subject.success?).to be(true)+ expect(subject.authorization).to eq(payment_intent_id)+ end+ end++ context 'when shipping address is invalid' do+ let(:order) do+ build(+ :order_with_line_items,+ ship_address: build(:address, address1: nil),+ store: store+ )+ end++ let(:payment_intent_id) { 'pi_3QY1a32ESifGlJez0k9YRZnS' }++ it 'creates the payment intent without shipping address' do+ VCR.use_cassette('create_payment_intent_invalid_address') do+ expect(subject.success?).to be(true)+ expect(subject.authorization).to eq(payment_intent_id)+ expect(subject.params['shipping']).to be_nil+ end+ end+ end++ context 'when auto_capture is false on the gateway' do+ before { gateway.update!(auto_capture: false) }++ it 'forwards capture_method: manual to the PaymentIntentPresenter' do+ expect(SpreeStripe::PaymentIntentPresenter).to receive(:new).with(+ hash_including(capture_method: 'manual')+ ).and_call_original++ VCR.use_cassette('create_payment_intent_manual_capture') do+ expect(subject.success?).to be(true)+ expect(subject.params['capture_method']).to eq('manual')+ expect(subject.params['status']).to eq('requires_payment_method')+ end+ end+ end++ context 'when auto_capture is true on the gateway' do+ before { gateway.update!(auto_capture: true) }++ it 'does not forward capture_method to the PaymentIntentPresenter' do+ expect(SpreeStripe::PaymentIntentPresenter).to receive(:new).with(+ hash_including(capture_method: nil)+ ).and_call_original++ VCR.use_cassette('create_payment_intent') do+ expect(subject.success?).to be(true)+ end+ end+ end+ end++ describe '#update_payment_intent' do+ subject { gateway.update_payment_intent(payment_intent_id, amount, order, payment_method_id) }++ let!(:gateway_customer) { create(:gateway_customer, customer: order.customer, payment_method: gateway, profile_id: customer_id) }+ let(:order) { create(:order_with_line_items, store: store) }++ let(:amount) { 4000 }+ let(:payment_method_id) { nil }++ let(:customer_id) { 'cus_RQdclxFVLH4oau' }+ let(:payment_intent_id) { 'pi_3QY2qD2ESifGlJez0VuzXjwK' }++ context 'when the amount is different' do+ let(:amount) { 6000 }++ it 'updates the payment intent with a new amount' do+ VCR.use_cassette('update_payment_intent_new_amount') do+ expect(subject.success?).to be(true)+ expect(subject.authorization).to eq(payment_intent_id)+ expect(subject.params['amount']).to eq(6000)+ end+ end+ end++ context 'when the shipping address is different' do+ let(:address) do+ create(+ :address,+ firstname: 'Jane',+ lastname: 'Zoe',+ address1: '100 California Street',+ address2: nil,+ city: 'San Francisco',+ zipcode: '94111',+ state: california_state,+ country: usa_country+ )+ end++ let(:usa_country) { Spree::Country.by_iso('US') || create(:country_us) }+ let(:california_state) { usa_country.states.find_by(abbr: 'CA') || create(:state, name: 'California', abbr: 'CA', country: usa_country) }++ before do+ order.update!(shipping_address: address)+ end++ it 'updates the payment intent with a new address' do+ VCR.use_cassette('update_payment_intent_new_address') do+ expect(subject.success?).to be(true)+ expect(subject.authorization).to eq(payment_intent_id)++ expect(subject.params['shipping']['name']).to eq('Jane Zoe')+ expect(subject.params['shipping']['address']).to eq(+ 'city' => 'San Francisco',+ 'country' => 'US',+ 'line1' => '100 California Street',+ 'line2' => nil,+ 'postal_code' => '94111',+ 'state' => 'CA'+ )+ end+ end+ end++ context 'when giving a payment method' do+ let(:payment_method_id) { 'pm_1QXmPJ2ESifGlJezC2py6ZqS' }++ it 'updates the payment intent with a payment method' do+ VCR.use_cassette('update_payment_intent_payment_method') do+ expect(subject.success?).to be(true)+ expect(subject.authorization).to eq(payment_intent_id)+ expect(subject.params['payment_method']).to eq(payment_method_id)+ end+ end+ end+ end++ describe '#cancel' do+ subject { gateway.cancel(payment_intent_id, payment) }++ let!(:refund_reason) { Spree::RefundReason.first || create(:default_refund_reason) }++ context 'when payment is completed' do+ let!(:order) { create(:order, store: store, total: 10, customer: create(:customer)) }+ let!(:gateway_customer) { create(:gateway_customer, customer: order.customer, payment_method: gateway) }++ let!(:payment) { create(:payment, state: 'completed', order: order, payment_method: gateway, amount: 10.0, response_code: payment_intent_id) }+ let!(:refund) { create(:refund, payment: payment, amount: 2.0) }++ let(:payment_intent_id) { 'pi_3QXmL12ESifGlJez0v0B8tUn' }+ let(:refund_id) { 're_3QXmL12ESifGlJez0GcOBHng' }++ it 'creates a refund with credit_allowed_amount' do+ VCR.use_cassette('create_refund') do+ expect { subject }.to change(Spree::Refund, :count).by(1)++ expect(payment.refunds.last.amount).to eq(8.0)++ expect(subject.success?).to be(true)+ expect(subject.authorization).to eq(payment_intent_id)++ expect(subject.params['id']).to eq(refund_id)+ expect(subject.params['status']).to eq('succeeded')+ expect(subject.params['payment_intent']).to eq(payment_intent_id)+ expect(subject.params['object']).to eq('refund')+ expect(subject.params['amount']).to eq(800)+ end+ end++ context 'if amount to refund is zero' do+ let!(:refund) { create(:refund, payment: payment, amount: payment.amount) }++ it 'does not create refund' do+ expect { subject }.not_to change(Spree::Refund, :count)++ expect(subject.success?).to be true+ expect(subject.authorization).to eq(payment_intent_id)+ end+ end+ end++ context 'when payment is not completed' do+ let!(:payment) { create(:payment, response_code: payment_intent_id) }++ let(:payment_intent_id) { 'pi_3QY1o72ESifGlJez06ZbKHjy' }++ it 'cancels the payment intent' do+ VCR.use_cassette('cancel_payment_intent') do+ expect { subject }.not_to change(Spree::Refund, :count)++ expect(subject.success?).to be(true)+ expect(subject.authorization).to eq(payment_intent_id)+ expect(subject.params['status']).to eq('canceled')+ end+ end+ end+ end++ describe '#credit' do+ subject { gateway.credit(amount_in_cents, nil, payment_intent_id, {}) }++ let(:amount_in_cents) { 800 }+ let(:payment_intent_id) { 'pi_3QXmL12ESifGlJez0v0B8tUn' }++ let(:refund_id) { 're_3QXmL12ESifGlJez0GcOBHng' }++ it 'refunds some of the payment amount' do+ VCR.use_cassette('create_refund') do+ expect(subject.success?).to be(true)+ expect(subject.authorization).to eq(refund_id)++ expect(subject.params['id']).to eq(refund_id)+ expect(subject.params['status']).to eq('succeeded')+ expect(subject.params['payment_intent']).to eq(payment_intent_id)+ expect(subject.params['object']).to eq('refund')+ expect(subject.params['amount']).to eq(800)+ end+ end+ end++ describe '#void' do+ subject(:void) { gateway.void(payment_intent_id, nil, nil) }++ let(:payment_intent_id) { 'pi_3QY1o72ESifGlJez06ZbKHjy' }++ it 'voids the payment intent' do+ VCR.use_cassette('cancel_payment_intent') do+ expect(void.success?).to be(true)+ expect(void.authorization).to eq(payment_intent_id)+ end+ end++ context 'when no response code is provided' do+ let(:payment_intent_id) { nil }++ it 'returns a failure' do+ expect(void.success?).to be(false)+ expect(void.message).to eq('Response code is blank')+ end+ end+ end++ describe '#capture' do+ subject { gateway.capture(amount_in_cents, payment_intent_id) }++ let(:amount_in_cents) { 1000 }++ # A manual-capture intent is bootstrapped on Stripe so it sits in+ # `requires_capture` before `gateway.capture(...)` runs. The cassette records+ # both, which is faithful to a real auth-then-capture flow.+ context 'when the payment intent is in requires_capture state' do+ let(:payment_intent_id) do+ Stripe::PaymentIntent.create(+ {+ amount: amount_in_cents,+ currency: 'usd',+ payment_method: 'pm_card_visa',+ confirm: true,+ capture_method: 'manual',+ automatic_payment_methods: { enabled: true, allow_redirects: 'never' }+ },+ { api_key: gateway.preferred_secret_key }+ ).id+ end++ it 'captures the payment intent through Stripe' do+ VCR.use_cassette('capture_payment_intent_requires_capture') do+ expect(subject.success?).to be(true)+ expect(subject.authorization).to eq(payment_intent_id)+ expect(subject.params['status']).to eq('succeeded')+ expect(subject.params['amount_received']).to eq(amount_in_cents)+ end+ end+ end++ context 'when the payment intent is already succeeded (idempotent capture)' do+ let(:payment_intent_id) do+ Stripe::PaymentIntent.create(+ {+ amount: amount_in_cents,+ currency: 'usd',+ payment_method: 'pm_card_visa',+ confirm: true,+ automatic_payment_methods: { enabled: true, allow_redirects: 'never' }+ },+ { api_key: gateway.preferred_secret_key }+ ).id+ end++ it 'returns the existing payment intent without re-capturing' do+ VCR.use_cassette('capture_payment_intent_already_succeeded') do+ expect(subject.success?).to be(true)+ expect(subject.params['status']).to eq('succeeded')+ end+ end+ end++ context 'when the payment intent is in an unsupported state' do+ let(:payment_intent_id) do+ Stripe::PaymentIntent.create(+ {+ amount: amount_in_cents,+ currency: 'usd',+ automatic_payment_methods: { enabled: true, allow_redirects: 'never' }+ },+ { api_key: gateway.preferred_secret_key }+ ).id+ end++ it 'raises a GatewayError' do+ VCR.use_cassette('capture_payment_intent_unsupported_state') do+ expect { subject }.to raise_error(Spree::Core::GatewayError, /Payment intent status is/)+ end+ end+ end+ end++ describe '#purchase' do+ subject { gateway.purchase(amount_in_cents, credit_card, { order_id: order_id }) }++ let(:amount_in_cents) { 1000 }+ let(:order_id) { "#{order.number}-#{payment.number}" }++ let!(:order) { create(:order_with_line_items, store: store, number: 'R111098765', customer: create(:customer)) }+ let!(:gateway_customer) { create(:gateway_customer, customer: order.customer, payment_method: gateway) }+ let!(:credit_card) { create(:credit_card, gateway_payment_profile_id: payment_method_id, payment_method: gateway) }+ let!(:payment) do+ create(:payment, number: 'ABC1DEF2', amount: order.total, payment_method: gateway, order: order,+ source: credit_card, response_code: payment_intent_id)+ end++ let(:payment_method_id) { 'pm_1QXmPJ2ESifGlJezC2py6ZqS' }+ let(:payment_intent_id) { 'pi_3QY1y22ESifGlJez12haN8ah' }++ it 'reads back the already confirmed payment intent' do+ VCR.use_cassette('create_payment_intent_with_payment_method') do+ expect(subject.success?).to be true++ expect(subject.authorization).to eq(payment_intent_id)+ expect(subject.params['status']).to eq('succeeded')+ expect(subject.params['amount']).to eq(amount_in_cents)+ end+ end++ context 'when the order id is malformed' do+ let(:order_id) { 'missing' }++ it 'returns failure' do+ expect(subject.success?).to be(false)+ expect(subject.message).to eq('Payment number is invalid')+ end+ end++ context 'when the payment has no payment intent' do+ let(:payment_intent_id) { nil }++ it 'returns failure' do+ expect(subject.success?).to be(false)+ expect(subject.message).to eq('Payment is missing a payment intent')+ end+ end+ end++ describe '#fetch_or_create_customer' do+ subject { gateway.fetch_or_create_customer(order: order, customer: customer) }++ let(:customer) { create(:customer) }+ let(:order) { nil }++ context 'when a gateway customer already exists' do+ let!(:gateway_customer) { create(:gateway_customer, customer: customer, payment_method: gateway) }++ it 'returns the existing record without calling Stripe' do+ expect { expect(subject).to eq(gateway_customer) }.not_to change(Spree::GatewayCustomer, :count)+ end+ end++ context 'when neither an order nor a customer is given' do+ let(:customer) { nil }++ it 'returns nil' do+ expect(subject).to be_nil+ end+ end+ end++ describe '#create_customer' do+ subject { gateway.create_customer(order: order, customer: customer) }++ let(:order) { create(:order_with_line_items, store: store, customer: customer, bill_address: bill_address, email: '[email protected]') }+ let(:customer) { create(:customer, email: '[email protected]', first_name: 'Jane', last_name: 'Moe', bill_address: customer_bill_address) }++ let(:bill_address) do+ create(+ :address,+ city: 'San Francisco',+ address1: '100 California Street',+ address2: 'Apt 1',+ zipcode: '94111',+ state: california_state,+ country: usa_country,+ firstname: 'John',+ lastname: 'Doe',+ phone: '1234567890'+ )+ end++ let(:customer_bill_address) do+ create(+ :address,+ city: 'New York',+ address1: '100 Main Street',+ address2: 'Apt 2',+ zipcode: '10001',+ state: new_york_state,+ country: usa_country+ )+ end++ let(:usa_country) { Spree::Country.by_iso('US') || create(:country_us) }+ let(:california_state) { usa_country.states.find_by(abbr: 'CA') || create(:state, name: 'California', abbr: 'CA', country: usa_country) }+ let(:new_york_state) { usa_country.states.find_by(abbr: 'NY') || create(:state, name: 'New York', abbr: 'NY', country: usa_country) }++ let(:gateway_customer) { Spree::GatewayCustomer.stripe.last }++ it 'creates a new Stripe customer and gateway customer record' do+ VCR.use_cassette('create_customer') do+ expect { subject }.to change(Spree::GatewayCustomer, :count).by(1)++ expect(subject).to eq(gateway_customer)+ expect(subject.customer).to eq(customer)+ expect(subject.profile_id).to eq(gateway_customer.profile_id)+ expect(subject.payment_method).to eq(gateway)+ expect(subject.persisted?).to be(true)+ end+ end++ it 'builds the Stripe payload from the order' do+ expect(SpreeStripe::CustomerPresenter).to receive(:new).with(+ name: order.name, email: order.email, address: bill_address+ ).and_call_original++ VCR.use_cassette('create_customer') { subject }+ end++ context 'when customer is nil' do+ let(:customer) { nil }+ let(:order) { create(:order_with_line_items, store: store, customer: nil, bill_address: bill_address, email: '[email protected]') }++ it 'creates a customer but does not save the gateway customer record' do+ VCR.use_cassette('create_customer') do+ expect { subject }.not_to change(Spree::GatewayCustomer, :count)++ expect(subject).to be_new_record+ expect(subject.customer).to be_nil+ expect(subject.profile_id).to be_present+ expect(subject.payment_method).to eq(gateway)+ end+ end+ end++ context 'when only a customer is provided' do+ subject { gateway.create_customer(customer: customer) }++ it 'creates a customer using only the customer information' do+ VCR.use_cassette('create_customer_based_on_user') do+ expect { subject }.to change(Spree::GatewayCustomer, :count).by(1)++ expect(subject).to eq(gateway_customer)+ expect(subject.customer).to eq(customer)+ expect(subject.persisted?).to be(true)+ end+ end++ it 'builds the Stripe payload from the customer' do+ expect(SpreeStripe::CustomerPresenter).to receive(:new).with(+ name: customer.full_name, email: customer.email, address: customer_bill_address+ ).and_call_original++ VCR.use_cassette('create_customer_based_on_user') { subject }+ end+ end+ end++ describe '#update_customer' do+ subject { gateway.update_customer(order: order, customer: customer) }++ let(:order) { create(:order_with_line_items, store: store, customer: customer, bill_address: bill_address) }+ let(:customer) { create(:customer, email: '[email protected]', first_name: 'Jane', last_name: 'Moe', bill_address: customer_bill_address) }++ let(:bill_address) do+ create(+ :address,+ city: 'San Francisco',+ address1: '200 California Street',+ address2: 'Apt 11',+ zipcode: '94112',+ state: california_state,+ country: usa_country,+ firstname: 'John',+ lastname: 'Doe'+ )+ end++ let(:customer_bill_address) do+ create(+ :address,+ city: 'New York',+ address1: '200 Main Street',+ address2: 'Apt 22',+ zipcode: '10002',+ state: new_york_state,+ country: usa_country+ )+ end++ let(:usa_country) { Spree::Country.by_iso('US') || create(:country_us) }+ let(:california_state) { usa_country.states.find_by(abbr: 'CA') || create(:state, name: 'California', abbr: 'CA', country: usa_country) }+ let(:new_york_state) { usa_country.states.find_by(abbr: 'NY') || create(:state, name: 'New York', abbr: 'NY', country: usa_country) }++ let!(:gateway_customer) { create(:gateway_customer, customer: customer, profile_id: customer_id, payment_method: gateway) }+ let(:customer_id) { 'cus_SeIsxI1TG3dGJv' }++ it 'updates the existing Stripe customer' do+ VCR.use_cassette('update_customer') do+ expect { subject }.not_to change(Spree::GatewayCustomer, :count)++ expect(subject.id).to eq(customer_id)+ end+ end++ context 'when customer is nil' do+ let(:customer) { nil }+ let(:gateway_customer) { nil }+ let(:order) { create(:order_with_line_items, store: store, customer: nil, bill_address: bill_address) }++ it 'does nothing' do+ expect(subject).to be_nil+ end+ end++ context 'when the gateway customer does not exist' do+ let(:gateway_customer) { nil }++ it 'does nothing' do+ expect(subject).to be_nil+ end+ end++ context 'when only a customer is provided' do+ subject { gateway.update_customer(customer: customer) }++ it 'updates the customer using only the customer information' do+ VCR.use_cassette('update_customer_based_on_user') do+ expect { subject }.not_to change(Spree::GatewayCustomer, :count)++ expect(subject.id).to eq(customer_id)+ end+ end+ end+ end++ describe 'being a provider' do+ let(:provider_methods) { %i[authorize purchase capture void credit] }++ it 'implements provider methods without delegating back to itself' do+ provider_methods.each do |method|+ expect(gateway).to respond_to method+ expect { gateway.send(method) }.to raise_error(ArgumentError)+ end+ end+ end++ describe '#setup_session_supported?' do+ it 'returns true' do+ expect(gateway.setup_session_supported?).to be(true)+ end+ end++ describe '#payment_setup_session_class' do+ it 'returns the Stripe STI subclass' do+ expect(gateway.payment_setup_session_class).to eq(Spree::PaymentSetupSessions::Stripe)+ end+ end++ describe '#create_payment_setup_session' do+ subject { gateway.create_payment_setup_session(customer: customer) }++ let(:customer) { create(:customer) }++ context 'when the customer has no saved Stripe customer' do+ it 'creates the gateway customer and a Stripe payment setup session' do+ VCR.use_cassette('create_payment_setup_session') do+ expect { subject }.to change(gateway.gateway_customers, :count).by(1).+ and change(Spree::PaymentSetupSession, :count).by(1)++ expect(subject).to be_a(Spree::PaymentSetupSessions::Stripe)+ expect(subject).to be_persisted+ expect(subject.customer).to eq(customer)+ expect(subject.payment_method).to eq(gateway)+ expect(subject.status).to eq('pending')+ expect(subject.external_id).to start_with('seti_')+ expect(subject.external_client_secret).to include('_secret_')+ expect(subject.external_data['customer_id']).to start_with('cus_')+ expect(subject.external_data['ephemeral_key_secret']).to start_with('ek_test_')+ end+ end+ end++ context 'when the customer has a saved Stripe customer' do+ let(:saved_customer_id) { 'cus_USE66TMAPae0UB' }+ let!(:gateway_customer) { create(:gateway_customer, customer: customer, profile_id: saved_customer_id, payment_method: gateway) }++ it 'reuses the saved customer for the setup session' do+ VCR.use_cassette('create_payment_setup_session_existing_customer') do+ expect { subject }.to_not change(gateway.gateway_customers, :count)+ expect(subject).to be_persisted+ expect(subject.external_data['customer_id']).to eq(saved_customer_id)+ end+ end+ end++ context 'when external_data is provided' do+ subject { gateway.create_payment_setup_session(customer: customer, external_data: { 'foo' => 'bar' }) }++ it 'merges the provided data into external_data' do+ VCR.use_cassette('create_payment_setup_session') do+ expect(subject.external_data).to include('foo' => 'bar')+ expect(subject.external_data).to include('customer_id', 'ephemeral_key_secret')+ end+ end+ end+ end++ describe '#complete_payment_setup_session' do+ subject { gateway.complete_payment_setup_session(setup_session: setup_session) }++ let(:customer) { create(:customer) }+ let!(:gateway_customer) { create(:gateway_customer, customer: customer, payment_method: gateway, profile_id: 'cus_test') }+ let(:setup_session) do+ create(:stripe_payment_setup_session,+ customer: customer,+ payment_method: gateway,+ external_id: 'seti_test_xyz',+ external_client_secret: 'seti_test_xyz_secret',+ external_data: { 'customer_id' => 'cus_test' })+ end++ let(:stripe_payment_method) do+ Stripe::StripeObject.construct_from(+ id: 'pm_card_visa',+ type: 'card',+ billing_details: { name: 'Jane Doe' },+ card: {+ brand: 'visa',+ last4: '4242',+ exp_month: 12,+ exp_year: 2030,+ fingerprint: 'FZqjhq46SWprIY8i',+ checks: nil,+ wallet: nil+ }+ )+ end++ context 'when the SetupIntent succeeded' do+ let(:stripe_setup_intent) do+ Stripe::StripeObject.construct_from(+ id: 'seti_test_xyz',+ status: 'succeeded',+ payment_method: stripe_payment_method+ )+ end++ before do+ allow(gateway).to receive(:retrieve_setup_intent).with('seti_test_xyz').and_return(stripe_setup_intent)+ end++ it 'creates a payment source and completes the session' do+ expect { subject }.to change(Spree::CreditCard, :count).by(1)++ setup_session.reload+ expect(setup_session.status).to eq('completed')+ expect(setup_session.payment_source).to be_a(Spree::CreditCard)+ expect(setup_session.payment_source.gateway_payment_profile_id).to eq('pm_card_visa')+ expect(setup_session.payment_source.customer).to eq(customer)+ end+ end++ context 'when the SetupIntent has not succeeded' do+ let(:stripe_setup_intent) do+ Stripe::StripeObject.construct_from(+ id: 'seti_test_xyz',+ status: 'requires_payment_method',+ payment_method: nil+ )+ end++ before do+ allow(gateway).to receive(:retrieve_setup_intent).with('seti_test_xyz').and_return(stripe_setup_intent)+ end++ it 'fails the session without creating a source' do+ expect(SpreeStripe::CreateSource).not_to receive(:new)+ expect { subject }.not_to change(Spree::CreditCard, :count)++ setup_session.reload+ expect(setup_session.status).to eq('failed')+ expect(setup_session.payment_source).to be_nil+ end+ end+ end++ describe '#parse_webhook_event' do+ subject(:result) { gateway.parse_webhook_event(raw_body, headers) }++ let(:order) { create(:order_with_line_items, store: store) }+ let(:raw_body) { '{"id": "evt_test"}' }+ let(:headers) { { 'HTTP_STRIPE_SIGNATURE' => 'sig_test' } }++ let!(:payment_session) do+ create(:stripe_payment_session, owner: order, payment_method: gateway, external_id: 'pi_webhook_999')+ end++ let(:stripe_event) do+ Stripe::StripeObject.construct_from(+ type: 'payment_intent.amount_capturable_updated',+ data: { object: { id: 'pi_webhook_999' } }+ )+ end++ context 'when the signature is valid' do+ before do+ allow(Stripe::Webhook).to receive(:construct_event).and_return(stripe_event)+ end++ let(:gateway) { create(:stripe_gateway, :with_webhook_signing_secret, store: store) }++ it 'verifies the signature against the gateway preference' do+ expect(Stripe::Webhook).to receive(:construct_event).with(raw_body, 'sig_test', 'whsec_test_1234567890')++ expect(result[:action]).to eq(:authorized)+ expect(result[:payment_session]).to eq(payment_session)+ end+ end++ context 'when the signature does not verify against any known secret' do+ let(:gateway) { create(:stripe_gateway, :with_webhook_signing_secret, store: store) }++ before do+ allow(Stripe::Webhook).to receive(:construct_event).and_raise(Stripe::SignatureVerificationError.new('bad', 'sig_test'))+ end++ it 'raises a WebhookSignatureError' do+ expect { result }.to raise_error(Spree::PaymentMethod::WebhookSignatureError)+ end+ end+ end++ describe 'webhook endpoint registration' do+ it 'enqueues the registration job on create' do+ expect { gateway }.to have_enqueued_job(SpreeStripe::CreateWebhookEndpointJob)+ end++ context 'when the signing secret is already stored' do+ it 'does not enqueue the registration job' do+ expect do+ create(:stripe_gateway, :with_webhook_signing_secret, store: store)+ end.not_to have_enqueued_job(SpreeStripe::CreateWebhookEndpointJob)+ end+ end+ end+enddiff --git a/spree/providers/stripe/spec/presenters/spree_stripe/payment_intent_presenter_spec.rb b/spree/providers/stripe/spec/presenters/spree_stripe/payment_intent_presenter_spec.rbnew file mode 100644index 0000000000..6d2f6a2ca4--- /dev/null+++ b/spree/providers/stripe/spec/presenters/spree_stripe/payment_intent_presenter_spec.rb@@ -0,0 +1,154 @@+require 'spec_helper'++RSpec.describe SpreeStripe::PaymentIntentPresenter do+ subject { presenter.call }++ let(:presenter) do+ described_class.new(+ amount: amount,+ order: order,+ customer: customer,+ payment_method_id: payment_method_id+ )+ end++ let(:order_number) { 'R123456789' }+ let(:store) { @default_store }+ let(:order) { create(:order, number: order_number, store: store) }+ let(:customer) { 'cus_123' }+ let(:amount) { 100 }+ let(:payment_method_id) { nil }++ let(:statement_descriptor_prefix) { 'ORDER123' }+ let(:statement_descriptor_stub) do+ instance_double(SpreeStripe::StatementDescriptorSuffixPresenter, call: statement_descriptor_prefix)+ end++ let(:base_payload) do+ {+ amount: amount,+ customer: customer,+ currency: order.currency,+ statement_descriptor_suffix: statement_descriptor_prefix,+ automatic_payment_methods: { enabled: true },+ transfer_group: order.number,+ metadata: { spree_order_id: order.id }+ }+ end++ let(:new_payment_method_payload) do+ {+ payment_method_options: {+ card: { setup_future_usage: 'off_session' },+ sepa_debit: { setup_future_usage: 'off_session' }+ }+ }+ end++ before do+ allow(SpreeStripe::StatementDescriptorSuffixPresenter).to receive(:new).+ with(order_description: order.number).and_return(statement_descriptor_stub)+ end++ context 'when payment_method_id is present' do+ let(:payment_method_id) { 'pm_123' }++ it 'returns a payload with the saved payment method' do+ expect(subject).to eq(base_payload.merge(payment_method: payment_method_id))+ end+ end++ context 'when payment_method_id is not present' do+ it 'returns a payload asking Stripe to save the new payment method' do+ expect(subject).to eq(base_payload.merge(new_payment_method_payload))+ end+ end++ context 'when the order has no customer' do+ let(:order) { create(:order, customer: nil, email: '[email protected]', number: order_number, store: store) }++ it 'returns a payload asking Stripe to save the new payment method' do+ expect(subject).to eq(base_payload.merge(new_payment_method_payload))+ end+ end++ context 'when ship_address is present' do+ let(:ship_address) { create(:address) }++ before { allow(order).to receive(:ship_address).and_return(ship_address) }++ it 'returns a payload with the shipping address' do+ expect(subject).to eq(+ base_payload.merge(new_payment_method_payload).merge(+ shipping: {+ address: {+ city: ship_address.city,+ country: ship_address.country_iso,+ line1: ship_address.address1,+ line2: ship_address.address2,+ postal_code: ship_address.zipcode,+ state: ship_address.state_abbr+ },+ name: ship_address.full_name+ }+ )+ )+ end++ context 'when the ship address has no address1' do+ let(:ship_address) { build(:address, address1: nil) }++ it 'omits the shipping address, which Stripe would reject' do+ expect(subject).not_to have_key(:shipping)+ end+ end+ end++ describe 'capture_method handling' do+ context 'when capture_method is nil (default)' do+ it 'does not include capture_method in the payload' do+ expect(subject).not_to have_key(:capture_method)+ end+ end++ context 'when capture_method is "manual"' do+ let(:presenter) do+ described_class.new(+ amount: amount,+ order: order,+ customer: customer,+ payment_method_id: payment_method_id,+ capture_method: 'manual'+ )+ end++ it 'includes capture_method: manual in the payload (new payment method flow)' do+ expect(subject[:capture_method]).to eq('manual')+ end++ context 'with a saved payment method' do+ let(:payment_method_id) { 'pm_123' }++ it 'includes capture_method: manual in the payload' do+ expect(subject[:capture_method]).to eq('manual')+ end+ end+ end++ context 'when capture_method is "automatic"' do+ let(:presenter) do+ described_class.new(+ amount: amount,+ order: order,+ customer: customer,+ payment_method_id: payment_method_id,+ capture_method: 'automatic'+ )+ end++ it 'does not include capture_method (Stripe default)' do+ expect(subject).not_to have_key(:capture_method)+ end+ end+ end+enddiff --git a/spree/providers/stripe/spec/presenters/spree_stripe/statement_descriptor_suffix_presenter_spec.rb b/spree/providers/stripe/spec/presenters/spree_stripe/statement_descriptor_suffix_presenter_spec.rbnew file mode 100644index 0000000000..8ae1a0cd22--- /dev/null+++ b/spree/providers/stripe/spec/presenters/spree_stripe/statement_descriptor_suffix_presenter_spec.rb@@ -0,0 +1,78 @@+require 'spec_helper'++RSpec.describe SpreeStripe::StatementDescriptorSuffixPresenter do+ subject(:presenter) { described_class.new(order_description: order_description).call }++ context 'when order_description contains allowed characters' do+ let(:order_description) { 'Order123' }++ it 'returns the upcased order description' do+ expect(presenter).to eq('ORDER123')+ end+ end++ context 'when order_description contains not allowed characters' do+ let(:order_description) { "Order<1>'*2\\" }++ it 'removes not allowed characters' do+ expect(presenter).to eq('ORDER12')+ end+ end++ context 'when order_description contains lowercase and spaces' do+ let(:order_description) { 'order 123' }++ it 'upcases and trims spaces' do+ expect(presenter).to eq('ORDER 123')+ end+ end++ context 'when order_description is longer than max chars' do+ let(:order_description) { 'ABCDEFGHIJKL' }++ it 'truncates to max chars' do+ expect(presenter.length).to eq(described_class::STATEMENT_DESCRIPTOR_MAX_CHARS)+ expect(presenter).to eq('ABCDEFGHIJ')+ end+ end++ context 'when order_description contains unicode characters' do+ let(:order_description) { 'Café Über' }++ it 'transliterates unicode to ascii' do+ expect(presenter).to eq('CAFE UBER')+ end+ end++ context 'when order_description is blank' do+ let(:order_description) { '' }++ it 'returns nil' do+ expect(presenter).to be_nil+ end+ end++ context 'when order_description has leading and trailing spaces' do+ let(:order_description) { ' order 123 ' }++ it 'strips spaces' do+ expect(presenter).to eq('ORDER 123')+ end+ end++ context 'when order_description does not contain a letter' do+ let(:order_description) { '123' }++ it 'adds the prefix' do+ expect(presenter).to eq('O#123')+ end++ context 'when order_description is longer than max chars' do+ let(:order_description) { '12345678901' }++ it 'truncates to max chars' do+ expect(presenter).to eq('O#12345678')+ end+ end+ end+enddiff --git a/spree/providers/stripe/spec/services/spree_stripe/create_gateway_webhooks_spec.rb b/spree/providers/stripe/spec/services/spree_stripe/create_gateway_webhooks_spec.rbnew file mode 100644index 0000000000..5f6d17985f--- /dev/null+++ b/spree/providers/stripe/spec/services/spree_stripe/create_gateway_webhooks_spec.rb@@ -0,0 +1,71 @@+require 'spec_helper'++RSpec.describe SpreeStripe::CreateGatewayWebhooks do+ subject { described_class.new.call(payment_method: payment_method) }++ let(:store) { @default_store }+ let(:payment_method) { create(:stripe_gateway, store: store) }+ let(:webhook_url) { 'https://spreecommerce.org/stripe/' }++ let(:stripe_webhooks) { Stripe::WebhookEndpoint.list({}, payment_method.api_options)[:data] }+ let(:spree_webhook_endpoints) { stripe_webhooks.select { |webhook| webhook[:url] == webhook_url } }+ let(:stripe_webhook) { spree_webhook_endpoints.first }++ before { allow(payment_method).to receive(:webhook_url).and_return(webhook_url) }++ it 'creates a webhook endpoint and stores its credentials on the gateway', vcr: { cassette_name: 'create_gateway_webhooks' } do+ subject++ expect(stripe_webhook.enabled_events).to match_array(SpreeStripe::Gateway::Webhooks::SUPPORTED_EVENTS)+ expect(stripe_webhook.status).to eq('enabled')++ expect(payment_method.reload.preferred_webhook_endpoint_id).to eq(stripe_webhook.id)+ expect(payment_method.preferred_webhook_signing_secret).to eq('<STRIPE_WEBHOOK_SIGNING_SECRET>')+ end++ context 'when the gateway has no webhook url' do+ before { allow(payment_method).to receive(:webhook_url).and_return(nil) }++ it 'does nothing' do+ expect(Stripe::WebhookEndpoint).not_to receive(:list)+ expect(subject).to be_nil+ end+ end++ context 'when a matching endpoint already exists' do+ context 'and the gateway already holds its id and signing secret' do+ before do+ payment_method.update!(+ preferred_webhook_endpoint_id: 'we_1TUq8w2ESifGlJezdHC8YApb',+ preferred_webhook_signing_secret: 'whsec_already_known'+ )+ end++ it 'reuses it without registering a new one', vcr: { cassette_name: 'existing_gateway_webhooks' } do+ expect(Stripe::WebhookEndpoint).not_to receive(:create)+ expect(Stripe::WebhookEndpoint).not_to receive(:delete)++ expect(subject[:id]).to eq('we_1TUq8w2ESifGlJezdHC8YApb')+ expect(payment_method.reload.preferred_webhook_signing_secret).to eq('whsec_already_known')+ end+ end++ # Stripe only reveals the signing secret at creation time, so an endpoint we+ # cannot verify against has to be replaced.+ context 'and the gateway has no signing secret for it' do+ # The recorded endpoint is long gone from the Stripe account, so the+ # deletion is asserted rather than replayed.+ before { allow(Stripe::WebhookEndpoint).to receive(:delete) }++ it 'deletes the stale endpoint and registers a fresh one', vcr: { cassette_name: 'create_another_gateway_webhooks' } do+ subject++ expect(Stripe::WebhookEndpoint).to have_received(:delete).+ with('we_1TUq8w2ESifGlJezdHC8YApb', {}, payment_method.api_options)++ expect(payment_method.reload.preferred_webhook_endpoint_id).to eq('we_1TUq8x2ESifGlJezmllQ9fRC')+ expect(payment_method.preferred_webhook_signing_secret).to eq('<STRIPE_WEBHOOK_SIGNING_SECRET>')+ end+ end+ end+enddiff --git a/spree/providers/stripe/spec/services/spree_stripe/create_payment_session_spec.rb b/spree/providers/stripe/spec/services/spree_stripe/create_payment_session_spec.rbnew file mode 100644index 0000000000..8a6a16d5b0--- /dev/null+++ b/spree/providers/stripe/spec/services/spree_stripe/create_payment_session_spec.rb@@ -0,0 +1,51 @@+require 'spec_helper'++RSpec.describe SpreeStripe::CreatePaymentSession do+ subject(:session) { described_class.new.call(order, gateway) }++ let(:store) { @default_store }+ let(:gateway) { create(:stripe_gateway, store: store) }+ let(:order) { create(:order_with_line_items, store: store) }++ context 'when store credits cover the whole order (zero amount)' do+ before { allow(order).to receive(:total_minus_store_credits).and_return(0) }++ it 'skips Stripe and returns nil' do+ expect(gateway).not_to receive(:create_payment_session)+ expect(gateway).not_to receive(:update_payment_session)+ expect(session).to be_nil+ end+ end++ context 'when no pending session exists' do+ it 'creates one for the order' do+ new_session = instance_double(Spree::PaymentSessions::Stripe)+ expect(gateway).to receive(:create_payment_session).with(order: order).and_return(new_session)+ expect(session).to eq(new_session)+ end+ end++ context 'when a pending session exists with the current amount' do+ let!(:existing) do+ create(:stripe_payment_session, owner: order, payment_method: gateway, amount: order.total_minus_store_credits)+ end++ it 'reuses it without creating or updating' do+ expect(gateway).not_to receive(:create_payment_session)+ expect(gateway).not_to receive(:update_payment_session)+ expect(session).to eq(existing)+ end+ end++ context 'when a pending session exists with a stale amount' do+ let!(:existing) do+ create(:stripe_payment_session, owner: order, payment_method: gateway, amount: 1)+ end++ it 'syncs the amount before reusing it' do+ expect(gateway).to receive(:update_payment_session).+ with(payment_session: existing, amount: order.total_minus_store_credits)+ expect(session).to eq(existing)+ end+ end+enddiff --git a/spree/providers/stripe/spec/services/spree_stripe/create_payment_spec.rb b/spree/providers/stripe/spec/services/spree_stripe/create_payment_spec.rbnew file mode 100644index 0000000000..d3fb78b5f3--- /dev/null+++ b/spree/providers/stripe/spec/services/spree_stripe/create_payment_spec.rb@@ -0,0 +1,75 @@+require 'spec_helper'++RSpec.describe SpreeStripe::CreatePayment do+ subject(:create_payment) { described_class.new(owner: order, payment_session: payment_session, gateway: gateway).call }++ let(:store) { @default_store }+ let!(:order) { create(:order_with_line_items, store: store) }+ let!(:gateway) { create(:stripe_gateway, store: store) }++ let(:payment_session) do+ create(:stripe_payment_session, owner: order, payment_method: gateway, external_id: payment_intent_id)+ end++ let!(:gateway_customer) do+ create(:gateway_customer, customer: order.customer, payment_method: gateway, profile_id: customer_id)+ end++ let(:payment_intent_id) { 'pi_3QY76s2ESifGlJez04sj0cMb' }+ let(:customer_id) { 'cus_RQdclxFVLH4oau' }+ let(:payment_method_id) { 'pm_1QY4zO2ESifGlJezkHIvUraY' }++ let(:payment) { order.payments.last }++ it 'creates a payment with the data from the Stripe charge' do+ VCR.use_cassette('retrieve_payment_intent_charge') do+ expect { subject }.to change { order.payments.count }.by(1).and change { Spree::CreditCard.count }.by(1)+ end++ expect(subject).to be_a Spree::Payment++ expect(payment.payment_method).to eq gateway+ expect(payment.amount).to eq order.total_minus_store_credits+ expect(payment.response_code).to eq(payment_intent_id)+ expect(payment.stripe_charge_id).to eq('ch_3QY76s2ESifGlJez0gG0FoF1')++ expect(payment.source).to be_a Spree::CreditCard+ expect(payment.source.gateway_payment_profile_id).to eq(payment_method_id)+ expect(payment.source.customer).to eq order.customer+ expect(payment.source.cc_type).to eq('visa')+ expect(payment.source.last_digits).to eq('4242')+ expect(payment.source.month).to eq(2)+ expect(payment.source.year).to eq(2027)++ expect(payment.avs_response).to eq('Y')+ expect(payment.cvv_response_code).to be_nil+ end++ it 'only creates the payment once' do+ VCR.use_cassette('retrieve_payment_intent_charge') do+ expect { subject }.to change { order.payments.count }.by(1)+ expect { described_class.new(owner: order, payment_session: payment_session, gateway: gateway).call }.+ not_to change { order.payments.count }+ end+ end++ context 'when the payment intent is a bank transfer' do+ let(:payment_intent_id) { 'pi_3ScPMjFmGsiQWfE61qMaWSFF' }+ let(:customer_id) { 'cus_TZFk4Fxe9gABNI' }+ let(:payment_method_id) { 'pm_1ScPNbFmGsiQWfE6IQ5cXwYc' }++ it 'builds the source from the intent, since there is no charge' do+ VCR.use_cassette('retrieve_payment_intent_bank_transfer') do+ expect { subject }.to change { order.payments.count }.by(1)+ end++ expect(payment.payment_method).to eq(gateway)+ expect(payment.amount).to eq(order.total_minus_store_credits)+ expect(payment.response_code).to eq(payment_intent_id)+ expect(payment.stripe_charge_id).to be_nil++ expect(payment.source).to be_a SpreeStripe::PaymentSources::BankTransfer+ expect(payment.source.gateway_payment_profile_id).to eq(payment_method_id)+ end+ end+enddiff --git a/spree/providers/stripe/spec/services/spree_stripe/create_source_spec.rb b/spree/providers/stripe/spec/services/spree_stripe/create_source_spec.rbnew file mode 100644index 0000000000..fd36ed5076--- /dev/null+++ b/spree/providers/stripe/spec/services/spree_stripe/create_source_spec.rb@@ -0,0 +1,322 @@+require 'spec_helper'++RSpec.describe SpreeStripe::CreateSource do+ subject do+ described_class.new(+ customer: customer,+ owner: order,+ stripe_payment_method_id: source_id,+ stripe_payment_method_details: payment_method_details,+ gateway: gateway,+ stripe_billing_details: billing_details+ ).call+ end++ let(:store) { @default_store }+ let(:customer) { create(:customer) }+ let(:order) { create(:order, store: store, customer: customer) }+ let!(:gateway) { create(:stripe_gateway, store: store) }+ let(:source_id) { 'source_id' }++ let(:billing_details) { Stripe::StripeObject.construct_from(name: 'John Snow') }++ let(:payment_method_details) do+ Stripe::StripeObject.construct_from(+ card: Stripe::StripeObject.construct_from(+ brand: 'mastercard',+ checks: Stripe::StripeObject.construct_from(+ address_line1_check: 'unchecked',+ address_postal_code_check: 'unchecked',+ cvc_check: nil+ ),+ country: 'PL',+ exp_month: 11,+ exp_year: 2035,+ fingerprint: 'FZqjhq46SWprIY8i',+ funding: 'debit',+ installments: nil,+ last4: '3522',+ mandate: nil,+ network: 'mastercard',+ three_d_secure: nil,+ wallet: Stripe::StripeObject.construct_from(+ apple_pay: nil,+ dynamic_last4: '3139',+ type: 'apple_pay'+ )+ ),+ type: 'card'+ )+ end++ describe '#call' do+ context 'when there is no customer' do+ let(:customer) { nil }+ let(:order) { create(:order, store: store, customer: nil) }++ it 'creates a source not assigned to any customer' do+ expect { subject }.to change { Spree::CreditCard.count }.by 1+ expect(subject.customer).to be_nil+ end+ end++ context 'when the customer already has a card with the same profile id' do+ let!(:credit_card) { create(:credit_card, customer: customer, gateway_payment_profile_id: source_id) }++ it 'returns the already created card' do+ expect(subject).to eq(credit_card)+ end+ end++ context 'when the customer has no card yet' do+ let!(:gateway_customer) { create(:gateway_customer, customer: customer, payment_method: gateway) }++ it 'creates a new source' do+ expect { subject }.to change { customer.credit_cards.count }.by 1++ expect(subject.month).to eq 11+ expect(subject.year).to eq 2035+ expect(subject.last_digits).to eq '3522'+ expect(subject.fingerprint).to eq 'FZqjhq46SWprIY8i'+ expect(subject.gateway_payment_profile_id).to eq source_id+ expect(subject.customer).to eq customer+ expect(subject.brand).to eq 'master'+ expect(subject.payment_method).to eq gateway+ expect(subject.gateway_customer).to eq gateway_customer+ expect(subject.gateway_customer_profile_id).to eq gateway_customer.profile_id+ expect(subject.name).to eq 'John Snow'+ expect(subject.metadata).to eq(+ 'wallet' => { 'type' => 'apple_pay' },+ 'checks' => {+ 'address_line1_check' => 'unchecked',+ 'address_postal_code_check' => 'unchecked',+ 'cvc_check' => nil+ }+ )+ end+ end++ context 'deduplicating the same physical card by fingerprint' do+ let(:source_id) { 'pm_new' }+ let!(:gateway_customer) { create(:gateway_customer, customer: customer, payment_method: gateway) }++ context 'when the same card is presented again with a new gateway_payment_profile_id' do+ let!(:existing_card) do+ create(:credit_card,+ customer: customer,+ payment_method: gateway,+ gateway_payment_profile_id: 'pm_old',+ fingerprint: 'FZqjhq46SWprIY8i',+ month: 11,+ year: 2035,+ cc_type: 'master')+ end++ it 'reuses the existing card instead of creating a duplicate' do+ expect { subject }.not_to change { Spree::CreditCard.count }+ expect(subject).to eq(existing_card)+ end++ it 'leaves the existing gateway_payment_profile_id untouched' do+ subject+ expect(existing_card.reload.gateway_payment_profile_id).to eq('pm_old')+ end+ end++ context 'when a genuinely different card is presented (different fingerprint, same last4)' do+ let!(:existing_card) do+ create(:credit_card,+ customer: customer,+ payment_method: gateway,+ gateway_payment_profile_id: 'pm_old',+ fingerprint: 'someOtherFingerprint',+ month: 11,+ year: 2035,+ cc_type: 'master')+ end++ it 'creates a new card' do+ expect { subject }.to change { customer.credit_cards.count }.by 1+ end+ end++ context 'when the same card number is reissued with a new expiry' do+ let!(:existing_card) do+ create(:credit_card,+ customer: customer,+ payment_method: gateway,+ gateway_payment_profile_id: 'pm_old',+ fingerprint: 'FZqjhq46SWprIY8i',+ month: 12,+ year: 2040,+ cc_type: 'master')+ end++ it 'creates a new card' do+ expect { subject }.to change { customer.credit_cards.count }.by 1+ end+ end++ context 'when the incoming card has no fingerprint' do+ let(:payment_method_details) do+ Stripe::StripeObject.construct_from(+ card: Stripe::StripeObject.construct_from(+ brand: 'mastercard',+ checks: nil,+ exp_month: 11,+ exp_year: 2035,+ fingerprint: nil,+ last4: '3522',+ wallet: nil+ ),+ type: 'card'+ )+ end++ let!(:existing_card) do+ create(:credit_card,+ customer: customer,+ payment_method: gateway,+ gateway_payment_profile_id: 'pm_old',+ fingerprint: nil,+ month: 11,+ year: 2035,+ cc_type: 'master')+ end++ it 'creates a new card' do+ expect { subject }.to change { customer.credit_cards.count }.by 1+ end+ end+ end++ context 'when the source is klarna' do+ let(:payment_method_details) do+ Stripe::StripeObject.construct_from(+ klarna: Stripe::StripeObject.construct_from(+ payment_method_category: 'pay_in_installments',+ preferred_locale: 'en-US'+ ),+ type: 'klarna'+ )+ end++ it 'creates a Klarna source' do+ expect(subject).to be_a(SpreeStripe::PaymentSources::Klarna)+ end+ end++ context 'when the source is afterpay_clearpay' do+ let(:payment_method_details) { Stripe::StripeObject.construct_from(type: 'afterpay_clearpay') }++ it 'creates an AfterPay source' do+ expect(subject).to be_a(SpreeStripe::PaymentSources::AfterPay)+ end+ end++ context 'when the source is sepa_debit' do+ let(:payment_method_details) { Stripe::StripeObject.construct_from(type: 'sepa_debit') }++ it 'creates a SepaDebit source' do+ expect(subject).to be_a(SpreeStripe::PaymentSources::SepaDebit)+ end+ end++ context 'when the source is customer_balance' do+ let(:payment_method_details) { Stripe::StripeObject.construct_from(type: 'customer_balance') }++ it 'creates a BankTransfer source' do+ expect(subject).to be_a(SpreeStripe::PaymentSources::BankTransfer)+ end+ end++ context 'when the source is us_bank_account' do+ let(:payment_method_details) { Stripe::StripeObject.construct_from(type: 'us_bank_account') }++ it 'creates a BankTransfer source' do+ expect(subject).to be_a(SpreeStripe::PaymentSources::BankTransfer)+ end+ end++ context 'when the source is p24' do+ let(:payment_method_details) do+ Stripe::StripeObject.construct_from(+ p24: Stripe::StripeObject.construct_from(+ bank: 'ing',+ reference: 'P24-N01-101-101 R751406491',+ verified_name: 'Jenny Rosen'+ ),+ type: 'p24'+ )+ end++ it 'creates a Przelewy24 source' do+ expect(subject).to be_a(SpreeStripe::PaymentSources::Przelewy24)+ expect(subject.bank).to eq 'ing'+ end+ end++ context 'when the source is alipay' do+ let(:payment_method_details) do+ Stripe::StripeObject.construct_from(+ alipay: Stripe::StripeObject.construct_from(fingerprint: nil, transaction_id: nil),+ type: 'alipay'+ )+ end++ it 'creates an Alipay source' do+ expect(subject).to be_a(SpreeStripe::PaymentSources::Alipay)+ end+ end++ context 'when the source is affirm' do+ let(:payment_method_details) { Stripe::StripeObject.construct_from(type: 'affirm') }++ it 'creates an Affirm source' do+ expect(subject).to be_a(SpreeStripe::PaymentSources::Affirm)+ end+ end++ context 'when the source is ideal' do+ let(:payment_method_details) do+ Stripe::StripeObject.construct_from(+ ideal: Stripe::StripeObject.construct_from(+ bank: 'rabobank',+ bic: 'RABONL2U',+ generated_sepa_debit: nil,+ generated_sepa_debit_mandate: nil,+ iban_last4: '5264',+ verified_name: 'Jenny Rosen'+ ),+ type: 'ideal'+ )+ end++ it 'creates an Ideal source' do+ expect(subject).to be_a(SpreeStripe::PaymentSources::Ideal)+ expect(subject.bank).to eq 'rabobank'+ expect(subject.last4).to eq '5264'+ end+ end++ context 'when the source is link' do+ let(:payment_method_details) do+ Stripe::StripeObject.construct_from(link: Stripe::StripeObject.new, type: 'link')+ end++ it 'creates a Link source' do+ expect(subject).to be_a(SpreeStripe::PaymentSources::Link)+ end+ end++ context 'when the source is of an unknown type' do+ let(:payment_method_details) { Stripe::StripeObject.construct_from(type: 'some_future_method') }++ it 'creates a generic PaymentSource' do+ expect(subject).to be_a(Spree::PaymentSource)+ expect(subject.gateway_payment_profile_id).to eq source_id+ expect(subject.payment_method).to eq gateway+ end+ end+ end+enddiff --git a/spree/providers/stripe/spec/services/spree_stripe/register_domain_spec.rb b/spree/providers/stripe/spec/services/spree_stripe/register_domain_spec.rbnew file mode 100644index 0000000000..a48ccf4f98--- /dev/null+++ b/spree/providers/stripe/spec/services/spree_stripe/register_domain_spec.rb@@ -0,0 +1,78 @@+require 'spec_helper'++RSpec.describe SpreeStripe::RegisterDomain do+ subject(:register_domain) { described_class.new.call(model: model) }++ let(:store) { create(:store) }+ let!(:stripe_gateway) { create(:stripe_gateway, store: store) }++ let(:payment_method_domain) do+ Stripe::PaymentMethodDomain.list({ domain_name: domain }, stripe_gateway.api_options).data.find do |stripe_domain|+ stripe_domain.domain_name == domain+ end+ end++ let(:apple_pay_top_level_domain) do+ Stripe::PaymentMethodDomain.list({ domain_name: tld_domain }, stripe_gateway.api_options).data.find do |stripe_domain|+ stripe_domain.domain_name == tld_domain+ end+ end++ context 'for store' do+ let(:model) { store }+ let(:domain) { 'dare-gerhold-and-pagac.lvh.me' }++ before { allow(model).to receive(:url).and_return(domain) }++ it 'register only store domain', :vcr do+ expect(Stripe::PaymentMethodDomain).to receive(:create).once.with({ domain_name: domain }, anything).and_call_original+ register_domain++ expect(payment_method_domain).to be_present+ expect(model.stripe_apple_pay_domain_id).to eq(payment_method_domain.id)+ end+ end++ # Custom domains ship in spree_multi_store, so these only run where it is loaded.+ context 'for custom domain', if: defined?(Spree::CustomDomain) do+ let(:model) { create(:custom_domain, url: domain, store: store) }++ context 'when tld length is more then 2' do+ let(:tld_domain) { 'store-with-apple-pay.com' }+ let(:domain) { "shop.#{tld_domain}" }++ it 'registers the Apple Pay domain and top level domain in Stripe', :vcr do+ register_domain++ expect(payment_method_domain).to be_present+ expect(apple_pay_top_level_domain).to be_present+ expect(model.stripe_apple_pay_domain_id).to eq(payment_method_domain.id)+ expect(model.stripe_top_level_domain_id).to eq(apple_pay_top_level_domain.id)+ end+ end++ context 'when tld length is 2' do+ let(:tld_domain) { 'store-with-apple-pay.com' }+ let(:domain) { tld_domain }++ it 'registers only custom domain', :vcr do+ expect(Stripe::PaymentMethodDomain).to receive(:create).once.with({ domain_name: domain }, anything).and_call_original+ register_domain++ expect(payment_method_domain).to be_present+ expect(model.stripe_apple_pay_domain_id).to eq(payment_method_domain.id)+ expect(model.stripe_top_level_domain_id).to be_nil+ end+ end+ end++ context 'when the store has no Stripe gateway' do+ let!(:stripe_gateway) { nil }+ let(:model) { store }++ it 'does nothing' do+ expect(Stripe::PaymentMethodDomain).not_to receive(:create)+ expect(register_domain).to be_nil+ end+ end+enddiff --git a/spree/providers/stripe/spec/services/spree_stripe/update_customer_spec.rb b/spree/providers/stripe/spec/services/spree_stripe/update_customer_spec.rbnew file mode 100644index 0000000000..e413fc546e--- /dev/null+++ b/spree/providers/stripe/spec/services/spree_stripe/update_customer_spec.rb@@ -0,0 +1,41 @@+require 'spec_helper'++RSpec.describe SpreeStripe::UpdateCustomer do+ subject { described_class.new.call(customer: customer) }++ let(:customer) { create(:customer) }+ let(:store) { @default_store }++ before do+ allow(Stripe::Customer).to receive(:update).and_return(double(id: 'cus_123'))+ end++ context 'when the customer has a Stripe gateway customer' do+ let!(:stripe_gateway) { create(:stripe_gateway, store: store) }+ let!(:gateway_customer) { create(:gateway_customer, customer: customer, payment_method: stripe_gateway, profile_id: 'cus_123') }++ it 'updates the Stripe customer' do+ subject+ expect(Stripe::Customer).to have_received(:update).with('cus_123', anything, anything)+ end+ end++ context 'when the customer only has non-Stripe gateway customers' do+ let!(:credit_card_payment_method) { create(:credit_card_payment_method, store: store) }+ let!(:gateway_customer) do+ create(:gateway_customer, customer: customer, payment_method: credit_card_payment_method, profile_id: 'other_123')+ end++ it 'does not update the Stripe customer' do+ subject+ expect(Stripe::Customer).not_to have_received(:update)+ end+ end++ context 'when the customer has no gateway customers at all' do+ it 'does not update the Stripe customer' do+ subject+ expect(Stripe::Customer).not_to have_received(:update)+ end+ end+enddiff --git a/spree/providers/stripe/spec/spec_helper.rb b/spree/providers/stripe/spec/spec_helper.rbnew file mode 100644index 0000000000..765d07f1ad--- /dev/null+++ b/spree/providers/stripe/spec/spec_helper.rb@@ -0,0 +1,78 @@+if ENV['COVERAGE']+ require 'simplecov'+ require 'simplecov-cobertura'+ SimpleCov.root(ENV.fetch('GITHUB_WORKSPACE', File.expand_path('../../..', __dir__)))+ SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter+ SimpleCov.start 'rails' do+ add_group 'Models', 'app/models'+ add_group 'Services', 'app/services'+ add_group 'Presenters', 'app/presenters'+ add_group 'Jobs', 'app/jobs'++ add_filter '/bin/'+ add_filter '/config/'+ add_filter '/db/'+ add_filter '/lib/generators/'+ add_filter '/lib/spree_stripe/testing_support/'+ add_filter '/lib/tasks/'+ add_filter '/spec/'++ suffix = [ENV.fetch('CI_SHARD', '1'), ENV['TEST_ENV_NUMBER']].compact.reject(&:empty?).join('_')+ coverage_dir "#{ENV['COVERAGE_DIR']}/stripe_#{suffix}" if ENV['COVERAGE_DIR']+ command_name "stripe_shard_#{suffix}"+ end+end++ENV['RAILS_ENV'] ||= 'test'++begin+ require File.expand_path('../dummy/config/environment', __FILE__)+rescue LoadError+ puts 'Could not load dummy application. Please ensure you have run `bundle exec rake test_app`'+end++require 'rspec/rails'+require 'database_cleaner/active_record'+require 'ffaker'++Dir['./spec/support/**/*.rb'].sort.each { |f| require f }++require 'spree/testing_support/factories'+require 'spree/testing_support/jobs'+require 'spree/testing_support/store'+require 'spree/testing_support/preferences'+require 'spree/testing_support/url_helpers'+require 'spree/testing_support/kernel'+require 'spree/testing_support/rspec_retry_config'+require 'spree_stripe/factories'++RSpec.configure do |config|+ config.color = true+ config.default_formatter = 'progress'+ config.fail_fast = ENV['FAIL_FAST'] || false+ config.infer_spec_type_from_file_location!+ config.mock_with :rspec+ config.raise_errors_for_deprecations!+ config.use_transactional_fixtures = true++ config.before(:suite) do+ Spree::Events.disable!+ DatabaseCleaner.clean_with(:truncation)+ end++ config.around(:each, events: true) do |example|+ Spree::Events.enable { example.run }+ end++ config.before(:each) do+ reset_spree_preferences+ I18n.locale = :en+ end++ config.include FactoryBot::Syntax::Methods+ config.include Spree::TestingSupport::Preferences+ config.include Spree::TestingSupport::Kernel++ config.order = :random+ Kernel.srand config.seed+enddiff --git a/spree/providers/stripe/spec/support/vcr.rb b/spree/providers/stripe/spec/support/vcr.rbnew file mode 100644index 0000000000..1560926c5a--- /dev/null+++ b/spree/providers/stripe/spec/support/vcr.rb@@ -0,0 +1,34 @@+require 'vcr'+require 'webmock/rspec'++WebMock.disable_net_connect!(net_http_connect_on_start: true, allow_localhost: true)++VCR.configure do |c|+ c.allow_http_connections_when_no_cassette = false+ c.cassette_library_dir = File.join(SpreeStripe::Engine.root, 'spec', 'vcr')+ c.hook_into :webmock+ c.ignore_localhost = true+ c.configure_rspec_metadata!++ # Offline by default: a missing cassette fails the example rather than quietly+ # recording one against whatever credentials happen to be in the environment.+ # Renaming a `:vcr` example changes its cassette path, so recording-by-default+ # turns a rename into a live API call. Opt in with RECORD_VCR=1 when you+ # genuinely intend to capture new interactions.+ c.default_cassette_options = { record: ENV['RECORD_VCR'] ? :new_episodes : :none }++ c.filter_sensitive_data('<STRIPE_PUBLISHABLE_KEY>') { ENV['STRIPE_PUBLISHABLE_KEY'] }+ c.filter_sensitive_data('<STRIPE_SECRET_KEY>') { ENV['STRIPE_SECRET_KEY'] }++ c.before_record do |interaction|+ # Carries the account's Stripe client fingerprint.+ headers = interaction.request.headers['X-Stripe-Client-User-Agent']+ Array(headers).each { |header| interaction.filter!(header, '<FILTERED>') }++ # Creating a webhook endpoint returns its signing secret in the response+ # body — a credential the request-side key filters never see.+ interaction.response.body = interaction.response.body&.gsub(+ /whsec_[A-Za-z0-9]+/, '<STRIPE_WEBHOOK_SIGNING_SECRET>'+ )+ end+enddiff --git a/spree/providers/stripe/spec/vcr/SpreeStripe_RegisterDomain/for_custom_domain/when_tld_length_is_2/registers_only_custom_domain.yml b/spree/providers/stripe/spec/vcr/SpreeStripe_RegisterDomain/for_custom_domain/when_tld_length_is_2/registers_only_custom_domain.ymlnew file mode 100644index 0000000000..01b325beaf--- /dev/null+++ b/spree/providers/stripe/spec/vcr/SpreeStripe_RegisterDomain/for_custom_domain/when_tld_length_is_2/registers_only_custom_domain.yml@@ -0,0 +1,387 @@+---+http_interactions:+- request:+ method: post+ uri: https://api.stripe.com/v1/apple_pay/domains+ body:+ encoding: UTF-8+ string: domain_name=store-with-apple-pay.com+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 PayRails/7.1.0 (https://github.com/pay-rails/pay)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ Idempotency-Key:+ - 6b1c174d-3557-4d9e-b402-a7128bd7e66e+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Thu, 15 Feb 2024 09:46:05 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '166'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET,HEAD,PUT,PATCH,POST,DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - report-uri https://q.stripe.com/csp-report?p=v1%2Fapple_pay%2Fdomains; block-all-mixed-content;+ default-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'+ Idempotency-Key:+ - 6b1c174d-3557-4d9e-b402-a7128bd7e66e+ Original-Request:+ - req_WEjy5iAPP7vrqT+ Request-Id:+ - req_WEjy5iAPP7vrqT+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "apwc_1OhWNdIhR0gIegIe8QpNWSqX",+ "object": "apple_pay_domain",+ "created": 1707394021,+ "domain_name": "store-with-apple-pay.com",+ "livemode": false+ }+ recorded_at: Thu, 15 Feb 2024 09:46:05 GMT+- request:+ method: get+ uri: https://api.stripe.com/v1/apple_pay/domains?domain_name=store-with-apple-pay.com+ body:+ encoding: US-ASCII+ string: ''+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 PayRails/7.1.0 (https://github.com/pay-rails/pay)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_WEjy5iAPP7vrqT","request_duration_ms":396}}'+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Thu, 15 Feb 2024 09:46:05 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '289'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET,HEAD,PUT,PATCH,POST,DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - report-uri https://q.stripe.com/csp-report?p=v1%2Fapple_pay%2Fdomains; block-all-mixed-content;+ default-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'+ Request-Id:+ - req_C8N8oANwwicBoO+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "object": "list",+ "data": [+ {+ "id": "apwc_1OhWNdIhR0gIegIe8QpNWSqX",+ "object": "apple_pay_domain",+ "created": 1707394021,+ "domain_name": "store-with-apple-pay.com",+ "livemode": false+ }+ ],+ "has_more": false,+ "url": "/v1/apple_pay/domains"+ }+ recorded_at: Thu, 15 Feb 2024 09:46:05 GMT+- request:+ method: post+ uri: https://api.stripe.com/v1/payment_method_domains+ body:+ encoding: UTF-8+ string: domain_name=store-with-apple-pay.com+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 Spree Stripe/1.0.0 (https://spreecommerce.org)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Tue, 31 Dec 2024 09:41:45 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '408'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; upgrade-insecure-requests;+ report-uri /csp-violation https://q.stripe.com/csp-violation?q=1ARCkfrIyfevu4VuIsPtIrYo-6G7s0xS8iNnIjwuARQZEuFIajmyq3-kmJylOPvCwlvi5KxqTg%3D%3D+ Cross-Origin-Opener-Policy-Report-Only:+ - same-origin; report-to="coop"+ Idempotency-Key:+ - e67f1ba1-79ef-484e-89b2-3c179b67cd40+ Original-Request:+ - req_lgqeYnYQU37zYu+ Report-To:+ - '{"group":"coop","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/coop-report"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - coop="https://q.stripe.com/coop-report"+ Request-Id:+ - req_lgqeYnYQU37zYu+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Content-Type-Options:+ - nosniff+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - AB+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "pmd_1Qc1xM2ESifGlJez2fLCZgBp",+ "object": "payment_method_domain",+ "amazon_pay": {+ "status": "active"+ },+ "apple_pay": {+ "status": "active"+ },+ "created": 1735638104,+ "domain_name": "store-with-apple-pay.com",+ "enabled": true,+ "google_pay": {+ "status": "active"+ },+ "link": {+ "status": "active"+ },+ "livemode": false,+ "paypal": {+ "status": "active"+ }+ }+ recorded_at: Tue, 31 Dec 2024 09:41:45 GMT+- request:+ method: get+ uri: https://api.stripe.com/v1/payment_method_domains?domain_name=store-with-apple-pay.com+ body:+ encoding: US-ASCII+ string: ''+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 Spree Stripe/1.0.0 (https://spreecommerce.org)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Api-Version:+ - '2023-10-16'+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Tue, 31 Dec 2024 09:41:45 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '600'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; upgrade-insecure-requests;+ report-uri /csp-violation https://q.stripe.com/csp-violation?q=dmV-g1_CTnTu-N8tEOeQacDg4WqYUL-RkM_aVdAMCtZnw7JXzTC-DCktrKdLRpDguTp0San5Nw%3D%3D+ Cross-Origin-Opener-Policy-Report-Only:+ - same-origin; report-to="coop"+ Report-To:+ - '{"group":"coop","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/coop-report"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - coop="https://q.stripe.com/coop-report"+ Request-Id:+ - req_hLSQFCkPJIpimU+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Content-Type-Options:+ - nosniff+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - AB+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "object": "list",+ "data": [+ {+ "id": "pmd_1Qc1xM2ESifGlJez2fLCZgBp",+ "object": "payment_method_domain",+ "amazon_pay": {+ "status": "active"+ },+ "apple_pay": {+ "status": "active"+ },+ "created": 1735638104,+ "domain_name": "store-with-apple-pay.com",+ "enabled": true,+ "google_pay": {+ "status": "active"+ },+ "link": {+ "status": "active"+ },+ "livemode": false,+ "paypal": {+ "status": "active"+ }+ }+ ],+ "has_more": false,+ "url": "/v1/payment_method_domains"+ }+ recorded_at: Tue, 31 Dec 2024 09:41:45 GMT+recorded_with: VCR 6.2.0diff --git a/spree/providers/stripe/spec/vcr/SpreeStripe_RegisterDomain/for_custom_domain/when_tld_length_is_more_then_2/registers_the_Apple_Pay_domain_and_top_level_domain_in_Stripe.yml b/spree/providers/stripe/spec/vcr/SpreeStripe_RegisterDomain/for_custom_domain/when_tld_length_is_more_then_2/registers_the_Apple_Pay_domain_and_top_level_domain_in_Stripe.ymlnew file mode 100644index 0000000000..d1e242da91--- /dev/null+++ b/spree/providers/stripe/spec/vcr/SpreeStripe_RegisterDomain/for_custom_domain/when_tld_length_is_more_then_2/registers_the_Apple_Pay_domain_and_top_level_domain_in_Stripe.yml@@ -0,0 +1,781 @@+---+http_interactions:+- request:+ method: post+ uri: https://api.stripe.com/v1/apple_pay/domains+ body:+ encoding: UTF-8+ string: domain_name=shop.store-with-apple-pay.com+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 PayRails/7.1.0 (https://github.com/pay-rails/pay)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_C8N8oANwwicBoO","request_duration_ms":353}}'+ Idempotency-Key:+ - 30a16f4f-95ec-46c7-aa4f-a1dd5c68ebe4+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Thu, 15 Feb 2024 09:46:06 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '171'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET,HEAD,PUT,PATCH,POST,DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - report-uri https://q.stripe.com/csp-report?p=v1%2Fapple_pay%2Fdomains; block-all-mixed-content;+ default-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'+ Idempotency-Key:+ - 30a16f4f-95ec-46c7-aa4f-a1dd5c68ebe4+ Original-Request:+ - req_z1L95Y1eeucosu+ Request-Id:+ - req_z1L95Y1eeucosu+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "apwc_1OhVNaIhR0gIegIea5bTfT3R",+ "object": "apple_pay_domain",+ "created": 1707390174,+ "domain_name": "shop.store-with-apple-pay.com",+ "livemode": false+ }+ recorded_at: Thu, 15 Feb 2024 09:46:06 GMT+- request:+ method: post+ uri: https://api.stripe.com/v1/apple_pay/domains+ body:+ encoding: UTF-8+ string: domain_name=store-with-apple-pay.com+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 PayRails/7.1.0 (https://github.com/pay-rails/pay)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_z1L95Y1eeucosu","request_duration_ms":245}}'+ Idempotency-Key:+ - 84248bdb-f430-4c5f-8f68-acce3bb60809+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Thu, 15 Feb 2024 09:46:06 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '166'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET,HEAD,PUT,PATCH,POST,DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - report-uri https://q.stripe.com/csp-report?p=v1%2Fapple_pay%2Fdomains; block-all-mixed-content;+ default-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'+ Idempotency-Key:+ - 84248bdb-f430-4c5f-8f68-acce3bb60809+ Original-Request:+ - req_XRRPlbEPkGFZHo+ Request-Id:+ - req_XRRPlbEPkGFZHo+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "apwc_1OhWNdIhR0gIegIe8QpNWSqX",+ "object": "apple_pay_domain",+ "created": 1707394021,+ "domain_name": "store-with-apple-pay.com",+ "livemode": false+ }+ recorded_at: Thu, 15 Feb 2024 09:46:06 GMT+- request:+ method: get+ uri: https://api.stripe.com/v1/apple_pay/domains?domain_name=shop.store-with-apple-pay.com+ body:+ encoding: US-ASCII+ string: ''+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 PayRails/7.1.0 (https://github.com/pay-rails/pay)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_XRRPlbEPkGFZHo","request_duration_ms":250}}'+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Thu, 15 Feb 2024 09:46:07 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '294'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET,HEAD,PUT,PATCH,POST,DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - report-uri https://q.stripe.com/csp-report?p=v1%2Fapple_pay%2Fdomains; block-all-mixed-content;+ default-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'+ Request-Id:+ - req_pxtwCV6Lsq6VVF+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "object": "list",+ "data": [+ {+ "id": "apwc_1OhVNaIhR0gIegIea5bTfT3R",+ "object": "apple_pay_domain",+ "created": 1707390174,+ "domain_name": "shop.store-with-apple-pay.com",+ "livemode": false+ }+ ],+ "has_more": false,+ "url": "/v1/apple_pay/domains"+ }+ recorded_at: Thu, 15 Feb 2024 09:46:06 GMT+- request:+ method: get+ uri: https://api.stripe.com/v1/apple_pay/domains?domain_name=store-with-apple-pay.com+ body:+ encoding: US-ASCII+ string: ''+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 PayRails/7.1.0 (https://github.com/pay-rails/pay)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_pxtwCV6Lsq6VVF","request_duration_ms":233}}'+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Thu, 15 Feb 2024 09:46:07 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '289'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET,HEAD,PUT,PATCH,POST,DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - report-uri https://q.stripe.com/csp-report?p=v1%2Fapple_pay%2Fdomains; block-all-mixed-content;+ default-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'+ Request-Id:+ - req_7Fz4Iub2PMVlr3+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "object": "list",+ "data": [+ {+ "id": "apwc_1OhWNdIhR0gIegIe8QpNWSqX",+ "object": "apple_pay_domain",+ "created": 1707394021,+ "domain_name": "store-with-apple-pay.com",+ "livemode": false+ }+ ],+ "has_more": false,+ "url": "/v1/apple_pay/domains"+ }+ recorded_at: Thu, 15 Feb 2024 09:46:07 GMT+- request:+ method: post+ uri: https://api.stripe.com/v1/payment_method_domains+ body:+ encoding: UTF-8+ string: domain_name=shop.store-with-apple-pay.com+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 Spree Stripe/1.0.0 (https://spreecommerce.org)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Tue, 31 Dec 2024 09:41:47 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '413'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; upgrade-insecure-requests;+ report-uri /csp-violation https://q.stripe.com/csp-violation?q=sx-GsN2cWpi7dFBpMr-DfZ2F6jTEvhCu2C2EvQMSjyQeijgA8FQWDX_o7rRwsVr-z8k0LxwgRw%3D%3D+ Cross-Origin-Opener-Policy-Report-Only:+ - same-origin; report-to="coop"+ Idempotency-Key:+ - b5226b62-65ca-4969-9a39-9757e171bfb9+ Original-Request:+ - req_s0QoJ38kGv6V6C+ Report-To:+ - '{"group":"coop","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/coop-report"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - coop="https://q.stripe.com/coop-report"+ Request-Id:+ - req_s0QoJ38kGv6V6C+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Content-Type-Options:+ - nosniff+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - AB+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "pmd_1Qc1xO2ESifGlJezySi9qH6t",+ "object": "payment_method_domain",+ "amazon_pay": {+ "status": "active"+ },+ "apple_pay": {+ "status": "active"+ },+ "created": 1735638106,+ "domain_name": "shop.store-with-apple-pay.com",+ "enabled": true,+ "google_pay": {+ "status": "active"+ },+ "link": {+ "status": "active"+ },+ "livemode": false,+ "paypal": {+ "status": "active"+ }+ }+ recorded_at: Tue, 31 Dec 2024 09:41:47 GMT+- request:+ method: post+ uri: https://api.stripe.com/v1/payment_method_domains+ body:+ encoding: UTF-8+ string: domain_name=store-with-apple-pay.com+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 Spree Stripe/1.0.0 (https://spreecommerce.org)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_s0QoJ38kGv6V6C","request_duration_ms":726}}'+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Tue, 31 Dec 2024 09:41:47 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '408'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; upgrade-insecure-requests;+ report-uri /csp-violation https://q.stripe.com/csp-violation?q=sx-GsN2cWpi7dFBpMr-DfZ2F6jTEvhCu2C2EvQMSjyQeijgA8FQWDX_o7rRwsVr-z8k0LxwgRw%3D%3D+ Cross-Origin-Opener-Policy-Report-Only:+ - same-origin; report-to="coop"+ Idempotency-Key:+ - c9aceb45-b08c-4ac9-8d5b-c61dc4dbe716+ Original-Request:+ - req_NOXd5iE53skZPp+ Report-To:+ - '{"group":"coop","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/coop-report"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - coop="https://q.stripe.com/coop-report"+ Request-Id:+ - req_NOXd5iE53skZPp+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Content-Type-Options:+ - nosniff+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - AB+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "pmd_1Qc1xM2ESifGlJez2fLCZgBp",+ "object": "payment_method_domain",+ "amazon_pay": {+ "status": "active"+ },+ "apple_pay": {+ "status": "active"+ },+ "created": 1735638104,+ "domain_name": "store-with-apple-pay.com",+ "enabled": true,+ "google_pay": {+ "status": "active"+ },+ "link": {+ "status": "active"+ },+ "livemode": false,+ "paypal": {+ "status": "active"+ }+ }+ recorded_at: Tue, 31 Dec 2024 09:41:47 GMT+- request:+ method: get+ uri: https://api.stripe.com/v1/payment_method_domains?domain_name=shop.store-with-apple-pay.com+ body:+ encoding: US-ASCII+ string: ''+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 Spree Stripe/1.0.0 (https://spreecommerce.org)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_hLSQFCkPJIpimU","request_duration_ms":303}}'+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Api-Version:+ - '2023-10-16'+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Tue, 31 Dec 2024 09:41:47 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '605'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; upgrade-insecure-requests;+ report-uri /csp-violation https://q.stripe.com/csp-violation?q=PsSIrpspD12C7yCoMcpVgJpYO3BWDbCrSWo2LGT6VyAXzd35uTrlD_gDlCV4mKpBVCNyOPkRhA%3D%3D+ Cross-Origin-Opener-Policy-Report-Only:+ - same-origin; report-to="coop"+ Report-To:+ - '{"group":"coop","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/coop-report"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - coop="https://q.stripe.com/coop-report"+ Request-Id:+ - req_2lQ7RHl1bgo61c+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Content-Type-Options:+ - nosniff+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - AB+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "object": "list",+ "data": [+ {+ "id": "pmd_1Qc1xO2ESifGlJezySi9qH6t",+ "object": "payment_method_domain",+ "amazon_pay": {+ "status": "active"+ },+ "apple_pay": {+ "status": "active"+ },+ "created": 1735638106,+ "domain_name": "shop.store-with-apple-pay.com",+ "enabled": true,+ "google_pay": {+ "status": "active"+ },+ "link": {+ "status": "active"+ },+ "livemode": false,+ "paypal": {+ "status": "active"+ }+ }+ ],+ "has_more": false,+ "url": "/v1/payment_method_domains"+ }+ recorded_at: Tue, 31 Dec 2024 09:41:47 GMT+- request:+ method: get+ uri: https://api.stripe.com/v1/payment_method_domains?domain_name=store-with-apple-pay.com+ body:+ encoding: US-ASCII+ string: ''+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 Spree Stripe/1.0.0 (https://spreecommerce.org)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_2lQ7RHl1bgo61c","request_duration_ms":384}}'+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Api-Version:+ - '2023-10-16'+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Tue, 31 Dec 2024 09:41:48 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '600'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; upgrade-insecure-requests;+ report-uri /csp-violation https://q.stripe.com/csp-violation?q=PsSIrpspD12C7yCoMcpVgJpYO3BWDbCrSWo2LGT6VyAXzd35uTrlD_gDlCV4mKpBVCNyOPkRhA%3D%3D+ Cross-Origin-Opener-Policy-Report-Only:+ - same-origin; report-to="coop"+ Report-To:+ - '{"group":"coop","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/coop-report"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - coop="https://q.stripe.com/coop-report"+ Request-Id:+ - req_ZONtgAiSWfhine+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Content-Type-Options:+ - nosniff+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - AB+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "object": "list",+ "data": [+ {+ "id": "pmd_1Qc1xM2ESifGlJez2fLCZgBp",+ "object": "payment_method_domain",+ "amazon_pay": {+ "status": "active"+ },+ "apple_pay": {+ "status": "active"+ },+ "created": 1735638104,+ "domain_name": "store-with-apple-pay.com",+ "enabled": true,+ "google_pay": {+ "status": "active"+ },+ "link": {+ "status": "active"+ },+ "livemode": false,+ "paypal": {+ "status": "active"+ }+ }+ ],+ "has_more": false,+ "url": "/v1/payment_method_domains"+ }+ recorded_at: Tue, 31 Dec 2024 09:41:48 GMT+recorded_with: VCR 6.2.0diff --git a/spree/providers/stripe/spec/vcr/SpreeStripe_RegisterDomain/for_store/register_only_store_domain.yml b/spree/providers/stripe/spec/vcr/SpreeStripe_RegisterDomain/for_store/register_only_store_domain.ymlnew file mode 100644index 0000000000..f3fcf4aca3--- /dev/null+++ b/spree/providers/stripe/spec/vcr/SpreeStripe_RegisterDomain/for_store/register_only_store_domain.yml@@ -0,0 +1,389 @@+---+http_interactions:+- request:+ method: post+ uri: https://api.stripe.com/v1/apple_pay/domains+ body:+ encoding: UTF-8+ string: domain_name=dare-gerhold-and-pagac.lvh.me+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 PayRails/7.1.0 (https://github.com/pay-rails/pay)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ Idempotency-Key:+ - f22b062e-f4a4-4318-87c5-d5e33ff21117+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Thu, 15 Feb 2024 10:22:13 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '171'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET,HEAD,PUT,PATCH,POST,DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - report-uri https://q.stripe.com/csp-report?p=v1%2Fapple_pay%2Fdomains; block-all-mixed-content;+ default-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'+ Idempotency-Key:+ - f22b062e-f4a4-4318-87c5-d5e33ff21117+ Original-Request:+ - req_K0lMqfwyi53yWN+ Request-Id:+ - req_K0lMqfwyi53yWN+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "apwc_1Ok252IhR0gIegIemv7L2GYk",+ "object": "apple_pay_domain",+ "created": 1707992532,+ "domain_name": "dare-gerhold-and-pagac.lvh.me",+ "livemode": false+ }+ recorded_at: Thu, 15 Feb 2024 10:22:12 GMT+- request:+ method: get+ uri: https://api.stripe.com/v1/apple_pay/domains?domain_name=dare-gerhold-and-pagac.lvh.me+ body:+ encoding: US-ASCII+ string: ''+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 PayRails/7.1.0 (https://github.com/pay-rails/pay)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_K0lMqfwyi53yWN","request_duration_ms":2956}}'+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Thu, 15 Feb 2024 10:22:13 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '294'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET,HEAD,PUT,PATCH,POST,DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - report-uri https://q.stripe.com/csp-report?p=v1%2Fapple_pay%2Fdomains; block-all-mixed-content;+ default-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'+ Request-Id:+ - req_ppI4p4poGhYkA6+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "object": "list",+ "data": [+ {+ "id": "apwc_1Ok252IhR0gIegIemv7L2GYk",+ "object": "apple_pay_domain",+ "created": 1707992532,+ "domain_name": "dare-gerhold-and-pagac.lvh.me",+ "livemode": false+ }+ ],+ "has_more": false,+ "url": "/v1/apple_pay/domains"+ }+ recorded_at: Thu, 15 Feb 2024 10:22:13 GMT+- request:+ method: post+ uri: https://api.stripe.com/v1/payment_method_domains+ body:+ encoding: UTF-8+ string: domain_name=dare-gerhold-and-pagac.lvh.me+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 Spree Stripe/1.0.0 (https://spreecommerce.org)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Tue, 31 Dec 2024 09:41:50 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '413'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; upgrade-insecure-requests;+ report-uri /csp-violation https://q.stripe.com/csp-violation?q=sx-GsN2cWpi7dFBpMr-DfZ2F6jTEvhCu2C2EvQMSjyQeijgA8FQWDX_o7rRwsVr-z8k0LxwgRw%3D%3D+ Cross-Origin-Opener-Policy-Report-Only:+ - same-origin; report-to="coop"+ Idempotency-Key:+ - ffa20cc8-fd99-423a-8933-9393215cb1b0+ Original-Request:+ - req_zIaZPMBhfNSczy+ Report-To:+ - '{"group":"coop","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/coop-report"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - coop="https://q.stripe.com/coop-report"+ Request-Id:+ - req_zIaZPMBhfNSczy+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Content-Type-Options:+ - nosniff+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - AB+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "pmd_1Qc1xR2ESifGlJezaInTCWpb",+ "object": "payment_method_domain",+ "amazon_pay": {+ "status": "active"+ },+ "apple_pay": {+ "status": "active"+ },+ "created": 1735638109,+ "domain_name": "dare-gerhold-and-pagac.lvh.me",+ "enabled": true,+ "google_pay": {+ "status": "active"+ },+ "link": {+ "status": "active"+ },+ "livemode": false,+ "paypal": {+ "status": "active"+ }+ }+ recorded_at: Tue, 31 Dec 2024 09:41:50 GMT+- request:+ method: get+ uri: https://api.stripe.com/v1/payment_method_domains?domain_name=dare-gerhold-and-pagac.lvh.me+ body:+ encoding: US-ASCII+ string: ''+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 Spree Stripe/1.0.0 (https://spreecommerce.org)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_ZONtgAiSWfhine","request_duration_ms":213}}'+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Api-Version:+ - '2023-10-16'+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Tue, 31 Dec 2024 09:41:50 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '605'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; upgrade-insecure-requests;+ report-uri /csp-violation https://q.stripe.com/csp-violation?q=PsSIrpspD12C7yCoMcpVgJpYO3BWDbCrSWo2LGT6VyAXzd35uTrlD_gDlCV4mKpBVCNyOPkRhA%3D%3D+ Cross-Origin-Opener-Policy-Report-Only:+ - same-origin; report-to="coop"+ Report-To:+ - '{"group":"coop","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/coop-report"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - coop="https://q.stripe.com/coop-report"+ Request-Id:+ - req_WuhbKq0Go1Jmn7+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Content-Type-Options:+ - nosniff+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - AB+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "object": "list",+ "data": [+ {+ "id": "pmd_1Qc1xR2ESifGlJezaInTCWpb",+ "object": "payment_method_domain",+ "amazon_pay": {+ "status": "active"+ },+ "apple_pay": {+ "status": "active"+ },+ "created": 1735638109,+ "domain_name": "dare-gerhold-and-pagac.lvh.me",+ "enabled": true,+ "google_pay": {+ "status": "active"+ },+ "link": {+ "status": "active"+ },+ "livemode": false,+ "paypal": {+ "status": "active"+ }+ }+ ],+ "has_more": false,+ "url": "/v1/payment_method_domains"+ }+ recorded_at: Tue, 31 Dec 2024 09:41:50 GMT+recorded_with: VCR 6.2.0diff --git a/spree/providers/stripe/spec/vcr/cancel_payment_intent.yml b/spree/providers/stripe/spec/vcr/cancel_payment_intent.ymlnew file mode 100644index 0000000000..29c72b0d00--- /dev/null+++ b/spree/providers/stripe/spec/vcr/cancel_payment_intent.yml@@ -0,0 +1,167 @@+---+http_interactions:+- request:+ method: post+ uri: https://api.stripe.com/v1/payment_intents/pi_3QY1o72ESifGlJez06ZbKHjy/cancel+ body:+ encoding: US-ASCII+ string: ''+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 Spree Stripe/1.0.0 (https://spreecommerce.org)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Fri, 20 Dec 2024 08:44:58 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '1925'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; upgrade-insecure-requests;+ report-uri /csp-violation https://q.stripe.com/csp-violation?q=wdKG283VVyBu6b4jEX1HIC8tpWSlpZYjeHiIXW1HbsOOzEmIF-Tbh3FfDe-yl9m-_bW5Rqsmww%3D%3D+ Cross-Origin-Opener-Policy-Report-Only:+ - same-origin; report-to="coop"+ Idempotency-Key:+ - dac1370a-a28f-4a59-998c-9e6c2b1a8c1e+ Original-Request:+ - req_T2mu659CvnbSxN+ Report-To:+ - '{"group":"coop","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/coop-report"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - coop="https://q.stripe.com/coop-report"+ Request-Id:+ - req_T2mu659CvnbSxN+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Content-Type-Options:+ - nosniff+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - AB+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "pi_3QY1o72ESifGlJez06ZbKHjy",+ "object": "payment_intent",+ "amount": 4000,+ "amount_capturable": 0,+ "amount_details": {+ "tip": {}+ },+ "amount_received": 0,+ "application": null,+ "application_fee_amount": null,+ "automatic_payment_methods": {+ "allow_redirects": "always",+ "enabled": true+ },+ "canceled_at": 1734684298,+ "cancellation_reason": null,+ "capture_method": "automatic",+ "client_secret": "pi_3QY1o72ESifGlJez06ZbKHjy_secret_F4jLDjxcB5zdjigXslucVZIc5",+ "confirmation_method": "automatic",+ "created": 1734684219,+ "currency": "usd",+ "customer": "cus_RQdclxFVLH4oau",+ "description": null,+ "invoice": null,+ "last_payment_error": null,+ "latest_charge": null,+ "livemode": false,+ "metadata": {+ "spree_order_id": "58317959-7154-4446-a925-f4057c5c8b12"+ },+ "next_action": null,+ "on_behalf_of": null,+ "payment_method": null,+ "payment_method_configuration_details": {+ "id": "pmc_1QVa9x2ESifGlJezRC5fgLVg",+ "parent": null+ },+ "payment_method_options": {+ "card": {+ "installments": null,+ "mandate_options": null,+ "network": null,+ "request_three_d_secure": "automatic",+ "setup_future_usage": "off_session"+ },+ "link": {+ "persistent_token": null+ }+ },+ "payment_method_types": [+ "card",+ "link"+ ],+ "processing": null,+ "receipt_email": null,+ "review": null,+ "setup_future_usage": null,+ "shipping": {+ "address": {+ "city": "San Francisco",+ "country": "US",+ "line1": "100 California Street",+ "line2": null,+ "postal_code": "94111",+ "state": "CA"+ },+ "carrier": null,+ "name": "John Doe",+ "phone": null,+ "tracking_number": null+ },+ "source": null,+ "statement_descriptor": null,+ "statement_descriptor_suffix": "R594422549 John Doe",+ "status": "canceled",+ "transfer_data": null,+ "transfer_group": "R594422549"+ }+ recorded_at: Fri, 20 Dec 2024 08:44:58 GMT+recorded_with: VCR 6.2.0diff --git a/spree/providers/stripe/spec/vcr/capture_payment_intent_already_succeeded.yml b/spree/providers/stripe/spec/vcr/capture_payment_intent_already_succeeded.ymlnew file mode 100644index 0000000000..23ed72da96--- /dev/null+++ b/spree/providers/stripe/spec/vcr/capture_payment_intent_already_succeeded.yml@@ -0,0 +1,357 @@+---+http_interactions:+- request:+ method: post+ uri: https://api.stripe.com/v1/payment_intents+ body:+ encoding: UTF-8+ string: amount=1000¤cy=usd&payment_method=pm_card_visa&confirm=true&automatic_payment_methods[enabled]=true&automatic_payment_methods[allow_redirects]=never+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/18.4.2 Spree Stripe/5.5.0.beta (https://spreecommerce.org)+ AIAgent/claude_code+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_ttFRqofAbo1BAB","request_duration_ms":848}}'+ Idempotency-Key:+ - 1ce9723e-8b3b-451d-a33e-bb46f49f509c+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Content-Type:+ - application/x-www-form-urlencoded+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Fri, 08 May 2026 15:12:56 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '1701'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=8DkIkjC-gku45NehfAQYrSS-1C4KY3HKUAJBYCcjIIlUZvWG7kYShkNME-sHlEFNgTGugDYHR3p5bBtm;+ report-to csp+ Idempotency-Key:+ - 1ce9723e-8b3b-451d-a33e-bb46f49f509c+ Original-Request:+ - req_P30Lxd5YH8wSHZ+ Report-To:+ - '{"group":"csp","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/csp-report-v2?q=8DkIkjC-gku45NehfAQYrSS-1C4KY3HKUAJBYCcjIIlUZvWG7kYShkNME-sHlEFNgTGugDYHR3p5bBtm&t=1"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - csp="https://q.stripe.com/csp-report-v2?q=8DkIkjC-gku45NehfAQYrSS-1C4KY3HKUAJBYCcjIIlUZvWG7kYShkNME-sHlEFNgTGugDYHR3p5bBtm&t=1"+ Request-Id:+ - req_P30Lxd5YH8wSHZ+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - 3c3+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "pi_3TUq5D2ESifGlJez1W9f3ccS",+ "object": "payment_intent",+ "amount": 1000,+ "amount_capturable": 0,+ "amount_details": {+ "tip": {}+ },+ "amount_received": 1000,+ "application": null,+ "application_fee_amount": null,+ "automatic_payment_methods": {+ "allow_redirects": "never",+ "enabled": true+ },+ "canceled_at": null,+ "cancellation_reason": null,+ "capture_method": "automatic",+ "client_secret": "pi_3TUq5D2ESifGlJez1W9f3ccS_secret_w2wRZk5YUW4OdZuMnGPnVImph",+ "confirmation_method": "automatic",+ "created": 1778253175,+ "currency": "usd",+ "customer": null,+ "customer_account": null,+ "description": null,+ "excluded_payment_method_types": null,+ "invoice": null,+ "last_payment_error": null,+ "latest_charge": "ch_3TUq5D2ESifGlJez1bUXXcLL",+ "livemode": false,+ "managed_payments": {+ "enabled": false+ },+ "metadata": {},+ "next_action": null,+ "on_behalf_of": null,+ "payment_method": "pm_1TUq5D2ESifGlJez52Ro4eZl",+ "payment_method_configuration_details": {+ "id": "pmc_1QVa9x2ESifGlJezRC5fgLVg",+ "parent": null+ },+ "payment_method_options": {+ "card": {+ "installments": null,+ "mandate_options": null,+ "network": null,+ "request_three_d_secure": "automatic"+ },+ "link": {+ "persistent_token": null+ }+ },+ "payment_method_types": [+ "card",+ "link"+ ],+ "processing": null,+ "receipt_email": null,+ "review": null,+ "setup_future_usage": null,+ "shared_payment_granted_token": null,+ "shipping": null,+ "source": null,+ "statement_descriptor": null,+ "statement_descriptor_suffix": null,+ "status": "succeeded",+ "transfer_data": null,+ "transfer_group": null+ }+ recorded_at: Fri, 08 May 2026 15:12:56 GMT+- request:+ method: get+ uri: https://api.stripe.com/v1/payment_intents/pi_3TUq5D2ESifGlJez1W9f3ccS?expand%5B%5D=payment_method+ body:+ encoding: US-ASCII+ string: ''+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/18.4.2 Spree Stripe/5.5.0.beta (https://spreecommerce.org)+ AIAgent/claude_code+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_P30Lxd5YH8wSHZ","request_duration_ms":1134}}'+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Fri, 08 May 2026 15:12:56 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '2893'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=8DkIkjC-gku45NehfAQYrSS-1C4KY3HKUAJBYCcjIIlUZvWG7kYShkNME-sHlEFNgTGugDYHR3p5bBtm;+ report-to csp+ Report-To:+ - '{"group":"csp","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/csp-report-v2?q=8DkIkjC-gku45NehfAQYrSS-1C4KY3HKUAJBYCcjIIlUZvWG7kYShkNME-sHlEFNgTGugDYHR3p5bBtm&t=1"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - csp="https://q.stripe.com/csp-report-v2?q=8DkIkjC-gku45NehfAQYrSS-1C4KY3HKUAJBYCcjIIlUZvWG7kYShkNME-sHlEFNgTGugDYHR3p5bBtm&t=1"+ Request-Id:+ - req_hsLgLI7yrBGeYr+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - 3c3+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "pi_3TUq5D2ESifGlJez1W9f3ccS",+ "object": "payment_intent",+ "amount": 1000,+ "amount_capturable": 0,+ "amount_details": {+ "tip": {}+ },+ "amount_received": 1000,+ "application": null,+ "application_fee_amount": null,+ "automatic_payment_methods": {+ "allow_redirects": "never",+ "enabled": true+ },+ "canceled_at": null,+ "cancellation_reason": null,+ "capture_method": "automatic",+ "client_secret": "pi_3TUq5D2ESifGlJez1W9f3ccS_secret_w2wRZk5YUW4OdZuMnGPnVImph",+ "confirmation_method": "automatic",+ "created": 1778253175,+ "currency": "usd",+ "customer": null,+ "customer_account": null,+ "description": null,+ "excluded_payment_method_types": null,+ "invoice": null,+ "last_payment_error": null,+ "latest_charge": "ch_3TUq5D2ESifGlJez1bUXXcLL",+ "livemode": false,+ "managed_payments": {+ "enabled": false+ },+ "metadata": {},+ "next_action": null,+ "on_behalf_of": null,+ "payment_method": {+ "id": "pm_1TUq5D2ESifGlJez52Ro4eZl",+ "object": "payment_method",+ "allow_redisplay": "unspecified",+ "billing_details": {+ "address": {+ "city": null,+ "country": null,+ "line1": null,+ "line2": null,+ "postal_code": null,+ "state": null+ },+ "email": null,+ "name": null,+ "phone": null,+ "tax_id": null+ },+ "card": {+ "brand": "visa",+ "checks": {+ "address_line1_check": null,+ "address_postal_code_check": null,+ "cvc_check": "pass"+ },+ "country": "US",+ "display_brand": "visa",+ "exp_month": 5,+ "exp_year": 2027,+ "fingerprint": "taGjeBd4Wh4btmTn",+ "funding": "credit",+ "generated_from": null,+ "last4": "4242",+ "networks": {+ "available": [+ "visa"+ ],+ "preferred": null+ },+ "regulated_status": "unregulated",+ "three_d_secure_usage": {+ "supported": true+ },+ "wallet": null+ },+ "created": 1778253175,+ "customer": null,+ "customer_account": null,+ "livemode": false,+ "metadata": {},+ "shared_payment_granted_token": null,+ "type": "card"+ },+ "payment_method_configuration_details": {+ "id": "pmc_1QVa9x2ESifGlJezRC5fgLVg",+ "parent": null+ },+ "payment_method_options": {+ "card": {+ "installments": null,+ "mandate_options": null,+ "network": null,+ "request_three_d_secure": "automatic"+ },+ "link": {+ "persistent_token": null+ }+ },+ "payment_method_types": [+ "card",+ "link"+ ],+ "processing": null,+ "receipt_email": null,+ "review": null,+ "setup_future_usage": null,+ "shared_payment_granted_token": null,+ "shipping": null,+ "source": null,+ "statement_descriptor": null,+ "statement_descriptor_suffix": null,+ "status": "succeeded",+ "transfer_data": null,+ "transfer_group": null+ }+ recorded_at: Fri, 08 May 2026 15:12:56 GMT+recorded_with: VCR 6.4.0diff --git a/spree/providers/stripe/spec/vcr/capture_payment_intent_requires_capture.yml b/spree/providers/stripe/spec/vcr/capture_payment_intent_requires_capture.ymlnew file mode 100644index 0000000000..8a2b8171dd--- /dev/null+++ b/spree/providers/stripe/spec/vcr/capture_payment_intent_requires_capture.yml@@ -0,0 +1,513 @@+---+http_interactions:+- request:+ method: post+ uri: https://api.stripe.com/v1/payment_intents+ body:+ encoding: UTF-8+ string: amount=1000¤cy=usd&payment_method=pm_card_visa&confirm=true&capture_method=manual&automatic_payment_methods[enabled]=true&automatic_payment_methods[allow_redirects]=never+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/18.4.2 Spree Stripe/5.5.0.beta (https://spreecommerce.org)+ AIAgent/claude_code+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_1FyKrdIqfbS4iC","request_duration_ms":330}}'+ Idempotency-Key:+ - 622e2959-3cd8-41ba-bbe6-af0365320cfe+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Content-Type:+ - application/x-www-form-urlencoded+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Fri, 08 May 2026 15:12:54 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '1705'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=8DkIkjC-gku45NehfAQYrSS-1C4KY3HKUAJBYCcjIIlUZvWG7kYShkNME-sHlEFNgTGugDYHR3p5bBtm;+ report-to csp+ Idempotency-Key:+ - 622e2959-3cd8-41ba-bbe6-af0365320cfe+ Original-Request:+ - req_0CE3adl6VfRx02+ Report-To:+ - '{"group":"csp","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/csp-report-v2?q=8DkIkjC-gku45NehfAQYrSS-1C4KY3HKUAJBYCcjIIlUZvWG7kYShkNME-sHlEFNgTGugDYHR3p5bBtm&t=1"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - csp="https://q.stripe.com/csp-report-v2?q=8DkIkjC-gku45NehfAQYrSS-1C4KY3HKUAJBYCcjIIlUZvWG7kYShkNME-sHlEFNgTGugDYHR3p5bBtm&t=1"+ Request-Id:+ - req_0CE3adl6VfRx02+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - 3c3+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "pi_3TUq5B2ESifGlJez1IcQm7th",+ "object": "payment_intent",+ "amount": 1000,+ "amount_capturable": 1000,+ "amount_details": {+ "tip": {}+ },+ "amount_received": 0,+ "application": null,+ "application_fee_amount": null,+ "automatic_payment_methods": {+ "allow_redirects": "never",+ "enabled": true+ },+ "canceled_at": null,+ "cancellation_reason": null,+ "capture_method": "manual",+ "client_secret": "pi_3TUq5B2ESifGlJez1IcQm7th_secret_0Q3XukcZ3l1MUwqEkASKOhdDK",+ "confirmation_method": "automatic",+ "created": 1778253173,+ "currency": "usd",+ "customer": null,+ "customer_account": null,+ "description": null,+ "excluded_payment_method_types": null,+ "invoice": null,+ "last_payment_error": null,+ "latest_charge": "ch_3TUq5B2ESifGlJez1RISTEDA",+ "livemode": false,+ "managed_payments": {+ "enabled": false+ },+ "metadata": {},+ "next_action": null,+ "on_behalf_of": null,+ "payment_method": "pm_1TUq5B2ESifGlJezQO2UfZxB",+ "payment_method_configuration_details": {+ "id": "pmc_1QVa9x2ESifGlJezRC5fgLVg",+ "parent": null+ },+ "payment_method_options": {+ "card": {+ "installments": null,+ "mandate_options": null,+ "network": null,+ "request_three_d_secure": "automatic"+ },+ "link": {+ "persistent_token": null+ }+ },+ "payment_method_types": [+ "card",+ "link"+ ],+ "processing": null,+ "receipt_email": null,+ "review": null,+ "setup_future_usage": null,+ "shared_payment_granted_token": null,+ "shipping": null,+ "source": null,+ "statement_descriptor": null,+ "statement_descriptor_suffix": null,+ "status": "requires_capture",+ "transfer_data": null,+ "transfer_group": null+ }+ recorded_at: Fri, 08 May 2026 15:12:54 GMT+- request:+ method: get+ uri: https://api.stripe.com/v1/payment_intents/pi_3TUq5B2ESifGlJez1IcQm7th?expand%5B%5D=payment_method+ body:+ encoding: US-ASCII+ string: ''+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/18.4.2 Spree Stripe/5.5.0.beta (https://spreecommerce.org)+ AIAgent/claude_code+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_0CE3adl6VfRx02","request_duration_ms":929}}'+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Fri, 08 May 2026 15:12:54 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '2897'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=8DkIkjC-gku45NehfAQYrSS-1C4KY3HKUAJBYCcjIIlUZvWG7kYShkNME-sHlEFNgTGugDYHR3p5bBtm;+ report-to csp+ Report-To:+ - '{"group":"csp","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/csp-report-v2?q=8DkIkjC-gku45NehfAQYrSS-1C4KY3HKUAJBYCcjIIlUZvWG7kYShkNME-sHlEFNgTGugDYHR3p5bBtm&t=1"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - csp="https://q.stripe.com/csp-report-v2?q=8DkIkjC-gku45NehfAQYrSS-1C4KY3HKUAJBYCcjIIlUZvWG7kYShkNME-sHlEFNgTGugDYHR3p5bBtm&t=1"+ Request-Id:+ - req_Z7DeOz4GieK1sq+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - 3c3+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "pi_3TUq5B2ESifGlJez1IcQm7th",+ "object": "payment_intent",+ "amount": 1000,+ "amount_capturable": 1000,+ "amount_details": {+ "tip": {}+ },+ "amount_received": 0,+ "application": null,+ "application_fee_amount": null,+ "automatic_payment_methods": {+ "allow_redirects": "never",+ "enabled": true+ },+ "canceled_at": null,+ "cancellation_reason": null,+ "capture_method": "manual",+ "client_secret": "pi_3TUq5B2ESifGlJez1IcQm7th_secret_0Q3XukcZ3l1MUwqEkASKOhdDK",+ "confirmation_method": "automatic",+ "created": 1778253173,+ "currency": "usd",+ "customer": null,+ "customer_account": null,+ "description": null,+ "excluded_payment_method_types": null,+ "invoice": null,+ "last_payment_error": null,+ "latest_charge": "ch_3TUq5B2ESifGlJez1RISTEDA",+ "livemode": false,+ "managed_payments": {+ "enabled": false+ },+ "metadata": {},+ "next_action": null,+ "on_behalf_of": null,+ "payment_method": {+ "id": "pm_1TUq5B2ESifGlJezQO2UfZxB",+ "object": "payment_method",+ "allow_redisplay": "unspecified",+ "billing_details": {+ "address": {+ "city": null,+ "country": null,+ "line1": null,+ "line2": null,+ "postal_code": null,+ "state": null+ },+ "email": null,+ "name": null,+ "phone": null,+ "tax_id": null+ },+ "card": {+ "brand": "visa",+ "checks": {+ "address_line1_check": null,+ "address_postal_code_check": null,+ "cvc_check": "pass"+ },+ "country": "US",+ "display_brand": "visa",+ "exp_month": 5,+ "exp_year": 2027,+ "fingerprint": "taGjeBd4Wh4btmTn",+ "funding": "credit",+ "generated_from": null,+ "last4": "4242",+ "networks": {+ "available": [+ "visa"+ ],+ "preferred": null+ },+ "regulated_status": "unregulated",+ "three_d_secure_usage": {+ "supported": true+ },+ "wallet": null+ },+ "created": 1778253173,+ "customer": null,+ "customer_account": null,+ "livemode": false,+ "metadata": {},+ "shared_payment_granted_token": null,+ "type": "card"+ },+ "payment_method_configuration_details": {+ "id": "pmc_1QVa9x2ESifGlJezRC5fgLVg",+ "parent": null+ },+ "payment_method_options": {+ "card": {+ "installments": null,+ "mandate_options": null,+ "network": null,+ "request_three_d_secure": "automatic"+ },+ "link": {+ "persistent_token": null+ }+ },+ "payment_method_types": [+ "card",+ "link"+ ],+ "processing": null,+ "receipt_email": null,+ "review": null,+ "setup_future_usage": null,+ "shared_payment_granted_token": null,+ "shipping": null,+ "source": null,+ "statement_descriptor": null,+ "statement_descriptor_suffix": null,+ "status": "requires_capture",+ "transfer_data": null,+ "transfer_group": null+ }+ recorded_at: Fri, 08 May 2026 15:12:54 GMT+- request:+ method: post+ uri: https://api.stripe.com/v1/payment_intents/pi_3TUq5B2ESifGlJez1IcQm7th/capture+ body:+ encoding: UTF-8+ string: amount_to_capture=1000+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/18.4.2 Spree Stripe/5.5.0.beta (https://spreecommerce.org)+ AIAgent/claude_code+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_Z7DeOz4GieK1sq","request_duration_ms":260}}'+ Idempotency-Key:+ - 279bc23e-c124-4c14-8c78-89fe51235c4c+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Content-Type:+ - application/x-www-form-urlencoded+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Fri, 08 May 2026 15:12:55 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '1698'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=8DkIkjC-gku45NehfAQYrSS-1C4KY3HKUAJBYCcjIIlUZvWG7kYShkNME-sHlEFNgTGugDYHR3p5bBtm;+ report-to csp+ Idempotency-Key:+ - 279bc23e-c124-4c14-8c78-89fe51235c4c+ Original-Request:+ - req_ttFRqofAbo1BAB+ Report-To:+ - '{"group":"csp","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/csp-report-v2?q=8DkIkjC-gku45NehfAQYrSS-1C4KY3HKUAJBYCcjIIlUZvWG7kYShkNME-sHlEFNgTGugDYHR3p5bBtm&t=1"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - csp="https://q.stripe.com/csp-report-v2?q=8DkIkjC-gku45NehfAQYrSS-1C4KY3HKUAJBYCcjIIlUZvWG7kYShkNME-sHlEFNgTGugDYHR3p5bBtm&t=1"+ Request-Id:+ - req_ttFRqofAbo1BAB+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - 3c3+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "pi_3TUq5B2ESifGlJez1IcQm7th",+ "object": "payment_intent",+ "amount": 1000,+ "amount_capturable": 0,+ "amount_details": {+ "tip": {}+ },+ "amount_received": 1000,+ "application": null,+ "application_fee_amount": null,+ "automatic_payment_methods": {+ "allow_redirects": "never",+ "enabled": true+ },+ "canceled_at": null,+ "cancellation_reason": null,+ "capture_method": "manual",+ "client_secret": "pi_3TUq5B2ESifGlJez1IcQm7th_secret_0Q3XukcZ3l1MUwqEkASKOhdDK",+ "confirmation_method": "automatic",+ "created": 1778253173,+ "currency": "usd",+ "customer": null,+ "customer_account": null,+ "description": null,+ "excluded_payment_method_types": null,+ "invoice": null,+ "last_payment_error": null,+ "latest_charge": "ch_3TUq5B2ESifGlJez1RISTEDA",+ "livemode": false,+ "managed_payments": {+ "enabled": false+ },+ "metadata": {},+ "next_action": null,+ "on_behalf_of": null,+ "payment_method": "pm_1TUq5B2ESifGlJezQO2UfZxB",+ "payment_method_configuration_details": {+ "id": "pmc_1QVa9x2ESifGlJezRC5fgLVg",+ "parent": null+ },+ "payment_method_options": {+ "card": {+ "installments": null,+ "mandate_options": null,+ "network": null,+ "request_three_d_secure": "automatic"+ },+ "link": {+ "persistent_token": null+ }+ },+ "payment_method_types": [+ "card",+ "link"+ ],+ "processing": null,+ "receipt_email": null,+ "review": null,+ "setup_future_usage": null,+ "shared_payment_granted_token": null,+ "shipping": null,+ "source": null,+ "statement_descriptor": null,+ "statement_descriptor_suffix": null,+ "status": "succeeded",+ "transfer_data": null,+ "transfer_group": null+ }+ recorded_at: Fri, 08 May 2026 15:12:55 GMT+recorded_with: VCR 6.4.0diff --git a/spree/providers/stripe/spec/vcr/capture_payment_intent_unsupported_state.yml b/spree/providers/stripe/spec/vcr/capture_payment_intent_unsupported_state.ymlnew file mode 100644index 0000000000..c06515478d--- /dev/null+++ b/spree/providers/stripe/spec/vcr/capture_payment_intent_unsupported_state.yml@@ -0,0 +1,303 @@+---+http_interactions:+- request:+ method: post+ uri: https://api.stripe.com/v1/payment_intents+ body:+ encoding: UTF-8+ string: amount=1000¤cy=usd&automatic_payment_methods[enabled]=true&automatic_payment_methods[allow_redirects]=never+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/18.4.2 Spree Stripe/5.5.0.beta (https://spreecommerce.org)+ AIAgent/claude_code+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Idempotency-Key:+ - 013b9787-f86d-49e9-8778-7b7e5932a33a+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Content-Type:+ - application/x-www-form-urlencoded+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Fri, 08 May 2026 15:12:52 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '1662'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=ib_-ibFZaxqlvMaIiEpIEqIUlrS2DkrHM3p_jXyt0G3GbwQ9fEpK14KnB9Qy3lY1dTxz72YKAXDpDsom;+ report-to csp+ Idempotency-Key:+ - 013b9787-f86d-49e9-8778-7b7e5932a33a+ Original-Request:+ - req_V0IiVAFBq9SZdS+ Report-To:+ - '{"group":"csp","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/csp-report-v2?q=ib_-ibFZaxqlvMaIiEpIEqIUlrS2DkrHM3p_jXyt0G3GbwQ9fEpK14KnB9Qy3lY1dTxz72YKAXDpDsom&t=1"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - csp="https://q.stripe.com/csp-report-v2?q=ib_-ibFZaxqlvMaIiEpIEqIUlrS2DkrHM3p_jXyt0G3GbwQ9fEpK14KnB9Qy3lY1dTxz72YKAXDpDsom&t=1"+ Request-Id:+ - req_V0IiVAFBq9SZdS+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - 3c3+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "pi_3TUq5A2ESifGlJez1yVQug45",+ "object": "payment_intent",+ "amount": 1000,+ "amount_capturable": 0,+ "amount_details": {+ "tip": {}+ },+ "amount_received": 0,+ "application": null,+ "application_fee_amount": null,+ "automatic_payment_methods": {+ "allow_redirects": "never",+ "enabled": true+ },+ "canceled_at": null,+ "cancellation_reason": null,+ "capture_method": "automatic",+ "client_secret": "pi_3TUq5A2ESifGlJez1yVQug45_secret_dEflALw8oEr57BGy8zsCecOBt",+ "confirmation_method": "automatic",+ "created": 1778253172,+ "currency": "usd",+ "customer": null,+ "customer_account": null,+ "description": null,+ "excluded_payment_method_types": null,+ "invoice": null,+ "last_payment_error": null,+ "latest_charge": null,+ "livemode": false,+ "managed_payments": {+ "enabled": false+ },+ "metadata": {},+ "next_action": null,+ "on_behalf_of": null,+ "payment_method": null,+ "payment_method_configuration_details": {+ "id": "pmc_1QVa9x2ESifGlJezRC5fgLVg",+ "parent": null+ },+ "payment_method_options": {+ "card": {+ "installments": null,+ "mandate_options": null,+ "network": null,+ "request_three_d_secure": "automatic"+ },+ "link": {+ "persistent_token": null+ }+ },+ "payment_method_types": [+ "card",+ "link"+ ],+ "processing": null,+ "receipt_email": null,+ "review": null,+ "setup_future_usage": null,+ "shared_payment_granted_token": null,+ "shipping": null,+ "source": null,+ "statement_descriptor": null,+ "statement_descriptor_suffix": null,+ "status": "requires_payment_method",+ "transfer_data": null,+ "transfer_group": null+ }+ recorded_at: Fri, 08 May 2026 15:12:52 GMT+- request:+ method: get+ uri: https://api.stripe.com/v1/payment_intents/pi_3TUq5A2ESifGlJez1yVQug45?expand%5B%5D=payment_method+ body:+ encoding: US-ASCII+ string: ''+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/18.4.2 Spree Stripe/5.5.0.beta (https://spreecommerce.org)+ AIAgent/claude_code+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_V0IiVAFBq9SZdS","request_duration_ms":441}}'+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Fri, 08 May 2026 15:12:53 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '1662'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=8DkIkjC-gku45NehfAQYrSS-1C4KY3HKUAJBYCcjIIlUZvWG7kYShkNME-sHlEFNgTGugDYHR3p5bBtm;+ report-to csp+ Report-To:+ - '{"group":"csp","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/csp-report-v2?q=8DkIkjC-gku45NehfAQYrSS-1C4KY3HKUAJBYCcjIIlUZvWG7kYShkNME-sHlEFNgTGugDYHR3p5bBtm&t=1"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - csp="https://q.stripe.com/csp-report-v2?q=8DkIkjC-gku45NehfAQYrSS-1C4KY3HKUAJBYCcjIIlUZvWG7kYShkNME-sHlEFNgTGugDYHR3p5bBtm&t=1"+ Request-Id:+ - req_1FyKrdIqfbS4iC+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - 3c3+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "pi_3TUq5A2ESifGlJez1yVQug45",+ "object": "payment_intent",+ "amount": 1000,+ "amount_capturable": 0,+ "amount_details": {+ "tip": {}+ },+ "amount_received": 0,+ "application": null,+ "application_fee_amount": null,+ "automatic_payment_methods": {+ "allow_redirects": "never",+ "enabled": true+ },+ "canceled_at": null,+ "cancellation_reason": null,+ "capture_method": "automatic",+ "client_secret": "pi_3TUq5A2ESifGlJez1yVQug45_secret_dEflALw8oEr57BGy8zsCecOBt",+ "confirmation_method": "automatic",+ "created": 1778253172,+ "currency": "usd",+ "customer": null,+ "customer_account": null,+ "description": null,+ "excluded_payment_method_types": null,+ "invoice": null,+ "last_payment_error": null,+ "latest_charge": null,+ "livemode": false,+ "managed_payments": {+ "enabled": false+ },+ "metadata": {},+ "next_action": null,+ "on_behalf_of": null,+ "payment_method": null,+ "payment_method_configuration_details": {+ "id": "pmc_1QVa9x2ESifGlJezRC5fgLVg",+ "parent": null+ },+ "payment_method_options": {+ "card": {+ "installments": null,+ "mandate_options": null,+ "network": null,+ "request_three_d_secure": "automatic"+ },+ "link": {+ "persistent_token": null+ }+ },+ "payment_method_types": [+ "card",+ "link"+ ],+ "processing": null,+ "receipt_email": null,+ "review": null,+ "setup_future_usage": null,+ "shared_payment_granted_token": null,+ "shipping": null,+ "source": null,+ "statement_descriptor": null,+ "statement_descriptor_suffix": null,+ "status": "requires_payment_method",+ "transfer_data": null,+ "transfer_group": null+ }+ recorded_at: Fri, 08 May 2026 15:12:53 GMT+recorded_with: VCR 6.4.0diff --git a/spree/providers/stripe/spec/vcr/create_another_gateway_webhooks.yml b/spree/providers/stripe/spec/vcr/create_another_gateway_webhooks.ymlnew file mode 100644index 0000000000..134fca3738--- /dev/null+++ b/spree/providers/stripe/spec/vcr/create_another_gateway_webhooks.yml@@ -0,0 +1,495 @@+---+http_interactions:+- request:+ method: get+ uri: https://api.stripe.com/v1/webhook_endpoints+ body:+ encoding: US-ASCII+ string: ''+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/18.4.2 Spree Stripe/5.5.0.beta (https://spreecommerce.org)+ AIAgent/claude_code+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_eelyyg4ahZ9eai","request_duration_ms":234}}'+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Fri, 08 May 2026 15:16:47 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '2894'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=F6Z3vOJntd60cmXfwceRRstcwCrzO9P9eCrum9DbLMfgKGHBj05saB6-QjdEjej96nqe5tqSHq-PloI-;+ report-to csp+ Report-To:+ - '{"group":"csp","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/csp-report-v2?q=F6Z3vOJntd60cmXfwceRRstcwCrzO9P9eCrum9DbLMfgKGHBj05saB6-QjdEjej96nqe5tqSHq-PloI-&t=1"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - csp="https://q.stripe.com/csp-report-v2?q=F6Z3vOJntd60cmXfwceRRstcwCrzO9P9eCrum9DbLMfgKGHBj05saB6-QjdEjej96nqe5tqSHq-PloI-&t=1"+ Request-Id:+ - req_blzsHqfRwRNNIg+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - 3c3+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "object": "list",+ "data": [+ {+ "id": "we_1TUq8w2ESifGlJezdHC8YApb",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1778253406,+ "description": null,+ "enabled_events": [+ "payment_intent.amount_capturable_updated",+ "payment_intent.payment_failed",+ "payment_intent.succeeded",+ "setup_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "https://spreecommerce.org/stripe/"+ },+ {+ "id": "we_1TAo7D2ESifGlJezqJgSzMOX",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1773479051,+ "description": null,+ "enabled_events": [+ "payment_intent.payment_failed",+ "payment_intent.succeeded",+ "setup_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "http://spreecommerce.org:3000/api/v3/webhooks/payments/pm_UkLWZg9DAJ"+ },+ {+ "id": "we_1RiGw92ESifGlJez0JdTGlQl",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1751901993,+ "description": null,+ "enabled_events": [+ "payment_intent.payment_failed",+ "payment_intent.succeeded",+ "setup_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "https://www.example.com/stripe"+ },+ {+ "id": "we_1R1ner2ESifGlJezydmoL0st",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1741779669,+ "description": null,+ "enabled_events": [+ "payment_intent.payment_failed",+ "payment_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "https://app.vendo.dev/stripe"+ },+ {+ "id": "we_1QqwMZ2ESifGlJezP0GF1ZHz",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": "ca_ROMtxw3OIzmnsWikic1yZQJ7AgMpmdOF",+ "created": 1739191523,+ "description": null,+ "enabled_events": [+ "account.updated"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "https://app.lvh.me/stripe"+ },+ {+ "id": "we_1QqwMY2ESifGlJezzFo7W4xt",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1739191522,+ "description": null,+ "enabled_events": [+ "payment_intent.payment_failed",+ "payment_intent.processing",+ "payment_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "https://app.lvh.me/stripe"+ }+ ],+ "has_more": false,+ "url": "/v1/webhook_endpoints"+ }+ recorded_at: Fri, 08 May 2026 15:16:47 GMT+- request:+ method: post+ uri: https://api.stripe.com/v1/webhook_endpoints+ body:+ encoding: UTF-8+ string: url=https%3A%2F%2Fspreecommerce.org%2Fstripe%2F&enabled_events[0]=payment_intent.amount_capturable_updated&enabled_events[1]=payment_intent.payment_failed&enabled_events[2]=payment_intent.succeeded&enabled_events[3]=setup_intent.succeeded&connect=false+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/18.4.2 Spree Stripe/5.5.0.beta (https://spreecommerce.org)+ AIAgent/claude_code+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_blzsHqfRwRNNIg","request_duration_ms":221}}'+ Idempotency-Key:+ - ad86e770-dc79-4baa-841b-14b87d678dab+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Content-Type:+ - application/x-www-form-urlencoded+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Fri, 08 May 2026 15:16:48 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '502'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=F6Z3vOJntd60cmXfwceRRstcwCrzO9P9eCrum9DbLMfgKGHBj05saB6-QjdEjej96nqe5tqSHq-PloI-;+ report-to csp+ Idempotency-Key:+ - ad86e770-dc79-4baa-841b-14b87d678dab+ Original-Request:+ - req_c3YVdQUfJ5iEQD+ Report-To:+ - '{"group":"csp","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/csp-report-v2?q=F6Z3vOJntd60cmXfwceRRstcwCrzO9P9eCrum9DbLMfgKGHBj05saB6-QjdEjej96nqe5tqSHq-PloI-&t=1"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - csp="https://q.stripe.com/csp-report-v2?q=F6Z3vOJntd60cmXfwceRRstcwCrzO9P9eCrum9DbLMfgKGHBj05saB6-QjdEjej96nqe5tqSHq-PloI-&t=1"+ Request-Id:+ - req_c3YVdQUfJ5iEQD+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - 3c3+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "we_1TUq8x2ESifGlJezmllQ9fRC",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1778253407,+ "description": null,+ "enabled_events": [+ "payment_intent.amount_capturable_updated",+ "payment_intent.payment_failed",+ "payment_intent.succeeded",+ "setup_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "secret": "<STRIPE_WEBHOOK_SIGNING_SECRET>",+ "status": "enabled",+ "url": "https://spreecommerce.org/stripe/"+ }+ recorded_at: Fri, 08 May 2026 15:16:48 GMT+- request:+ method: get+ uri: https://api.stripe.com/v1/webhook_endpoints+ body:+ encoding: US-ASCII+ string: ''+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/18.4.2 Spree Stripe/5.5.0.beta (https://spreecommerce.org)+ AIAgent/claude_code+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_c3YVdQUfJ5iEQD","request_duration_ms":381}}'+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Fri, 08 May 2026 15:16:48 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '3416'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=F6Z3vOJntd60cmXfwceRRstcwCrzO9P9eCrum9DbLMfgKGHBj05saB6-QjdEjej96nqe5tqSHq-PloI-;+ report-to csp+ Report-To:+ - '{"group":"csp","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/csp-report-v2?q=F6Z3vOJntd60cmXfwceRRstcwCrzO9P9eCrum9DbLMfgKGHBj05saB6-QjdEjej96nqe5tqSHq-PloI-&t=1"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - csp="https://q.stripe.com/csp-report-v2?q=F6Z3vOJntd60cmXfwceRRstcwCrzO9P9eCrum9DbLMfgKGHBj05saB6-QjdEjej96nqe5tqSHq-PloI-&t=1"+ Request-Id:+ - req_MXBkLe0lwmi5jR+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - 3c3+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "object": "list",+ "data": [+ {+ "id": "we_1TUq8x2ESifGlJezmllQ9fRC",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1778253407,+ "description": null,+ "enabled_events": [+ "payment_intent.amount_capturable_updated",+ "payment_intent.payment_failed",+ "payment_intent.succeeded",+ "setup_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "https://spreecommerce.org/stripe/"+ },+ {+ "id": "we_1TUq8w2ESifGlJezdHC8YApb",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1778253406,+ "description": null,+ "enabled_events": [+ "payment_intent.amount_capturable_updated",+ "payment_intent.payment_failed",+ "payment_intent.succeeded",+ "setup_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "https://spreecommerce.org/stripe/"+ },+ {+ "id": "we_1TAo7D2ESifGlJezqJgSzMOX",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1773479051,+ "description": null,+ "enabled_events": [+ "payment_intent.payment_failed",+ "payment_intent.succeeded",+ "setup_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "http://spreecommerce.org:3000/api/v3/webhooks/payments/pm_UkLWZg9DAJ"+ },+ {+ "id": "we_1RiGw92ESifGlJez0JdTGlQl",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1751901993,+ "description": null,+ "enabled_events": [+ "payment_intent.payment_failed",+ "payment_intent.succeeded",+ "setup_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "https://www.example.com/stripe"+ },+ {+ "id": "we_1R1ner2ESifGlJezydmoL0st",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1741779669,+ "description": null,+ "enabled_events": [+ "payment_intent.payment_failed",+ "payment_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "https://app.vendo.dev/stripe"+ },+ {+ "id": "we_1QqwMZ2ESifGlJezP0GF1ZHz",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": "ca_ROMtxw3OIzmnsWikic1yZQJ7AgMpmdOF",+ "created": 1739191523,+ "description": null,+ "enabled_events": [+ "account.updated"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "https://app.lvh.me/stripe"+ },+ {+ "id": "we_1QqwMY2ESifGlJezzFo7W4xt",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1739191522,+ "description": null,+ "enabled_events": [+ "payment_intent.payment_failed",+ "payment_intent.processing",+ "payment_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "https://app.lvh.me/stripe"+ }+ ],+ "has_more": false,+ "url": "/v1/webhook_endpoints"+ }+ recorded_at: Fri, 08 May 2026 15:16:48 GMT+recorded_with: VCR 6.4.0diff --git a/spree/providers/stripe/spec/vcr/create_customer.yml b/spree/providers/stripe/spec/vcr/create_customer.ymlnew file mode 100644index 0000000000..5af9589ffc--- /dev/null+++ b/spree/providers/stripe/spec/vcr/create_customer.yml@@ -0,0 +1,223 @@+---+http_interactions:+- request:+ method: post+ uri: https://api.stripe.com/v1/customers+ body:+ encoding: UTF-8+ string: address[city]=San+Francisco&address[line1]=100+California+Street&address[line2]=Apt+1&address[postal_code]=94111&address[country]=United+States+of+America&address[state]=California&email=test%40example.com&name=John+Doe+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 Spree Stripe/5.0.0.alpha (https://spreecommerce.org)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Wed, 09 Jul 2025 15:50:49 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '821'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=QIoqrK3c43g-1giy2ws3aqVBZucVDv2Cekn0w__tL2t3jyfKGmUFjlP3C5a9bYR1Uz6n4KYszP8M_RIn+ Idempotency-Key:+ - 1528d097-00c4-4d73-aec6-ce8f9ec13c07+ Original-Request:+ - req_zib7L3mBFBGqiV+ Request-Id:+ - req_zib7L3mBFBGqiV+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - ABGHIJ+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "cus_SeIsxI1TG3dGJv",+ "object": "customer",+ "address": {+ "city": "San Francisco",+ "country": "United States of America",+ "line1": "100 California Street",+ "line2": "Apt 1",+ "postal_code": "94111",+ "state": "California"+ },+ "balance": 0,+ "created": 1752076249,+ "currency": null,+ "default_source": null,+ "delinquent": false,+ "description": null,+ "discount": null,+ "email": "[email protected]",+ "invoice_prefix": "NRF6DCGN",+ "invoice_settings": {+ "custom_fields": null,+ "default_payment_method": null,+ "footer": null,+ "rendering_options": null+ },+ "livemode": false,+ "metadata": {},+ "name": "John Doe",+ "next_invoice_sequence": 1,+ "phone": null,+ "preferred_locales": [],+ "shipping": null,+ "tax_exempt": "none",+ "test_clock": null+ }+ recorded_at: Wed, 09 Jul 2025 15:50:49 GMT+- request:+ method: get+ uri: https://api.stripe.com/v1/customers/cus_SeIsxI1TG3dGJv+ body:+ encoding: US-ASCII+ string: ''+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 Spree Stripe/5.0.0.alpha (https://spreecommerce.org)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Wed, 09 Jul 2025 15:52:06 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '821'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=rTuNmXofIr7Bqlo21t41dIsuPKCTwsylX4kc1AQlRCoyKKptU7-h34SAIMK--D9Ai6W7iIZ6qnmnZJxC+ Request-Id:+ - req_sp0USclSJKFEAK+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - ABGHIJ+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "cus_SeIsxI1TG3dGJv",+ "object": "customer",+ "address": {+ "city": "San Francisco",+ "country": "United States of America",+ "line1": "100 California Street",+ "line2": "Apt 1",+ "postal_code": "94111",+ "state": "California"+ },+ "balance": 0,+ "created": 1752076249,+ "currency": null,+ "default_source": null,+ "delinquent": false,+ "description": null,+ "discount": null,+ "email": "[email protected]",+ "invoice_prefix": "NRF6DCGN",+ "invoice_settings": {+ "custom_fields": null,+ "default_payment_method": null,+ "footer": null,+ "rendering_options": null+ },+ "livemode": false,+ "metadata": {},+ "name": "John Doe",+ "next_invoice_sequence": 1,+ "phone": null,+ "preferred_locales": [],+ "shipping": null,+ "tax_exempt": "none",+ "test_clock": null+ }+ recorded_at: Wed, 09 Jul 2025 15:52:06 GMT+recorded_with: VCR 6.3.1diff --git a/spree/providers/stripe/spec/vcr/create_customer_based_on_user.yml b/spree/providers/stripe/spec/vcr/create_customer_based_on_user.ymlnew file mode 100644index 0000000000..a11a35c0e0--- /dev/null+++ b/spree/providers/stripe/spec/vcr/create_customer_based_on_user.yml@@ -0,0 +1,223 @@+---+http_interactions:+- request:+ method: post+ uri: https://api.stripe.com/v1/customers+ body:+ encoding: UTF-8+ string: address[city]=New+York&address[line1]=100+Main+Street&address[line2]=Apt+2&address[postal_code]=10001&address[country]=United+States+of+America&address[state]=New+York&email=test%40example.com&name=Jane+Moe+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 Spree Stripe/5.0.0.alpha (https://spreecommerce.org)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Wed, 09 Jul 2025 15:57:25 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '808'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=fUFLn2j3-z1KRjfv-RqEG2Ofz6n0nWjCTMyvKvs725XG6scQDIgIR8pVWADHKt5iG7GUjgI34J2Q2aO6+ Idempotency-Key:+ - 4af89f33-ce96-4bd4-999e-27727ae57e64+ Original-Request:+ - req_WawpLvjm2VOo92+ Request-Id:+ - req_WawpLvjm2VOo92+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - ABGHIJ+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "cus_SeIzmCh2MX8eaK",+ "object": "customer",+ "address": {+ "city": "New York",+ "country": "United States of America",+ "line1": "100 Main Street",+ "line2": "Apt 2",+ "postal_code": "10001",+ "state": "New York"+ },+ "balance": 0,+ "created": 1752076645,+ "currency": null,+ "default_source": null,+ "delinquent": false,+ "description": null,+ "discount": null,+ "email": "[email protected]",+ "invoice_prefix": "X8FIIPUY",+ "invoice_settings": {+ "custom_fields": null,+ "default_payment_method": null,+ "footer": null,+ "rendering_options": null+ },+ "livemode": false,+ "metadata": {},+ "name": "Jane Moe",+ "next_invoice_sequence": 1,+ "phone": null,+ "preferred_locales": [],+ "shipping": null,+ "tax_exempt": "none",+ "test_clock": null+ }+ recorded_at: Wed, 09 Jul 2025 15:57:25 GMT+- request:+ method: get+ uri: https://api.stripe.com/v1/customers/cus_SeIzmCh2MX8eaK+ body:+ encoding: US-ASCII+ string: ''+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 Spree Stripe/5.0.0.alpha (https://spreecommerce.org)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Wed, 09 Jul 2025 15:57:26 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '808'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=KSCC9H4qQqlr4QQxL7khV-wCePHI5Qo_uyaDc_-XK3WkGCY3KR-O6juNZkrDVH91J8lKz9k0ybBbDgqU+ Request-Id:+ - req_LJibUszP78tF55+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - ABGHIJ+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "cus_SeIzmCh2MX8eaK",+ "object": "customer",+ "address": {+ "city": "New York",+ "country": "United States of America",+ "line1": "100 Main Street",+ "line2": "Apt 2",+ "postal_code": "10001",+ "state": "New York"+ },+ "balance": 0,+ "created": 1752076645,+ "currency": null,+ "default_source": null,+ "delinquent": false,+ "description": null,+ "discount": null,+ "email": "[email protected]",+ "invoice_prefix": "X8FIIPUY",+ "invoice_settings": {+ "custom_fields": null,+ "default_payment_method": null,+ "footer": null,+ "rendering_options": null+ },+ "livemode": false,+ "metadata": {},+ "name": "Jane Moe",+ "next_invoice_sequence": 1,+ "phone": null,+ "preferred_locales": [],+ "shipping": null,+ "tax_exempt": "none",+ "test_clock": null+ }+ recorded_at: Wed, 09 Jul 2025 15:57:26 GMT+recorded_with: VCR 6.3.1diff --git a/spree/providers/stripe/spec/vcr/create_gateway_webhooks.yml b/spree/providers/stripe/spec/vcr/create_gateway_webhooks.ymlnew file mode 100644index 0000000000..45aa8782a0--- /dev/null+++ b/spree/providers/stripe/spec/vcr/create_gateway_webhooks.yml@@ -0,0 +1,457 @@+---+http_interactions:+- request:+ method: get+ uri: https://api.stripe.com/v1/webhook_endpoints+ body:+ encoding: US-ASCII+ string: ''+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/18.4.2 Spree Stripe/5.5.0.beta (https://spreecommerce.org)+ AIAgent/claude_code+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Fri, 08 May 2026 15:16:45 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '2372'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=gPadiA8gqaE1tIiBwcovCmfX4N5k5tArOP8Z2H1B6VZsmnw3q7MD7Ix9IWxKF4UApVR1-qJWugIjaJMk;+ report-to csp+ Report-To:+ - '{"group":"csp","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/csp-report-v2?q=gPadiA8gqaE1tIiBwcovCmfX4N5k5tArOP8Z2H1B6VZsmnw3q7MD7Ix9IWxKF4UApVR1-qJWugIjaJMk&t=1"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - csp="https://q.stripe.com/csp-report-v2?q=gPadiA8gqaE1tIiBwcovCmfX4N5k5tArOP8Z2H1B6VZsmnw3q7MD7Ix9IWxKF4UApVR1-qJWugIjaJMk&t=1"+ Request-Id:+ - req_U7M2vkWCL6nokW+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - 3c3+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "object": "list",+ "data": [+ {+ "id": "we_1TAo7D2ESifGlJezqJgSzMOX",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1773479051,+ "description": null,+ "enabled_events": [+ "payment_intent.payment_failed",+ "payment_intent.succeeded",+ "setup_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "http://spreecommerce.org:3000/api/v3/webhooks/payments/pm_UkLWZg9DAJ"+ },+ {+ "id": "we_1RiGw92ESifGlJez0JdTGlQl",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1751901993,+ "description": null,+ "enabled_events": [+ "payment_intent.payment_failed",+ "payment_intent.succeeded",+ "setup_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "https://www.example.com/stripe"+ },+ {+ "id": "we_1R1ner2ESifGlJezydmoL0st",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1741779669,+ "description": null,+ "enabled_events": [+ "payment_intent.payment_failed",+ "payment_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "https://app.vendo.dev/stripe"+ },+ {+ "id": "we_1QqwMZ2ESifGlJezP0GF1ZHz",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": "ca_ROMtxw3OIzmnsWikic1yZQJ7AgMpmdOF",+ "created": 1739191523,+ "description": null,+ "enabled_events": [+ "account.updated"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "https://app.lvh.me/stripe"+ },+ {+ "id": "we_1QqwMY2ESifGlJezzFo7W4xt",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1739191522,+ "description": null,+ "enabled_events": [+ "payment_intent.payment_failed",+ "payment_intent.processing",+ "payment_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "https://app.lvh.me/stripe"+ }+ ],+ "has_more": false,+ "url": "/v1/webhook_endpoints"+ }+ recorded_at: Fri, 08 May 2026 15:16:45 GMT+- request:+ method: post+ uri: https://api.stripe.com/v1/webhook_endpoints+ body:+ encoding: UTF-8+ string: url=https%3A%2F%2Fspreecommerce.org%2Fstripe%2F&enabled_events[0]=payment_intent.amount_capturable_updated&enabled_events[1]=payment_intent.payment_failed&enabled_events[2]=payment_intent.succeeded&enabled_events[3]=setup_intent.succeeded&connect=false+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/18.4.2 Spree Stripe/5.5.0.beta (https://spreecommerce.org)+ AIAgent/claude_code+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_U7M2vkWCL6nokW","request_duration_ms":351}}'+ Idempotency-Key:+ - e4bcc425-db3e-4156-bbc3-313f4d9a4f67+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Content-Type:+ - application/x-www-form-urlencoded+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Fri, 08 May 2026 15:16:46 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '502'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=F6Z3vOJntd60cmXfwceRRstcwCrzO9P9eCrum9DbLMfgKGHBj05saB6-QjdEjej96nqe5tqSHq-PloI-;+ report-to csp+ Idempotency-Key:+ - e4bcc425-db3e-4156-bbc3-313f4d9a4f67+ Original-Request:+ - req_cHJ8fZrKYzXd7l+ Report-To:+ - '{"group":"csp","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/csp-report-v2?q=F6Z3vOJntd60cmXfwceRRstcwCrzO9P9eCrum9DbLMfgKGHBj05saB6-QjdEjej96nqe5tqSHq-PloI-&t=1"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - csp="https://q.stripe.com/csp-report-v2?q=F6Z3vOJntd60cmXfwceRRstcwCrzO9P9eCrum9DbLMfgKGHBj05saB6-QjdEjej96nqe5tqSHq-PloI-&t=1"+ Request-Id:+ - req_cHJ8fZrKYzXd7l+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - 3c3+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "we_1TUq8w2ESifGlJezdHC8YApb",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1778253406,+ "description": null,+ "enabled_events": [+ "payment_intent.amount_capturable_updated",+ "payment_intent.payment_failed",+ "payment_intent.succeeded",+ "setup_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "secret": "<STRIPE_WEBHOOK_SIGNING_SECRET>",+ "status": "enabled",+ "url": "https://spreecommerce.org/stripe/"+ }+ recorded_at: Fri, 08 May 2026 15:16:46 GMT+- request:+ method: get+ uri: https://api.stripe.com/v1/webhook_endpoints+ body:+ encoding: US-ASCII+ string: ''+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/18.4.2 Spree Stripe/5.5.0.beta (https://spreecommerce.org)+ AIAgent/claude_code+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_cHJ8fZrKYzXd7l","request_duration_ms":615}}'+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Fri, 08 May 2026 15:16:46 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '2894'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=F6Z3vOJntd60cmXfwceRRstcwCrzO9P9eCrum9DbLMfgKGHBj05saB6-QjdEjej96nqe5tqSHq-PloI-;+ report-to csp+ Report-To:+ - '{"group":"csp","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/csp-report-v2?q=F6Z3vOJntd60cmXfwceRRstcwCrzO9P9eCrum9DbLMfgKGHBj05saB6-QjdEjej96nqe5tqSHq-PloI-&t=1"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - csp="https://q.stripe.com/csp-report-v2?q=F6Z3vOJntd60cmXfwceRRstcwCrzO9P9eCrum9DbLMfgKGHBj05saB6-QjdEjej96nqe5tqSHq-PloI-&t=1"+ Request-Id:+ - req_ZU3Jye3BVOYTTB+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - 3c3+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "object": "list",+ "data": [+ {+ "id": "we_1TUq8w2ESifGlJezdHC8YApb",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1778253406,+ "description": null,+ "enabled_events": [+ "payment_intent.amount_capturable_updated",+ "payment_intent.payment_failed",+ "payment_intent.succeeded",+ "setup_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "https://spreecommerce.org/stripe/"+ },+ {+ "id": "we_1TAo7D2ESifGlJezqJgSzMOX",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1773479051,+ "description": null,+ "enabled_events": [+ "payment_intent.payment_failed",+ "payment_intent.succeeded",+ "setup_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "http://spreecommerce.org:3000/api/v3/webhooks/payments/pm_UkLWZg9DAJ"+ },+ {+ "id": "we_1RiGw92ESifGlJez0JdTGlQl",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1751901993,+ "description": null,+ "enabled_events": [+ "payment_intent.payment_failed",+ "payment_intent.succeeded",+ "setup_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "https://www.example.com/stripe"+ },+ {+ "id": "we_1R1ner2ESifGlJezydmoL0st",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1741779669,+ "description": null,+ "enabled_events": [+ "payment_intent.payment_failed",+ "payment_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "https://app.vendo.dev/stripe"+ },+ {+ "id": "we_1QqwMZ2ESifGlJezP0GF1ZHz",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": "ca_ROMtxw3OIzmnsWikic1yZQJ7AgMpmdOF",+ "created": 1739191523,+ "description": null,+ "enabled_events": [+ "account.updated"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "https://app.lvh.me/stripe"+ },+ {+ "id": "we_1QqwMY2ESifGlJezzFo7W4xt",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1739191522,+ "description": null,+ "enabled_events": [+ "payment_intent.payment_failed",+ "payment_intent.processing",+ "payment_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "https://app.lvh.me/stripe"+ }+ ],+ "has_more": false,+ "url": "/v1/webhook_endpoints"+ }+ recorded_at: Fri, 08 May 2026 15:16:46 GMT+recorded_with: VCR 6.4.0diff --git a/spree/providers/stripe/spec/vcr/create_payment_intent.yml b/spree/providers/stripe/spec/vcr/create_payment_intent.ymlnew file mode 100644index 0000000000..c7a1964901--- /dev/null+++ b/spree/providers/stripe/spec/vcr/create_payment_intent.yml@@ -0,0 +1,290 @@+---+http_interactions:+- request:+ method: post+ uri: https://api.stripe.com/v1/customers+ body:+ encoding: UTF-8+ string: address[city]=Herndon&address[line1]=1+Lovely+Street&address[line2]=Northwest&address[postal_code]=35005&address[country]=United+States&email=mable_beahan%40romaguera.info&name=John+Doe+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 Spree Stripe/1.0.0 (https://spreecommerce.org)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Thu, 19 Dec 2024 16:33:26 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '805'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; upgrade-insecure-requests;+ report-uri /csp-violation https://q.stripe.com/csp-violation?q=Oc6A_8cbAr2Kv-QWbIhLUXdHSDX0CJQtnaNRhoUGzNiRrPiEioFSvymGbB55jyPhMMKpiHrttQ%3D%3D+ Cross-Origin-Opener-Policy-Report-Only:+ - same-origin; report-to="coop"+ Idempotency-Key:+ - 00f89279-c62b-4a72-8027-ec79b2f34854+ Original-Request:+ - req_vVSLBPe0xdRZzp+ Report-To:+ - '{"group":"coop","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/coop-report"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - coop="https://q.stripe.com/coop-report"+ Request-Id:+ - req_vVSLBPe0xdRZzp+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Content-Type-Options:+ - nosniff+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - AB+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "cus_RQdxueQXRuXVxx",+ "object": "customer",+ "address": {+ "city": "Herndon",+ "country": "United States",+ "line1": "1 Lovely Street",+ "line2": "Northwest",+ "postal_code": "35005",+ "state": null+ },+ "balance": 0,+ "created": 1734626006,+ "currency": null,+ "default_source": null,+ "delinquent": false,+ "description": null,+ "discount": null,+ "email": "[email protected]",+ "invoice_prefix": "3BDCB319",+ "invoice_settings": {+ "custom_fields": null,+ "default_payment_method": null,+ "footer": null,+ "rendering_options": null+ },+ "livemode": false,+ "metadata": {},+ "name": "John Doe",+ "next_invoice_sequence": 1,+ "phone": null,+ "preferred_locales": [],+ "shipping": null,+ "tax_exempt": "none",+ "test_clock": null+ }+ recorded_at: Thu, 19 Dec 2024 16:33:26 GMT+- request:+ method: post+ uri: https://api.stripe.com/v1/payment_intents+ body:+ encoding: UTF-8+ string: payment_method_options[card][setup_future_usage]=off_session&amount=100&customer=cus_RQdxueQXRuXVxx¤cy=USD&statement_descriptor_suffix=R111598559+tempora&automatic_payment_methods[enabled]=true&transfer_group=R111598559&metadata[spree_order_id]=7b2830cc-1b6c-430c-9dbe-ca948f042c41&shipping[address][city]=Herndon&shipping[address][country]=US&shipping[address][line1]=2+Lovely+Street&shipping[address][line2]=Northwest&shipping[address][postal_code]=35005&shipping[address][state]=STATE_ABBR_2&shipping[name]=John+Doe+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 Spree Stripe/1.0.0 (https://spreecommerce.org)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_vVSLBPe0xdRZzp","request_duration_ms":420}}'+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Thu, 19 Dec 2024 16:33:26 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '1937'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; upgrade-insecure-requests;+ report-uri /csp-violation https://q.stripe.com/csp-violation?q=2j2Vsh7jp5c3btBnKbykkVlMgzGeWB8dJEwXVrABurXhOHy3GWRKKmJcKW-VVmXuvwE4cSeKAA%3D%3D+ Cross-Origin-Opener-Policy-Report-Only:+ - same-origin; report-to="coop"+ Idempotency-Key:+ - fc513147-4969-45d5-846a-6fd95b2ee710+ Original-Request:+ - req_KOuz9aRI8GQidn+ Report-To:+ - '{"group":"coop","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/coop-report"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - coop="https://q.stripe.com/coop-report"+ Request-Id:+ - req_KOuz9aRI8GQidn+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Content-Type-Options:+ - nosniff+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - AB+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "pi_3QXmfC2ESifGlJez0qSmz8Vf",+ "object": "payment_intent",+ "amount": 100,+ "amount_capturable": 0,+ "amount_details": {+ "tip": {}+ },+ "amount_received": 0,+ "application": null,+ "application_fee_amount": null,+ "automatic_payment_methods": {+ "allow_redirects": "always",+ "enabled": true+ },+ "canceled_at": null,+ "cancellation_reason": null,+ "capture_method": "automatic",+ "client_secret": "pi_3QXmfC2ESifGlJez0qSmz8Vf_secret_y0WGpGMeCM5Ce0g5hHi1zzxcp",+ "confirmation_method": "automatic",+ "created": 1734626006,+ "currency": "usd",+ "customer": "cus_RQdxueQXRuXVxx",+ "description": null,+ "invoice": null,+ "last_payment_error": null,+ "latest_charge": null,+ "livemode": false,+ "metadata": {+ "spree_order_id": "7b2830cc-1b6c-430c-9dbe-ca948f042c41"+ },+ "next_action": null,+ "on_behalf_of": null,+ "payment_method": null,+ "payment_method_configuration_details": {+ "id": "pmc_1QVa9x2ESifGlJezRC5fgLVg",+ "parent": null+ },+ "payment_method_options": {+ "card": {+ "installments": null,+ "mandate_options": null,+ "network": null,+ "request_three_d_secure": "automatic",+ "setup_future_usage": "off_session"+ },+ "link": {+ "persistent_token": null+ }+ },+ "payment_method_types": [+ "card",+ "link"+ ],+ "processing": null,+ "receipt_email": null,+ "review": null,+ "setup_future_usage": null,+ "shipping": {+ "address": {+ "city": "Herndon",+ "country": "US",+ "line1": "2 Lovely Street",+ "line2": "Northwest",+ "postal_code": "35005",+ "state": "STATE_ABBR_2"+ },+ "carrier": null,+ "name": "John Doe",+ "phone": null,+ "tracking_number": null+ },+ "source": null,+ "statement_descriptor": null,+ "statement_descriptor_suffix": "R111598559 tempora",+ "status": "requires_payment_method",+ "transfer_data": null,+ "transfer_group": "R111598559"+ }+ recorded_at: Thu, 19 Dec 2024 16:33:26 GMT+recorded_with: VCR 6.2.0diff --git a/spree/providers/stripe/spec/vcr/create_payment_intent_invalid_address.yml b/spree/providers/stripe/spec/vcr/create_payment_intent_invalid_address.ymlnew file mode 100644index 0000000000..46395e0e77--- /dev/null+++ b/spree/providers/stripe/spec/vcr/create_payment_intent_invalid_address.yml@@ -0,0 +1,275 @@+---+http_interactions:+- request:+ method: post+ uri: https://api.stripe.com/v1/customers+ body:+ encoding: UTF-8+ string: address[city]=Herndon&address[line1]=1+Lovely+Street&address[line2]=Northwest&address[postal_code]=35005&address[country]=United+States&email=tarsha.moore%40senger.com&name=John+Doe+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 Spree Stripe/1.0.0 (https://spreecommerce.org)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Fri, 20 Dec 2024 08:29:07 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '801'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; upgrade-insecure-requests;+ report-uri /csp-violation https://q.stripe.com/csp-violation?q=i3YC0SESJ3NIQgsdBRrnQt3h9PXszFYiRUmSibQA2z9HLF2W5A0gFHEZlroogSCud6mEtjgiMg%3D%3D+ Cross-Origin-Opener-Policy-Report-Only:+ - same-origin; report-to="coop"+ Idempotency-Key:+ - bc0ed289-fef0-4860-b160-e3c283528edb+ Original-Request:+ - req_iI2K6TeFaMmy5J+ Report-To:+ - '{"group":"coop","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/coop-report"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - coop="https://q.stripe.com/coop-report"+ Request-Id:+ - req_iI2K6TeFaMmy5J+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Content-Type-Options:+ - nosniff+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - AB+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "cus_RQtMxdcMhzDlNf",+ "object": "customer",+ "address": {+ "city": "Herndon",+ "country": "United States",+ "line1": "1 Lovely Street",+ "line2": "Northwest",+ "postal_code": "35005",+ "state": null+ },+ "balance": 0,+ "created": 1734683346,+ "currency": null,+ "default_source": null,+ "delinquent": false,+ "description": null,+ "discount": null,+ "email": "[email protected]",+ "invoice_prefix": "E2394B7E",+ "invoice_settings": {+ "custom_fields": null,+ "default_payment_method": null,+ "footer": null,+ "rendering_options": null+ },+ "livemode": false,+ "metadata": {},+ "name": "John Doe",+ "next_invoice_sequence": 1,+ "phone": null,+ "preferred_locales": [],+ "shipping": null,+ "tax_exempt": "none",+ "test_clock": null+ }+ recorded_at: Fri, 20 Dec 2024 08:29:07 GMT+- request:+ method: post+ uri: https://api.stripe.com/v1/payment_intents+ body:+ encoding: UTF-8+ string: payment_method_options[card][setup_future_usage]=off_session&amount=100&customer=cus_RQtMxdcMhzDlNf¤cy=USD&statement_descriptor_suffix=vitae&automatic_payment_methods[enabled]=true+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 Spree Stripe/1.0.0 (https://spreecommerce.org)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_iI2K6TeFaMmy5J","request_duration_ms":448}}'+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Fri, 20 Dec 2024 08:29:07 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '1565'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; upgrade-insecure-requests;+ report-uri /csp-violation https://q.stripe.com/csp-violation?q=IFHODJStsDdtfRhiSMgbxyktHQHgN2CU2zECfRb0vcxKsZjlJWUFahBeaAXZ01I6Ovwf3H0_bg%3D%3D+ Cross-Origin-Opener-Policy-Report-Only:+ - same-origin; report-to="coop"+ Idempotency-Key:+ - 4cb4c0bb-84b6-4d5b-8913-6c7521b907aa+ Original-Request:+ - req_CylwLS0fyvaM7s+ Report-To:+ - '{"group":"coop","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/coop-report"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - coop="https://q.stripe.com/coop-report"+ Request-Id:+ - req_CylwLS0fyvaM7s+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Content-Type-Options:+ - nosniff+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - AB+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "pi_3QY1a32ESifGlJez0k9YRZnS",+ "object": "payment_intent",+ "amount": 100,+ "amount_capturable": 0,+ "amount_details": {+ "tip": {}+ },+ "amount_received": 0,+ "application": null,+ "application_fee_amount": null,+ "automatic_payment_methods": {+ "allow_redirects": "always",+ "enabled": true+ },+ "canceled_at": null,+ "cancellation_reason": null,+ "capture_method": "automatic",+ "client_secret": "pi_3QY1a32ESifGlJez0k9YRZnS_secret_lxba1Pvpo3y9Flh2OaAWrHpjc",+ "confirmation_method": "automatic",+ "created": 1734683347,+ "currency": "usd",+ "customer": "cus_RQtMxdcMhzDlNf",+ "description": null,+ "invoice": null,+ "last_payment_error": null,+ "latest_charge": null,+ "livemode": false,+ "metadata": {},+ "next_action": null,+ "on_behalf_of": null,+ "payment_method": null,+ "payment_method_configuration_details": {+ "id": "pmc_1QVa9x2ESifGlJezRC5fgLVg",+ "parent": null+ },+ "payment_method_options": {+ "card": {+ "installments": null,+ "mandate_options": null,+ "network": null,+ "request_three_d_secure": "automatic",+ "setup_future_usage": "off_session"+ },+ "link": {+ "persistent_token": null+ }+ },+ "payment_method_types": [+ "card",+ "link"+ ],+ "processing": null,+ "receipt_email": null,+ "review": null,+ "setup_future_usage": null,+ "shipping": null,+ "source": null,+ "statement_descriptor": null,+ "statement_descriptor_suffix": "vitae",+ "status": "requires_payment_method",+ "transfer_data": null,+ "transfer_group": null+ }+ recorded_at: Fri, 20 Dec 2024 08:29:07 GMT+recorded_with: VCR 6.2.0diff --git a/spree/providers/stripe/spec/vcr/create_payment_intent_manual_capture.yml b/spree/providers/stripe/spec/vcr/create_payment_intent_manual_capture.ymlnew file mode 100644index 0000000000..dc30975a2d--- /dev/null+++ b/spree/providers/stripe/spec/vcr/create_payment_intent_manual_capture.yml@@ -0,0 +1,307 @@+---+http_interactions:+- request:+ method: post+ uri: https://api.stripe.com/v1/customers+ body:+ encoding: UTF-8+ string: address[city]=New+York&address[line1]=33+Lovely+Street&address[line2]=Northwest&address[postal_code]=10118&address[country]=United+States+of+America&address[state]=New+York&email=estella.lynch%40fadel.info&name=John+Doe+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/18.4.2 Spree Stripe/5.5.0.beta (https://spreecommerce.org)+ AIAgent/claude_code+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_KOuz9aRI8GQidn","request_duration_ms":1}}'+ Idempotency-Key:+ - e3a5778b-2005-4025-bbd3-88e0b79e9c9d+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Content-Type:+ - application/x-www-form-urlencoded+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Fri, 08 May 2026 15:11:50 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '849'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=Zx0OHNWSgDTSzOj5Pkp_BHa3Ogdvf85LOl4pIpHKcEP00CKZPp3kLmmwEVYyCjH-TPYjQe4pANhk3gbJ;+ report-to csp+ Idempotency-Key:+ - e3a5778b-2005-4025-bbd3-88e0b79e9c9d+ Original-Request:+ - req_3BLSecPTZoarbr+ Report-To:+ - '{"group":"csp","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/csp-report-v2?q=Zx0OHNWSgDTSzOj5Pkp_BHa3Ogdvf85LOl4pIpHKcEP00CKZPp3kLmmwEVYyCjH-TPYjQe4pANhk3gbJ&t=1"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - csp="https://q.stripe.com/csp-report-v2?q=Zx0OHNWSgDTSzOj5Pkp_BHa3Ogdvf85LOl4pIpHKcEP00CKZPp3kLmmwEVYyCjH-TPYjQe4pANhk3gbJ&t=1"+ Request-Id:+ - req_3BLSecPTZoarbr+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - 3c3+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "cus_UTnfWyIfDZZlfU",+ "object": "customer",+ "address": {+ "city": "New York",+ "country": "United States of America",+ "line1": "33 Lovely Street",+ "line2": "Northwest",+ "postal_code": "10118",+ "state": "New York"+ },+ "balance": 0,+ "created": 1778253110,+ "currency": null,+ "customer_account": null,+ "default_source": null,+ "delinquent": false,+ "description": null,+ "discount": null,+ "email": "[email protected]",+ "invoice_prefix": "LMCXNGL9",+ "invoice_settings": {+ "custom_fields": null,+ "default_payment_method": null,+ "footer": null,+ "rendering_options": null+ },+ "livemode": false,+ "metadata": {},+ "name": "John Doe",+ "next_invoice_sequence": 1,+ "phone": null,+ "preferred_locales": [],+ "shipping": null,+ "tax_exempt": "none",+ "test_clock": null+ }+ recorded_at: Fri, 08 May 2026 15:11:50 GMT+- request:+ method: post+ uri: https://api.stripe.com/v1/payment_intents+ body:+ encoding: UTF-8+ string: payment_method_options[card][setup_future_usage]=off_session&payment_method_options[sepa_debit][setup_future_usage]=off_session&amount=100&customer=cus_UTnfWyIfDZZlfU¤cy=USD&statement_descriptor_suffix=R258461850&automatic_payment_methods[enabled]=true&transfer_group=R258461850&metadata[spree_order_id]=1&capture_method=manual&shipping[address][city]=New+York&shipping[address][country]=US&shipping[address][line1]=34+Lovely+Street&shipping[address][line2]=Northwest&shipping[address][postal_code]=10118&shipping[address][state]=NY&shipping[name]=John+Doe+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/18.4.2 Spree Stripe/5.5.0.beta (https://spreecommerce.org)+ AIAgent/claude_code+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_3BLSecPTZoarbr","request_duration_ms":482}}'+ Idempotency-Key:+ - a0445d43-0a5c-451f-ba87-15f571d3c185+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Content-Type:+ - application/x-www-form-urlencoded+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Fri, 08 May 2026 15:11:50 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '2193'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=Zx0OHNWSgDTSzOj5Pkp_BHa3Ogdvf85LOl4pIpHKcEP00CKZPp3kLmmwEVYyCjH-TPYjQe4pANhk3gbJ;+ report-to csp+ Idempotency-Key:+ - a0445d43-0a5c-451f-ba87-15f571d3c185+ Original-Request:+ - req_EutEo4AzOUi8Gi+ Report-To:+ - '{"group":"csp","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/csp-report-v2?q=Zx0OHNWSgDTSzOj5Pkp_BHa3Ogdvf85LOl4pIpHKcEP00CKZPp3kLmmwEVYyCjH-TPYjQe4pANhk3gbJ&t=1"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - csp="https://q.stripe.com/csp-report-v2?q=Zx0OHNWSgDTSzOj5Pkp_BHa3Ogdvf85LOl4pIpHKcEP00CKZPp3kLmmwEVYyCjH-TPYjQe4pANhk3gbJ&t=1"+ Request-Id:+ - req_EutEo4AzOUi8Gi+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - 3c3+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "pi_3TUq4A2ESifGlJez1znHBNDU",+ "object": "payment_intent",+ "amount": 100,+ "amount_capturable": 0,+ "amount_details": {+ "tip": {}+ },+ "amount_received": 0,+ "application": null,+ "application_fee_amount": null,+ "automatic_payment_methods": {+ "allow_redirects": "always",+ "enabled": true+ },+ "canceled_at": null,+ "cancellation_reason": null,+ "capture_method": "manual",+ "client_secret": "pi_3TUq4A2ESifGlJez1znHBNDU_secret_a5xEFPV8MtFMZ8j8ulMBy6JFR",+ "confirmation_method": "automatic",+ "created": 1778253110,+ "currency": "usd",+ "customer": "cus_UTnfWyIfDZZlfU",+ "customer_account": null,+ "description": null,+ "excluded_payment_method_types": null,+ "invoice": null,+ "last_payment_error": null,+ "latest_charge": null,+ "livemode": false,+ "managed_payments": {+ "enabled": false+ },+ "metadata": {+ "spree_order_id": "1"+ },+ "next_action": null,+ "on_behalf_of": null,+ "payment_method": null,+ "payment_method_configuration_details": {+ "id": "pmc_1QVa9x2ESifGlJezRC5fgLVg",+ "parent": null+ },+ "payment_method_options": {+ "afterpay_clearpay": {+ "reference": null+ },+ "card": {+ "installments": null,+ "mandate_options": null,+ "network": null,+ "request_three_d_secure": "automatic",+ "setup_future_usage": "off_session"+ },+ "klarna": {+ "preferred_locale": null+ },+ "link": {+ "persistent_token": null+ }+ },+ "payment_method_types": [+ "card",+ "afterpay_clearpay",+ "klarna",+ "link"+ ],+ "processing": null,+ "receipt_email": null,+ "review": null,+ "setup_future_usage": null,+ "shared_payment_granted_token": null,+ "shipping": {+ "address": {+ "city": "New York",+ "country": "US",+ "line1": "34 Lovely Street",+ "line2": "Northwest",+ "postal_code": "10118",+ "state": "NY"+ },+ "carrier": null,+ "name": "John Doe",+ "phone": null,+ "tracking_number": null+ },+ "source": null,+ "statement_descriptor": null,+ "statement_descriptor_suffix": "R258461850",+ "status": "requires_payment_method",+ "transfer_data": null,+ "transfer_group": "R258461850"+ }+ recorded_at: Fri, 08 May 2026 15:11:50 GMT+recorded_with: VCR 6.4.0diff --git a/spree/providers/stripe/spec/vcr/create_payment_intent_with_payment_method.yml b/spree/providers/stripe/spec/vcr/create_payment_intent_with_payment_method.ymlnew file mode 100644index 0000000000..1e8e3b7a4c--- /dev/null+++ b/spree/providers/stripe/spec/vcr/create_payment_intent_with_payment_method.yml@@ -0,0 +1,368 @@+---+http_interactions:+- request:+ method: post+ uri: https://api.stripe.com/v1/payment_intents+ body:+ encoding: UTF-8+ string: payment_method=pm_1QXmPJ2ESifGlJezC2py6ZqS&off_session=true&confirm=true&amount=1000&customer=cus_RQdclxFVLH4oau¤cy=USD&statement_descriptor_suffix=R111098765+sapiente&automatic_payment_methods[enabled]=true&transfer_group=R111098765&metadata[spree_order_id]=09840627-957a-4acc-b0cd-b6a60cb79294&shipping[address][city]=Herndon&shipping[address][country]=US&shipping[address][line1]=2+Lovely+Street&shipping[address][line2]=Northwest&shipping[address][postal_code]=35005&shipping[address][state]=STATE_ABBR_2&shipping[name]=John+Doe+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 Spree Stripe/1.0.0 (https://spreecommerce.org)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Fri, 20 Dec 2024 08:53:55 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '1935'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; upgrade-insecure-requests;+ report-uri /csp-violation https://q.stripe.com/csp-violation?q=Nt939IZg8FBkb3mpZHxy4hOum94u6IWPnC7dBOdo4_hNEc4L_GqdfS4wiQXAT-16KcD79SydLA%3D%3D+ Cross-Origin-Opener-Policy-Report-Only:+ - same-origin; report-to="coop"+ Idempotency-Key:+ - 55810c27-0ca0-444a-8e51-cfaa7daa932e+ Original-Request:+ - req_rt5eMyr4HhuPYS+ Report-To:+ - '{"group":"coop","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/coop-report"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - coop="https://q.stripe.com/coop-report"+ Request-Id:+ - req_rt5eMyr4HhuPYS+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Content-Type-Options:+ - nosniff+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - AB+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "pi_3QY1y22ESifGlJez12haN8ah",+ "object": "payment_intent",+ "amount": 1000,+ "amount_capturable": 0,+ "amount_details": {+ "tip": {}+ },+ "amount_received": 1000,+ "application": null,+ "application_fee_amount": null,+ "automatic_payment_methods": {+ "allow_redirects": "always",+ "enabled": true+ },+ "canceled_at": null,+ "cancellation_reason": null,+ "capture_method": "automatic",+ "client_secret": "pi_3QY1y22ESifGlJez12haN8ah_secret_P7VkZ3YZ5cWrlZ31iPyI0vnkh",+ "confirmation_method": "automatic",+ "created": 1734684834,+ "currency": "usd",+ "customer": "cus_RQdclxFVLH4oau",+ "description": null,+ "invoice": null,+ "last_payment_error": null,+ "latest_charge": "ch_3QY1y22ESifGlJez1rJunOIg",+ "livemode": false,+ "metadata": {+ "spree_order_id": "09840627-957a-4acc-b0cd-b6a60cb79294"+ },+ "next_action": null,+ "on_behalf_of": null,+ "payment_method": "pm_1QXmPJ2ESifGlJezC2py6ZqS",+ "payment_method_configuration_details": {+ "id": "pmc_1QVa9x2ESifGlJezRC5fgLVg",+ "parent": null+ },+ "payment_method_options": {+ "card": {+ "installments": null,+ "mandate_options": null,+ "network": null,+ "request_three_d_secure": "automatic"+ },+ "link": {+ "persistent_token": null+ }+ },+ "payment_method_types": [+ "card",+ "link"+ ],+ "processing": null,+ "receipt_email": null,+ "review": null,+ "setup_future_usage": null,+ "shipping": {+ "address": {+ "city": "Herndon",+ "country": "US",+ "line1": "2 Lovely Street",+ "line2": "Northwest",+ "postal_code": "35005",+ "state": "STATE_ABBR_2"+ },+ "carrier": null,+ "name": "John Doe",+ "phone": null,+ "tracking_number": null+ },+ "source": null,+ "statement_descriptor": null,+ "statement_descriptor_suffix": "R111098765 sapiente",+ "status": "succeeded",+ "transfer_data": null,+ "transfer_group": "R111098765"+ }+ recorded_at: Fri, 20 Dec 2024 08:53:55 GMT+- request:+ method: get+ uri: https://api.stripe.com/v1/payment_intents/pi_3QY1y22ESifGlJez12haN8ah?expand%5B%5D=payment_method+ body:+ encoding: US-ASCII+ string: ''+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 Spree Stripe/5.1.1 (https://spreecommerce.org)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_rt5eMyr4HhuPYS","request_duration_ms":122}}'+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Fri, 05 Dec 2025 16:23:19 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '3187'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=xWE6qyTJsno7iNx7zpX4mmGa0zffvSHgCWfgdQyf8FGmluweBVTq-8xVfzeZy40-dPZ2qQ6rJ-95nYeb+ Request-Id:+ - req_mb4t6awPrTRb55+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - ABGHIJ+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "pi_3QY1y22ESifGlJez12haN8ah",+ "object": "payment_intent",+ "amount": 1000,+ "amount_capturable": 0,+ "amount_details": {+ "tip": {}+ },+ "amount_received": 1000,+ "application": null,+ "application_fee_amount": null,+ "automatic_payment_methods": {+ "allow_redirects": "always",+ "enabled": true+ },+ "canceled_at": null,+ "cancellation_reason": null,+ "capture_method": "automatic",+ "client_secret": "pi_3QY1y22ESifGlJez12haN8ah_secret_P7VkZ3YZ5cWrlZ31iPyI0vnkh",+ "confirmation_method": "automatic",+ "created": 1734684834,+ "currency": "usd",+ "customer": "cus_RQdclxFVLH4oau",+ "description": null,+ "excluded_payment_method_types": null,+ "invoice": null,+ "last_payment_error": null,+ "latest_charge": "ch_3QY1y22ESifGlJez1rJunOIg",+ "livemode": false,+ "metadata": {+ "spree_order_id": "09840627-957a-4acc-b0cd-b6a60cb79294"+ },+ "next_action": null,+ "on_behalf_of": null,+ "payment_method": {+ "id": "pm_1QXmPJ2ESifGlJezC2py6ZqS",+ "object": "payment_method",+ "allow_redisplay": "unspecified",+ "billing_details": {+ "address": {+ "city": "San Francisco",+ "country": "US",+ "line1": "100 California Street",+ "line2": null,+ "postal_code": "94111",+ "state": "CA"+ },+ "email": "[email protected]",+ "name": "John Doe",+ "phone": null,+ "tax_id": null+ },+ "card": {+ "brand": "visa",+ "checks": {+ "address_line1_check": "pass",+ "address_postal_code_check": "pass",+ "cvc_check": "pass"+ },+ "country": "US",+ "display_brand": "visa",+ "exp_month": 2,+ "exp_year": 2027,+ "fingerprint": "taGjeBd4Wh4btmTn",+ "funding": "credit",+ "generated_from": null,+ "last4": "4242",+ "networks": {+ "available": [+ "visa"+ ],+ "preferred": null+ },+ "regulated_status": "unregulated",+ "three_d_secure_usage": {+ "supported": true+ },+ "wallet": null+ },+ "created": 1734625021,+ "customer": "cus_RQdclxFVLH4oau",+ "livemode": false,+ "metadata": {},+ "type": "card"+ },+ "payment_method_configuration_details": {+ "id": "pmc_1QVa9x2ESifGlJezRC5fgLVg",+ "parent": null+ },+ "payment_method_options": {+ "card": {+ "installments": null,+ "mandate_options": null,+ "network": null,+ "request_three_d_secure": "automatic"+ },+ "link": {+ "persistent_token": null+ }+ },+ "payment_method_types": [+ "card",+ "link"+ ],+ "processing": null,+ "receipt_email": null,+ "review": null,+ "setup_future_usage": null,+ "shipping": {+ "address": {+ "city": "Herndon",+ "country": "US",+ "line1": "2 Lovely Street",+ "line2": "Northwest",+ "postal_code": "35005",+ "state": "STATE_ABBR_2"+ },+ "carrier": null,+ "name": "John Doe",+ "phone": null,+ "tracking_number": null+ },+ "source": null,+ "statement_descriptor": null,+ "statement_descriptor_suffix": "R111098765 sapiente",+ "status": "succeeded",+ "transfer_data": null,+ "transfer_group": "R111098765"+ }+ recorded_at: Fri, 05 Dec 2025 16:23:19 GMT+recorded_with: VCR 6.3.1diff --git a/spree/providers/stripe/spec/vcr/create_payment_setup_session.yml b/spree/providers/stripe/spec/vcr/create_payment_setup_session.ymlnew file mode 100644index 0000000000..a193d2686a--- /dev/null+++ b/spree/providers/stripe/spec/vcr/create_payment_setup_session.yml@@ -0,0 +1,350 @@+---+http_interactions:+- request:+ method: post+ uri: https://api.stripe.com/v1/customers+ body:+ encoding: UTF-8+ string: email=fatima_rodriguez%40waters.biz&name=Euna+Schmitt+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/18.4.2 Spree Stripe/5.4.0.beta6 (https://spreecommerce.org)+ AIAgent/claude_code+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Idempotency-Key:+ - 873d8de7-5cbb-4605-91e8-ae5c32f63cf8+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Content-Type:+ - application/x-www-form-urlencoded+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Mon, 04 May 2026 10:22:26 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '677'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=WRoqIgRC7cPEuYssKzbs52TY2w1xZmEK7CqZ1uRyviQ0dbmz4JJKdgpapGFBHCWPlhHILDpo6rnJ7LIV+ Idempotency-Key:+ - 873d8de7-5cbb-4605-91e8-ae5c32f63cf8+ Original-Request:+ - req_fzIyWsmlvX11Ec+ Report-To:+ - '{"group":"csp","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/csp-report-v2?q=WRoqIgRC7cPEuYssKzbs52TY2w1xZmEK7CqZ1uRyviQ0dbmz4JJKdgpapGFBHCWPlhHILDpo6rnJ7LIV&t=1"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - csp="https://q.stripe.com/csp-report-v2?q=WRoqIgRC7cPEuYssKzbs52TY2w1xZmEK7CqZ1uRyviQ0dbmz4JJKdgpapGFBHCWPlhHILDpo6rnJ7LIV&t=1"+ Request-Id:+ - req_fzIyWsmlvX11Ec+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - 3c3+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "cus_USE66TMAPae0UB",+ "object": "customer",+ "address": null,+ "balance": 0,+ "created": 1777890146,+ "currency": null,+ "customer_account": null,+ "default_source": null,+ "delinquent": false,+ "description": null,+ "discount": null,+ "email": "[email protected]",+ "invoice_prefix": "WCUW0KLR",+ "invoice_settings": {+ "custom_fields": null,+ "default_payment_method": null,+ "footer": null,+ "rendering_options": null+ },+ "livemode": false,+ "metadata": {},+ "name": "Euna Schmitt",+ "next_invoice_sequence": 1,+ "phone": null,+ "preferred_locales": [],+ "shipping": null,+ "tax_exempt": "none",+ "test_clock": null+ }+ recorded_at: Mon, 04 May 2026 10:22:26 GMT+- request:+ method: post+ uri: https://api.stripe.com/v1/setup_intents+ body:+ encoding: UTF-8+ string: customer=cus_USE66TMAPae0UB&automatic_payment_methods[enabled]=true+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/18.4.2 Spree Stripe/5.4.0.beta6 (https://spreecommerce.org)+ AIAgent/claude_code+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_fzIyWsmlvX11Ec","request_duration_ms":471}}'+ Idempotency-Key:+ - 03fefee4-56d9-4cec-beea-8f1361f6898c+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Content-Type:+ - application/x-www-form-urlencoded+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Mon, 04 May 2026 10:22:26 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '1150'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=WRoqIgRC7cPEuYssKzbs52TY2w1xZmEK7CqZ1uRyviQ0dbmz4JJKdgpapGFBHCWPlhHILDpo6rnJ7LIV+ Idempotency-Key:+ - 03fefee4-56d9-4cec-beea-8f1361f6898c+ Original-Request:+ - req_I3Px2fEQK6YNuy+ Report-To:+ - '{"group":"csp","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/csp-report-v2?q=WRoqIgRC7cPEuYssKzbs52TY2w1xZmEK7CqZ1uRyviQ0dbmz4JJKdgpapGFBHCWPlhHILDpo6rnJ7LIV&t=1"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - csp="https://q.stripe.com/csp-report-v2?q=WRoqIgRC7cPEuYssKzbs52TY2w1xZmEK7CqZ1uRyviQ0dbmz4JJKdgpapGFBHCWPlhHILDpo6rnJ7LIV&t=1"+ Request-Id:+ - req_I3Px2fEQK6YNuy+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - 3c3+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "seti_1TTJdu2ESifGlJezDk0Xping",+ "object": "setup_intent",+ "application": null,+ "automatic_payment_methods": {+ "allow_redirects": "always",+ "enabled": true+ },+ "cancellation_reason": null,+ "client_secret": "seti_1TTJdu2ESifGlJezDk0Xping_secret_USE6HMjWDP9baDy5OxmvqV1zNcI7G2R",+ "created": 1777890146,+ "customer": "cus_USE66TMAPae0UB",+ "customer_account": null,+ "description": null,+ "excluded_payment_method_types": null,+ "flow_directions": null,+ "last_setup_error": null,+ "latest_attempt": null,+ "livemode": false,+ "managed_payments": {+ "enabled": false+ },+ "mandate": null,+ "metadata": {},+ "next_action": null,+ "on_behalf_of": null,+ "payment_method": null,+ "payment_method_configuration_details": {+ "id": "pmc_1QVa9x2ESifGlJezRC5fgLVg",+ "parent": null+ },+ "payment_method_options": {+ "card": {+ "mandate_options": null,+ "network": null,+ "request_three_d_secure": "automatic"+ }+ },+ "payment_method_types": [+ "card",+ "klarna",+ "link"+ ],+ "single_use_mandate": null,+ "status": "requires_payment_method",+ "usage": "off_session"+ }+ recorded_at: Mon, 04 May 2026 10:22:26 GMT+- request:+ method: post+ uri: https://api.stripe.com/v1/ephemeral_keys+ body:+ encoding: UTF-8+ string: customer=cus_USE66TMAPae0UB+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/18.4.2 Spree Stripe/5.4.0.beta6 (https://spreecommerce.org)+ AIAgent/claude_code+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_I3Px2fEQK6YNuy","request_duration_ms":264}}'+ Idempotency-Key:+ - 9a27b606-0db7-4bcb-9bfa-d1ce5f36c98d+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Content-Type:+ - application/x-www-form-urlencoded+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Mon, 04 May 2026 10:22:26 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '353'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=WRoqIgRC7cPEuYssKzbs52TY2w1xZmEK7CqZ1uRyviQ0dbmz4JJKdgpapGFBHCWPlhHILDpo6rnJ7LIV+ Idempotency-Key:+ - 9a27b606-0db7-4bcb-9bfa-d1ce5f36c98d+ Original-Request:+ - req_oEeH1fHPnk4EoU+ Report-To:+ - '{"group":"csp","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/csp-report-v2?q=WRoqIgRC7cPEuYssKzbs52TY2w1xZmEK7CqZ1uRyviQ0dbmz4JJKdgpapGFBHCWPlhHILDpo6rnJ7LIV&t=1"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - csp="https://q.stripe.com/csp-report-v2?q=WRoqIgRC7cPEuYssKzbs52TY2w1xZmEK7CqZ1uRyviQ0dbmz4JJKdgpapGFBHCWPlhHILDpo6rnJ7LIV&t=1"+ Request-Id:+ - req_oEeH1fHPnk4EoU+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - 3c3+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "ephkey_1TTJdu2ESifGlJezMHmwix65",+ "object": "ephemeral_key",+ "associated_objects": [+ {+ "id": "cus_USE66TMAPae0UB",+ "type": "customer"+ }+ ],+ "created": 1777890146,+ "expires": 1777893746,+ "livemode": false,+ "secret": "ek_test_YWNjdF8xUVZhOWsyRVNpZkdsSmV6LHFydWdCR0RQdmJ6MzREMW1uU1lKRmhuWjZZQ2xDZ1U_0049Z6rFbW"+ }+ recorded_at: Mon, 04 May 2026 10:22:26 GMT+recorded_with: VCR 6.4.0diff --git a/spree/providers/stripe/spec/vcr/create_payment_setup_session_existing_customer.yml b/spree/providers/stripe/spec/vcr/create_payment_setup_session_existing_customer.ymlnew file mode 100644index 0000000000..476c3bdd49--- /dev/null+++ b/spree/providers/stripe/spec/vcr/create_payment_setup_session_existing_customer.yml@@ -0,0 +1,236 @@+---+http_interactions:+- request:+ method: post+ uri: https://api.stripe.com/v1/setup_intents+ body:+ encoding: UTF-8+ string: customer=cus_USE66TMAPae0UB&automatic_payment_methods[enabled]=true+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/18.4.2 Spree Stripe/5.4.0.beta6 (https://spreecommerce.org)+ AIAgent/claude_code+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_oEeH1fHPnk4EoU","request_duration_ms":1}}'+ Idempotency-Key:+ - d66e6ccf-51fe-490d-b79a-75543e624186+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Content-Type:+ - application/x-www-form-urlencoded+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Mon, 04 May 2026 10:23:12 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '1150'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=038AqnLkjtdcNmGhNWRNUVXV4Ld1kOwafiEeMpOKnWMXb2og87O0HzI68E4bWbKJ10x8MLlUMuhjDmpq+ Idempotency-Key:+ - d66e6ccf-51fe-490d-b79a-75543e624186+ Original-Request:+ - req_RE17TqLp2Mu85X+ Report-To:+ - '{"group":"csp","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/csp-report-v2?q=038AqnLkjtdcNmGhNWRNUVXV4Ld1kOwafiEeMpOKnWMXb2og87O0HzI68E4bWbKJ10x8MLlUMuhjDmpq&t=1"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - csp="https://q.stripe.com/csp-report-v2?q=038AqnLkjtdcNmGhNWRNUVXV4Ld1kOwafiEeMpOKnWMXb2og87O0HzI68E4bWbKJ10x8MLlUMuhjDmpq&t=1"+ Request-Id:+ - req_RE17TqLp2Mu85X+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - 3c3+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "seti_1TTJee2ESifGlJezA8ixwucs",+ "object": "setup_intent",+ "application": null,+ "automatic_payment_methods": {+ "allow_redirects": "always",+ "enabled": true+ },+ "cancellation_reason": null,+ "client_secret": "seti_1TTJee2ESifGlJezA8ixwucs_secret_USE6M97PVPAV0dCoNQopTNmAFlfqBPT",+ "created": 1777890192,+ "customer": "cus_USE66TMAPae0UB",+ "customer_account": null,+ "description": null,+ "excluded_payment_method_types": null,+ "flow_directions": null,+ "last_setup_error": null,+ "latest_attempt": null,+ "livemode": false,+ "managed_payments": {+ "enabled": false+ },+ "mandate": null,+ "metadata": {},+ "next_action": null,+ "on_behalf_of": null,+ "payment_method": null,+ "payment_method_configuration_details": {+ "id": "pmc_1QVa9x2ESifGlJezRC5fgLVg",+ "parent": null+ },+ "payment_method_options": {+ "card": {+ "mandate_options": null,+ "network": null,+ "request_three_d_secure": "automatic"+ }+ },+ "payment_method_types": [+ "card",+ "klarna",+ "link"+ ],+ "single_use_mandate": null,+ "status": "requires_payment_method",+ "usage": "off_session"+ }+ recorded_at: Mon, 04 May 2026 10:23:12 GMT+- request:+ method: post+ uri: https://api.stripe.com/v1/ephemeral_keys+ body:+ encoding: UTF-8+ string: customer=cus_USE66TMAPae0UB+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/18.4.2 Spree Stripe/5.4.0.beta6 (https://spreecommerce.org)+ AIAgent/claude_code+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_RE17TqLp2Mu85X","request_duration_ms":367}}'+ Idempotency-Key:+ - 3aaf8470-dfe9-4f45-bc1c-1e0d996e4a50+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Content-Type:+ - application/x-www-form-urlencoded+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Mon, 04 May 2026 10:23:13 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '353'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=038AqnLkjtdcNmGhNWRNUVXV4Ld1kOwafiEeMpOKnWMXb2og87O0HzI68E4bWbKJ10x8MLlUMuhjDmpq+ Idempotency-Key:+ - 3aaf8470-dfe9-4f45-bc1c-1e0d996e4a50+ Original-Request:+ - req_ivMozSOnM0pqIW+ Report-To:+ - '{"group":"csp","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/csp-report-v2?q=038AqnLkjtdcNmGhNWRNUVXV4Ld1kOwafiEeMpOKnWMXb2og87O0HzI68E4bWbKJ10x8MLlUMuhjDmpq&t=1"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - csp="https://q.stripe.com/csp-report-v2?q=038AqnLkjtdcNmGhNWRNUVXV4Ld1kOwafiEeMpOKnWMXb2og87O0HzI68E4bWbKJ10x8MLlUMuhjDmpq&t=1"+ Request-Id:+ - req_ivMozSOnM0pqIW+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - 3c3+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "ephkey_1TTJee2ESifGlJez5RyBnGEG",+ "object": "ephemeral_key",+ "associated_objects": [+ {+ "id": "cus_USE66TMAPae0UB",+ "type": "customer"+ }+ ],+ "created": 1777890192,+ "expires": 1777893792,+ "livemode": false,+ "secret": "ek_test_YWNjdF8xUVZhOWsyRVNpZkdsSmV6LFdwYXkxSkxhWmhoT0k2ZlpLb005MDlyNXZQVjZmOFM_00OVxbc0Um"+ }+ recorded_at: Mon, 04 May 2026 10:23:12 GMT+recorded_with: VCR 6.4.0diff --git a/spree/providers/stripe/spec/vcr/create_refund.yml b/spree/providers/stripe/spec/vcr/create_refund.ymlnew file mode 100644index 0000000000..4e56f92b23--- /dev/null+++ b/spree/providers/stripe/spec/vcr/create_refund.yml@@ -0,0 +1,112 @@+---+http_interactions:+- request:+ method: post+ uri: https://api.stripe.com/v1/refunds+ body:+ encoding: UTF-8+ string: amount=800&payment_intent=pi_3QXmL12ESifGlJez0v0B8tUn+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 Spree Stripe/1.0.0 (https://spreecommerce.org)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Fri, 20 Dec 2024 08:39:52 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '614'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; upgrade-insecure-requests;+ report-uri /csp-violation https://q.stripe.com/csp-violation?q=jt4JYpEPZ_FFrOB4laNNyTOgX-syXdHuf83kzf6UbqujxzbOqiVfHeg9GsxlinOJXMJInA_REg%3D%3D+ Cross-Origin-Opener-Policy-Report-Only:+ - same-origin; report-to="coop"+ Idempotency-Key:+ - f453a41a-2602-4497-8de3-1be119bceafc+ Original-Request:+ - req_fVm6JJCCxmXmYm+ Report-To:+ - '{"group":"coop","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/coop-report"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - coop="https://q.stripe.com/coop-report"+ Request-Id:+ - req_fVm6JJCCxmXmYm+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Content-Type-Options:+ - nosniff+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - AB+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "re_3QXmL12ESifGlJez0GcOBHng",+ "object": "refund",+ "amount": 800,+ "balance_transaction": "txn_3QXmL12ESifGlJez0FIoQqq9",+ "charge": "ch_3QXmL12ESifGlJez0Ts8qFDi",+ "created": 1734683992,+ "currency": "usd",+ "destination_details": {+ "card": {+ "reference_status": "pending",+ "reference_type": "acquirer_reference_number",+ "type": "refund"+ },+ "type": "card"+ },+ "metadata": {},+ "payment_intent": "pi_3QXmL12ESifGlJez0v0B8tUn",+ "reason": null,+ "receipt_number": null,+ "source_transfer_reversal": null,+ "status": "succeeded",+ "transfer_reversal": null+ }+ recorded_at: Fri, 20 Dec 2024 08:39:53 GMT+recorded_with: VCR 6.2.0diff --git a/spree/providers/stripe/spec/vcr/existing_gateway_webhooks.yml b/spree/providers/stripe/spec/vcr/existing_gateway_webhooks.ymlnew file mode 100644index 0000000000..a726ecd3dc--- /dev/null+++ b/spree/providers/stripe/spec/vcr/existing_gateway_webhooks.yml@@ -0,0 +1,371 @@+---+http_interactions:+- request:+ method: get+ uri: https://api.stripe.com/v1/webhook_endpoints+ body:+ encoding: US-ASCII+ string: ''+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/18.4.2 Spree Stripe/5.5.0.beta (https://spreecommerce.org)+ AIAgent/claude_code+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_ZU3Jye3BVOYTTB","request_duration_ms":233}}'+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Fri, 08 May 2026 15:16:47 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '2894'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=F6Z3vOJntd60cmXfwceRRstcwCrzO9P9eCrum9DbLMfgKGHBj05saB6-QjdEjej96nqe5tqSHq-PloI-;+ report-to csp+ Report-To:+ - '{"group":"csp","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/csp-report-v2?q=F6Z3vOJntd60cmXfwceRRstcwCrzO9P9eCrum9DbLMfgKGHBj05saB6-QjdEjej96nqe5tqSHq-PloI-&t=1"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - csp="https://q.stripe.com/csp-report-v2?q=F6Z3vOJntd60cmXfwceRRstcwCrzO9P9eCrum9DbLMfgKGHBj05saB6-QjdEjej96nqe5tqSHq-PloI-&t=1"+ Request-Id:+ - req_hZjIyGpvyOWzfG+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - 3c3+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "object": "list",+ "data": [+ {+ "id": "we_1TUq8w2ESifGlJezdHC8YApb",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1778253406,+ "description": null,+ "enabled_events": [+ "payment_intent.amount_capturable_updated",+ "payment_intent.payment_failed",+ "payment_intent.succeeded",+ "setup_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "https://spreecommerce.org/stripe/"+ },+ {+ "id": "we_1TAo7D2ESifGlJezqJgSzMOX",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1773479051,+ "description": null,+ "enabled_events": [+ "payment_intent.payment_failed",+ "payment_intent.succeeded",+ "setup_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "http://spreecommerce.org:3000/api/v3/webhooks/payments/pm_UkLWZg9DAJ"+ },+ {+ "id": "we_1RiGw92ESifGlJez0JdTGlQl",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1751901993,+ "description": null,+ "enabled_events": [+ "payment_intent.payment_failed",+ "payment_intent.succeeded",+ "setup_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "https://www.example.com/stripe"+ },+ {+ "id": "we_1R1ner2ESifGlJezydmoL0st",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1741779669,+ "description": null,+ "enabled_events": [+ "payment_intent.payment_failed",+ "payment_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "https://app.vendo.dev/stripe"+ },+ {+ "id": "we_1QqwMZ2ESifGlJezP0GF1ZHz",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": "ca_ROMtxw3OIzmnsWikic1yZQJ7AgMpmdOF",+ "created": 1739191523,+ "description": null,+ "enabled_events": [+ "account.updated"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "https://app.lvh.me/stripe"+ },+ {+ "id": "we_1QqwMY2ESifGlJezzFo7W4xt",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1739191522,+ "description": null,+ "enabled_events": [+ "payment_intent.payment_failed",+ "payment_intent.processing",+ "payment_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "https://app.lvh.me/stripe"+ }+ ],+ "has_more": false,+ "url": "/v1/webhook_endpoints"+ }+ recorded_at: Fri, 08 May 2026 15:16:47 GMT+- request:+ method: get+ uri: https://api.stripe.com/v1/webhook_endpoints+ body:+ encoding: US-ASCII+ string: ''+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/18.4.2 Spree Stripe/5.5.0.beta (https://spreecommerce.org)+ AIAgent/claude_code+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_hZjIyGpvyOWzfG","request_duration_ms":227}}'+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Fri, 08 May 2026 15:16:47 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '2894'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=F6Z3vOJntd60cmXfwceRRstcwCrzO9P9eCrum9DbLMfgKGHBj05saB6-QjdEjej96nqe5tqSHq-PloI-;+ report-to csp+ Report-To:+ - '{"group":"csp","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/csp-report-v2?q=F6Z3vOJntd60cmXfwceRRstcwCrzO9P9eCrum9DbLMfgKGHBj05saB6-QjdEjej96nqe5tqSHq-PloI-&t=1"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - csp="https://q.stripe.com/csp-report-v2?q=F6Z3vOJntd60cmXfwceRRstcwCrzO9P9eCrum9DbLMfgKGHBj05saB6-QjdEjej96nqe5tqSHq-PloI-&t=1"+ Request-Id:+ - req_eelyyg4ahZ9eai+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - 3c3+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "object": "list",+ "data": [+ {+ "id": "we_1TUq8w2ESifGlJezdHC8YApb",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1778253406,+ "description": null,+ "enabled_events": [+ "payment_intent.amount_capturable_updated",+ "payment_intent.payment_failed",+ "payment_intent.succeeded",+ "setup_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "https://spreecommerce.org/stripe/"+ },+ {+ "id": "we_1TAo7D2ESifGlJezqJgSzMOX",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1773479051,+ "description": null,+ "enabled_events": [+ "payment_intent.payment_failed",+ "payment_intent.succeeded",+ "setup_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "http://spreecommerce.org:3000/api/v3/webhooks/payments/pm_UkLWZg9DAJ"+ },+ {+ "id": "we_1RiGw92ESifGlJez0JdTGlQl",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1751901993,+ "description": null,+ "enabled_events": [+ "payment_intent.payment_failed",+ "payment_intent.succeeded",+ "setup_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "https://www.example.com/stripe"+ },+ {+ "id": "we_1R1ner2ESifGlJezydmoL0st",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1741779669,+ "description": null,+ "enabled_events": [+ "payment_intent.payment_failed",+ "payment_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "https://app.vendo.dev/stripe"+ },+ {+ "id": "we_1QqwMZ2ESifGlJezP0GF1ZHz",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": "ca_ROMtxw3OIzmnsWikic1yZQJ7AgMpmdOF",+ "created": 1739191523,+ "description": null,+ "enabled_events": [+ "account.updated"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "https://app.lvh.me/stripe"+ },+ {+ "id": "we_1QqwMY2ESifGlJezzFo7W4xt",+ "object": "webhook_endpoint",+ "api_version": null,+ "application": null,+ "created": 1739191522,+ "description": null,+ "enabled_events": [+ "payment_intent.payment_failed",+ "payment_intent.processing",+ "payment_intent.succeeded"+ ],+ "livemode": false,+ "metadata": {},+ "status": "enabled",+ "url": "https://app.lvh.me/stripe"+ }+ ],+ "has_more": false,+ "url": "/v1/webhook_endpoints"+ }+ recorded_at: Fri, 08 May 2026 15:16:47 GMT+recorded_with: VCR 6.4.0diff --git a/spree/providers/stripe/spec/vcr/retrieve_payment_intent_bank_transfer.yml b/spree/providers/stripe/spec/vcr/retrieve_payment_intent_bank_transfer.ymlnew file mode 100644index 0000000000..854f0c24a6--- /dev/null+++ b/spree/providers/stripe/spec/vcr/retrieve_payment_intent_bank_transfer.yml@@ -0,0 +1,533 @@+---+http_interactions:+- request:+ method: get+ uri: https://api.stripe.com/v1/payment_intents/pi_3ScPMjFmGsiQWfE61qMaWSFF?expand%5B%5D=payment_method+ body:+ encoding: US-ASCII+ string: ''+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 Spree Stripe/5.2.1 (https://spreecommerce.org)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Tue, 09 Dec 2025 12:22:14 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '5299'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=l--2UhR30u698AZakjIG1OPal_S8HLn4iji_-eS19k4ppciJ5ewqpsZferinr6AXNlvgllFWWbM2BaSu+ Request-Id:+ - req_iojWJUbliLu5iq+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - ABGHIJ+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "pi_3ScPMjFmGsiQWfE61qMaWSFF",+ "object": "payment_intent",+ "amount": 4000,+ "amount_capturable": 0,+ "amount_details": {+ "tip": {}+ },+ "amount_received": 0,+ "application": null,+ "application_fee_amount": null,+ "automatic_payment_methods": {+ "allow_redirects": "always",+ "enabled": true+ },+ "canceled_at": null,+ "cancellation_reason": null,+ "capture_method": "automatic",+ "client_secret": "pi_3ScPMjFmGsiQWfE61qMaWSFF_secret_Cl5waHuNY3QiBpa0Kl5Xt03EK",+ "confirmation_method": "automatic",+ "created": 1765280761,+ "currency": "usd",+ "customer": "cus_TZFk4Fxe9gABNI",+ "customer_account": null,+ "description": null,+ "excluded_payment_method_types": null,+ "invoice": null,+ "last_payment_error": null,+ "latest_charge": null,+ "livemode": false,+ "metadata": {+ "spree_order_id": "159"+ },+ "next_action": {+ "display_bank_transfer_instructions": {+ "amount_remaining": 4000,+ "currency": "usd",+ "financial_addresses": [+ {+ "aba": {+ "account_holder_address": {+ "city": "South San Francisco",+ "country": "US",+ "line1": "354 Oyster Point Blvd",+ "line2": null,+ "postal_code": "94080",+ "state": "CA"+ },+ "account_holder_name": "UFC Meals",+ "account_number": "11119958118330123",+ "account_type": "checking",+ "bank_address": {+ "city": "San Francisco",+ "country": "US",+ "line1": "420 Montgomery Street",+ "line2": null,+ "postal_code": "94104",+ "state": "CA"+ },+ "bank_name": "US Test Bank",+ "routing_number": "999999999"+ },+ "supported_networks": [+ "ach",+ "domestic_wire_us"+ ],+ "type": "aba"+ },+ {+ "supported_networks": [+ "swift"+ ],+ "swift": {+ "account_holder_address": {+ "city": "South San Francisco",+ "country": "US",+ "line1": "354 Oyster Point Blvd",+ "line2": null,+ "postal_code": "94080",+ "state": "CA"+ },+ "account_holder_name": "UFC Meals",+ "account_number": "11119958118330123",+ "account_type": "checking",+ "bank_address": {+ "city": "San Francisco",+ "country": "US",+ "line1": "420 Montgomery Street",+ "line2": null,+ "postal_code": "94104",+ "state": "CA"+ },+ "bank_name": "US Test Bank",+ "swift_code": "TESTUS99XXX"+ },+ "type": "swift"+ }+ ],+ "hosted_instructions_url": "https://payments.stripe.com/bank_transfers/instructions/test_YWNjdF8xUk1uMnBGbUdzaVFXZkU2LF9UWllVdEJiN2NEMzlVTGc0V1hPTXJNbENKY2sxaThn01006xj2lWnQ",+ "reference": "SCBJWXEZAFH8",+ "type": "us_bank_transfer"+ },+ "type": "display_bank_transfer_instructions"+ },+ "on_behalf_of": null,+ "payment_method": {+ "id": "pm_1ScPNbFmGsiQWfE6IQ5cXwYc",+ "object": "payment_method",+ "allow_redisplay": "unspecified",+ "billing_details": {+ "address": {+ "city": "San Francisco",+ "country": "US",+ "line1": "100 California Street",+ "line2": null,+ "postal_code": "94111",+ "state": "CA"+ },+ "email": "[email protected]",+ "name": "Johnathan Doe",+ "phone": null,+ "tax_id": null+ },+ "created": 1765280815,+ "customer": null,+ "customer_account": null,+ "customer_balance": {},+ "livemode": false,+ "metadata": {},+ "type": "customer_balance"+ },+ "payment_method_configuration_details": {+ "id": "pmc_1RMn31FmGsiQWfE6vaR9S4rU",+ "parent": null+ },+ "payment_method_options": {+ "card": {+ "installments": null,+ "mandate_options": null,+ "network": null,+ "request_three_d_secure": "automatic",+ "setup_future_usage": "off_session"+ },+ "customer_balance": {+ "bank_transfer": {+ "type": "us_bank_transfer"+ },+ "funding_type": "bank_transfer"+ },+ "link": {+ "persistent_token": null+ },+ "us_bank_account": {+ "financial_connections": {+ "permissions": [+ "payment_method"+ ],+ "prefetch": []+ },+ "mandate_options": {},+ "verification_method": "automatic"+ }+ },+ "payment_method_types": [+ "card",+ "link",+ "us_bank_account",+ "customer_balance"+ ],+ "processing": null,+ "receipt_email": null,+ "review": null,+ "setup_future_usage": null,+ "shipping": {+ "address": {+ "city": "San Francisco",+ "country": "US",+ "line1": "100 California Street",+ "line2": null,+ "postal_code": "94111",+ "state": "CA"+ },+ "carrier": null,+ "name": "Johnathan Doe",+ "phone": null,+ "tracking_number": null+ },+ "source": null,+ "statement_descriptor": null,+ "statement_descriptor_suffix": "R209095837",+ "status": "requires_action",+ "transfer_data": null,+ "transfer_group": "R209095837"+ }+ recorded_at: Tue, 09 Dec 2025 12:22:14 GMT+- request:+ method: get+ uri: https://api.stripe.com/v1/payment_intents/pi_3ScPMjFmGsiQWfE61qMaWSFF?expand%5B%5D=payment_method+ body:+ encoding: US-ASCII+ string: ''+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 Spree Stripe/5.2.1 (https://spreecommerce.org)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Tue, 09 Dec 2025 12:49:35 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '5299'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=j7qxfBdPbGyc38CROozdnnHAswKzbE-mfXn4ay1Z_A0ZmUnHltqsaZKDSys_qcsNFw3IVBC4Nk-mlarO+ Request-Id:+ - req_KaFkqwsJofAUlD+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - ABGHIJ+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "pi_3ScPMjFmGsiQWfE61qMaWSFF",+ "object": "payment_intent",+ "amount": 4000,+ "amount_capturable": 0,+ "amount_details": {+ "tip": {}+ },+ "amount_received": 0,+ "application": null,+ "application_fee_amount": null,+ "automatic_payment_methods": {+ "allow_redirects": "always",+ "enabled": true+ },+ "canceled_at": null,+ "cancellation_reason": null,+ "capture_method": "automatic",+ "client_secret": "pi_3ScPMjFmGsiQWfE61qMaWSFF_secret_Cl5waHuNY3QiBpa0Kl5Xt03EK",+ "confirmation_method": "automatic",+ "created": 1765280761,+ "currency": "usd",+ "customer": "cus_TZFk4Fxe9gABNI",+ "customer_account": null,+ "description": null,+ "excluded_payment_method_types": null,+ "invoice": null,+ "last_payment_error": null,+ "latest_charge": null,+ "livemode": false,+ "metadata": {+ "spree_order_id": "159"+ },+ "next_action": {+ "display_bank_transfer_instructions": {+ "amount_remaining": 4000,+ "currency": "usd",+ "financial_addresses": [+ {+ "aba": {+ "account_holder_address": {+ "city": "South San Francisco",+ "country": "US",+ "line1": "354 Oyster Point Blvd",+ "line2": null,+ "postal_code": "94080",+ "state": "CA"+ },+ "account_holder_name": "UFC Meals",+ "account_number": "11119958118330123",+ "account_type": "checking",+ "bank_address": {+ "city": "San Francisco",+ "country": "US",+ "line1": "420 Montgomery Street",+ "line2": null,+ "postal_code": "94104",+ "state": "CA"+ },+ "bank_name": "US Test Bank",+ "routing_number": "999999999"+ },+ "supported_networks": [+ "ach",+ "domestic_wire_us"+ ],+ "type": "aba"+ },+ {+ "supported_networks": [+ "swift"+ ],+ "swift": {+ "account_holder_address": {+ "city": "South San Francisco",+ "country": "US",+ "line1": "354 Oyster Point Blvd",+ "line2": null,+ "postal_code": "94080",+ "state": "CA"+ },+ "account_holder_name": "UFC Meals",+ "account_number": "11119958118330123",+ "account_type": "checking",+ "bank_address": {+ "city": "San Francisco",+ "country": "US",+ "line1": "420 Montgomery Street",+ "line2": null,+ "postal_code": "94104",+ "state": "CA"+ },+ "bank_name": "US Test Bank",+ "swift_code": "TESTUS99XXX"+ },+ "type": "swift"+ }+ ],+ "hosted_instructions_url": "https://payments.stripe.com/bank_transfers/instructions/test_YWNjdF8xUk1uMnBGbUdzaVFXZkU2LF9UWllVdEJiN2NEMzlVTGc0V1hPTXJNbENKY2sxaThn01006xj2lWnQ",+ "reference": "SCBJWXEZAFH8",+ "type": "us_bank_transfer"+ },+ "type": "display_bank_transfer_instructions"+ },+ "on_behalf_of": null,+ "payment_method": {+ "id": "pm_1ScPNbFmGsiQWfE6IQ5cXwYc",+ "object": "payment_method",+ "allow_redisplay": "unspecified",+ "billing_details": {+ "address": {+ "city": "San Francisco",+ "country": "US",+ "line1": "100 California Street",+ "line2": null,+ "postal_code": "94111",+ "state": "CA"+ },+ "email": "[email protected]",+ "name": "Johnathan Doe",+ "phone": null,+ "tax_id": null+ },+ "created": 1765280815,+ "customer": null,+ "customer_account": null,+ "customer_balance": {},+ "livemode": false,+ "metadata": {},+ "type": "customer_balance"+ },+ "payment_method_configuration_details": {+ "id": "pmc_1RMn31FmGsiQWfE6vaR9S4rU",+ "parent": null+ },+ "payment_method_options": {+ "card": {+ "installments": null,+ "mandate_options": null,+ "network": null,+ "request_three_d_secure": "automatic",+ "setup_future_usage": "off_session"+ },+ "customer_balance": {+ "bank_transfer": {+ "type": "us_bank_transfer"+ },+ "funding_type": "bank_transfer"+ },+ "link": {+ "persistent_token": null+ },+ "us_bank_account": {+ "financial_connections": {+ "permissions": [+ "payment_method"+ ],+ "prefetch": []+ },+ "mandate_options": {},+ "verification_method": "automatic"+ }+ },+ "payment_method_types": [+ "card",+ "link",+ "us_bank_account",+ "customer_balance"+ ],+ "processing": null,+ "receipt_email": null,+ "review": null,+ "setup_future_usage": null,+ "shipping": {+ "address": {+ "city": "San Francisco",+ "country": "US",+ "line1": "100 California Street",+ "line2": null,+ "postal_code": "94111",+ "state": "CA"+ },+ "carrier": null,+ "name": "Johnathan Doe",+ "phone": null,+ "tracking_number": null+ },+ "source": null,+ "statement_descriptor": null,+ "statement_descriptor_suffix": "R209095837",+ "status": "requires_action",+ "transfer_data": null,+ "transfer_group": "R209095837"+ }+ recorded_at: Tue, 09 Dec 2025 12:49:35 GMT+recorded_with: VCR 6.3.1diff --git a/spree/providers/stripe/spec/vcr/retrieve_payment_intent_charge.yml b/spree/providers/stripe/spec/vcr/retrieve_payment_intent_charge.ymlnew file mode 100644index 0000000000..2c53a4875d--- /dev/null+++ b/spree/providers/stripe/spec/vcr/retrieve_payment_intent_charge.yml@@ -0,0 +1,412 @@+---+http_interactions:+- request:+ method: get+ uri: https://api.stripe.com/v1/payment_intents/pi_3QY76s2ESifGlJez04sj0cMb?expand%5B%5D=payment_method+ body:+ encoding: US-ASCII+ string: ''+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 Spree Stripe/5.1.1 (https://spreecommerce.org)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Fri, 05 Dec 2025 16:31:17 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '3221'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=4UucLKNTIMVxMe-YjJansRHnaPXLj12r1NXQ8jmSejFhkXQkN2LLy5DDsviLbbJQathEQsCEJJpk-3gn+ Request-Id:+ - req_JwHgSrAnkHXnmn+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - ABGHIJ+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "pi_3QY76s2ESifGlJez04sj0cMb",+ "object": "payment_intent",+ "amount": 4500,+ "amount_capturable": 0,+ "amount_details": {+ "tip": {}+ },+ "amount_received": 4500,+ "application": null,+ "application_fee_amount": null,+ "automatic_payment_methods": {+ "allow_redirects": "always",+ "enabled": true+ },+ "canceled_at": null,+ "cancellation_reason": null,+ "capture_method": "automatic",+ "client_secret": "pi_3QY76s2ESifGlJez04sj0cMb_secret_HzJtNRi61JiDzq9fjXVwxYYq5",+ "confirmation_method": "automatic",+ "created": 1734704602,+ "currency": "usd",+ "customer": "cus_RQdclxFVLH4oau",+ "description": null,+ "excluded_payment_method_types": null,+ "invoice": null,+ "last_payment_error": null,+ "latest_charge": "ch_3QY76s2ESifGlJez0gG0FoF1",+ "livemode": false,+ "metadata": {+ "spree_order_id": "85c07c2a-64cf-41c0-9bfd-d41bde07ac9d"+ },+ "next_action": null,+ "on_behalf_of": null,+ "payment_method": {+ "id": "pm_1QY4zO2ESifGlJezkHIvUraY",+ "object": "payment_method",+ "allow_redisplay": "unspecified",+ "billing_details": {+ "address": {+ "city": "Santa Cruz",+ "country": "US",+ "line1": "200 California Street",+ "line2": null,+ "postal_code": "95060",+ "state": "CA"+ },+ "email": "[email protected]",+ "name": "Janek Kowalsky",+ "phone": null,+ "tax_id": null+ },+ "card": {+ "brand": "visa",+ "checks": {+ "address_line1_check": "pass",+ "address_postal_code_check": "pass",+ "cvc_check": "pass"+ },+ "country": "US",+ "display_brand": "visa",+ "exp_month": 2,+ "exp_year": 2027,+ "fingerprint": "taGjeBd4Wh4btmTn",+ "funding": "credit",+ "generated_from": null,+ "last4": "4242",+ "networks": {+ "available": [+ "visa"+ ],+ "preferred": null+ },+ "regulated_status": "unregulated",+ "three_d_secure_usage": {+ "supported": true+ },+ "wallet": null+ },+ "created": 1734696451,+ "customer": "cus_RQdclxFVLH4oau",+ "livemode": false,+ "metadata": {},+ "type": "card"+ },+ "payment_method_configuration_details": {+ "id": "pmc_1QVa9x2ESifGlJezRC5fgLVg",+ "parent": null+ },+ "payment_method_options": {+ "card": {+ "installments": null,+ "mandate_options": null,+ "network": null,+ "request_three_d_secure": "automatic",+ "setup_future_usage": "off_session"+ },+ "link": {+ "persistent_token": null+ }+ },+ "payment_method_types": [+ "card",+ "link"+ ],+ "processing": null,+ "receipt_email": null,+ "review": null,+ "setup_future_usage": null,+ "shipping": {+ "address": {+ "city": "New York",+ "country": "US",+ "line1": "110 Chambers Street",+ "line2": null,+ "postal_code": "10007",+ "state": "NY"+ },+ "carrier": null,+ "name": "John Doe",+ "phone": null,+ "tracking_number": null+ },+ "source": null,+ "statement_descriptor": null,+ "statement_descriptor_suffix": "R808743511 John Doe",+ "status": "succeeded",+ "transfer_data": null,+ "transfer_group": "R808743511"+ }+ recorded_at: Fri, 05 Dec 2025 16:31:17 GMT+- request:+ method: get+ uri: https://api.stripe.com/v1/charges/ch_3QY76s2ESifGlJez0gG0FoF1+ body:+ encoding: US-ASCII+ string: ''+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 Spree Stripe/1.0.0 (https://spreecommerce.org)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ X-Stripe-Client-Telemetry:+ - '{"last_request_metrics":{"request_id":"req_gcBRJiIZVsKrn7","request_duration_ms":424}}'+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Fri, 20 Dec 2024 16:23:28 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '3387'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; upgrade-insecure-requests;+ report-uri /csp-violation https://q.stripe.com/csp-violation?q=SW5BG4aATvVZhjUu6WSHfjiEuiRg5zwkSJ6pMpNb4H9Iu0iVkoyqoP-i4Ni76pJ7cw8CVmGwnw%3D%3D+ Cross-Origin-Opener-Policy-Report-Only:+ - same-origin; report-to="coop"+ Report-To:+ - '{"group":"coop","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/coop-report"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - coop="https://q.stripe.com/coop-report"+ Request-Id:+ - req_Qgi9KyMHZ86CMD+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Content-Type-Options:+ - nosniff+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - AB+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "ch_3QY76s2ESifGlJez0gG0FoF1",+ "object": "charge",+ "amount": 4500,+ "amount_captured": 4500,+ "amount_refunded": 0,+ "application": null,+ "application_fee": null,+ "application_fee_amount": null,+ "balance_transaction": "txn_3QY76s2ESifGlJez0kDDfrNF",+ "billing_details": {+ "address": {+ "city": "Santa Cruz",+ "country": "US",+ "line1": "200 California Street",+ "line2": null,+ "postal_code": "95060",+ "state": "CA"+ },+ "email": "[email protected]",+ "name": "Janek Kowalsky",+ "phone": null+ },+ "calculated_statement_descriptor": "ABCDEF ABC* R808743511",+ "captured": true,+ "created": 1734704622,+ "currency": "usd",+ "customer": "cus_RQdclxFVLH4oau",+ "description": null,+ "destination": null,+ "dispute": null,+ "disputed": false,+ "failure_balance_transaction": null,+ "failure_code": null,+ "failure_message": null,+ "fraud_details": {},+ "invoice": null,+ "livemode": false,+ "metadata": {+ "spree_order_id": "85c07c2a-64cf-41c0-9bfd-d41bde07ac9d"+ },+ "on_behalf_of": null,+ "order": null,+ "outcome": {+ "advice_code": null,+ "network_advice_code": null,+ "network_decline_code": null,+ "network_status": "approved_by_network",+ "reason": null,+ "risk_level": "normal",+ "risk_score": 22,+ "seller_message": "Payment complete.",+ "type": "authorized"+ },+ "paid": true,+ "payment_intent": "pi_3QY76s2ESifGlJez04sj0cMb",+ "payment_method": "pm_1QY4zO2ESifGlJezkHIvUraY",+ "payment_method_details": {+ "card": {+ "amount_authorized": 4500,+ "authorization_code": null,+ "brand": "visa",+ "checks": {+ "address_line1_check": "pass",+ "address_postal_code_check": "pass",+ "cvc_check": null+ },+ "country": "US",+ "exp_month": 2,+ "exp_year": 2027,+ "extended_authorization": {+ "status": "disabled"+ },+ "fingerprint": "taGjeBd4Wh4btmTn",+ "funding": "credit",+ "incremental_authorization": {+ "status": "unavailable"+ },+ "installments": null,+ "last4": "4242",+ "mandate": null,+ "multicapture": {+ "status": "unavailable"+ },+ "network": "visa",+ "network_token": {+ "used": false+ },+ "network_transaction_id": "116977110610166",+ "overcapture": {+ "maximum_amount_capturable": 4500,+ "status": "unavailable"+ },+ "regulated_status": "unregulated",+ "three_d_secure": null,+ "wallet": null+ },+ "type": "card"+ },+ "radar_options": {},+ "receipt_email": null,+ "receipt_number": null,+ "receipt_url": "https://pay.stripe.com/receipts/payment/CAcaFwoVYWNjdF8xUVZhOWsyRVNpZkdsSmV6KIC0lrsGMgYGrjskQi46LBb0zaBzweYiALdzyRxzQrMzjvE8TzZ1sFYSBZVQ1AF68LoJK_VSisrzJ5fj",+ "refunded": false,+ "review": null,+ "shipping": {+ "address": {+ "city": "New York",+ "country": "US",+ "line1": "110 Chambers Street",+ "line2": null,+ "postal_code": "10007",+ "state": "NY"+ },+ "carrier": null,+ "name": "John Doe",+ "phone": null,+ "tracking_number": null+ },+ "source": null,+ "source_transfer": null,+ "statement_descriptor": null,+ "statement_descriptor_suffix": "R808743511 John Doe",+ "status": "succeeded",+ "transfer_data": null,+ "transfer_group": "R808743511"+ }+ recorded_at: Fri, 20 Dec 2024 16:23:28 GMT+recorded_with: VCR 6.3.1diff --git a/spree/providers/stripe/spec/vcr/update_customer.yml b/spree/providers/stripe/spec/vcr/update_customer.ymlnew file mode 100644index 0000000000..a8c3da6084--- /dev/null+++ b/spree/providers/stripe/spec/vcr/update_customer.yml@@ -0,0 +1,223 @@+---+http_interactions:+- request:+ method: post+ uri: https://api.stripe.com/v1/customers/cus_SeIsxI1TG3dGJv+ body:+ encoding: UTF-8+ string: address[city]=San+Francisco&address[line1]=200+California+Street&address[line2]=Apt+11&address[postal_code]=94112&address[country]=United+States+of+America&address[state]=California&email=test-updated%40example.com&name=John+Doe+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 Spree Stripe/5.0.0.alpha (https://spreecommerce.org)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Wed, 09 Jul 2025 16:07:07 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '832'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=AAMjilQRL0ZuZ_PQxQxkqatRpl0jkvpuuZX8QPN3D5hVUDRPRYiRWTbDB3EEkVNXqJVIPwDUlS2K0cOc+ Idempotency-Key:+ - 3926197c-8d7b-4f43-9885-2950cd742f6a+ Original-Request:+ - req_ZBRZpKnB1o3YBL+ Request-Id:+ - req_ZBRZpKnB1o3YBL+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - ABGHIJ+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "cus_SeIsxI1TG3dGJv",+ "object": "customer",+ "address": {+ "city": "San Francisco",+ "country": "United States of America",+ "line1": "200 California Street",+ "line2": "Apt 11",+ "postal_code": "94112",+ "state": "California"+ },+ "balance": 0,+ "created": 1752076249,+ "currency": null,+ "default_source": null,+ "delinquent": false,+ "description": null,+ "discount": null,+ "email": "[email protected]",+ "invoice_prefix": "NRF6DCGN",+ "invoice_settings": {+ "custom_fields": null,+ "default_payment_method": null,+ "footer": null,+ "rendering_options": null+ },+ "livemode": false,+ "metadata": {},+ "name": "John Doe",+ "next_invoice_sequence": 1,+ "phone": null,+ "preferred_locales": [],+ "shipping": null,+ "tax_exempt": "none",+ "test_clock": null+ }+ recorded_at: Wed, 09 Jul 2025 16:07:07 GMT+- request:+ method: get+ uri: https://api.stripe.com/v1/customers/cus_SeIsxI1TG3dGJv+ body:+ encoding: US-ASCII+ string: ''+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 Spree Stripe/5.0.0.alpha (https://spreecommerce.org)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Wed, 09 Jul 2025 16:07:07 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '832'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=6XFjq_pl332Vy2KysoBDvhVl0My72nnLRgFa5pneQohlZnWCwl3bpdAOlYcKJPC86vHqX4UOLNj7XXE9+ Request-Id:+ - req_KYU69KFy2Txepg+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - ABGHIJ+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "cus_SeIsxI1TG3dGJv",+ "object": "customer",+ "address": {+ "city": "San Francisco",+ "country": "United States of America",+ "line1": "200 California Street",+ "line2": "Apt 11",+ "postal_code": "94112",+ "state": "California"+ },+ "balance": 0,+ "created": 1752076249,+ "currency": null,+ "default_source": null,+ "delinquent": false,+ "description": null,+ "discount": null,+ "email": "[email protected]",+ "invoice_prefix": "NRF6DCGN",+ "invoice_settings": {+ "custom_fields": null,+ "default_payment_method": null,+ "footer": null,+ "rendering_options": null+ },+ "livemode": false,+ "metadata": {},+ "name": "John Doe",+ "next_invoice_sequence": 1,+ "phone": null,+ "preferred_locales": [],+ "shipping": null,+ "tax_exempt": "none",+ "test_clock": null+ }+ recorded_at: Wed, 09 Jul 2025 16:07:07 GMT+recorded_with: VCR 6.3.1diff --git a/spree/providers/stripe/spec/vcr/update_customer_based_on_user.yml b/spree/providers/stripe/spec/vcr/update_customer_based_on_user.ymlnew file mode 100644index 0000000000..9601eb1dcc--- /dev/null+++ b/spree/providers/stripe/spec/vcr/update_customer_based_on_user.yml@@ -0,0 +1,223 @@+---+http_interactions:+- request:+ method: post+ uri: https://api.stripe.com/v1/customers/cus_SeIsxI1TG3dGJv+ body:+ encoding: UTF-8+ string: address[city]=New+York&address[line1]=200+Main+Street&address[line2]=Apt+22&address[postal_code]=10002&address[country]=United+States+of+America&address[state]=New+York&email=test-updated%40example.com&name=Jane+Moe+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 Spree Stripe/5.0.0.alpha (https://spreecommerce.org)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Wed, 09 Jul 2025 16:10:13 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '817'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=6XFjq_pl332Vy2KysoBDvhVl0My72nnLRgFa5pneQohlZnWCwl3bpdAOlYcKJPC86vHqX4UOLNj7XXE9+ Idempotency-Key:+ - 13c6dcc4-1c97-401e-8afa-24dd445d3423+ Original-Request:+ - req_UqLvAEdrEl63cy+ Request-Id:+ - req_UqLvAEdrEl63cy+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - ABGHIJ+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "cus_SeIsxI1TG3dGJv",+ "object": "customer",+ "address": {+ "city": "New York",+ "country": "United States of America",+ "line1": "200 Main Street",+ "line2": "Apt 22",+ "postal_code": "10002",+ "state": "New York"+ },+ "balance": 0,+ "created": 1752076249,+ "currency": null,+ "default_source": null,+ "delinquent": false,+ "description": null,+ "discount": null,+ "email": "[email protected]",+ "invoice_prefix": "NRF6DCGN",+ "invoice_settings": {+ "custom_fields": null,+ "default_payment_method": null,+ "footer": null,+ "rendering_options": null+ },+ "livemode": false,+ "metadata": {},+ "name": "Jane Moe",+ "next_invoice_sequence": 1,+ "phone": null,+ "preferred_locales": [],+ "shipping": null,+ "tax_exempt": "none",+ "test_clock": null+ }+ recorded_at: Wed, 09 Jul 2025 16:10:13 GMT+- request:+ method: get+ uri: https://api.stripe.com/v1/customers/cus_SeIsxI1TG3dGJv+ body:+ encoding: US-ASCII+ string: ''+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 Spree Stripe/5.0.0.alpha (https://spreecommerce.org)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Wed, 09 Jul 2025 16:10:13 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '817'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src+ 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=F78N_Rjd-ygB5NB__AmF26Asa-xuXdIl9x0-8Q2ykA-cpC0V8Im6AMdFW7WBGoPJKsd5HTOoREPz9UoW+ Request-Id:+ - req_bIHxUNvZEb3SH3+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - ABGHIJ+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "cus_SeIsxI1TG3dGJv",+ "object": "customer",+ "address": {+ "city": "New York",+ "country": "United States of America",+ "line1": "200 Main Street",+ "line2": "Apt 22",+ "postal_code": "10002",+ "state": "New York"+ },+ "balance": 0,+ "created": 1752076249,+ "currency": null,+ "default_source": null,+ "delinquent": false,+ "description": null,+ "discount": null,+ "email": "[email protected]",+ "invoice_prefix": "NRF6DCGN",+ "invoice_settings": {+ "custom_fields": null,+ "default_payment_method": null,+ "footer": null,+ "rendering_options": null+ },+ "livemode": false,+ "metadata": {},+ "name": "Jane Moe",+ "next_invoice_sequence": 1,+ "phone": null,+ "preferred_locales": [],+ "shipping": null,+ "tax_exempt": "none",+ "test_clock": null+ }+ recorded_at: Wed, 09 Jul 2025 16:10:13 GMT+recorded_with: VCR 6.3.1diff --git a/spree/providers/stripe/spec/vcr/update_payment_intent_new_address.yml b/spree/providers/stripe/spec/vcr/update_payment_intent_new_address.ymlnew file mode 100644index 0000000000..2b132b12d7--- /dev/null+++ b/spree/providers/stripe/spec/vcr/update_payment_intent_new_address.yml@@ -0,0 +1,167 @@+---+http_interactions:+- request:+ method: post+ uri: https://api.stripe.com/v1/payment_intents/pi_3QY2qD2ESifGlJez0VuzXjwK+ body:+ encoding: UTF-8+ string: amount=4000¤cy=USD&shipping[address][city]=San+Francisco&shipping[address][country]=US&shipping[address][line1]=100+California+Street&shipping[address][postal_code]=94111&shipping[address][state]=CA&shipping[name]=Jane+Zoe&customer=cus_RQdclxFVLH4oau+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 Spree Stripe/1.0.0 (https://spreecommerce.org)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Fri, 20 Dec 2024 10:18:36 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '1934'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; upgrade-insecure-requests;+ report-uri /csp-violation https://q.stripe.com/csp-violation?q=603ir3ms36KSabQcLPYF5CRXTUb0pCgItKwurKLnqqgDZGxyvG-zBAAFRD4io7Abs9beeTumXA%3D%3D+ Cross-Origin-Opener-Policy-Report-Only:+ - same-origin; report-to="coop"+ Idempotency-Key:+ - afee1ead-424a-4f0b-9d48-06f3fbf0848e+ Original-Request:+ - req_dxal6vQ05zQ3ha+ Report-To:+ - '{"group":"coop","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/coop-report"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - coop="https://q.stripe.com/coop-report"+ Request-Id:+ - req_dxal6vQ05zQ3ha+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Content-Type-Options:+ - nosniff+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - AB+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "pi_3QY2qD2ESifGlJez0VuzXjwK",+ "object": "payment_intent",+ "amount": 4000,+ "amount_capturable": 0,+ "amount_details": {+ "tip": {}+ },+ "amount_received": 0,+ "application": null,+ "application_fee_amount": null,+ "automatic_payment_methods": {+ "allow_redirects": "always",+ "enabled": true+ },+ "canceled_at": null,+ "cancellation_reason": null,+ "capture_method": "automatic",+ "client_secret": "pi_3QY2qD2ESifGlJez0VuzXjwK_secret_x30uGfPVmhEj3lOCPOTiICqdx",+ "confirmation_method": "automatic",+ "created": 1734688193,+ "currency": "usd",+ "customer": "cus_RQdclxFVLH4oau",+ "description": null,+ "invoice": null,+ "last_payment_error": null,+ "latest_charge": null,+ "livemode": false,+ "metadata": {+ "spree_order_id": "4490655f-4ab0-43a2-936e-150bf547c26b"+ },+ "next_action": null,+ "on_behalf_of": null,+ "payment_method": null,+ "payment_method_configuration_details": {+ "id": "pmc_1QVa9x2ESifGlJezRC5fgLVg",+ "parent": null+ },+ "payment_method_options": {+ "card": {+ "installments": null,+ "mandate_options": null,+ "network": null,+ "request_three_d_secure": "automatic",+ "setup_future_usage": "off_session"+ },+ "link": {+ "persistent_token": null+ }+ },+ "payment_method_types": [+ "card",+ "link"+ ],+ "processing": null,+ "receipt_email": null,+ "review": null,+ "setup_future_usage": null,+ "shipping": {+ "address": {+ "city": "San Francisco",+ "country": "US",+ "line1": "100 California Street",+ "line2": null,+ "postal_code": "94111",+ "state": "CA"+ },+ "carrier": null,+ "name": "Jane Zoe",+ "phone": null,+ "tracking_number": null+ },+ "source": null,+ "statement_descriptor": null,+ "statement_descriptor_suffix": "R096430553 John Doe",+ "status": "requires_payment_method",+ "transfer_data": null,+ "transfer_group": "R096430553"+ }+ recorded_at: Fri, 20 Dec 2024 10:18:36 GMT+recorded_with: VCR 6.2.0diff --git a/spree/providers/stripe/spec/vcr/update_payment_intent_new_amount.yml b/spree/providers/stripe/spec/vcr/update_payment_intent_new_amount.ymlnew file mode 100644index 0000000000..e296eabae1--- /dev/null+++ b/spree/providers/stripe/spec/vcr/update_payment_intent_new_amount.yml@@ -0,0 +1,167 @@+---+http_interactions:+- request:+ method: post+ uri: https://api.stripe.com/v1/payment_intents/pi_3QY2qD2ESifGlJez0VuzXjwK+ body:+ encoding: UTF-8+ string: amount=6000¤cy=USD&shipping[address][city]=Herndon&shipping[address][country]=US&shipping[address][line1]=13+Lovely+Street&shipping[address][line2]=Northwest&shipping[address][postal_code]=35005&shipping[address][state]=STATE_ABBR_14&shipping[name]=John+Doe&customer=cus_RQdclxFVLH4oau+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 Spree Stripe/1.0.0 (https://spreecommerce.org)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Fri, 20 Dec 2024 10:29:23 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '1964'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; upgrade-insecure-requests;+ report-uri /csp-violation https://q.stripe.com/csp-violation?q=0r-ttE9jm0K_K2YDXPXKBfvLmhFL7U8k1z1TliXiAOWR4WWYOtYwnNl756RZnssYYgcSflLNQg%3D%3D+ Cross-Origin-Opener-Policy-Report-Only:+ - same-origin; report-to="coop"+ Idempotency-Key:+ - 77a8c86b-11c6-4054-9f54-858bc851eb93+ Original-Request:+ - req_6kLVbKLlARCjVk+ Report-To:+ - '{"group":"coop","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/coop-report"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - coop="https://q.stripe.com/coop-report"+ Request-Id:+ - req_6kLVbKLlARCjVk+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Content-Type-Options:+ - nosniff+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - AB+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "pi_3QY2qD2ESifGlJez0VuzXjwK",+ "object": "payment_intent",+ "amount": 6000,+ "amount_capturable": 0,+ "amount_details": {+ "tip": {}+ },+ "amount_received": 0,+ "application": null,+ "application_fee_amount": null,+ "automatic_payment_methods": {+ "allow_redirects": "always",+ "enabled": true+ },+ "canceled_at": null,+ "cancellation_reason": null,+ "capture_method": "automatic",+ "client_secret": "pi_3QY2qD2ESifGlJez0VuzXjwK_secret_x30uGfPVmhEj3lOCPOTiICqdx",+ "confirmation_method": "automatic",+ "created": 1734688193,+ "currency": "usd",+ "customer": "cus_RQdclxFVLH4oau",+ "description": null,+ "invoice": null,+ "last_payment_error": null,+ "latest_charge": null,+ "livemode": false,+ "metadata": {+ "spree_order_id": "4490655f-4ab0-43a2-936e-150bf547c26b"+ },+ "next_action": null,+ "on_behalf_of": null,+ "payment_method": "pm_1QXmPJ2ESifGlJezC2py6ZqS",+ "payment_method_configuration_details": {+ "id": "pmc_1QVa9x2ESifGlJezRC5fgLVg",+ "parent": null+ },+ "payment_method_options": {+ "card": {+ "installments": null,+ "mandate_options": null,+ "network": null,+ "request_three_d_secure": "automatic",+ "setup_future_usage": "off_session"+ },+ "link": {+ "persistent_token": null+ }+ },+ "payment_method_types": [+ "card",+ "link"+ ],+ "processing": null,+ "receipt_email": null,+ "review": null,+ "setup_future_usage": null,+ "shipping": {+ "address": {+ "city": "Herndon",+ "country": "US",+ "line1": "13 Lovely Street",+ "line2": "Northwest",+ "postal_code": "35005",+ "state": "STATE_ABBR_14"+ },+ "carrier": null,+ "name": "John Doe",+ "phone": null,+ "tracking_number": null+ },+ "source": null,+ "statement_descriptor": null,+ "statement_descriptor_suffix": "R096430553 John Doe",+ "status": "requires_confirmation",+ "transfer_data": null,+ "transfer_group": "R096430553"+ }+ recorded_at: Fri, 20 Dec 2024 10:29:23 GMT+recorded_with: VCR 6.2.0diff --git a/spree/providers/stripe/spec/vcr/update_payment_intent_payment_method.yml b/spree/providers/stripe/spec/vcr/update_payment_intent_payment_method.ymlnew file mode 100644index 0000000000..c73f20ed78--- /dev/null+++ b/spree/providers/stripe/spec/vcr/update_payment_intent_payment_method.yml@@ -0,0 +1,167 @@+---+http_interactions:+- request:+ method: post+ uri: https://api.stripe.com/v1/payment_intents/pi_3QY2qD2ESifGlJez0VuzXjwK+ body:+ encoding: UTF-8+ string: amount=4000¤cy=USD&payment_method=pm_1QXmPJ2ESifGlJezC2py6ZqS&shipping[address][city]=Herndon&shipping[address][country]=US&shipping[address][line1]=2+Lovely+Street&shipping[address][line2]=Northwest&shipping[address][postal_code]=35005&shipping[address][state]=STATE_ABBR_2&shipping[name]=John+Doe&customer=cus_RQdclxFVLH4oau+ headers:+ User-Agent:+ - Stripe/v1 RubyBindings/10.1.0 Spree Stripe/1.0.0 (https://spreecommerce.org)+ Authorization:+ - Bearer <STRIPE_SECRET_KEY>+ Content-Type:+ - application/x-www-form-urlencoded+ Stripe-Version:+ - '2023-10-16'+ X-Stripe-Client-User-Agent:+ - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ response:+ status:+ code: 200+ message: OK+ headers:+ Server:+ - nginx+ Date:+ - Fri, 20 Dec 2024 10:22:20 GMT+ Content-Type:+ - application/json+ Content-Length:+ - '1962'+ Connection:+ - keep-alive+ Access-Control-Allow-Credentials:+ - 'true'+ Access-Control-Allow-Methods:+ - GET, HEAD, PUT, PATCH, POST, DELETE+ Access-Control-Allow-Origin:+ - "*"+ Access-Control-Expose-Headers:+ - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required,+ X-Stripe-Privileged-Session-Required+ Access-Control-Max-Age:+ - '300'+ Cache-Control:+ - no-cache, no-store+ Content-Security-Policy:+ - base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none';+ img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; upgrade-insecure-requests;+ report-uri /csp-violation https://q.stripe.com/csp-violation?q=1J2A0YojPF04lw3JRBBX-wsNxA0suRfwkEPFs6Bwo3UlshDD49VTm0WeTY410tpHlreh7FJWyQ%3D%3D+ Cross-Origin-Opener-Policy-Report-Only:+ - same-origin; report-to="coop"+ Idempotency-Key:+ - 990d96ac-b217-4b9b-ab0b-5e7cb0bdf5e1+ Original-Request:+ - req_TmH0dtrZrVh31b+ Report-To:+ - '{"group":"coop","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/coop-report"}],"include_subdomains":true}'+ Reporting-Endpoints:+ - coop="https://q.stripe.com/coop-report"+ Request-Id:+ - req_TmH0dtrZrVh31b+ Stripe-Should-Retry:+ - 'false'+ Stripe-Version:+ - '2023-10-16'+ Vary:+ - Origin+ X-Content-Type-Options:+ - nosniff+ X-Stripe-Priority-Routing-Enabled:+ - 'true'+ X-Stripe-Routing-Context-Priority-Tier:+ - api-testmode+ X-Wc:+ - AB+ Strict-Transport-Security:+ - max-age=63072000; includeSubDomains; preload+ body:+ encoding: UTF-8+ string: |-+ {+ "id": "pi_3QY2qD2ESifGlJez0VuzXjwK",+ "object": "payment_intent",+ "amount": 4000,+ "amount_capturable": 0,+ "amount_details": {+ "tip": {}+ },+ "amount_received": 0,+ "application": null,+ "application_fee_amount": null,+ "automatic_payment_methods": {+ "allow_redirects": "always",+ "enabled": true+ },+ "canceled_at": null,+ "cancellation_reason": null,+ "capture_method": "automatic",+ "client_secret": "pi_3QY2qD2ESifGlJez0VuzXjwK_secret_x30uGfPVmhEj3lOCPOTiICqdx",+ "confirmation_method": "automatic",+ "created": 1734688193,+ "currency": "usd",+ "customer": "cus_RQdclxFVLH4oau",+ "description": null,+ "invoice": null,+ "last_payment_error": null,+ "latest_charge": null,+ "livemode": false,+ "metadata": {+ "spree_order_id": "4490655f-4ab0-43a2-936e-150bf547c26b"+ },+ "next_action": null,+ "on_behalf_of": null,+ "payment_method": "pm_1QXmPJ2ESifGlJezC2py6ZqS",+ "payment_method_configuration_details": {+ "id": "pmc_1QVa9x2ESifGlJezRC5fgLVg",+ "parent": null+ },+ "payment_method_options": {+ "card": {+ "installments": null,+ "mandate_options": null,+ "network": null,+ "request_three_d_secure": "automatic",+ "setup_future_usage": "off_session"+ },+ "link": {+ "persistent_token": null+ }+ },+ "payment_method_types": [+ "card",+ "link"+ ],+ "processing": null,+ "receipt_email": null,+ "review": null,+ "setup_future_usage": null,+ "shipping": {+ "address": {+ "city": "Herndon",+ "country": "US",+ "line1": "2 Lovely Street",+ "line2": "Northwest",+ "postal_code": "35005",+ "state": "STATE_ABBR_2"+ },+ "carrier": null,+ "name": "John Doe",+ "phone": null,+ "tracking_number": null+ },+ "source": null,+ "statement_descriptor": null,+ "statement_descriptor_suffix": "R096430553 John Doe",+ "status": "requires_confirmation",+ "transfer_data": null,+ "transfer_group": "R096430553"+ }+ recorded_at: Fri, 20 Dec 2024 10:22:20 GMT+recorded_with: VCR 6.2.0diff --git a/spree/providers/stripe/spree_stripe.gemspec b/spree/providers/stripe/spree_stripe.gemspecnew file mode 100644index 0000000000..b13e2e6c3a--- /dev/null+++ b/spree/providers/stripe/spree_stripe.gemspec@@ -0,0 +1,32 @@+# encoding: UTF-8++require_relative '../../core/lib/spree/core/version.rb'++Gem::Specification.new do |s|+ s.platform = Gem::Platform::RUBY+ s.name = 'spree_stripe'+ s.version = Spree.version+ s.authors = ['Vendo Connect Inc.', 'Vendo Sp. z o.o.']+ s.email = '[email protected]'+ s.summary = 'Official Stripe payment gateway for Spree Commerce'+ s.description = 'Optional Stripe payment gateway for Spree, implementing the payment session API'+ s.homepage = 'https://spreecommerce.org'+ s.license = 'BSD-3-Clause'++ s.metadata = {+ "bug_tracker_uri" => "https://github.com/spree/spree/issues",+ "changelog_uri" => "https://github.com/spree/spree/releases/tag/v#{s.version}",+ "documentation_uri" => "https://docs.spreecommerce.org/",+ "source_code_uri" => "https://github.com/spree/spree/tree/v#{s.version}",+ }++ s.required_ruby_version = '>= 3.2'++ s.files = Dir["{app,config,db,lib,vendor}/**/*", "Rakefile", "README.md"].reject { |f| f.match(/^spec/) && !f.match(/^spec\/fixtures/) }+ s.require_path = 'lib'++ s.add_dependency 'spree_core', ">= #{s.version}"+ s.add_dependency 'stripe', '>= 10.1', '< 19'++ s.add_development_dependency 'vcr'+end