# PayPal

Source: https://kart.bnomei.com/docs/providers/paypal
Updated: 2025-08-08T14:20:54+00:00
Summary: Integrate PayPal payments in Kirby CMS with bnomei.kart: set API credentials, sandbox/production endpoints, virtual fields, and customize checkout via callbacks

> PayPal has no dashboard to create products afaik, but they will be synced if you create some via their API.  
> Make sure to target the right `endpoint` as it has one each for sandbox and production environments.

## Using the provider

Path: site/config/config.php  
Code (php):  
```
<?php

return [
   'bnomei.kart.provider' => 'paypal',
   // other options
];
```

  
## Virtual Fields

You can define which fields are treated as purely virtual and fetched from the provider ignoring any changes you make within the panel.

Code (php):  
```
<?php

return [
 'bnomei.kart.providers.paypal.virtual' => true,
 // 'bnomei.kart.providers.paypal.virtual' => ['raw', 'title', 'description', 'gallery'],

 // other options
];
```

  
## API Credentials

You can create the `CLIENT ID` and `SECRET` within the [PayPal developer dashboard](https://developer.paypal.com/dashboard/applications/sandbox). Make sure to start testing your application in **Sandbox**-mode. You need to provide the credentials as config values or via an `.env` file ([plugin](https://github.com/bnomei/kirby3-dotenv)).

![](https://kart.bnomei.com/media/pages/media/b9cf5675ae-1746706068/paypal-1920x.webp)  
Path: .env  
Code (plaintext):  
```
PAYPAL_CLIENT_ID=XXX
PAYPAL_CLIENT_SECRET=ZZZ
PAYPAL_ENDPOINT=https://api-m.sandbox.paypal.com
# PAYPAL_ENDPOINT=https://api.paypal.com
```

  
## Customzing the Checkout

You can use callbacks to customise both the checkout process and each line item. The returned arrays from your callbacks will be merged with the defaults created by the plugin for this provider, allowing you to override those defaults. Check the relevant PHP class and the linked online documentation for the provider to learn more about the expected data structure.

Code (php):  
```
<?php

return [
    'bnomei.kart.providers.paypal.checkout_options' => function (\Bnomei\Kart\Kart $kart) {
        // configure the checkout based on current kart instance
        // https://developer.paypal.com/docs/api/orders/v2/#orders_create
        return [];
    },
    'bnomei.kart.providers.paypal.checkout_line' => function (\Bnomei\Kart\Kart $kart, \Bnomei\Kart\CartLine $line) {
        // add custom data to the current checkout line
        return [];
    },
    // other options
];
```

  