manza 1.3.0 → 2.0.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 +111 -0
- data/README.md +13 -8
- data/lib/manza/client.rb +6 -0
- data/lib/manza/errors.rb +20 -0
- data/lib/manza/resources/invoices.rb +32 -10
- data/lib/manza/resources/payments.rb +21 -4
- data/lib/manza/resources/transfer_authorizer.rb +4 -2
- data/lib/manza/transfer_authorization.rb +15 -5
- data/lib/manza/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a4009879784a4fe224aad551e8b6ae32d24a95ee53d6e91b586b76ea82599ae7
|
|
4
|
+
data.tar.gz: 3b8cbc9687b092878374293b7590f8f18461849c4926f48c291eee2282b8c67d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 190adce457837ad6464b655f4c813ff9b793aa3d03fae1f5c0e54418398f6e1a005cd77d1ffaabde597753e11ef6a0d7eca3584844ed69bb76e0bf4523214c04
|
|
7
|
+
data.tar.gz: f26e7c292a1d1a10bc1cd7e349186489bbf45a9fa61dce4357f984d6c4946d9ae07057aced3466013f3dd1c751461f8ab3201c04b97ae3cc4ba182d6e30473f9
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,117 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [2.0.0] - 2026-11-14
|
|
11
|
+
|
|
12
|
+
Synced to the Manza API at getmanza/app `906ec486e5` (API version
|
|
13
|
+
`2026-11-13`). A major release: see Migrating from 1.x below.
|
|
14
|
+
|
|
15
|
+
### Removed
|
|
16
|
+
|
|
17
|
+
- **Breaking:** `manza.invoices.create_payment_link` (`POST
|
|
18
|
+
/api/invoices/:id/payment_link`). The API retired the endpoint: ask for the
|
|
19
|
+
link with `generate_payment_link: true` on `invoices.create` or
|
|
20
|
+
`invoices.update` instead.
|
|
21
|
+
- **Breaking:** the v1 transfer-authorization signer. `Manza::TransferAuthorization`
|
|
22
|
+
builds only the v2 input (below).
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
|
|
26
|
+
- **Breaking:** `Manza::TransferAuthorization::SIGNATURE_VERSION` is
|
|
27
|
+
`manza.transfer-authorization.v2`, and `signature_input` takes a required
|
|
28
|
+
`transfer_method:` keyword, appended after `client_reference` (`""` when
|
|
29
|
+
nil): `manza.transfer-authorization.v2|payment_id|nonce|amount|currency_code|account_id|payee|client_reference|transfer_method`.
|
|
30
|
+
The API verifies v2 for every request that is unpinned or sends
|
|
31
|
+
`Manza-Version: 2026-11-13`; only `2026-03-27` still verifies v1. Pass the
|
|
32
|
+
payment's `transfer_method` as the API returned it.
|
|
33
|
+
- The example authorizer (`examples/transfer_authorizer`) records the
|
|
34
|
+
create response's `transfer_method` in its ledger, checks it against the
|
|
35
|
+
webhook's `payment.transfer_method`, signs v2, and compares its input with
|
|
36
|
+
the webhook's `signature_input_v2`. `Ledger#record` takes `transfer_method:`.
|
|
37
|
+
- Invoice docs: `account_id` is required on `invoices.create` (without one
|
|
38
|
+
the API answers 422 `state_error`; an account that is not the entity's,
|
|
39
|
+
422 with `param` `account_id`), and `invoices.update` takes it too. An
|
|
40
|
+
invoice's `status` may be `declined`, and `invoices.delete` also takes a
|
|
41
|
+
`declined` invoice that has no number.
|
|
42
|
+
|
|
43
|
+
### Added
|
|
44
|
+
|
|
45
|
+
- `Manza::PlanLimitReachedError`, a `Manza::ValidationError` raised for a
|
|
46
|
+
422 whose `type` is `plan_limit_reached` (a plan cap, which the API used
|
|
47
|
+
to answer with a 500). `#kind`, `#current` and `#max` read the cap from
|
|
48
|
+
the error body; `#to_h` includes them.
|
|
49
|
+
- `generate_payment_link` on `invoices.create` and `invoices.update` (needs
|
|
50
|
+
the `payment_links:write` scope; taken only while payment links are
|
|
51
|
+
enabled for the entity). Invoice responses carry `generate_payment_link`
|
|
52
|
+
and the embedded `account`.
|
|
53
|
+
- `transfer_method` on `payments.create`: `eft` or `rtc` in South Africa,
|
|
54
|
+
`standard` or `instant` in Morocco; one the market does not offer raises
|
|
55
|
+
`Manza::ValidationError` with `param` `transfer_method`. Payment responses
|
|
56
|
+
carry `transfer_method` (the rail sent, the provider's default when left
|
|
57
|
+
out, nil where the market offers no choice).
|
|
58
|
+
- Documented: the authorization `refusal_reason` `rail_limit_exceeded`
|
|
59
|
+
(status `superseded`): an authorized transfer over its rail's limit at
|
|
60
|
+
execution, sent to the approvers; the authorize call raises a 422
|
|
61
|
+
`Manza::ValidationError` (`state_error`). A non-boolean
|
|
62
|
+
`generate_payment_link` raises `Manza::ValidationError` (400).
|
|
63
|
+
- Documented: the `payment.authorization_requested` webhook's
|
|
64
|
+
`signature_input_v2` and `payment.transfer_method`, and
|
|
65
|
+
`transfer_authorizer.get`'s `trust_new_payees` and `new_payee_limit`.
|
|
66
|
+
|
|
67
|
+
### Fixed (API side, no wire change)
|
|
68
|
+
|
|
69
|
+
- `accounts.list_transactions` and `accounts.get_transaction` return
|
|
70
|
+
posted movements only (getmanza/app 818432457a); the SDK is unchanged.
|
|
71
|
+
|
|
72
|
+
### Changed (cassettes)
|
|
73
|
+
|
|
74
|
+
Every cassette was re-recorded against staging. An SDK that replays
|
|
75
|
+
`cassettes-v2.0.0` sends these changed or new requests:
|
|
76
|
+
|
|
77
|
+
| Cassette | Request |
|
|
78
|
+
|---|---|
|
|
79
|
+
| `invoices/create` | `POST https://ma.manza.dev/api/invoices` with `account_id` (`fixture-account-id`), `generate_payment_link: true` and new dates (`issue_date` `2026-11-14`, `due_date` `2026-12-14`: staging refuses a date in a month before its newest invoice number) |
|
|
80
|
+
| `invoices/create_invalid_generate_payment_link` (new) | `POST https://ma.manza.dev/api/invoices` with `generate_payment_link: "yes please"`: 400 |
|
|
81
|
+
| `invoices/create_without_account` (new) | `POST https://ma.manza.dev/api/invoices` without `account_id`: 422 `state_error` |
|
|
82
|
+
| `invoices/update` | `PATCH https://ma.manza.dev/api/invoices/fixture-invoice-id` with `account_id`, `notes` and `generate_payment_link: true` |
|
|
83
|
+
| `payments/create` | `POST https://ma.manza.dev/api/payments` with `transfer_method: "standard"` |
|
|
84
|
+
| `payments/create_invalid_transfer_method` (new) | `POST https://ma.manza.dev/api/payments` with an unoffered `transfer_method`: 422, `param` `transfer_method` |
|
|
85
|
+
|
|
86
|
+
The authorize cassettes sign v2 over `transfer_method` `standard` (the
|
|
87
|
+
seeded drafts send it); the recorded `signature` stays scrubbed to
|
|
88
|
+
`<SIGNATURE>`, and replay matches the body without it. The
|
|
89
|
+
`invoices/create_payment_link` cassette never existed (the spec was
|
|
90
|
+
pending).
|
|
91
|
+
|
|
92
|
+
### Migrating from 1.x
|
|
93
|
+
|
|
94
|
+
- **`create_payment_link` is gone.** Replace
|
|
95
|
+
`manza.invoices.create_payment_link(id, account_id: acc)` with
|
|
96
|
+
`manza.invoices.update(id, account_id: acc, generate_payment_link: true)`,
|
|
97
|
+
or pass `generate_payment_link: true` on create. `update` returns the
|
|
98
|
+
invoice, not a link: the link is made from the invoice's account when
|
|
99
|
+
the invoice is approved, and appears in the invoice's `payment_link`.
|
|
100
|
+
`update` takes only an invoice that is still `draft`,
|
|
101
|
+
`pending_approval` or `declined` (any other raises
|
|
102
|
+
`Manza::ValidationError`, `state_error`); for an invoice already
|
|
103
|
+
approved or sent, there is no API path to attach a link to it:
|
|
104
|
+
`manza.payment_links.create(account_id:, amount:, ...)` makes a
|
|
105
|
+
standalone link instead.
|
|
106
|
+
- **`account_id` is required on invoice create.** Pass the account the
|
|
107
|
+
invoice is paid into (`manza.accounts.list`); 1.x calls without it now
|
|
108
|
+
raise `Manza::ValidationError`.
|
|
109
|
+
- **v2 signatures only.** Add `transfer_method: payment["transfer_method"]`
|
|
110
|
+
to every `Manza::TransferAuthorization.signature_input` call, and compare
|
|
111
|
+
with the webhook's `signature_input_v2` instead of `signature_input`. A
|
|
112
|
+
client pinned to `Manza-Version: 2026-03-27` (`api_version:` or
|
|
113
|
+
`MANZA_API_VERSION`) is verified v1 and must stay on manza 1.x; unpin it,
|
|
114
|
+
or pin `2026-11-13`, to move to 2.0.
|
|
115
|
+
- **Plan caps.** A `rescue Manza::ServerError` around creates that may hit
|
|
116
|
+
a plan cap no longer catches it: rescue `Manza::PlanLimitReachedError`
|
|
117
|
+
(or its parent `Manza::ValidationError`), and do not retry it.
|
|
118
|
+
|
|
119
|
+
## [1.3.0]
|
|
120
|
+
|
|
10
121
|
### Added
|
|
11
122
|
|
|
12
123
|
- `manza.payments` (`Manza::Resources::Payments`): `create`, `get`,
|
data/README.md
CHANGED
|
@@ -49,16 +49,18 @@ manza.customers.delete("01a0...")
|
|
|
49
49
|
manza.invoices.list(status: "sent", limit: 50)
|
|
50
50
|
manza.invoices.create(
|
|
51
51
|
customer_id: "01a0...",
|
|
52
|
+
account_id: "019dde7d-...", # required: the account the invoice is paid into
|
|
52
53
|
currency_code: "MAD",
|
|
53
54
|
issue_date: "2026-05-03",
|
|
54
55
|
due_date: "2026-06-03",
|
|
56
|
+
generate_payment_link: true, # a card payment link, made when approved (payment_links:write; payment links enabled for the entity)
|
|
55
57
|
items: [{ description: "Consulting", quantity: 10, unit_price: "150.00" }]
|
|
56
58
|
)
|
|
59
|
+
manza.invoices.update("01a0...", account_id: "019dde7d-...", generate_payment_link: false)
|
|
57
60
|
manza.invoices.send_invoice("01a0...")
|
|
58
61
|
manza.invoices.mark_as_paid("01a0...")
|
|
59
62
|
manza.invoices.cancel("01a0...")
|
|
60
63
|
manza.invoices.credit_note("01a0...")
|
|
61
|
-
manza.invoices.create_payment_link("01a0...", account_id: "019dde7d-...")
|
|
62
64
|
|
|
63
65
|
manza.payment_links.list(status: "active")
|
|
64
66
|
manza.payment_links.create(
|
|
@@ -92,13 +94,15 @@ manza.payments.create(
|
|
|
92
94
|
account_id: "019dde7d-...",
|
|
93
95
|
beneficiary_id: "01a0...",
|
|
94
96
|
amount: "2500.00",
|
|
95
|
-
client_reference: "po_1042" # unique per entity; a duplicate raises Manza::ConflictError
|
|
97
|
+
client_reference: "po_1042", # unique per entity; a duplicate raises Manza::ConflictError
|
|
98
|
+
transfer_method: "standard" # optional rail: eft/rtc (ZA), standard/instant (MA); omitted → the default
|
|
96
99
|
)
|
|
97
100
|
manza.payments.get("01a3...") # authorization: status, refusal_reason
|
|
98
101
|
manza.payments.decline("01a3...", authorization_id: "01a4...", reason: "Not ours")
|
|
99
102
|
# manza.transfer_drafts is a deprecated alias of manza.payments (same methods, /api/payments)
|
|
100
103
|
|
|
101
|
-
manza.transfer_authorizer.get # status, suspension_reason, limits, daily_authorized_total
|
|
104
|
+
manza.transfer_authorizer.get # status, suspension_reason, limits, daily_authorized_total, trust_new_payees,
|
|
105
|
+
# new_payee_limit; NotFoundError: none enrolled
|
|
102
106
|
|
|
103
107
|
manza.webhook_endpoints.list
|
|
104
108
|
manza.webhook_endpoints.create(
|
|
@@ -153,7 +157,7 @@ end
|
|
|
153
157
|
|
|
154
158
|
### Signing the challenge
|
|
155
159
|
|
|
156
|
-
Sign the draft from **your own record** of it with the endpoint's signing secret:
|
|
160
|
+
Sign the draft from **your own record** of it with the endpoint's signing secret. The SDK builds the v2 input (`manza.transfer-authorization.v2`), which ends with the payment's `transfer_method` (an empty segment when it is `null`); compare it with the webhook's `signature_input_v2`. The webhook's `signature_input` is the v1 string, verified only for clients pinned to `Manza-Version: 2026-03-27`: those stay on manza 1.x.
|
|
157
161
|
|
|
158
162
|
```ruby
|
|
159
163
|
input = Manza::TransferAuthorization.signature_input(
|
|
@@ -163,7 +167,8 @@ input = Manza::TransferAuthorization.signature_input(
|
|
|
163
167
|
currency_code: draft["currency_code"],
|
|
164
168
|
account_id: draft["account_id"],
|
|
165
169
|
payee: Manza::TransferAuthorization.payee_for(external_account_id: draft["external_account_id"]),
|
|
166
|
-
client_reference: draft["client_reference"]
|
|
170
|
+
client_reference: draft["client_reference"],
|
|
171
|
+
transfer_method: draft["transfer_method"] # required; nil signs as ""
|
|
167
172
|
)
|
|
168
173
|
signature = Manza::TransferAuthorization.sign(secret: signing_secret, signature_input: input)
|
|
169
174
|
|
|
@@ -203,7 +208,7 @@ Every non-2xx response raises a subclass of `Manza::Error`:
|
|
|
203
208
|
| 400 | `Manza::ValidationError` (malformed request, e.g. bad `limit`/`cursor`) |
|
|
204
209
|
| 404 | `Manza::NotFoundError` |
|
|
205
210
|
| 409 | `Manza::ConflictError` (carries `#payment_id` for a duplicate `client_reference`) |
|
|
206
|
-
| 422 | `Manza::ValidationError` |
|
|
211
|
+
| 422 | `Manza::ValidationError`; `Manza::PlanLimitReachedError` (a subclass) for `type` `plan_limit_reached`, carrying `#kind`, `#current` and `#max` |
|
|
207
212
|
| 429 | `Manza::RateLimitError` (carries `#retry_after`) |
|
|
208
213
|
| 5xx | `Manza::ServerError` |
|
|
209
214
|
| network | `Manza::ConnectionError` |
|
|
@@ -223,10 +228,10 @@ end
|
|
|
223
228
|
## Versioning the API contract
|
|
224
229
|
|
|
225
230
|
```ruby
|
|
226
|
-
manza = Manza.new(api_key: "...", api_version: "2026-
|
|
231
|
+
manza = Manza.new(api_key: "...", api_version: "2026-11-13")
|
|
227
232
|
```
|
|
228
233
|
|
|
229
|
-
Or via env: `MANZA_API_VERSION=2026-03-27
|
|
234
|
+
Or via env: `MANZA_API_VERSION=2026-11-13`. Unpinned, the API answers with its current version. manza 2.x signs transfer authorizations v2, which the API verifies for unpinned requests and requests pinned to `2026-11-13` or later; a client pinned to `2026-03-27` must stay on manza 1.x. The header is sent on every request; the API echoes it back in `Manza-Version` (and the legacy `Zazu-Version`); `response.api_version` reads it.
|
|
230
235
|
|
|
231
236
|
## Development
|
|
232
237
|
|
data/lib/manza/client.rb
CHANGED
|
@@ -177,6 +177,12 @@ module Manza
|
|
|
177
177
|
message = payload["message"]
|
|
178
178
|
kwargs = error_kwargs(response, payload)
|
|
179
179
|
|
|
180
|
+
if response.status == 422 && payload["type"] == "plan_limit_reached"
|
|
181
|
+
return PlanLimitReachedError.new(
|
|
182
|
+
message || "Plan limit reached", kind: payload["kind"], current: payload["current"], max: payload["max"], **kwargs
|
|
183
|
+
)
|
|
184
|
+
end
|
|
185
|
+
|
|
180
186
|
if (mapping = ERROR_BY_STATUS[response.status])
|
|
181
187
|
klass, default_message = mapping
|
|
182
188
|
return klass.new(message || default_message, **kwargs)
|
data/lib/manza/errors.rb
CHANGED
|
@@ -48,6 +48,26 @@ module Manza
|
|
|
48
48
|
# field name when the API supplies it.
|
|
49
49
|
class ValidationError < Error; end
|
|
50
50
|
|
|
51
|
+
# 422 with `type` "plan_limit_reached" — the entity's plan caps this
|
|
52
|
+
# kind of record and the cap is reached. Retrying does not help until
|
|
53
|
+
# the plan changes or the period rolls over. `#kind` names what is
|
|
54
|
+
# capped (e.g. "invoices"), `#current` the count the entity holds and
|
|
55
|
+
# `#max` the cap.
|
|
56
|
+
class PlanLimitReachedError < ValidationError
|
|
57
|
+
attr_reader :kind, :current, :max
|
|
58
|
+
|
|
59
|
+
def initialize(message = nil, kind: nil, current: nil, max: nil, **)
|
|
60
|
+
super(message, **)
|
|
61
|
+
@kind = kind
|
|
62
|
+
@current = current
|
|
63
|
+
@max = max
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def to_h
|
|
67
|
+
super.merge(kind:, current:, max:).compact
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
51
71
|
# 409 — the request conflicts with an existing resource. For a
|
|
52
72
|
# duplicate `client_reference` on a transfer draft (`type`
|
|
53
73
|
# "duplicate_client_reference"), `#payment_id` names the draft that
|
|
@@ -5,6 +5,9 @@ module Manza
|
|
|
5
5
|
# Invoices and their lifecycle actions.
|
|
6
6
|
class Invoices < Base
|
|
7
7
|
# GET /api/invoices
|
|
8
|
+
#
|
|
9
|
+
# `status`: draft, pending_approval, declined, approved, sent, paid,
|
|
10
|
+
# overdue or cancelled.
|
|
8
11
|
def list(status: nil, customer_id: nil, limit: MAX_PER_PAGE, cursor: nil)
|
|
9
12
|
list_page(
|
|
10
13
|
"api/invoices",
|
|
@@ -21,11 +24,36 @@ module Manza
|
|
|
21
24
|
end
|
|
22
25
|
|
|
23
26
|
# POST /api/invoices
|
|
27
|
+
#
|
|
28
|
+
# Required: customer_id, account_id (the entity's account the invoice
|
|
29
|
+
# is paid into, from {Accounts#list}; without one the API answers 422
|
|
30
|
+
# `state_error`, and an account that is not the entity's 422 with
|
|
31
|
+
# `param` "account_id"), issue_date, due_date and items. Optional:
|
|
32
|
+
# currency_code, reference, notes, payment_terms, send_to_email,
|
|
33
|
+
# discounts, delivery_date (MA only) and generate_payment_link.
|
|
34
|
+
#
|
|
35
|
+
# `generate_payment_link: true` asks for a card payment link, made
|
|
36
|
+
# from the invoice's account when the invoice is approved; it needs
|
|
37
|
+
# the `payment_links:write` scope and is taken only while payment
|
|
38
|
+
# links are enabled for the entity. A boolean, nil (no link) or the
|
|
39
|
+
# strings "true", "false", "1" and "0" are taken; any other value
|
|
40
|
+
# raises {Manza::ValidationError} (400) and nothing is created. It
|
|
41
|
+
# replaces the removed `create_payment_link`.
|
|
42
|
+
#
|
|
43
|
+
# The response carries `generate_payment_link`, the embedded
|
|
44
|
+
# `account` (`id`, `name`, `currency_code`, and `rib` in Morocco or
|
|
45
|
+
# `account_number` in South Africa) and `payment_link` once one
|
|
46
|
+
# exists. A plan that caps invoices raises
|
|
47
|
+
# {Manza::PlanLimitReachedError}.
|
|
24
48
|
def create(**attributes)
|
|
25
49
|
http_post("api/invoices", body: attributes)
|
|
26
50
|
end
|
|
27
51
|
|
|
28
52
|
# PATCH /api/invoices/:id
|
|
53
|
+
#
|
|
54
|
+
# Takes the create fields, account_id and generate_payment_link
|
|
55
|
+
# included (the same scope and entity rule apply), on an invoice
|
|
56
|
+
# that is still editable.
|
|
29
57
|
def update(id, **attributes)
|
|
30
58
|
http_patch(encode_path("api/invoices", id), body: attributes)
|
|
31
59
|
end
|
|
@@ -51,19 +79,13 @@ module Manza
|
|
|
51
79
|
end
|
|
52
80
|
|
|
53
81
|
# DELETE /api/invoices/:id
|
|
82
|
+
#
|
|
83
|
+
# Only a `draft`, `pending_approval` or `declined` invoice that has
|
|
84
|
+
# no number yet; any other raises {Manza::ValidationError}
|
|
85
|
+
# (`state_error`).
|
|
54
86
|
def delete(id)
|
|
55
87
|
http_delete(encode_path("api/invoices", id))
|
|
56
88
|
end
|
|
57
|
-
|
|
58
|
-
# POST /api/invoices/:invoice_id/payment_link
|
|
59
|
-
#
|
|
60
|
-
# @param account_id [String] the funding account for the link
|
|
61
|
-
def create_payment_link(invoice_id, account_id:)
|
|
62
|
-
http_post(
|
|
63
|
-
encode_path("api/invoices", invoice_id, "payment_link"),
|
|
64
|
-
body: { account_id: account_id }
|
|
65
|
-
)
|
|
66
|
-
end
|
|
67
89
|
end
|
|
68
90
|
end
|
|
69
91
|
end
|
|
@@ -26,9 +26,12 @@ module Manza
|
|
|
26
26
|
# `over_transfer_limit`, `over_daily_limit`, `currency_mismatch`,
|
|
27
27
|
# `suspended` or `secret_expired`.
|
|
28
28
|
# - `expired` / `superseded` / `failed`: a challenge was sent and closed
|
|
29
|
-
# without
|
|
29
|
+
# without executing the transfer: `expired` (no answer within the hour),
|
|
30
30
|
# `stale` (the draft, its payee's bank details or the endpoint changed
|
|
31
|
-
# while it was open)
|
|
31
|
+
# while it was open), `signature_failed` (five invalid signatures)
|
|
32
|
+
# or `rail_limit_exceeded` (status `superseded`: the challenge was
|
|
33
|
+
# authorized, but the transfer was over its rail's limit when it
|
|
34
|
+
# executed, so nothing moved).
|
|
32
35
|
# One exception: the in-app approval that finalizes the draft while
|
|
33
36
|
# its challenge is open supersedes it (`stale`), and the draft
|
|
34
37
|
# executes or is scheduled; the draft's own `status` shows which.
|
|
@@ -47,7 +50,15 @@ module Manza
|
|
|
47
50
|
# Optional: external_account_id, currency_code, payment_reference,
|
|
48
51
|
# internal_notes, client_reference (unique per entity, at most 128
|
|
49
52
|
# characters; a duplicate raises {Manza::ConflictError} whose
|
|
50
|
-
# `payment_id` names the existing draft)
|
|
53
|
+
# `payment_id` names the existing draft), transfer_method (the rail:
|
|
54
|
+
# `eft` or `rtc` in South Africa, `standard` or `instant` in Morocco;
|
|
55
|
+
# one the market does not offer raises {Manza::ValidationError} with
|
|
56
|
+
# `param` "transfer_method", and nothing is created).
|
|
57
|
+
#
|
|
58
|
+
# The response's `transfer_method` is the rail sent, or the provider's
|
|
59
|
+
# default when left out; nil where the market offers no choice. The
|
|
60
|
+
# machine-authorization signature signs it
|
|
61
|
+
# ({Manza::TransferAuthorization.signature_input}).
|
|
51
62
|
def create(**attributes)
|
|
52
63
|
http_post("api/payments", body: attributes)
|
|
53
64
|
end
|
|
@@ -61,7 +72,9 @@ module Manza
|
|
|
61
72
|
#
|
|
62
73
|
# Executes the draft. `authorization_id` comes from the
|
|
63
74
|
# `payment.authorization_requested` webhook; build `signature` with
|
|
64
|
-
# {Manza::TransferAuthorization}
|
|
75
|
+
# {Manza::TransferAuthorization} (the v2 input, which the API
|
|
76
|
+
# verifies unless the client is pinned to `Manza-Version:
|
|
77
|
+
# 2026-03-27`). Requires the `transfers:authorize`
|
|
65
78
|
# scope on a key other than the draft's creator (otherwise 403
|
|
66
79
|
# `same_key_forbidden`), bound to an IP allowlist (otherwise 403
|
|
67
80
|
# `unrestricted_api_key`). A 409 {Manza::ConflictError} with `type`
|
|
@@ -69,6 +82,10 @@ module Manza
|
|
|
69
82
|
# revocation on the payee was in flight: retry. A blank signature
|
|
70
83
|
# raises {Manza::ArgumentError} and is never sent: the API would count
|
|
71
84
|
# it as a failed attempt. Five invalid signatures fail the challenge.
|
|
85
|
+
# A valid signature on a transfer over its rail's limit raises a 422
|
|
86
|
+
# {Manza::ValidationError} (`state_error`): nothing moved, the
|
|
87
|
+
# authorization is `superseded` with `refusal_reason`
|
|
88
|
+
# `rail_limit_exceeded`, and the draft went to your approvers.
|
|
72
89
|
def authorize(id, authorization_id:, signature:)
|
|
73
90
|
raise Manza::ArgumentError, "signature cannot be blank" if signature.to_s.strip.empty?
|
|
74
91
|
|
|
@@ -16,8 +16,10 @@ module Manza
|
|
|
16
16
|
# `secret_expired`, `endpoint_disabled`; nil when active),
|
|
17
17
|
# `currency_code`, `per_transfer_limit`, `daily_limit`,
|
|
18
18
|
# `daily_authorized_total` (the last 24 hours), `secret_expires_at`,
|
|
19
|
-
# `webhook_endpoint_id
|
|
20
|
-
# new payees
|
|
19
|
+
# `webhook_endpoint_id`, `enrolled_at`, `trust_new_payees` (whether
|
|
20
|
+
# "Approve transfers to new payees" is on) and `new_payee_limit` (the
|
|
21
|
+
# ceiling for a transfer to a new payee, a decimal string; nil while
|
|
22
|
+
# `trust_new_payees` is off). Raises {Manza::NotFoundError} when no
|
|
21
23
|
# authorizer is enrolled.
|
|
22
24
|
def get
|
|
23
25
|
http_get("api/transfer_authorizer")
|
|
@@ -9,7 +9,7 @@ module Manza
|
|
|
9
9
|
# The `payment.authorization_requested` webhook delivers the
|
|
10
10
|
# authorization id and a one-time nonce. Build the signature input
|
|
11
11
|
# from your *own* record of the transfer (not the webhook's
|
|
12
|
-
# `
|
|
12
|
+
# `signature_input_v2`, which is there only to compare against), sign
|
|
13
13
|
# it with the authorizer endpoint's signing secret, and pass the
|
|
14
14
|
# result to {Resources::Payments#authorize}:
|
|
15
15
|
#
|
|
@@ -17,22 +17,32 @@ module Manza
|
|
|
17
17
|
# payment_id: draft["id"], nonce: nonce, amount: draft["amount"],
|
|
18
18
|
# currency_code: draft["currency_code"], account_id: draft["account_id"],
|
|
19
19
|
# payee: Manza::TransferAuthorization.payee_for(external_account_id: draft["external_account_id"]),
|
|
20
|
-
# client_reference: draft["client_reference"]
|
|
20
|
+
# client_reference: draft["client_reference"], transfer_method: draft["transfer_method"]
|
|
21
21
|
# )
|
|
22
22
|
# signature = Manza::TransferAuthorization.sign(secret: signing_secret, signature_input: input)
|
|
23
23
|
# manza.payments.authorize(draft["id"], authorization_id: authorization_id, signature: signature)
|
|
24
|
+
#
|
|
25
|
+
# This is the v2 input, which the API verifies for every request that
|
|
26
|
+
# is unpinned or sends `Manza-Version: 2026-11-13` or later. A client
|
|
27
|
+
# pinned to `Manza-Version: 2026-03-27` must sign v1 and stays on
|
|
28
|
+
# manza 1.x.
|
|
24
29
|
module TransferAuthorization
|
|
25
|
-
SIGNATURE_VERSION = "manza.transfer-authorization.
|
|
30
|
+
SIGNATURE_VERSION = "manza.transfer-authorization.v2"
|
|
26
31
|
|
|
27
32
|
module_function
|
|
28
33
|
|
|
29
34
|
# `amount` must be the API's decimal string verbatim (e.g. "2500.0").
|
|
30
35
|
# `client_reference` is empty when the transfer has none.
|
|
31
|
-
|
|
36
|
+
# `transfer_method` is the payment's rail as the API stores it (the
|
|
37
|
+
# create response's `transfer_method`): required, and nil (signed as
|
|
38
|
+
# an empty segment) where the market offers no choice.
|
|
39
|
+
def signature_input(payment_id:, nonce:, amount:, currency_code:, account_id:, payee:, transfer_method:,
|
|
40
|
+
client_reference: nil)
|
|
32
41
|
raise Manza::ArgumentError, "amount must be the API's decimal string (got #{amount.inspect})" unless amount.is_a?(String)
|
|
33
42
|
|
|
34
43
|
[
|
|
35
|
-
SIGNATURE_VERSION, payment_id, nonce, amount, currency_code, account_id, payee, client_reference.to_s
|
|
44
|
+
SIGNATURE_VERSION, payment_id, nonce, amount, currency_code, account_id, payee, client_reference.to_s,
|
|
45
|
+
transfer_method.to_s
|
|
36
46
|
].join("|")
|
|
37
47
|
end
|
|
38
48
|
|
data/lib/manza/version.rb
CHANGED