@pybara/pybara-js 0.3.0 → 0.4.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.
@@ -7,7 +7,6 @@
7
7
  * consumers that drive the modal directly (the plugins) import it from here.
8
8
  *
9
9
  * @internal Not part of the public API: no compatibility promise between versions, even minor ones.
10
- * Its raw `sdkFields` are the payment log's own field format, which `Pybara.checkout()` never asks an integrator to hold.
11
10
  *
12
11
  * This was `@pybara/pybara-ux` — absorbed into pybara-js so the SDK and its
13
12
  * modal kit version together.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/modal/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,aAAa,EACb,aAAa,EACb,KAAK,QAAQ,EACb,KAAK,mBAAmB,EACxB,KAAK,SAAS,EACd,KAAK,WAAW,GACjB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/modal/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,aAAa,EACb,aAAa,EACb,KAAK,QAAQ,EACb,KAAK,mBAAmB,EACxB,KAAK,SAAS,EACd,KAAK,WAAW,GACjB,MAAM,YAAY,CAAC"}
@@ -1 +1 @@
1
- export { t as CheckoutModal, n as EmbeddedError } from "../modal-BCDMoDW9.js";
1
+ export { t as CheckoutModal, n as EmbeddedError } from "../modal-DCwwkKZ7.js";
@@ -8,8 +8,6 @@
8
8
  * open() and show() then only reveal an already-loaded frame, at the moment latency matters most.
9
9
  */
