> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flexwash.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Purchase Portal

> Sell washes, gift cards, and wash books online with an embeddable purchase portal.

<Warning>
  To embed iFrames your domain has to be whitelisted. Please reach out to
  support to do so.
</Warning>

### **iFrame**

In the Website page under the Admin section you can copy the HTML for the Purchase Portal iFrame. A preview box for testing is available in the same section.

<img src="https://mintcdn.com/flexwash/BmCPR0FRJ0vihLVV/configuration/portals/purchase-portal/purchase-portal.png?fit=max&auto=format&n=BmCPR0FRJ0vihLVV&q=85&s=85e6297d9093ab31ea37de7b39017500" alt="Membership Pn" width="2113" height="638" data-path="configuration/portals/purchase-portal/purchase-portal.png" />

### **Configuration**

You must select a location and package for the iFrame. That is the location to which the money will be deposited.

You can optionally have a promotion pre-selected if you want to run ads and allow for easy sign up.

### **Callbacks**

You can have your webpage listen for success/fail callbacks from the iFrame to respond accordingly. For example to redirect to a branded thank you page, or to feed the data into ads or 3rd party systems. There are two types of messages posted to the parent site:

* **flexwash-purchase-portal-success** with the name, and email of the member
* **flexwash-purchase-portal-error**

Below is example Javascript that can be used for sign up portal events.

```js theme={null}
<script>
  function handleMessage(event) {
    if (event.origin !== 'https://app.flexwash.com') { return; }
    const { type } = event.data;
    if (type === 'flexwash-purchase-portal-error') {
      // error case
    } if (type === 'flexwash-purchase-portal-success') {
      // success case

      // name = event.data.name
      // email = event.data.email
    }
  }
  window.addEventListener('message', handleMessage);
</script>
```
