The @zenobia/ui-solid package provides Solid.js UI components and builds targets into vanilla javascript. This public npm package includes the "Pay with Zenobia" button component and other UI elements needed for seamless payment integration.
npm install @zenobia/ui-solidor
yarn add @zenobia/ui-solidThis package requires Solid.js as a peer dependency:
npm install solid-jsTo avoid the peer dependency, use the precompiled source hosted on our CDNs:
import { ZenobiaPayButton } from "@zenobia/ui-solid";
function CheckoutPage() {
const handleSuccess = (payment) => {
console.log("Payment successful:", payment);
};
const handleError = (error) => {
console.error("Payment failed:", error);
};
return (
<ZenobiaPayButton
amount={99.99}
orderId="order-123"
merchantId="your-merchant-id"
onSuccess={handleSuccess}
onError={handleError}
/>
);
}<!-- Include the standalone script -->
<script src="https://zenobiapay.com/embed/latest/zenobia-pay.js"></script>
<!-- Initialize the button -->
<div id="zenobia-button"></div>
<script>
ZenobiaPay.mount("#zenobia-button", {
amount: 99.99,
orderId: "order-123",
merchantId: "your-merchant-id",
});
</script>The main payment button component.
<ZenobiaPayButton
amount={100.0}
orderId="order-123"
merchantId="merchant-id"
description="Purchase from Store"
metadata={{ customField: "value" }}
environment="production"
theme="light"
size="large"
onSuccess={(payment) => {}}
onError={(error) => {}}
onCancel={() => {}}
/>Props:
amount(number, required): Payment amountorderId(string, required): Your order IDmerchantId(string, required): Zenobia merchant IDdescription(string): Payment descriptionmetadata(object): Additional metadataenvironment(string): 'production' or 'sandbox'theme(string): 'light' or 'dark'size(string): 'small', 'medium', or 'large'onSuccess(function): Success callbackonError(function): Error callbackonCancel(function): Cancel callback
Modal component for embedded checkout.
import { ZenobiaPayModal } from "@zenobia/ui-solid";
<ZenobiaPayModal
isOpen={showModal()}
amount={100.0}
orderId="order-123"
merchantId="merchant-id"
onClose={() => setShowModal(false)}
onSuccess={handleSuccess}
/>;Props:
isOpen(boolean): Modal visibilityamount(number): Payment amountorderId(string): Order IDmerchantId(string): Merchant IDonClose(function): Close callbackonSuccess(function): Success callback
QR code display component.
import { ZenobiaQRCode } from "@zenobia/ui-solid";
<ZenobiaQRCode
paymentId="payment-123"
size={256}
showAmount={true}
amount={100.0}
/>;Props:
paymentId(string): Payment ID for QR codesize(number): QR code size in pixelsshowAmount(boolean): Display amount below QRamount(number): Payment amount
The package provides multiple build outputs:
npm run builddist/index.js- Main entry pointdist/index.d.ts- TypeScript definitions
npm run build:zenobiadist/zenobia/zenobia-pay.js- Standalone script for web embedding
npm run build:modaldist/zenobia/zenobia-pay-modal.js- Modal-specific build
npm run build:zenobia-bigcommercedist/zenobia/zenobia-pay-bigcommerce.js- BigCommerce integration build
# Build all formats
npm run build
# Build specific format
npm run build:zenobia
npm run build:modal
npm run build:zenobia-bigcommercenpm testTo publish a new version:
npx changeset
npm run releaseThe release script will:
- Run
changeset versionto update versions - Commit and push changes with tags
- Build all formats
- Run
changeset publishto publish to npm - Deploy standalone scripts to CDN
After building, deploy the standalone scripts to the CDN:
- Build the standalone version:
npm run release- What this does is copies
dist/zenobia/zenobia-pay.jsto the landing page public folder (assuming this is a in the big monorepo)
(yea probably not the ideal deployment pipeline but screw you)
There are a few build targets here, for different uses:
- standard build, which exports a button component to be used
- zenobia-pay-modal.js. rather than export a button that the consumer renders, this bundle inializes itself on load and . it is for serverside creation of transfer requests, which then want to send clients to a page where they just see a transfer QR without
MIT License - see LICENSE for details.