Class: Nombaone::Resources::Sandbox
- Inherits:
-
BaseResource
- Object
- BaseResource
- Nombaone::Resources::Sandbox
- Defined in:
- lib/nombaone/resources/sandbox.rb,
sig/nombaone/resources.rbs
Overview
Sandbox only. Simulation instruments that make billing outcomes happen on demand — no cron waits, no real cards. These endpoints exist only on the sandbox deployment; calling any of them with a live key raises locally, before any network request.
Instance Method Summary collapse
-
#advance_cycle(subscription_id, request_options: {}) ⇒ NombaObject
Sandbox only. The test clock: run the subscription's next billing cycle right now, through the real engine — invoice, charge, ledger, webhooks and all.
-
#assert_sandbox! ⇒ void
Fail locally, before any network call, when constructed with a live key.
-
#create_payment_method(customer_id:, behavior: OMIT, kind: OMIT, request_options: {}) ⇒ NombaObject
Sandbox only. Mint a ready, chargeable test payment method whose
behaviordecides every future charge outcome deterministically. -
#simulate_webhook(type:, payload: OMIT, request_options: {}) ⇒ NombaObject
Sandbox only. Emit a real, signed catalog event to your registered endpoints — the genuine pipeline (real secret, real signature, real retries), not a mock.
Methods inherited from BaseResource
#encode, #initialize, #request, #request_page
Constructor Details
This class inherits a constructor from Nombaone::Resources::BaseResource
Instance Method Details
#advance_cycle(subscription_id, request_options: {}) ⇒ NombaObject
Sandbox only. The test clock: run the subscription's next billing cycle right now, through the real engine — invoice, charge, ledger, webhooks and all.
42 43 44 45 46 |
# File 'lib/nombaone/resources/sandbox.rb', line 42 def advance_cycle(subscription_id, request_options: {}) assert_sandbox! request(:post, "/sandbox/subscriptions/#{encode(subscription_id)}/advance-cycle", body: {}, options: ) end |
#assert_sandbox! ⇒ void
This method returns an undefined value.
Fail locally, before any network call, when constructed with a live key.
71 72 73 74 75 76 77 78 |
# File 'lib/nombaone/resources/sandbox.rb', line 71 def assert_sandbox! return unless @client.mode == "live" raise Error, "nombaone.sandbox.* only works with a sandbox key (nbo_sandbox_…) — the " \ "/v1/sandbox endpoints do not exist on the live API. Use your sandbox key to " \ "rehearse, then go live without the sandbox calls." end |
#create_payment_method(customer_id:, behavior: OMIT, kind: OMIT, request_options: {}) ⇒ NombaObject
Sandbox only. Mint a ready, chargeable test payment method whose
behavior decides every future charge outcome deterministically.
24 25 26 27 28 29 |
# File 'lib/nombaone/resources/sandbox.rb', line 24 def create_payment_method(customer_id:, behavior: OMIT, kind: OMIT, request_options: {}) assert_sandbox! request(:post, "/sandbox/payment-methods", body: { customer_id: customer_id, behavior: behavior, kind: kind }, options: ) end |
#simulate_webhook(type:, payload: OMIT, request_options: {}) ⇒ NombaObject
Sandbox only. Emit a real, signed catalog event to your registered endpoints — the genuine pipeline (real secret, real signature, real retries), not a mock. This is how you rehearse your handler.
62 63 64 65 66 |
# File 'lib/nombaone/resources/sandbox.rb', line 62 def simulate_webhook(type:, payload: OMIT, request_options: {}) assert_sandbox! request(:post, "/sandbox/webhooks/simulate", body: { type: type, payload: payload }, options: ) end |