waffo-pancake 0.3.0 → 0.5.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 +52 -0
- data/README.md +151 -8
- data/lib/generators/waffo_pancake/install/templates/webhook_job.rb.tt +6 -0
- data/lib/waffo/pancake/api/customer_actions.rb +55 -0
- data/lib/waffo/pancake/api/product_actions.rb +64 -0
- data/lib/waffo/pancake/api/promotion_actions.rb +39 -0
- data/lib/waffo/pancake/api/queries.rb +293 -0
- data/lib/waffo/pancake/api/store_actions.rb +64 -0
- data/lib/waffo/pancake/client.rb +74 -165
- data/lib/waffo/pancake/connection.rb +113 -0
- data/lib/waffo/pancake/customer_session.rb +55 -0
- data/lib/waffo/pancake/errors.rb +5 -3
- data/lib/waffo/pancake/invoice.rb +27 -0
- data/lib/waffo/pancake/requests.rb +91 -0
- data/lib/waffo/pancake/store_checkout.rb +41 -0
- data/lib/waffo/pancake/test_helpers.rb +28 -6
- data/lib/waffo/pancake/version.rb +1 -1
- data/lib/waffo/pancake/webhook/event.rb +43 -3
- data/lib/waffo/pancake/webhook.rb +1 -0
- data/lib/waffo/pancake.rb +2 -0
- metadata +11 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f18c75d9eb86e7b1cd10a99fd51cc078ecc9964209bf419136e7a401fedd98bd
|
|
4
|
+
data.tar.gz: ed4f28af7464c740a900d0f35b5d28aa79c125ce9a0ad5939fd987dd6ad26a8d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f451e9e62bc478c82f0651903f69ecb2ce15f657364488ab5a4c8b54bc9b2322005dbc3c159c0219337d54bb49c32c12a0f138ebf84cbf262a8fd8a010f3e987
|
|
7
|
+
data.tar.gz: 21eae65851e7af4d21220b0e000e60917ecf3cbc0d9709f7ced5eb2c4a7851a2131e8b4a135f2106efaa0f68bf2596a05ab4672e07b8f68d8a0b638491a401ba
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,57 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
- Webhook event types: `store.domain_changed` and `store.domain_unbound` (Waffo's November update),
|
|
6
|
+
so `EVENT_TYPES` lists 16. `Webhook.family` returns `:store` for them, and `Event#store?` answers.
|
|
7
|
+
- `EventData` readers for the fields Waffo documents but the gem did not read: `payment_timestamp`,
|
|
8
|
+
`payment_method`, `payment_method_brand`, `payment_id`, `payment_status`, `payment_date`,
|
|
9
|
+
`payment_last4`, `payment_failure_reason`, `refund_status`, `refund_reason`, `refund_created_at`,
|
|
10
|
+
`plan_change`, `store_id`, `store_name`, `old_domain`, `new_domain`, `effective_at`, `domain`,
|
|
11
|
+
`unbound_at` and `unbind_method`.
|
|
12
|
+
- Fixed: reading a deprecated field (`amount`, `total`, ...) on an event that does not carry its
|
|
13
|
+
replacement, such as a store event, raised `KeyError`. It now warns with the replacements for all
|
|
14
|
+
payment, refund and subscription events.
|
|
15
|
+
- `Waffo::Pancake::Invoice.url(payment_id, invoice_token)`: the buyer's invoice link, nil until the
|
|
16
|
+
token exists.
|
|
17
|
+
- GraphQL `PAYMENT_FIELDS` selects `invoiceToken`.
|
|
18
|
+
- The generated `WaffoWebhookJob` template has branches for the two store events. Apps that already
|
|
19
|
+
ran the generator need to add them by hand.
|
|
20
|
+
- README: the idempotency key is required for any write a retry could repeat.
|
|
21
|
+
|
|
22
|
+
## 0.4.0
|
|
23
|
+
|
|
24
|
+
- Every endpoint in Waffo's API reference now has a method:
|
|
25
|
+
- Stores: `create_store`, `update_store`, `delete_store`.
|
|
26
|
+
- Store members: `add_store_merchant`, `remove_store_merchant`, `update_store_merchant_role`.
|
|
27
|
+
- Webhooks: `update_webhook`.
|
|
28
|
+
- Notification recipients: `add_notification_recipient`, `update_notification_recipient`,
|
|
29
|
+
`remove_notification_recipient`.
|
|
30
|
+
- Products: `update_onetime_product`, `publish_onetime_product`,
|
|
31
|
+
`update_onetime_product_status`, `update_subscription_product_status`.
|
|
32
|
+
- Product groups: `create_subscription_product_group`, `update_…`, `delete_…`, `publish_…`.
|
|
33
|
+
- Promotions: `create_coupon`, `update_coupon`, `deactivate_coupon`, `create_promotion_code`,
|
|
34
|
+
`generate_promotion_codes`, `deactivate_promotion_code`.
|
|
35
|
+
- Refund tickets: `create_refund_ticket`, `resubmit_refund_ticket`.
|
|
36
|
+
- Plan changes: `create_plan_change_session`, `create_authenticated_plan_change`.
|
|
37
|
+
- Content safety: `scan_prompt`.
|
|
38
|
+
- `Client#customer(token, environment:)` returns a `CustomerSession`, authenticated with a session
|
|
39
|
+
token, with the customer actions plus `create_onetime_order` and `create_subscription_order`.
|
|
40
|
+
- `StoreCheckout.new(store_slug:, environment:)` for anonymous checkout with only the store slug.
|
|
41
|
+
- GraphQL readers, generated from the schema that introspection reports: lists, `*_count` and
|
|
42
|
+
single-record methods, `*_aggregate` methods and analytics methods. Filters travel as typed
|
|
43
|
+
variables.
|
|
44
|
+
- `idempotency_key:` on every action, sent as `X-Idempotency-Key`.
|
|
45
|
+
- `Waffo::Pancake::NULL` sends an explicit JSON null, which clears a field. A nil is still dropped.
|
|
46
|
+
- `Error#retry_after`, from the `Retry-After` header.
|
|
47
|
+
- An action's result has a `"warnings"` key when Waffo sent warnings.
|
|
48
|
+
- `Client.new(environment:)`, defaulting to the configured environment.
|
|
49
|
+
- `TestHelpers::FakeClient` has every API method, generated, so a new endpoint cannot be missing.
|
|
50
|
+
- Changed: `graphql` now raises on a non-2xx status without `errors`. It used to return nil.
|
|
51
|
+
- Known: with an API key, `reactivate_subscription` and `cancel_onetime_order` get a 401 from
|
|
52
|
+
Waffo's gateway. Call them through `client.customer(token)`.
|
|
53
|
+
- `rake test:live` runs the real API with a test-mode key. It is not part of `rake test`.
|
|
54
|
+
|
|
3
55
|
## 0.3.0
|
|
4
56
|
|
|
5
57
|
- Webhook amount fields (Waffo, 2026-09-20 to 2026-09-22):
|
data/README.md
CHANGED
|
@@ -100,13 +100,15 @@ settings: the portal's return button links only there.
|
|
|
100
100
|
|
|
101
101
|
```ruby
|
|
102
102
|
client.cancel_subscription("ORD_...") # => {"orderId" => "ORD_...", "status" => "canceling"}
|
|
103
|
-
client.reactivate_subscription("ORD_...") # while still canceling
|
|
104
103
|
client.subscription_order("ORD_...") # GraphQL; nil when unknown
|
|
105
104
|
# => {"status" => "active", "currentPeriodEnd" => "2027-10-08T...", "merchantProvidedBuyerIdentity" => "user-42", ...}
|
|
106
105
|
```
|
|
107
106
|
|
|
108
107
|
`canceling` keeps access until `currentPeriodEnd`. The terminal `canceled` arrives as a webhook.
|
|
109
108
|
|
|
109
|
+
Waffo's gateway refuses an API key on `reactivate_subscription` and `cancel_onetime_order` with
|
|
110
|
+
a 401. Call them as the customer; see [Customer sessions](#customer-sessions).
|
|
111
|
+
|
|
110
112
|
## Products
|
|
111
113
|
|
|
112
114
|
```ruby
|
|
@@ -119,13 +121,121 @@ client.publish_subscription_product(id: "PROD_...") # test → prod, first publ
|
|
|
119
121
|
|
|
120
122
|
Amounts are display strings (`"9.99"`), not cents.
|
|
121
123
|
|
|
122
|
-
##
|
|
124
|
+
## Stores, coupons and refunds
|
|
125
|
+
|
|
126
|
+
```ruby
|
|
127
|
+
client.create_store(name: "My Store")
|
|
128
|
+
client.update_store(id: "STO_...", logo: Waffo::Pancake::NULL) # NULL clears a field; nil is dropped
|
|
129
|
+
|
|
130
|
+
client.update_onetime_product_status(id: "PROD_...", status: "inactive")
|
|
131
|
+
client.create_subscription_product_group(store_id: "STO_...", name: "Plans", product_ids: ["PROD_..."])
|
|
132
|
+
|
|
133
|
+
client.update_webhook(id: webhook["id"], url: "https://example.com/hooks/waffo")
|
|
134
|
+
client.add_notification_recipient(store_id: "STO_...", email: "ops@example.com")
|
|
135
|
+
client.add_store_merchant(store_id: "STO_...", email: "ada@example.com", role: "member")
|
|
136
|
+
|
|
137
|
+
coupon = client.create_coupon(store_id: "STO_...", name: "Launch", discount: { type: "percentage", percentOff: 20 })
|
|
138
|
+
client.generate_promotion_codes(coupon_id: "CPN_...", count: 100, prefix: "LAUNCH")
|
|
139
|
+
|
|
140
|
+
client.create_refund_ticket(payment_id: "PAY_...", reason: "Duplicate charge",
|
|
141
|
+
requested_amount: { amount: "9.99", currency: "USD" })
|
|
142
|
+
client.scan_prompt(prompt: "...")
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Every action takes `idempotency_key:` (1 to 256 characters of `A-Z a-z 0-9 _ -`). It is sent as
|
|
146
|
+
`X-Idempotency-Key`, and Waffo keeps the answer for 24 hours. Nothing is sent unless you pass one,
|
|
147
|
+
and Waffo does not deduplicate a write without a key: a write retried after a timeout can run twice.
|
|
148
|
+
Pass a key on every write that a retry could repeat. Use a key that is unique per request; a key
|
|
149
|
+
built from a hash of the body, or a short guessable one, can collide with another request's key.
|
|
150
|
+
|
|
151
|
+
```ruby
|
|
152
|
+
client.create_refund_ticket(..., idempotency_key: "refund-#{order.id}")
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
When Waffo sends warnings with a successful answer, the result has a `"warnings"` key.
|
|
156
|
+
|
|
157
|
+
## Customer sessions
|
|
158
|
+
|
|
159
|
+
Some routes act as one customer and take a session token instead of an API key. A token does not
|
|
160
|
+
carry an environment, so the session needs one, from `environment:` or the configuration.
|
|
161
|
+
|
|
162
|
+
```ruby
|
|
163
|
+
token = client.issue_session_token(buyer_identity: "user-42", store_id: "STO_...")["token"]
|
|
164
|
+
customer = client.customer(token, environment: "test")
|
|
165
|
+
|
|
166
|
+
customer.reactivate_subscription("ORD_...")
|
|
167
|
+
customer.cancel_onetime_order("ORD_...")
|
|
168
|
+
customer.create_onetime_order(checkout_session_id: "cs_...", billing_detail: { country: "US", ... },
|
|
169
|
+
language: "en", buyer_email: "ada@example.com")
|
|
170
|
+
# create_subscription_order takes the same arguments. buyer_email: is required unless the checkout
|
|
171
|
+
# session already has one.
|
|
172
|
+
customer.graphql("{ onetimeOrders { id status } }")
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
`inspect` hides the token. A plan change the customer confirms on Waffo's page:
|
|
176
|
+
|
|
177
|
+
```ruby
|
|
178
|
+
link = client.create_authenticated_plan_change(origin_order_id: "ORD_...", product_id: "PROD_...",
|
|
179
|
+
currency: "USD", buyer_identity: "user-42")
|
|
180
|
+
redirect_to link["checkoutUrl"], allow_other_host: true # a bearer credential: never log it
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Anonymous checkout with only the public store slug, which needs no secret:
|
|
184
|
+
|
|
185
|
+
```ruby
|
|
186
|
+
storefront = Waffo::Pancake::StoreCheckout.new(store_slug: "my-store", environment: "test")
|
|
187
|
+
storefront.create_checkout_session(product_id: "PROD_...", currency: "USD")
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Reading data
|
|
123
191
|
|
|
124
192
|
```ruby
|
|
125
|
-
client.
|
|
126
|
-
client.
|
|
193
|
+
client.onetime_products(limit: 20) # store_id: defaults to WAFFO_STORE_ID
|
|
194
|
+
client.onetime_products(store_slug: "my-store")
|
|
195
|
+
client.onetime_products_count
|
|
196
|
+
client.onetime_product("PROD_...") # nil when unknown
|
|
197
|
+
client.payments(filter: { status: { eq: "succeeded" } }, order_by: :created_at_desc, offset: 20)
|
|
198
|
+
client.promotion_codes(coupon_id: "CPN_...")
|
|
199
|
+
client.subscription_product_versions("PROD_...")
|
|
200
|
+
client.me
|
|
127
201
|
```
|
|
128
202
|
|
|
203
|
+
There are readers for stores, merchants, store merchants, products, product groups, orders,
|
|
204
|
+
payments, refunds, refund tickets, chargebacks, customers, coupons, promotion codes, discount
|
|
205
|
+
applications, email deliveries, cancel reasons, webhooks and notification recipients.
|
|
206
|
+
`Waffo::Pancake::API::Queries::LISTS` is the full table. `fields:` replaces the default selection.
|
|
207
|
+
It is written into the query, so it must come from your code and never from a request. Filters
|
|
208
|
+
travel as GraphQL variables, so they are safe for any value.
|
|
209
|
+
|
|
210
|
+
Analytics return the fields you ask for, and aggregates can group by a dimension:
|
|
211
|
+
|
|
212
|
+
```ruby
|
|
213
|
+
client.order_statistics(fields: "totalCount buyerMetrics { totalBuyers }",
|
|
214
|
+
start_date: 1.month.ago, end_date: Time.now, currency: "USD")
|
|
215
|
+
client.payments_aggregate(group_by: :status, granularity: :month, filter: { currency: { eq: "USD" } })
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Anything else goes through the low-level calls:
|
|
219
|
+
|
|
220
|
+
```ruby
|
|
221
|
+
client.graphql("query ($id: String!) { payoutTicket(id: $id) { id status } }", id: "...")
|
|
222
|
+
client.action("/v1/actions/some-group/some-action", { some_param: "..." })
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Invoices
|
|
226
|
+
|
|
227
|
+
Waffo gives every succeeded payment an `invoiceToken`, read with the payment's GraphQL fields.
|
|
228
|
+
`Invoice.url` builds the buyer's invoice link from the payment id and that token. It returns nil
|
|
229
|
+
while the token is missing, which is before the payment succeeds:
|
|
230
|
+
|
|
231
|
+
```ruby
|
|
232
|
+
Waffo::Pancake::Invoice.url("PAY_...", invoice_token)
|
|
233
|
+
# => "https://pancake.waffo.ai/invoice/PAY_...?token=..."
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
The link is a bearer credential for that one invoice: it grants nothing else, and the receipt email
|
|
237
|
+
contains the same link. `payments` selects `invoiceToken` by default.
|
|
238
|
+
|
|
129
239
|
## Webhooks
|
|
130
240
|
|
|
131
241
|
Pass the raw body; a body that was parsed and re-serialized will not verify.
|
|
@@ -158,7 +268,28 @@ The platform's public keys are built in. When Waffo rotates them, set
|
|
|
158
268
|
both), or pass `public_key:`. Timestamps may be up to 45 minutes old and 1 minute ahead by default
|
|
159
269
|
(`tolerance:`, `future_tolerance:`, in seconds; `tolerance: 0` turns the check off).
|
|
160
270
|
|
|
161
|
-
`Waffo::Pancake::Webhook::EVENT_TYPES` lists the event types
|
|
271
|
+
`Waffo::Pancake::Webhook::EVENT_TYPES` lists the 16 event types: payment, subscription, refund and
|
|
272
|
+
store. `Webhook.family` names each one's family (`:payment`, `:refund`, `:subscription`, `:store`), and
|
|
273
|
+
`event.store?` answers for the store family.
|
|
274
|
+
|
|
275
|
+
`store.domain_changed` and `store.domain_unbound` carry the store's domain. A store that leaves
|
|
276
|
+
production with `store.domain_unbound` gets it from production webhooks only; its `id` and `eventId`
|
|
277
|
+
are plain UUIDs, not `PAY_xxx` style ids.
|
|
278
|
+
|
|
279
|
+
### Payment, refund and store fields
|
|
280
|
+
|
|
281
|
+
| Reader | Field | Events |
|
|
282
|
+
|---|---|---|
|
|
283
|
+
| `payment_timestamp` | `paymentTimestamp` | Payment, `refund.*`: UTC with milliseconds, e.g. `2026-03-10T08:29:58.412Z` |
|
|
284
|
+
| `payment_method`, `payment_method_brand` | `paymentMethod`, `paymentMethodBrand` | Same, when known. The brand is an open string (`wechatpay`, `alipay`, `visa`, ...) |
|
|
285
|
+
| `payment_id`, `payment_status`, `payment_date`, `payment_last4`, `payment_failure_reason` | `paymentId`, `paymentStatus`, `paymentDate`, `paymentLast4`, `paymentFailureReason` | Payment and `refund.*` events |
|
|
286
|
+
| `refund_status`, `refund_reason`, `refund_created_at` | `refundStatus`, `refundReason`, `refundCreatedAt` | `refund.*` |
|
|
287
|
+
| `plan_change` | `planChange` | `subscription.plan_changed`, `plan_change_scheduled`, `plan_change_failed` |
|
|
288
|
+
| `store_id`, `store_name`, `old_domain`, `new_domain`, `effective_at` | `storeId`, `storeName`, `oldDomain`, `newDomain`, `effectiveAt` | `store.domain_changed`; `old_domain` is nil when the store had no verified domain |
|
|
289
|
+
| `domain`, `unbound_at`, `unbind_method` | `domain`, `unboundAt`, `method` | `store.domain_unbound`; `unbind_method` is `"merchant"` or `"admin"` |
|
|
290
|
+
|
|
291
|
+
A deprecated field read on an event that does not carry it (for example `amount` on a store event)
|
|
292
|
+
reports the warning without raising.
|
|
162
293
|
|
|
163
294
|
### Amount fields
|
|
164
295
|
|
|
@@ -302,14 +433,15 @@ end
|
|
|
302
433
|
|
|
303
434
|
`FakeClient` answers `subscription_order` from the orders it was given, moves an order to
|
|
304
435
|
`canceling` / `active` on cancel / reactivate, records every call in `calls`, and raises
|
|
305
|
-
`fail_with` when set.
|
|
436
|
+
`fail_with` when set. It has every API method: lists answer `[]`, counts `0`, reads `nil` and
|
|
437
|
+
writes `{}`. `customer(token)` answers with the same fake.
|
|
306
438
|
|
|
307
439
|
## Errors
|
|
308
440
|
|
|
309
441
|
| Class | When |
|
|
310
442
|
|---|---|
|
|
311
443
|
| `Waffo::Pancake::Rejected` | Waffo refused the request (4xx other than 429). `status` and `errors` carry the details. |
|
|
312
|
-
| `Waffo::Pancake::Unavailable` | Network failure, timeout, 429 or 5xx. Worth retrying later. |
|
|
444
|
+
| `Waffo::Pancake::Unavailable` | Network failure, timeout, 429 or 5xx. Worth retrying later, after `retry_after` seconds when it is set. |
|
|
313
445
|
| `Waffo::Pancake::ConfigurationError` | Missing merchant id, or a key that does not parse. |
|
|
314
446
|
| `Waffo::Pancake::InvalidSignature` | A webhook that does not verify. |
|
|
315
447
|
|
|
@@ -318,7 +450,7 @@ All inherit from `Waffo::Pancake::Error`.
|
|
|
318
450
|
## Testing your code
|
|
319
451
|
|
|
320
452
|
`Client.new` takes a `transport:` callable that replaces the HTTP call. It receives the URI,
|
|
321
|
-
the headers and the JSON body and returns `[status, body]`.
|
|
453
|
+
the headers and the JSON body and returns `[status, body]` or `[status, body, headers]`.
|
|
322
454
|
|
|
323
455
|
```ruby
|
|
324
456
|
transport = ->(uri, headers, json) { [200, '{"data":{"orderId":"ORD_1","status":"canceling"}}'] }
|
|
@@ -334,6 +466,17 @@ bundle install
|
|
|
334
466
|
bundle exec rake test # test:core (no Rails loaded) and test:rails
|
|
335
467
|
```
|
|
336
468
|
|
|
469
|
+
`rake test:live` calls the real API. It needs a **test-mode** key and refuses to run otherwise:
|
|
470
|
+
|
|
471
|
+
```sh
|
|
472
|
+
WAFFO_LIVE=1 WAFFO_ENVIRONMENT=test WAFFO_MERCHANT_ID=... WAFFO_PRIVATE_KEY=... WAFFO_STORE_ID=... \
|
|
473
|
+
bundle exec rake test:live
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
`WAFFO_STORE_ID` is only read. Writes go to a temporary store that the run creates and deletes.
|
|
477
|
+
The `Live API` workflow runs this on pushes to `main` and by hand, from the `WAFFO_*` Actions
|
|
478
|
+
secrets. It never runs for pull requests, so a fork cannot reach the key.
|
|
479
|
+
|
|
337
480
|
Releases are published to RubyGems by the `Release` workflow when a `v*` tag is pushed (see
|
|
338
481
|
[RELEASING.md](RELEASING.md)). It uses
|
|
339
482
|
[trusted publishing](https://guides.rubygems.org/trusted-publishing/), so no API key is stored.
|
|
@@ -24,6 +24,12 @@ class WaffoWebhookJob < ApplicationJob
|
|
|
24
24
|
# The renewal failed; the payment channel retries once, usually the next day.
|
|
25
25
|
when "refund.succeeded"
|
|
26
26
|
# event.data.refunded_amount, out of event.data.original_charged_amount actually collected.
|
|
27
|
+
when "store.domain_changed"
|
|
28
|
+
# The store serves event.data.new_domain from event.data.effective_at. event.data.old_domain
|
|
29
|
+
# is nil when the store had no verified domain before.
|
|
30
|
+
when "store.domain_unbound"
|
|
31
|
+
# The store left production at event.data.unbound_at (event.data.unbind_method: "merchant" or
|
|
32
|
+
# "admin"). event.data.domain is no longer bound to the store.
|
|
27
33
|
end
|
|
28
34
|
|
|
29
35
|
event.update!(processed_at: Time.current)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Waffo
|
|
4
|
+
module Pancake
|
|
5
|
+
module API
|
|
6
|
+
# Actions that act for one customer, so both Client and CustomerSession have them.
|
|
7
|
+
#
|
|
8
|
+
# The gateway decides which credential a route takes, and the two groups below differ:
|
|
9
|
+
# with an API key, reactivate-order and onetime-order/cancel-order answer 401 "API Key
|
|
10
|
+
# authentication not supported for this route" (tested on 2026-11-04). They stay here so
|
|
11
|
+
# the 0.x Client API keeps its shape, and because Waffo can open these routes later.
|
|
12
|
+
module CustomerActions
|
|
13
|
+
def create_checkout_session(product_id:, currency:, **params)
|
|
14
|
+
action("/v1/actions/checkout/create-session", product_id: product_id, currency: currency, **params)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# A checkout session that changes the plan of `origin_order_id`. Without a coupon of its
|
|
18
|
+
# own, the session follows the rules of the origin order's product group.
|
|
19
|
+
def create_plan_change_session(origin_order_id:, product_id:, currency:, **params)
|
|
20
|
+
action("/v1/actions/checkout/create-session", origin_order_id: origin_order_id, product_id: product_id,
|
|
21
|
+
currency: currency, **params)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# pending → canceled at once; active, trialing and past_due → canceling, ending with the
|
|
25
|
+
# paid period. The terminal `canceled` arrives later as a webhook. Optional: cancel_reason,
|
|
26
|
+
# cancel_comment.
|
|
27
|
+
def cancel_subscription(order_id, **params)
|
|
28
|
+
action("/v1/actions/subscription-order/cancel-order", order_id: order_id, **params)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Undoes a cancellation while the order is still `canceling`. Session token only; see the
|
|
32
|
+
# module comment.
|
|
33
|
+
def reactivate_subscription(order_id, **params)
|
|
34
|
+
action("/v1/actions/subscription-order/reactivate-order", order_id: order_id, **params)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Session token only; see the module comment.
|
|
38
|
+
def cancel_onetime_order(order_id, **params)
|
|
39
|
+
action("/v1/actions/onetime-order/cancel-order", order_id: order_id, **params)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# requested_amount: { amount: "9.99", currency: "USD" }
|
|
43
|
+
def create_refund_ticket(payment_id:, reason:, requested_amount:, **params)
|
|
44
|
+
action("/v1/actions/refund-ticket/create-ticket", payment_id: payment_id, reason: reason,
|
|
45
|
+
requested_amount: requested_amount, **params)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def resubmit_refund_ticket(ticket_id:, reason:, requested_amount:, **params)
|
|
49
|
+
action("/v1/actions/refund-ticket/resubmit-ticket", ticket_id: ticket_id, reason: reason,
|
|
50
|
+
requested_amount: requested_amount, **params)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Waffo
|
|
4
|
+
module Pancake
|
|
5
|
+
module API
|
|
6
|
+
# Products and subscription product groups. Merchant API key.
|
|
7
|
+
module ProductActions
|
|
8
|
+
# prices: { "USD" => { amount: "9.99", taxCategory: "saas" } }
|
|
9
|
+
def create_subscription_product(store_id:, name:, billing_period:, prices:, **params)
|
|
10
|
+
action("/v1/actions/subscription-product/create-product",
|
|
11
|
+
store_id: store_id, name: name, billing_period: billing_period, prices: prices, **params)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def update_subscription_product(id:, **params)
|
|
15
|
+
action("/v1/actions/subscription-product/update-product", id: id, **params)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Copies the test version to production (first publish only).
|
|
19
|
+
def publish_subscription_product(id:, **params)
|
|
20
|
+
action("/v1/actions/subscription-product/publish-product", id: id, **params)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# status: "active" or "inactive"
|
|
24
|
+
def update_subscription_product_status(id:, status:, **params)
|
|
25
|
+
action("/v1/actions/subscription-product/update-status", id: id, status: status, **params)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def create_onetime_product(store_id:, name:, prices:, **params)
|
|
29
|
+
action("/v1/actions/onetime-product/create-product", store_id: store_id, name: name, prices: prices, **params)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def update_onetime_product(id:, **params)
|
|
33
|
+
action("/v1/actions/onetime-product/update-product", id: id, **params)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Copies the test version to production.
|
|
37
|
+
def publish_onetime_product(id:, **params)
|
|
38
|
+
action("/v1/actions/onetime-product/publish-product", id: id, **params)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# status: "active" or "inactive"
|
|
42
|
+
def update_onetime_product_status(id:, status:, **params)
|
|
43
|
+
action("/v1/actions/onetime-product/update-status", id: id, status: status, **params)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def create_subscription_product_group(store_id:, name:, **params)
|
|
47
|
+
action("/v1/actions/subscription-product-group/create-group", store_id: store_id, name: name, **params)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def update_subscription_product_group(id:, **params)
|
|
51
|
+
action("/v1/actions/subscription-product-group/update-group", id: id, **params)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def delete_subscription_product_group(id:, **params)
|
|
55
|
+
action("/v1/actions/subscription-product-group/delete-group", id: id, **params)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def publish_subscription_product_group(id:, **params)
|
|
59
|
+
action("/v1/actions/subscription-product-group/publish-group", id: id, **params)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Waffo
|
|
4
|
+
module Pancake
|
|
5
|
+
module API
|
|
6
|
+
# Coupons, promotion codes and the prompt scan. Merchant API key.
|
|
7
|
+
module PromotionActions
|
|
8
|
+
# discount: { type: "percentage", percentOff: 20 }
|
|
9
|
+
def create_coupon(store_id:, name:, discount:, **params)
|
|
10
|
+
action("/v1/actions/coupon/create-coupon", store_id: store_id, name: name, discount: discount, **params)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def update_coupon(id:, name:, **params)
|
|
14
|
+
action("/v1/actions/coupon/update-coupon", id: id, name: name, **params)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def deactivate_coupon(id:, **params)
|
|
18
|
+
action("/v1/actions/coupon/deactivate-coupon", id: id, **params)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def create_promotion_code(coupon_id:, **params)
|
|
22
|
+
action("/v1/actions/promotion-code/create-promotion-code", coupon_id: coupon_id, **params)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def generate_promotion_codes(coupon_id:, count:, **params)
|
|
26
|
+
action("/v1/actions/promotion-code/generate-promotion-codes", coupon_id: coupon_id, count: count, **params)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def deactivate_promotion_code(id:, **params)
|
|
30
|
+
action("/v1/actions/promotion-code/deactivate-promotion-code", id: id, **params)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def scan_prompt(prompt:, **params)
|
|
34
|
+
action("/v1/actions/verification/scan-prompt", prompt: prompt, **params)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|