Skip to content

feat: optional iframe init option on invoices.create - #16

Merged
MHJaafar9869 merged 1 commit into
mainfrom
feat/iframe-init-option
Aug 6, 2026
Merged

feat: optional iframe init option on invoices.create#16
MHJaafar9869 merged 1 commit into
mainfrom
feat/iframe-init-option

Conversation

@MHJaafar9869

Copy link
Copy Markdown
Collaborator

Summary

Adds an optional iframe field to invoices.create, mirroring the existing unsigned paymentMode passthrough. Set iframe: true to request a checkout suitable for embedding.

The GetPayIn v2 init endpoint reads iframe as a boolean via Laravel $request->boolean('iframe') (treats "1"/"true" as true). Like paymentMode, it is unsigned — sent in the request body but excluded from the HMAC signature.

This SDK remains server-side only: no browser/DOM/postMessage embed helper is added — just the init option.

Changes

  • src/types.ts — added iframe?: boolean | number to CreateInvoiceParams; updated the doc comment to note it is an optional unsigned passthrough like paymentMode.
  • src/internal/fieldOrders.ts — added { sdk: 'iframe', wire: 'iframe', signed: false } after the paymentMode entry in INVOICE_CREATE.fields.
  • Boolean coercion — verified coerceToString already maps true -> "1" / false -> "0" (Laravel-boolean-truthy). No coercion change was required.
  • Tests — added an unsigned iframe test to test/sign-request.test.ts (asserts body.iframe === "1" and that the signature is identical with/without iframe); added iframe to the accepted-keys spec in test/type-safety.test.ts.
  • Docs — README quick-start now shows an iframe: true embedded-checkout example; CHANGELOG [Unreleased] -> Added notes the field.
  • Version — bumped 0.1.1 -> 0.2.0 in package.json and src/version.ts (kept in sync per the existing retry.test.ts guard).

Verification

  • npm test — 109 passed (10 files)
  • npm run typecheck — clean
  • npm run build — ESM + CJS + DTS all succeed
  • npm run lint and npm run format:check — clean

No shared golden vectors were modified; only SDK-local tests were added.

Adds an optional `iframe` field to CreateInvoiceParams, mirroring the
existing unsigned `paymentMode` passthrough. It is sent in the request
body (as a Laravel-boolean-truthy "1") but excluded from the HMAC
signature. Set `iframe: true` to request a checkout suitable for
embedding.

Boolean coercion is already handled correctly by coerceToString
(true -> "1", false -> "0"), so no coercion changes were needed.

Bumps version 0.1.1 -> 0.2.0.
@MHJaafar9869
MHJaafar9869 merged commit 7145e4c into main Aug 6, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant