Skip to main content

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​

  1. Allow your site. In the Console, register the origin of the page that will host the checkout. See Allowed Origins.
  2. Create something to pay for. Create a Charge (POST /invoices) or a Payment Link (POST /payment-links) and read data.short_code from the response.
  3. Show the checkout. Pass the short_code to <morph-checkout> or Morph.checkout.create(). See Embed Checkout.
  4. The customer pays inside the embedded checkout. Use the events to update your page.
  5. 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.