10
10
  export interface ModalData {
11
- /** Order or donation total in USD; the frame converts it into whichever token the buyer picks. Left out with a `checkout`, whose amount the frame converts itself. */
12
- amountUSD?: number;
13
11
  /** The recipient's principal (merchant or donation recipient); the frame checks it against the connecting origin's DNS record before any transfer. */
14
12
  beneficiary: string;
15
13
  /** Base64 salt for the deposit subaccount: random per order or donation, never reused. */
@@ -39,23 +37,17 @@ export interface CheckoutModalConfig {
39
37
  /** What show() needs that only exists once the order or donation does — unlike CheckoutModalConfig, known at construction. */
40
38
  export interface PaymentData {
41
39
  modalData: ModalData;
42
- /**
43
- * Present only for a recurring payment. totalPulls: 0 means unlimited, as in subs.mo's CreateSubscriptionArgs.
44
- * With a `checkout`, totalPulls is left out: the frame computes it from durationMonths (absent: unlimited).
45
- */
40
+ /** Present only for a recurring payment; the frame computes the number of pulls from durationMonths (absent: unlimited). */
46
41
  recurring?: {
47
42
  frequency: string;
48
- totalPulls?: number;
49
- /** Months the donor chose, when bounded. totalPulls is derived from it; the checkout shows both. */
43
+ /** Months the donor chose, when bounded; the checkout shows them with the number of pulls they make. */
50
44
  durationMonths?: number;
51
45
  };
52
- /** Opaque key-value metadata forwarded unchanged to settle's pay_and_log()/donate_and_log(): order or donor details the platform already has (email, WooCommerce order ID, …). The frame never interprets them. */
53
- sdkFields?: [string, string][];
54
- /** The semantic checkout, which the frame turns into the log fields and the USD amount itself; sent instead of `sdkFields` and `modalData.amountUSD`, never with them. */
55
- checkout?: Checkout;
46
+ /** The checkout, which the frame turns into the USD amount and the payment log's fields itself. */
47
+ checkout: Checkout;
56
48
  }
57
49
  /**
58
- * Mirrors pybara-wallet's EmbeddedCheckout (modes/mode-2-embedded/contract.ts), version 1: a core every kind of checkout shares, and the part for its kind, matching `context`.
50
+ * Mirrors pybara-wallet's EmbeddedCheckout (modes/mode-2-embedded/contract.ts), version 1: a core every kind of checkout shares, and the part for its kind, matching `context`: `donation`, or `order` for a merchant payment.
59
51
  * The frame validates it field by field and refuses it with INVALID_CHECKOUT, naming the faulty field.
60
52
  */
61
53
  export interface Checkout {
@@ -104,6 +96,54 @@ export interface Checkout {
104
96
  isAnonymous?: boolean;
105
97
  wantsTaxReceipt?: boolean;
106
98
  };
99
+ /** A merchant payment's part (context 'payment'): the order. Informational amounts are decimal text or numbers, any decimals; only `id` and each item's `name` and `quantity` are required. */
100
+ order?: {
101
+ /** The shop's order number, digits only. */
102
+ id: string;
103
+ url?: string;
104
+ checkoutType?: string;
105
+ buyer?: {
106
+ country?: string;
107
+ isReturning?: boolean;
108
+ };
109
+ discountTotal?: string | number;
110
+ taxTotal?: string | number;
111
+ shipping?: {
112
+ needed?: boolean;
113
+ country?: string;
114
+ total?: string | number;
115
+ tax?: string | number;
116
+ };
117
+ items?: {
118
+ name: string;
119
+ quantity: number;
120
+ unitPrice?: string | number;
121
+ subtotal?: string | number;
122
+ total?: string | number;
123
+ taxSubtotal?: string | number;
124
+ taxTotal?: string | number;
125
+ productId?: string;
126
+ variationId?: string;
127
+ sku?: string;
128
+ variant?: string;
129
+ productType?: string;
130
+ categories?: string;
131
+ isVirtual?: boolean;
132
+ isDownloadable?: boolean;
133
+ taxClass?: string;
134
+ taxStatus?: string;
135
+ weight?: string | number;
136
+ weightUnit?: string;
137
+ imageUrl?: string;
138
+ taxLines?: {
139
+ label: string;
140
+ ratePct: string | number;
141
+ subtotal: string | number;
142
+ amount: string | number;
143
+ rateId?: string;
144
+ }[];
145
+ }[];
146
+ };
107
147
  }
108
148
  /**
109
149
  * Mirrors pybara-wallet's EmbeddedErrorCode. Every value but RATE_UNAVAILABLE is a terminal refusal; the frame handles other transient failures with its own retry screen and never posts them.
@@ -1 +1 @@
1
- {"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../src/modal/modal.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AASH,MAAM,WAAW,SAAS;IACtB,sKAAsK;IACtK,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sJAAsJ;IACtJ,WAAW,EAAE,MAAM,CAAC;IACpB,0FAA0F;IAC1F,IAAI,EAAE,MAAM,CAAC;IACb,+JAA+J;IAC/J,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,mBAAmB;IAChC,yFAAyF;IACzF,SAAS,EAAE,MAAM,CAAC;IAClB,6HAA6H;IAC7H,OAAO,EAAE,SAAS,GAAG,UAAU,CAAC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,EAAE,OAAO,EAAE,MAAM;CAOnE;AAWD,qBAAa,aAAa;IACtB,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,MAAM,CAAkC;IAChD,uIAAuI;IACvI,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,aAAa,CAAgD;IACrE,OAAO,CAAC,eAAe,CAA6C;IACpE,kKAAkK;IAClK,OAAO,CAAC,QAAQ,CAAQ;IACxB,+EAA+E;IAC/E,OAAO,CAAC,YAAY,CAAS;IAC7B,8EAA8E;IAC9E,OAAO,CAAC,kBAAkB,CAA4B;gBAE1C,MAAM,EAAE,mBAAmB;IAMvC,wGAAwG;IACxG,OAAO,CAAC,YAAY;IAiIpB,OAAO,CAAC,eAAe;IAcvB;;;OAGG;IACH,IAAI,IAAI,IAAI;IASZ,uIAAuI;IACvI,IAAI,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;IAS7B;;;OAGG;IACH,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IA2C1C;;;OAGG;IACH,KAAK,IAAI,IAAI;CAoChB"}
@@ -127,12 +127,10 @@ var g = class {
127
127
  type: "pybara_embedded_init",
128
128
  beneficiary: e.modalData.beneficiary,
129
129
  salt: e.modalData.salt,
130
- ...e.modalData.amountUSD === void 0 ? {} : { amountUSD: e.modalData.amountUSD },
131
130
  reference: e.modalData.reference,
132
131
  context: this.config.context,
133
132
  ...e.recurring ? { recurring: e.recurring } : {},
134
- ...e.sdkFields ? { sdkFields: e.sdkFields } : {},
135
- ...e.checkout ? { checkout: e.checkout } : {},
133
+ checkout: e.checkout,
136
134
  ...this.config.thankYouMessage ? { thankYouMessage: this.config.thankYouMessage } : {}
137
135
  };
138
136
  this.iframe?.contentWindow?.postMessage(t, this.walletOrigin);
@@ -33,7 +33,7 @@ ic-request`);var $r=new TextEncoder().encode(`\vic-response`);new TextEncoder().
33
33
  <svg viewBox="0 0 50 50" width="50" height="50">
34
34
  <circle cx="25" cy="25" r="20" fill="none" stroke="white" stroke-width="3" stroke-linecap="round" stroke-dasharray="80" stroke-dashoffset="20"/>
35
35
  </svg>
36
- `,n.querySelector(`svg`)?.animate([{transform:`rotate(0deg)`},{transform:`rotate(360deg)`}],{duration:1e3,iterations:1/0}),t.addEventListener(`load`,()=>{this.iframeLoaded=!0,this.pendingPaymentData&&=(this.sendInitMessage(this.pendingPaymentData),null)},{once:!0}),this.handleMessage=e=>{if(e.origin===this.walletOrigin&&e.source===t.contentWindow&&td(e.data))switch(e.data.type){case`pybara_embedded_result`:this.config.onSuccess?.({blockIndex:e.data.blockIndex,reference:e.data.reference,payerPrincipal:e.data.payerPrincipal,token:e.data.token});break;case`pybara_embedded_error`:this.close(),this.config.onError?.(new ed($u(e.data.code),e.data.message));break;case`pybara_embedded_closed`:this.close(),this.config.onClose?.();break;case`pybara_embedded_resize`:t.style.height!==`${e.data.height}px`&&(t.style.height=`${e.data.height}px`),this.spinner&&(this.spinner.remove(),this.spinner=null,Zu()||t.animate([{transform:`translateY(20px)`,opacity:0},{transform:`none`,opacity:1}],{duration:Vu.PANEL_OPEN_MS,easing:`ease`}));break;case`pybara_embedded_closable`:this.closable=e.data.closable}},window.addEventListener(`message`,this.handleMessage),this.handleEscapeKey=e=>{e.key===`Escape`&&this.closable&&(this.close(),this.config.onClose?.())},document.addEventListener(`keydown`,this.handleEscapeKey),e.appendChild(n),e.appendChild(t),document.body.appendChild(e),this.overlay=e,this.iframe=t,this.spinner=n}sendInitMessage(e){let t={type:`pybara_embedded_init`,beneficiary:e.modalData.beneficiary,salt:e.modalData.salt,...e.modalData.amountUSD===void 0?{}:{amountUSD:e.modalData.amountUSD},reference:e.modalData.reference,context:this.config.context,...e.recurring?{recurring:e.recurring}:{},...e.sdkFields?{sdkFields:e.sdkFields}:{},...e.checkout?{checkout:e.checkout}:{},...this.config.thankYouMessage?{thankYouMessage:this.config.thankYouMessage}:{}};this.iframe?.contentWindow?.postMessage(t,this.walletOrigin)}open(){this.overlay&&this.overlay.style.display!==`flex`&&(Yu(),this.overlay.style.display=`flex`,Zu()||this.overlay.animate([{opacity:0},{opacity:1}],{duration:Vu.OVERLAY_FADE_IN_MS,easing:`ease`}))}show(e){this.open(),this.iframeLoaded?this.sendInitMessage(e):this.pendingPaymentData=e}renderTerminalState(e){this.close(),Yu();let t=document.createElement(`div`);t.className=`pybara-checkout-overlay`,t.style.cssText=`
36
+ `,n.querySelector(`svg`)?.animate([{transform:`rotate(0deg)`},{transform:`rotate(360deg)`}],{duration:1e3,iterations:1/0}),t.addEventListener(`load`,()=>{this.iframeLoaded=!0,this.pendingPaymentData&&=(this.sendInitMessage(this.pendingPaymentData),null)},{once:!0}),this.handleMessage=e=>{if(e.origin===this.walletOrigin&&e.source===t.contentWindow&&td(e.data))switch(e.data.type){case`pybara_embedded_result`:this.config.onSuccess?.({blockIndex:e.data.blockIndex,reference:e.data.reference,payerPrincipal:e.data.payerPrincipal,token:e.data.token});break;case`pybara_embedded_error`:this.close(),this.config.onError?.(new ed($u(e.data.code),e.data.message));break;case`pybara_embedded_closed`:this.close(),this.config.onClose?.();break;case`pybara_embedded_resize`:t.style.height!==`${e.data.height}px`&&(t.style.height=`${e.data.height}px`),this.spinner&&(this.spinner.remove(),this.spinner=null,Zu()||t.animate([{transform:`translateY(20px)`,opacity:0},{transform:`none`,opacity:1}],{duration:Vu.PANEL_OPEN_MS,easing:`ease`}));break;case`pybara_embedded_closable`:this.closable=e.data.closable}},window.addEventListener(`message`,this.handleMessage),this.handleEscapeKey=e=>{e.key===`Escape`&&this.closable&&(this.close(),this.config.onClose?.())},document.addEventListener(`keydown`,this.handleEscapeKey),e.appendChild(n),e.appendChild(t),document.body.appendChild(e),this.overlay=e,this.iframe=t,this.spinner=n}sendInitMessage(e){let t={type:`pybara_embedded_init`,beneficiary:e.modalData.beneficiary,salt:e.modalData.salt,reference:e.modalData.reference,context:this.config.context,...e.recurring?{recurring:e.recurring}:{},checkout:e.checkout,...this.config.thankYouMessage?{thankYouMessage:this.config.thankYouMessage}:{}};this.iframe?.contentWindow?.postMessage(t,this.walletOrigin)}open(){this.overlay&&this.overlay.style.display!==`flex`&&(Yu(),this.overlay.style.display=`flex`,Zu()||this.overlay.animate([{opacity:0},{opacity:1}],{duration:Vu.OVERLAY_FADE_IN_MS,easing:`ease`}))}show(e){this.open(),this.iframeLoaded?this.sendInitMessage(e):this.pendingPaymentData=e}renderTerminalState(e){this.close(),Yu();let t=document.createElement(`div`);t.className=`pybara-checkout-overlay`,t.style.cssText=`
37
37
  position: fixed;
38
38
  top: 0;
39
39
  left: 0;
package/dist/pybara-js.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /* Pybara.js - pybara.com */
2
2
  import { n as e, r as t, t as n } from "./admin-B1pVP25-.js";
3
- import { t as r } from "./modal-BCDMoDW9.js";
3
+ import { t as r } from "./modal-DCwwkKZ7.js";
4
4
  var i = {
5
5
  widget: "donate-widget",
6
6
  recurring: "donate-widget-recurring"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pybara/pybara-js",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Accept crypto payments and donations with Pybara on any page — a callable checkout, in the stripe-js / paypal-js convention.",
5
5
  "keywords": [
6
6
  "pybara",