spree-bank_payments 5.3.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +194 -0
- data/README.md +230 -117
- data/Rakefile +39 -1
- data/app/controllers/concerns/spree/bank_payments/release_on_other_method.rb +56 -0
- data/app/controllers/spree/api/v3/admin/bank_payments/accounts_controller.rb +135 -0
- data/app/controllers/spree/api/v3/admin/bank_payments/health_controller.rb +44 -0
- data/app/controllers/spree/api/v3/admin/bank_payments/orders_controller.rb +44 -0
- data/app/controllers/spree/api/v3/admin/bank_payments/payment_methods_controller.rb +32 -0
- data/app/controllers/spree/api/v3/admin/bank_payments/resource_controller.rb +40 -0
- data/app/controllers/spree/api/v3/admin/bank_payments/transfers_controller.rb +179 -0
- data/app/jobs/spree/bank_payments/expire_sessions_job.rb +67 -57
- data/app/jobs/spree/bank_payments/send_reminders_job.rb +4 -1
- data/app/mailers/spree/bank_payments/instructions_mailer.rb +47 -12
- data/app/models/spree/bank_payments/adjusters/discount.rb +99 -0
- data/app/models/spree/bank_payments/bank_account.rb +3 -0
- data/app/models/spree/bank_payments/base.rb +8 -0
- data/app/models/spree/bank_payments/current.rb +10 -0
- data/app/models/spree/bank_payments/gateway.rb +204 -72
- data/app/models/spree/bank_payments/incoming_transfer.rb +5 -0
- data/app/models/spree/payment_sessions/bank_transfer.rb +80 -9
- data/app/serializers/spree/api/v3/admin/bank_payments/bank_account_serializer.rb +23 -0
- data/app/serializers/spree/api/v3/admin/bank_payments/incoming_transfer_serializer.rb +48 -0
- data/app/serializers/spree/api/v3/admin/bank_payments/payment_session_serializer.rb +21 -0
- data/app/serializers/spree/api/v3/admin/bank_payments/suggestion_serializer.rb +40 -0
- data/app/services/spree/bank_payments/apply_transfer.rb +74 -45
- data/app/services/spree/bank_payments/guard_capture.rb +17 -0
- data/app/services/spree/bank_payments/health_reporter.rb +8 -6
- data/app/services/spree/bank_payments/ignore_transfer.rb +37 -0
- data/app/services/spree/bank_payments/ingest_transfer.rb +16 -4
- data/app/services/spree/bank_payments/migrate_legacy_accounts.rb +5 -1
- data/app/services/spree/bank_payments/migrate_legacy_discounts.rb +82 -0
- data/app/services/spree/bank_payments/record_manual_transfer.rb +136 -0
- data/app/services/spree/bank_payments/release_selection.rb +58 -0
- data/app/services/spree/bank_payments/settle_at_completion.rb +35 -0
- data/app/services/spree/bank_payments/suggest_matches.rb +7 -3
- data/app/subscribers/spree/bank_payments/instructions_mailer_subscriber.rb +45 -0
- data/app/subscribers/spree/bank_payments/order_placed_subscriber.rb +31 -0
- data/app/views/spree/bank_payments/instructions_mailer/_payment_details.html.erb +24 -0
- data/app/views/spree/bank_payments/instructions_mailer/_payment_details.text.erb +11 -0
- data/app/views/spree/bank_payments/instructions_mailer/expired.html.erb +8 -0
- data/app/views/spree/bank_payments/instructions_mailer/expired.text.erb +7 -0
- data/app/views/spree/bank_payments/instructions_mailer/instructions.html.erb +7 -25
- data/app/views/spree/bank_payments/instructions_mailer/instructions.text.erb +8 -0
- data/app/views/spree/bank_payments/instructions_mailer/reminder.html.erb +7 -27
- data/app/views/spree/bank_payments/instructions_mailer/reminder.text.erb +8 -0
- data/config/initializers/spree.rb +50 -56
- data/config/locales/en.yml +41 -1
- data/config/routes.rb +23 -15
- data/lib/generators/spree/bank_payments/install/install_generator.rb +202 -1
- data/lib/spree/bank_payments/api_fields.rb +39 -0
- data/lib/spree/bank_payments/events.rb +36 -0
- data/lib/spree/bank_payments/factories.rb +10 -5
- data/lib/spree/bank_payments/version.rb +2 -2
- data/lib/spree/bank_payments.rb +27 -57
- data/lib/tasks/spree_bank_payments.rake +9 -0
- metadata +36 -65
- data/app/controllers/spree/admin/bank_accounts_controller.rb +0 -134
- data/app/controllers/spree/admin/bank_transfers_controller.rb +0 -293
- data/app/models/spree/bank_payments/adjuster/discount.rb +0 -55
- data/app/models/spree/bank_payments/payment_decorator.rb +0 -22
- data/app/services/spree/bank_payments/apply_discount.rb +0 -154
- data/app/views/spree/admin/bank_accounts/_form.html.erb +0 -33
- data/app/views/spree/admin/bank_accounts/edit.html.erb +0 -3
- data/app/views/spree/admin/bank_accounts/index.html.erb +0 -84
- data/app/views/spree/admin/bank_accounts/new.html.erb +0 -3
- data/app/views/spree/admin/bank_transfers/index.html.erb +0 -91
- data/app/views/spree/admin/bank_transfers/new.html.erb +0 -46
- data/app/views/spree/admin/payment_methods/configuration_guides/_spree_bank_payments.html.erb +0 -52
- data/app/views/spree/admin/payment_methods/descriptions/_spree_bank_payments.html.erb +0 -4
- data/app/views/spree/bank_payments/_order_instructions.html.erb +0 -82
- data/app/views/spree/bank_payments/admin/_order_panel.html.erb +0 -55
- data/app/views/spree/checkout/payment/_spree_bank_payments.html.erb +0 -13
- data/lib/spree/bank_payments/subscribers.rb +0 -42
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0e70d0bdec00b95438a25a779a8e1ef5db3648906f42661bee23cba72186c03c
|
|
4
|
+
data.tar.gz: 935ddbb7b530efe56150eda78d0afcf1eda873216e66e1e4b50e4a78543bbb4a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 95591d2649a8e6cb6c318029e33ac0c499af3ba99cbcc4a33b673b1b5212aaecd1218bc4069b62dc954fe5657a3a3e6d2029daeb26e36a180019c1d7fd833c38
|
|
7
|
+
data.tar.gz: 8cc010e5de2156ca1543c576eb9ff8631d7f403d69072edb5ec288885432f6d84b30b2f3f29034f5503dd1197cc95544753e0efad19d8e4e2e87bfb641c9fb0d
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,200 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented in this file.
|
|
4
4
|
|
|
5
|
+
## 6.1.0
|
|
6
|
+
|
|
7
|
+
Found running the gem and its dashboard plugin end to end on a stock Spree 6
|
|
8
|
+
store, which sends the gem's own emails and schedules jobs with Solid Queue.
|
|
9
|
+
6.0.1 was never released; its fixes ship here.
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- **An email when an unpaid order is cancelled.** The bundled mailer now sends
|
|
14
|
+
one on `bank_transfer.expired`: the order, the amount, the deadline that
|
|
15
|
+
passed, and what to do if the transfer was already sent. A store on the
|
|
16
|
+
mailer previously told the buyer nothing, because expiry cancels with
|
|
17
|
+
`notify_customer: false`.
|
|
18
|
+
- **The install generator schedules the jobs.** It writes `ExpireSessionsJob`,
|
|
19
|
+
`SendRemindersJob` and `PollJob` into `config/recurring.yml` (Solid Queue,
|
|
20
|
+
a stock Spree 6 store) or `config/schedule.yml` (sidekiq-cron), chosen from
|
|
21
|
+
the app's Active Job adapter or `--scheduler`. On an existing install, run
|
|
22
|
+
`bin/rails g spree:bank_payments:install --skip-migrations` to schedule
|
|
23
|
+
the jobs only; it schedules nothing twice. A schedule file it cannot edit
|
|
24
|
+
safely (an anchored or aliased `production` key, ERB, no environment keys)
|
|
25
|
+
is left as it is, and the jobs are listed to add by hand.
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- **The instructions and reminder emails name the order and give the
|
|
30
|
+
deadline.** Subjects are "Bank transfer details for order #R123" and
|
|
31
|
+
"Reminder: pay for order #R123 by 11 November 2026", after the store's
|
|
32
|
+
name, as Spree's own emails start. The body gives the deadline as a date
|
|
33
|
+
and time in the store's time zone, and the reminder no longer counts days
|
|
34
|
+
("within 1 days"). Every email has a plain-text part.
|
|
35
|
+
- The bundled mailer honours the store's "send customer emails" setting
|
|
36
|
+
(`send_consumer_transactional_emails`), as Spree's own customer emails do.
|
|
37
|
+
- The `spree.bank_payments.pay_within` translation is gone; the email copy is
|
|
38
|
+
under `spree.bank_payments.mailer`.
|
|
39
|
+
- The dashboard plugin has unit tests (`pnpm test`), run in CI and before
|
|
40
|
+
each npm release.
|
|
41
|
+
|
|
42
|
+
### Fixed
|
|
43
|
+
|
|
44
|
+
- **The dashboard queue ignored every filter and the search.** The plugin
|
|
45
|
+
sent the table's filters as bare query parameters (`state_in=unmatched`),
|
|
46
|
+
and Spree's Admin API reads filters only from `q[...]`, so the queue listed
|
|
47
|
+
every transfer whatever the status chip, search or date range said. They
|
|
48
|
+
are now sent as `q[...]`, as Spree's own resource clients send them.
|
|
49
|
+
- **Clearing the queue's filters brought the "unmatched" default back.**
|
|
50
|
+
"Clear all", or "Select all" in the status chip, now lists every transfer.
|
|
51
|
+
Only a fresh visit, from the sidebar, opens on unmatched transfers.
|
|
52
|
+
- **A recorded transfer's date is read in the store's time zone.** The record
|
|
53
|
+
form sends the day the money arrived, and the server read it as midnight
|
|
54
|
+
UTC, so the queue showed a transfer received today as "about 23 hours ago"
|
|
55
|
+
and a store west of UTC could show the day before. The form also defaulted
|
|
56
|
+
to the browser's UTC date, a day ahead every evening west of UTC. Transfers
|
|
57
|
+
already recorded keep their identity, so recording one again still says
|
|
58
|
+
"already recorded". Their stored time is not changed: in a store west of
|
|
59
|
+
UTC, one recorded on 6.0.x still shows the day before.
|
|
60
|
+
- The queue and the transfer page show the day a transfer arrived as a date
|
|
61
|
+
in the store's time zone, not a relative time.
|
|
62
|
+
|
|
63
|
+
## 6.0.0
|
|
64
|
+
|
|
65
|
+
Spree 6 support. The major version tracks Spree's, so 6.x supports Spree 6.
|
|
66
|
+
Spree 5.6 stays on 5.3.x, on the `5-3-stable` branch. To upgrade, see
|
|
67
|
+
[docs/upgrading-5-to-6.md](docs/upgrading-5-to-6.md).
|
|
68
|
+
|
|
69
|
+
### Requirements
|
|
70
|
+
|
|
71
|
+
- Spree `~> 6.0` and Ruby 3.3 or newer. The 5.x releases do not install on
|
|
72
|
+
Spree 6.
|
|
73
|
+
- The `spree_admin` dependency is gone: Spree 6 has no Rails admin.
|
|
74
|
+
|
|
75
|
+
### Removed
|
|
76
|
+
|
|
77
|
+
- **The Rails admin screens**: the unmatched-transfers queue, the "record a
|
|
78
|
+
received transfer" form, the bank accounts screen, the sidebar entry, the
|
|
79
|
+
order panel partial and the payment method configuration guide. Spree 6's
|
|
80
|
+
dashboard plugin replaces them (see "The dashboard" below).
|
|
81
|
+
- **The Rails storefront partials** (the checkout payment partial and
|
|
82
|
+
`spree/bank_payments/_order_instructions`). A storefront reads the quote
|
|
83
|
+
from the Store API instead.
|
|
84
|
+
- `Gateway#bank_details` (deprecated in 5.2.0), `#method_type`,
|
|
85
|
+
`#description_partial_name`, `#configuration_guide_partial_name` and
|
|
86
|
+
`#auto_capture?`.
|
|
87
|
+
- `Spree::BankPayments.gateway_type_names` and `.gateway_scope`.
|
|
88
|
+
|
|
89
|
+
### The dashboard
|
|
90
|
+
|
|
91
|
+
- **A Spree dashboard plugin**, `@aypex-io/spree-bank-payments-dashboard` on
|
|
92
|
+
npm, released with the gem at the same version. `pnpm add` it in the
|
|
93
|
+
dashboard app and the next build picks it up. It brings back the 5.x
|
|
94
|
+
screens: the unmatched-transfers queue under Orders, each transfer's
|
|
95
|
+
possible matches with Apply and Ignore, recording a received transfer, the
|
|
96
|
+
bank accounts screen, a Bank transfer card on the order page and the
|
|
97
|
+
payment method's setup guide.
|
|
98
|
+
- **Applying a transfer for a different amount asks first.** The Admin API
|
|
99
|
+
answers 422 `amount_mismatch`, with both amounts, until the request
|
|
100
|
+
confirms with `confirm_mismatch`.
|
|
101
|
+
- **Accounts can be added by hand** from the dashboard, for the `manual`
|
|
102
|
+
reconciler. Sync from provider is offered only for a provider's
|
|
103
|
+
reconciler, as in 5.x.
|
|
104
|
+
- **An Admin API** under `/api/v3/admin/bank_payments`: transfers (list,
|
|
105
|
+
show, suggestions, record, apply, ignore), the store's bank transfer
|
|
106
|
+
payment methods, each one's accounts (list, create, update, delete, sync
|
|
107
|
+
plan, sync) and reconciler health, and an order's bank transfer. Transfers and accounts have prefixed ids,
|
|
108
|
+
`btxfr_` and `bacct_`.
|
|
109
|
+
- **A Bank transfers permission** for staff roles (`read_bank_payments`,
|
|
110
|
+
`write_bank_payments`): read to see the queue, write to act on it.
|
|
111
|
+
|
|
112
|
+
### Checkout
|
|
113
|
+
|
|
114
|
+
- **The gateway is session-based** and its API type is `bank_transfer`.
|
|
115
|
+
Creating a payment session quotes the cart: a fresh reference, the amount
|
|
116
|
+
due after the discount, the deadline and the bank details, under
|
|
117
|
+
`external_data.bank_transfer`, which a client cannot write. Completing the
|
|
118
|
+
session re-quotes, then leaves a pending payment carrying the reference, so
|
|
119
|
+
Spree places the order unpaid (`payment_status` `authorized`).
|
|
120
|
+
- **Changing the cart after choosing bank transfer** re-quotes it, up to the
|
|
121
|
+
moment the order is placed: completing the session re-quotes, and so does
|
|
122
|
+
completing the cart, under Spree's lock. The quote, the pending payment and
|
|
123
|
+
the order total are always equal.
|
|
124
|
+
- **A released, expired or completed session cannot be completed again**
|
|
125
|
+
(or updated): the Store API answers 422, so an order is never placed
|
|
126
|
+
against a reference nothing will match.
|
|
127
|
+
- **Switching to another payment method releases bank transfer first.**
|
|
128
|
+
Before the Store API creates another method's session or payment, or
|
|
129
|
+
updates or completes one created earlier, the bank transfer session is
|
|
130
|
+
cancelled, its payment voided and the discount recalculated away, so the
|
|
131
|
+
other method charges the full total. A request Spree refuses releases
|
|
132
|
+
nothing. A bank transfer session the buyer never completed is released when
|
|
133
|
+
the cart completes, so an order is never placed on a discount bank transfer
|
|
134
|
+
is not paying.
|
|
135
|
+
- **Spree holds dispatch of an unpaid bank transfer order** unless staff
|
|
136
|
+
force it: the gateway captures at checkout, so its pending payment does not
|
|
137
|
+
count as money staff have taken charge of collecting. `authorize` and
|
|
138
|
+
`purchase` refuse, and the dashboard offers no Capture: Spree's capture
|
|
139
|
+
workflow refuses a bank transfer payment unless a transfer is being applied
|
|
140
|
+
to it. Money moves only when a transfer is reconciled.
|
|
141
|
+
- **The Store API shows the quote**: a bank transfer payment, on the cart and
|
|
142
|
+
on the order, carries a `bank_transfer` field with the reference, amount,
|
|
143
|
+
deadline and bank details. The payment method carries
|
|
144
|
+
`bank_transfer.discount_percent` and `expiry_days`.
|
|
145
|
+
|
|
146
|
+
### Discount
|
|
147
|
+
|
|
148
|
+
- Written as one `manual` `Spree::Discount` per line item, found by
|
|
149
|
+
`metadata.source = "spree_bank_payments"`, through an adjuster registered in
|
|
150
|
+
`Spree.adjusters`. The figures do not change: 3% off a 20% VAT-inclusive
|
|
151
|
+
100.00 line records 16.17 VAT, and a 20% promotion plus 3% is 23%. Shares
|
|
152
|
+
round to the currency's own minor unit.
|
|
153
|
+
|
|
154
|
+
### Reconciliation and expiry
|
|
155
|
+
|
|
156
|
+
- A transfer settles through `Spree.payment_capture_workflow`, so Spree
|
|
157
|
+
records the capture and publishes `payment.captured`. Under the order's
|
|
158
|
+
lock it re-checks that the session is still open and the order still
|
|
159
|
+
placed, so a second transfer racing the first queues rather than being
|
|
160
|
+
marked applied with nothing captured.
|
|
161
|
+
- **Only placed orders reconcile automatically.** A transfer quoting a
|
|
162
|
+
reference from a checkout that was never placed queues for a person, and is
|
|
163
|
+
never suggested; it is not used to place the cart.
|
|
164
|
+
- `parse_webhook_event` ingests the transfer and returns `nil`, so Spree's
|
|
165
|
+
webhook workflow has nothing to settle a second time.
|
|
166
|
+
- An unpaid placed order past its deadline is cancelled through
|
|
167
|
+
`Spree.order_cancel_workflow`, which releases its stock and voids the
|
|
168
|
+
payment, with a staff note. A cancel Spree refuses, or one that raises,
|
|
169
|
+
leaves the session open and reports `bank_transfer.expiry_failed`, and the
|
|
170
|
+
run carries on with the next session. A session whose checkout was never
|
|
171
|
+
placed is expired silently.
|
|
172
|
+
- An order counts as paid when its `payment_status` is `paid`, `overcharged`,
|
|
173
|
+
`partially_refunded` or `refunded`: it is never cancelled for an unpaid
|
|
174
|
+
transfer, and a transfer for it queues for a person.
|
|
175
|
+
- **Upgrading:** Spree's own upgrade writes each 5.x bank transfer discount as
|
|
176
|
+
a 0.00 surcharge. Run `bin/rails spree_bank_payments:upgrade:legacy_discounts`
|
|
177
|
+
after `spree:upgrade` to restore them as discounts; otherwise the next
|
|
178
|
+
re-sum of such an order raises its total by the discount.
|
|
179
|
+
|
|
180
|
+
### Events and email
|
|
181
|
+
|
|
182
|
+
- **Instructions are sent when the order is placed**, not when the session is
|
|
183
|
+
created, and the payment window starts then. Reminders go only to placed
|
|
184
|
+
orders.
|
|
185
|
+
- Every event is declared. The operational ones
|
|
186
|
+
(`reconciler_unhealthy`, `expiry_failed`, `reconciler_health.*`) are
|
|
187
|
+
declared `webhook: false`: their payloads carry error text.
|
|
188
|
+
- Events are published under the gateway's store, so they reach webhook
|
|
189
|
+
endpoints from the background jobs too.
|
|
190
|
+
- **Payloads use string keys and prefixed ids** (`ps_...`, `pm_...`), and the
|
|
191
|
+
customer-facing payload adds `order_id`, `discount_percent` and
|
|
192
|
+
`bank_details`. A subscriber reading `payload[:payment_session_id]` must
|
|
193
|
+
read `payload['payment_session_id']`.
|
|
194
|
+
- The default mailer is `Spree::BankPayments::InstructionsMailerSubscriber`,
|
|
195
|
+
registered through `Spree.subscribers`. 5.x subscribed blocks from
|
|
196
|
+
`to_prepare`, which on Spree 6 stopped every one of Spree's own subscribers
|
|
197
|
+
from registering. `InstructionsMailer` takes the session's prefixed id.
|
|
198
|
+
|
|
5
199
|
## 5.3.0
|
|
6
200
|
|
|
7
201
|
### Upgrading from 5.2.0
|