# Magento

The PayLater plugin lets merchants integrate Buy Now, Pay Later (BNPL) into their Magento 2 stores, giving customers flexible payment options. This comprehensive guide walks you through the step-by-step installation and configuration process for a seamless integration.

## Download plugin

**Download:** [Magento 2 / Adobe Commerce v4.1.5 · latest](https://docs.paylaterapp.com/downloads/PayLater_PayLaterpay-4.1.5.zip) ([release notes](https://docs.paylaterapp.com/release-notes.html#magento-4-1-5))

Always install the latest version. Older releases are deprecated — see the [release notes](https://docs.paylaterapp.com/release-notes.html) for the full version history.

> **Note: PHP requirement**
>
> The PayLater plugin needs **PHP 8.2 or newer**. Keep PHP up to date with the latest security release for your version.

## Compatibility

| Component | Supported |
| --- | --- |
| Platform | Magento 2.4.x, Adobe Commerce 2.4.x, Mage-OS (tested on Mage-OS 3.6.0, Magento 2.4.9 code base) |
| PHP | 8.2 or newer (tested on 8.3) |
| Cron | Magento cron must be running. The plugin reconciles pending PayLater orders every 10 minutes. |
| Store currency | QAR |
| Install method | Manual (`app/code`). The package is not available through Composer. |

## Manual setup

The zip already contains the `PayLater/PayLaterpay` folder, so extract it straight into `app/code/`. Do not create the `PayLater/PayLaterpay` folder yourself first, or the module ends up one level too deep and Magento cannot find it.

Run every command below as the user that owns the Magento files (usually the web server user, for example `www-data`), not as `root`. Files created by `root` stop the store and later commands from writing to `generated/` and `var/`.

- Extract the zip into your Magento 2 `[ROOT]/app/code/` directory.
- Check that `[ROOT]/app/code/PayLater/PayLaterpay/registration.php` exists.
- Enable the module:

```bash
cd [ROOT]
unzip PayLater_PayLaterpay-<version>.zip -d app/code/
php bin/magento module:enable PayLater_PayLaterpay
```

- Then run the following commands in order. Run `setup:static-content:deploy` only if your store is in production mode (check with `php bin/magento deploy:mode:show`). In default and developer mode Magento builds static files itself and refuses to run it.

```bash
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
php bin/magento cache:flush
```

### Upgrading

- Put the store into maintenance mode: `php bin/magento maintenance:enable`.
- Delete `[ROOT]/app/code/PayLater/PayLaterpay`, then extract the new zip into `app/code/` as above. Your admin settings are kept, because they are stored in the database.
- Run the four commands above, then `php bin/magento maintenance:disable`.

### Removing the plugin

```bash
php bin/magento module:disable PayLater_PayLaterpay
rm -rf app/code/PayLater/PayLaterpay
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento cache:flush
```

In production mode, also run `setup:static-content:deploy` before `cache:flush`. `setup:upgrade` clears the compiled code, so the store shows errors until it is compiled again.

Before you remove it, wait until no orders are still waiting for a PayLater payment. Pending orders are only reconciled while the module is enabled.

### Frontend widgets

PLP — Product List Page

![PayLater widget on the Magento product list page](https://docs.paylaterapp.com/assets/img/plugins/magento/01.png)

PDP — Product Detail Page

![PayLater widget on the Magento product detail page](https://docs.paylaterapp.com/assets/img/plugins/magento/02.png)

![PayLater instalment breakdown on the Magento product detail page](https://docs.paylaterapp.com/assets/img/plugins/magento/03.png)

Log in to your Magento Admin Panel.

![Magento Admin Panel login screen](https://docs.paylaterapp.com/assets/img/plugins/magento/04.png)

## Admin configuration

Admin configuration is a crucial step in setting up the PayLater plugin in your Magento 2 store. In this section you'll access the Magento Admin Panel and navigate through specific settings to tailor the PayLater payment gateway to your preferences.

- Log in to your Magento Admin Panel.
- Navigate to **Stores → Configuration → Sales → Payment Methods** and expand the **Other Payment Methods** tab. You will see the **PayLater — Shop Now Pay Later** option.

![PayLater under Other Payment Methods in Magento configuration](https://docs.paylaterapp.com/assets/img/plugins/magento/05.png)

## Payment settings

| Setting | What to enter |
| --- | --- |
| Enabled | Turns the PayLater payment method on or off. |
| Title | The payment method name shown at checkout. |
| Client ID | Your OAuth client ID from PayLater, for example `merchant-815`. |
| Client Secret | Your OAuth client secret from PayLater. |
| Webhook Secret | Provided by PayLater after they register your webhook URL (see below). |
| Minimum Order Amount | Smallest order total that can use PayLater. Must be 300 or higher; lower values are rejected on save. |
| Outlet ID | Your outlet ID from PayLater. |
| Payment Mode | **UAT** for testing with the [test credentials](https://docs.paylaterapp.com/test-environment.html), **Live** for production. Use the credentials that match the mode. |
| Enable Logging | Logs every PayLater action. Useful while testing; turn it off in production. |
| Pre-Checkout Inventory Check | Checks stock before redirecting the shopper to PayLater. Turn it off for stores that use multi-source inventory or external stock management. Magento still checks stock when the order is placed. |
| Sort Order | Position of PayLater in the list of payment methods. |

Your webhook URL is `https://<your-store>/ppaylater/webhook/notify`. Send it to the PayLater team; they register it and give you the **Webhook Secret**.

Under **Widget Settings** you can turn the PayLater widget on or off for the product list page and the product detail page, and set its main heading, sub heading and terms text.

![PayLater payment settings in the Magento admin](https://docs.paylaterapp.com/assets/img/plugins/magento/06.png)

![PayLater payment settings — Client ID, Client Secret and Outlet ID fields](https://docs.paylaterapp.com/assets/img/plugins/magento/07.png)

- Save the configuration and **clear the cache**.

## Testing

To ensure smooth functionality, it's recommended to test the PayLater payment option:

- Add a product to your cart and proceed to checkout.
- During checkout, select **PayLater** as the payment method.
- You will be redirected to the secure PayLater platform to complete the BNPL payment process.
- Use a test shopper account from the [Test environment](https://docs.paylaterapp.com/test-environment.html).
- Please use **300 QAR** as the amount to test.

> **Note: Order numbers PayLater has already seen**
>
> The test credentials are shared by many stores, and a new Magento store numbers its orders from `000000001`. If PayLater already holds an order number, the plugin retries once with a short suffix, for example `000000123-a7f2`. That reference is what appears in the PayLater merchant portal for the order; the Magento order number does not change. Versions before 4.1.1 cancelled the order instead, so upgrade if you see `Order ID already exists`.

> **Note: Credentials**
>
> Get your `Client ID`, `Client Secret`, and `Outlet ID` from your PayLater account dashboard. For your `Webhook Secret`, share your webhook endpoint with the PayLater team. For sandbox values and test shoppers, see the [Test environment](https://docs.paylaterapp.com/test-environment.html).
