Widget Overview
Widget Overview
The Widget lets you show Morph Payments checkout inside your own page instead of sending the customer to a Hosted Checkout page. The customer pays without leaving your site, and the signed webhook tells you the result.
How it works
- Allow your site. In the Console, register the origin of the page that will host the checkout. See Allowed Origins.
- Create something to pay for. Create a Charge
(
POST /invoices) or a Payment Link (POST /payment-links) and readdata.short_codefrom the response. - Show the checkout. Pass the
short_codeto<morph-checkout>orMorph.checkout.create(). See Embed Checkout. - The customer pays inside the embedded checkout. Use the events to update your page.
- Confirm on your backend. Morph sends the signed webhook. See Events Reference and Signature Verification.
Minimal example
<script src="https://embed-pay.morph.network/embed/v1/embed.js"></script>
<morph-checkout id="checkout" short-code="abc123"></morph-checkout>
<script>
document.getElementById('checkout').addEventListener('morph:success', () => {
// update your UI
});
</script>
The checkout appears in an iframe and resizes itself to fit.
caution
Events fired in the browser are for updating your UI only. Never ship goods or mark an order as paid because of a frontend event. Always wait for the signed webhook.