@pybara/pybara-js 0.6.0 → 0.7.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.
- package/checkout.schema.json +24 -0
- package/dist/buttons.d.ts +11 -0
- package/dist/buttons.d.ts.map +1 -0
- package/dist/checkout.d.ts +12 -1
- package/dist/checkout.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/pybara-js.iife.js +9 -9
- package/dist/pybara-js.js +123 -30
- package/dist/types.d.ts +33 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/checkout.schema.json
CHANGED
|
@@ -145,6 +145,30 @@
|
|
|
145
145
|
"onError": { "description": "function (Error) => void — called on frame-level errors; not expressible in JSON." },
|
|
146
146
|
"onClose": { "description": "function () => void — called when the payer closes the checkout; not expressible in JSON." }
|
|
147
147
|
}
|
|
148
|
+
},
|
|
149
|
+
"buttons": {
|
|
150
|
+
"title": "checkout.buttons(options)",
|
|
151
|
+
"description": "A 'Pybara' button, served by Pybara, that opens this checkout on the payer's click. Draw it with .render(element or selector), as often as wanted; .destroy() removes them. Its look follows availability by itself; call checkout.precheck({ amount, currency }) when the form changes.",
|
|
152
|
+
"type": "object",
|
|
153
|
+
"additionalProperties": false,
|
|
154
|
+
"required": ["createPayment"],
|
|
155
|
+
"properties": {
|
|
156
|
+
"style": {
|
|
157
|
+
"type": "object",
|
|
158
|
+
"description": "Passed to the button as given. Copy a PayPal button's style and the two match.",
|
|
159
|
+
"properties": {
|
|
160
|
+
"color": { "type": "string", "description": "'brand' | 'black' | 'white' (PayPal's names; its 'gold', 'blue', 'silver' read as 'brand'). Default 'brand'." },
|
|
161
|
+
"shape": { "type": "string", "description": "'pill' | 'rect' | 'sharp'. Default 'pill'." },
|
|
162
|
+
"height": { "type": "number", "minimum": 25, "maximum": 55, "description": "CSS pixels, PayPal's range. Default 45." }
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
"hideWhenUnavailable": { "type": "boolean", "description": "Collapse the button to no height when Pybara is unavailable here; by default its slot stays, empty." },
|
|
166
|
+
"createPayment": { "description": "function () => payment | Promise<payment> — called on the click: the payment from the form's current values, as open() takes it (amount, currency, frequency, donor fields), without callbacks; not expressible in JSON." },
|
|
167
|
+
"onStateChange": { "description": "function (Availability) => void — the checkout's availability answer, once per answer; e.g. show availability.message below the minimum. Not expressible in JSON." },
|
|
168
|
+
"onSuccess": { "description": "function (CheckoutResult) => void — the payment is confirmed on-chain; not expressible in JSON." },
|
|
169
|
+
"onError": { "description": "function (Error) => void — a refusal from createPayment(), open() or the checkout; not expressible in JSON." },
|
|
170
|
+
"onClose": { "description": "function () => void — the payer closed the checkout; not expressible in JSON." }
|
|
171
|
+
}
|
|
148
172
|
}
|
|
149
173
|
}
|
|
150
174
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Availability } from './modal/modal';
|
|
2
|
+
import { ButtonsOptions, PaymentParams, PybaraButtons } from './types';
|
|
3
|
+
/** What the loader needs from its checkout: the frame's origin, open(), and the availability answers. */
|
|
4
|
+
export interface ButtonsHost {
|
|
5
|
+
walletUrl: string;
|
|
6
|
+
open(payment: PaymentParams): Promise<void>;
|
|
7
|
+
/** Subscribes to every availability answer, first with the latest one if there is one; returns the unsubscribe. */
|
|
8
|
+
subscribeAvailability(listener: (availability: Availability) => void): () => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function createButtons(host: ButtonsHost, options: ButtonsOptions): PybaraButtons;
|
|
11
|
+
//# sourceMappingURL=buttons.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buttons.d.ts","sourceRoot":"","sources":["../src/buttons.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAe,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAEnG,yGAAyG;AACzG,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,mHAAmH;IACnH,qBAAqB,CAAC,QAAQ,EAAE,CAAC,YAAY,EAAE,YAAY,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CACnF;AAoBD,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,GAAG,aAAa,CAqFvF"}
|
package/dist/checkout.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WidgetGate } from './gate';
|
|
2
|
-
import { CheckoutConfig, PaymentParams } from './types';
|
|
2
|
+
import { ButtonsOptions, CheckoutConfig, PaymentParams, PybaraButtons } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* A bound checkout — what Pybara.checkout() returns.
|
|
5
5
|
*
|
|
@@ -20,7 +20,18 @@ export declare class PybaraCheckout {
|
|
|
20
20
|
readonly ready: Promise<void>;
|
|
21
21
|
/** The latest precheck()'s amount and currency, sent again to each rebuilt checkout frame. */
|
|
22
22
|
private lastPrecheck;
|
|
23
|
+
/** Every listener for availability answers: the config's onAvailability, and each rendered button. */
|
|
24
|
+
private readonly availabilityListeners;
|
|
25
|
+
/** The latest answer, handed to a listener as it subscribes. */
|
|
26
|
+
private latestAvailability;
|
|
23
27
|
constructor(userConfig: CheckoutConfig);
|
|
28
|
+
/**
|
|
29
|
+
* A "Pybara" button, served by Pybara, that opens this checkout on the payer's click with the payment createPayment() returns.
|
|
30
|
+
* Its look follows availability by itself (disabled below the minimum, hidden when Pybara can't be used here); call precheck({ amount }) as the form changes.
|
|
31
|
+
* Render it as often as wanted, e.g. a one-time and a monthly button side by side: they share this one checkout.
|
|
32
|
+
*/
|
|
33
|
+
buttons(options: ButtonsOptions): PybaraButtons;
|
|
34
|
+
private emitAvailability;
|
|
24
35
|
/**
|
|
25
36
|
* Ask whether a payment of this amount would go through right now; the answer arrives on the config's onAvailability.
|
|
26
37
|
* Call it again whenever the form's amount or currency changes: only the latest is answered.
|
package/dist/checkout.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../src/checkout.ts"],"names":[],"mappings":"AAMA,OAAO,EAAmB,KAAK,UAAU,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../src/checkout.ts"],"names":[],"mappings":"AAMA,OAAO,EAAmB,KAAK,UAAU,EAAE,MAAM,QAAQ,CAAC;AAE1D,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,cAAc,EAEnB,KAAK,aAAa,EAElB,KAAK,aAAa,EACnB,MAAM,SAAS,CAAC;AAcjB;;;;;;GAMG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyB;IAChD,OAAO,CAAC,WAAW,CAAkC;IACrD,OAAO,CAAC,KAAK,CAA8B;IAC3C,OAAO,CAAC,WAAW,CAA2B;IAC9C,OAAO,CAAC,MAAM,CAAS;IACvB,gIAAgI;IAChI,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,aAAa,CAA8B;IACnD,uGAAuG;IACvG,SAAgB,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,8FAA8F;IAC9F,OAAO,CAAC,YAAY,CAA8C;IAClE,sGAAsG;IACtG,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAmD;IACzF,gEAAgE;IAChE,OAAO,CAAC,kBAAkB,CAA6B;gBAE3C,UAAU,EAAE,cAAc;IAQtC;;;;OAIG;IACH,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,aAAa;IAgB/C,OAAO,CAAC,gBAAgB;IAKxB;;;;OAIG;IACH,QAAQ,CAAC,MAAM,GAAE;QAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,IAAI;YAM9D,YAAY;IAkB1B,2IAA2I;IAC3I,IAAI,IAAI,IAAI,UAAU,GAAG,IAAI,CAE5B;IAED;;;;;OAKG;IACG,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IA8EjD,4EAA4E;IAC5E,KAAK,IAAI,IAAI;YAIC,IAAI;IA8ClB,OAAO,CAAC,iBAAiB;IAyDzB;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAmCnB,6FAA6F;IAC7F,OAAO,CAAC,gBAAgB;CAOzB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -11,5 +11,5 @@ export declare const Pybara: {
|
|
|
11
11
|
export { PybaraCheckout } from './checkout';
|
|
12
12
|
export { type Availability } from './modal/modal';
|
|
13
13
|
export { type WidgetGate } from './gate';
|
|
14
|
-
export { type CheckoutConfig, type CheckoutResult, type Frequency, type PaymentParams, PybaraError, type PybaraErrorCode, } from './types';
|
|
14
|
+
export { type ButtonPayment, type ButtonsOptions, type CheckoutConfig, type CheckoutResult, type Frequency, type PaymentParams, PybaraError, type PybaraButtons, type PybaraErrorCode, } from './types';
|
|
15
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAE/D;AAID,eAAO,MAAM,MAAM;;CAAe,CAAC;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,WAAW,EACX,KAAK,eAAe,GACrB,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAE/D;AAID,eAAO,MAAM,MAAM;;CAAe,CAAC;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,eAAe,GACrB,MAAM,SAAS,CAAC"}
|