---
updatedAt: 2026-03-02T15:55:37.000Z
agentTools:
  projectIndex: https://docs.br-dge.io/llms.txt
---

# PayPal Smart Module

<Callout icon="❗️">
  The PayPal Smart module has been deprecated. It should no longer be used for new PayPal integrations.

  Please use the dedicated <Anchor label="PayPal guide" target="_blank" href="/docs/paypal">PayPal guide</Anchor> when integrating PayPal via **BR-DGE**
</Callout>

Enable <Glossary>payments</Glossary> with \[PayPal]. This works by integrating with PayPal APIs to generate a single use PayPal nonce, which can be used by your server as a <Glossary>payment instrument</Glossary> with the [BR-DGE REST API].

<Image align="center" src="https://files.readme.io/3690a49-comcarde-web-paypal-smart-module-components.svg" />

## Add the PayPal Smart Module to your App

After you have set up the [Comcarde JavaScript Client], you can add the following to your website source.

```Text Script for Sandbox Testing
<script src="https://sandbox-assets.comcarde.com/web/v2/js/paypal-smart.min.js"></script>
```
```Text Script for Production Testing
<script src="https://assets.comcarde.com/web/v2/js/paypal-smart.min.js"></script>
```

Next, insert a placeholder element for the PayPal Button to target and load. In the example below we have chosen the id of `paypal-button`. This is the default container id that the module will use.

```html
<div id="paypal-button"></div>
```

If you wish to use another id attribute, this is an option you can choose as part of the configuration and, as shown above, is set to the default value of `paypal-button`. You can set this to any id attribute you require, but this must be passed into the options of the `paypalSmart.create` method.

**Example:**

### Default Container ID

```html
<div id="paypal-button"></div>
```

```js
comcarde.paypalSmart.create({
  client: clientInstance
}, ...
```

### Custom Container ID

```html
<div id="my-paypal-id"></div>
```

```js
comcarde.paypalSmart.create({
  client: clientInstance,
  containerId: 'my-paypal-id'
},  ...
```

Finally, add the PayPal Smart functionality to your [Comcarde JavaScript Client]:

```js
comcarde.client.create(
  {
    authorization: client - api - key, // your client API Key
  },
  function (clientErr, clientInstance) {
    // optionally configure other plugin modules...

    /*
     * Create a paypal-smart plugin module component. This example uses the default
     * container id attribute of paypal-button
     */
    comcarde.paypalSmart.create(
      {
        client: clientInstance,
        currency: 'GBP', // currency code of the amount
      },
      createOrder,
      onApprove,
      onCancel,
      onError
    )

    /*
     * Callback promise allowing you to provide checkout data after your user clicks the
     * paypal button
     */
    function createOrder() {
      return new Promise((resolve, reject) => {
        resolve({
          // amount of the transaction in the lowest denomination of the given currency.
          amount: 1234,
          // unique customer order code to represent the transaction.
          customerOrderCode: 'abc-1234',
        })
      })
    }

    /*
     * Callback method providing you with a nonce that can be used as a PayPal Payment
     * Instrument by your server.
     */
    function onApprove(nonce) {
      console.log('Got a PayPal nonce: ' + nonce)
    }

    /*
     * Callback method for when your user decides to cancel using PayPal
     */
    function onCancel(onCancelEvent) {
      console.log(onCancelEvent)
    }

    /*
     * Callback method for when an error is encountered
     */
    function onError(onErrorEvent) {
      console.error(onErrorEvent)
    }
  }
)
```

[comcarde javascript client]: web-sdk-introduction#comcarde-javascript-client

[br-dge rest api]: /reference/

[paypal smart buttons]: https://developer.paypal.com/docs/checkout/