# Accept payments on a Wix site (/wix)
> Copy the MPS files into your Premium Wix site, save your API key in the Secrets Manager, and take MPS payments at the Wix checkout.
The MPS files add **Powered by MPS** as a payment method to the checkout of your own Wix site. Your customer
pays on the MPS checkout and comes back to your site, and Wix marks the order paid once MPS confirms it. You
copy a few files into the site's code and save two codes from the MPS platform.
The files send the order amount, the reference Wix gives the payment and the site's return addresses to MPS (Mobile Payment
Solutions) to open each payment.
[Download mps-payments-wix.zip](https://github.com/mps-emi/plugins/releases/download/wix-latest/mps-payments-wix.zip) — always the latest version. Every version is in its [releases on GitHub](https://github.com/mps-emi/plugins/releases?q=wix&expanded=true), with the [source](https://github.com/mps-emi/plugins/tree/main/wix).
You write no code, but installing copies files into your site's code in the Wix editor (Velo). If you do not
work in the editor's code panel yourself, ask the developer who looks after your site to do the install steps.
- A Wix site on a Premium plan that takes payments, with Wix Stores or another Wix app that has a checkout
- Your site's currency set to euro (EUR)
- Your site published at least once, at the address shoppers use
- A test API key and its webhook signing secret, from **Online › API keys** on the MPS platform. [Connect your webshop](/connect-your-webshop#create-a-test-key) shows how.
## Install and connect
Unzip `mps-payments-wix.zip`. It holds the folder `mps-payments/backend` with the files laid out as the Wix
code panel shows them.
In the Wix editor, turn on the code panel (**Dev Mode** in the Wix Editor, the **Code** icon in Wix Studio)
and open **Public & Backend**. Under **Service Plugins**, click **+**, choose **Payment**, enter the name
`mps-payments` exactly, and click **Add & Edit Code**.
Wix creates the folder `payment-provider/mps-payments` with two files. Replace the content of each with the
file of the same name from the zip:
| In the Wix code panel | From the zip |
|---|---|
| `payment-provider/mps-payments/mps-payments.js` | `backend/service-plugins/payment-provider/mps-payments/mps-payments.js` |
| `payment-provider/mps-payments/mps-payments-config.js` | `backend/service-plugins/payment-provider/mps-payments/mps-payments-config.js` |
Under **Backend**, add a folder `mps` and, in it, a file for each file in the zip's `backend/mps/` folder,
with the same name and content: `api.js`, `outcome.js`, `provider.js`, `refund.js`, `signature.js`,
`version.js` and `wix.js`.
Under **Backend**, add the file `http-functions.js` from the zip. If your site already has one, add the
zip's two `import` lines and its `post_mpsWebhook` function to it instead.
In your site's dashboard, open **Developer Tools › Secrets Manager** and add two entries:
| Name | Value |
|---|---|
| `mps_api_key` | Your test key, starting `mps_test_` |
| `mps_webhook_secret` | The key's webhook signing secret, starting `whsec_` |
The code reads them on Wix's servers; they never reach
the browser.
Publish the site. Wix reads the payment method's name and settings when you publish.
In the dashboard, open **Settings › Accept Payments**, click **See More Payment Options**, find
**Powered by MPS** and click **Connect**. Enter your site's address as shoppers open it, such as
`https://www.myshop.be` (on a free Wix address, `https://.wixsite.com/`), and click **Connect**.
Connecting checks the API key with MPS straight away. **Powered by MPS (test key)** shows as connected, or
Wix shows why MPS refused ([Troubleshooting](#errors)).
Place an order on your site and pay it with one of the [test cards](/online-payments#test-mode). You come
back to the Wix confirmation, and the order is paid in **Orders**, as
[How payments are confirmed](#how-payments-are-confirmed) describes.
Go live: in the Secrets Manager, replace `mps_api_key` with your live key and `mps_webhook_secret` with the
live key's webhook signing secret. See [Switch to live payments](/take-live-payments#a-shop-plugin) for what
MPS needs first.
## Test mode
A test key is an API key starting `mps_test_`. A card payment made with a test key is a **test payment**: the
checkout shows a test-mode banner and takes only the [test cards](/online-payments#test-mode), no card is
charged and nothing is paid out. Orders still move through paid or failed exactly as they do in live mode.
The key decides the mode: there is no separate test or live switch. A test key does not expire. It works until
you revoke it.
## How payments are confirmed
The shopper clicks **Place Order** and goes on to the MPS checkout. Wix keeps the order waiting for payment
until MPS confirms it.
The MPS files never take the shopper's return to your site as proof of payment. When MPS sends its webhook,
they read the payment from MPS and tell Wix what MPS says:
| MPS payment | Wix |
|---|---|
| Paid, full amount | Wix is told the order is paid. |
| Paid, less than the order total | Wix is told the payment is declined, and the code logs that a part was paid. A card issuer can approve part of an amount: refund that part in MPS. |
| Failed | Wix is told the payment is declined. |
| Shopper left without paying | Wix is told the shopper canceled. |
MPS sends its webhook the moment a payment arrives. Wix learns that an order is paid only from that webhook,
so the webhook signing secret is required: connecting refuses to finish without it.
## Settings
| Setting | Where | What it does |
|---|---|---|
| `mps_api_key` | **Secrets Manager** | Your API key, sent with every call. A key starting `mps_test_` is a test key: MPS test cards only, no card charged. |
| `mps_webhook_secret` | **Secrets Manager** | The key's webhook signing secret. See [Webhook signing secret](#webhook-signing-secret). |
| `mps_gateway_url` | **Secrets Manager**, optional | Leave it out unless MPS asks you to set it. |
| Site address | **Accept Payments › Powered by MPS** | The address MPS sends its webhooks to: your site's address followed by `/_functions/mpsWebhook`. |
The name shoppers and the dashboard see is **Powered by MPS**, the same in every language.
## Refunds
Refund an order paid with MPS from **Orders** in your dashboard, in full or in parts. A refund MPS refuses is
not made, and Wix shows why.
A test key can always refund. A live key needs the refund permission first: ask MPS to add it to your key.
Every refund waits 4 hours before it is sent, and can be [canceled in MPS](/refunds#cancel-a-refund) until then.
Wix shows a refund as made as soon as MPS accepts it: a refund you cancel in MPS stays refunded in Wix, so
correct the order yourself.
## Updates
Replace the content of each file in your site with the file of the same name from the new zip, then publish
the site. `backend/mps/version.js` names the version you have.
## Not supported yet
- Currencies other than EUR. Wix refuses to connect MPS on a site whose currency is not EUR, and a payment in
another currency is declined.
- A logo next to **Powered by MPS** at checkout.
- Listing MPS in the Wix App Market. These files are for your own site.
## For your host or developer [#for-your-host-or-developer]
The details below are for whoever looks after your site's code.
### Webhooks
Every payment carries the webhook address built from the site address you entered when connecting, so there
is no address to register anywhere. The address is your site's address followed by `/_functions/mpsWebhook`,
served by `post_mpsWebhook` in `backend/http-functions.js`.
A webhook only tells the code to read the payment from MPS, and Wix is told what MPS answers, so a forged
webhook cannot mark an order paid. A payment MPS still reads as pending is answered `503`, and MPS delivers
the webhook again later. A repeated webhook tells Wix the same thing again and changes nothing.
### Webhook signing secret
Every webhook MPS sends is signed with a signing secret that belongs to your key. Every key issued in the MPS
platform, test or live, comes with one. The code checks the signature and that the webhook is less than five
minutes old, and refuses anything that does not match with `401`.
| | |
|---|---|
| What it looks like | `whsec_` followed by 43 characters |
| Where to get it | Shown with your key in **Online › API keys**. A new key comes with a new signing secret: save it again when you switch keys. |
| Where to save it | **Developer Tools › Secrets Manager**, as `mps_webhook_secret` |
When MPS issues you a new signing secret, the previous one keeps being accepted for 24 hours and
webhooks carry both signatures in that time. Save the new signing secret whenever it suits you
within that day; no webhook is lost.
### Refund permission [#refund-permission]
Refunding from Wix needs the `payments:refund` scope on the API key: a test key always has it, a live key
only once MPS granted it.
### How the key check works [#how-the-key-check-works]
To check the key when you connect, the code reads a payment that does not exist. MPS answers `404` to a key it
accepts, and `401` or `403` to a key it refuses. A `404` for that call in **Logs** is the check passing, not a
fault.
### Logs
The code writes every call to MPS to the site's logs (**Developer Tools › Logging Tools**), each line starting
`[MPS]`: never the API key, the webhook signing secret or payment links.
## Troubleshooting [#errors]
| What you see | Cause | What to do |
|---|---|---|
| **Powered by MPS** is not in **See More Payment Options** | The site is not published since the files were added, or the service plugin is not named `mps-payments`. | Check the folder name, then publish the site. |
| Connecting says the API key is missing | No `mps_api_key` in the Secrets Manager, or it does not start `mps_live_` or `mps_test_`. | Add the key in **Developer Tools › Secrets Manager**. |
| Connecting says the webhook signing secret is missing | No `mps_webhook_secret` in the Secrets Manager. | Add the key's webhook signing secret. |
| Connecting says MPS refused the API key | A wrong or revoked API key. A test key works until you revoke it. | Create a new key in **Online › API keys** and save it with its webhook signing secret. See [API key errors](/authentication#api-key-errors). |
| Connecting says the site address is not valid | The address does not start `https://`, or is not a public address. | Enter the address shoppers open, such as `https://www.myshop.be`. |
| An order stays waiting for payment after paying | The webhook did not reach the site, or was refused. | In the logs, look for *Webhook refused: signature or timestamp does not match* (the signing secret is not this key's), or for no `[MPS] Webhook` line at all (check the site address you connected with). |
## Related
- [Connect your webshop](/connect-your-webshop): the other shop systems, and the steps from test order to live
- [Switch to live payments](/take-live-payments#a-shop-plugin): from the test key to the live key
- For your developer: [Webhooks](/webhooks), [Payment lifecycle](/payment-lifecycle), [Refunds](/refunds) and
[Test mode and test cards](/online-payments#test-mode)