# Pandadoc integration with e-signature in CPQ

- Published on Nov 15, 2023

- 2 minute(s) read

## PandaDoc configuration

# ADL Configuration

Code snippet

```xml
    <prop key="cpq-signing-enabled">1</prop>

<prop key="pandadoc-prefix">pandadoc-</prop>

<prop key="pandadoc-base-url">https://api.pandadoc.com</prop>
    <prop key="pandadoc-oauth-version">2.0</prop>
    <prop key="pandadoc-oauth-clientid">AABBCC</prop>
    <prop key="pandadoc-oauth-clientsecret">DDEEFF</prop>
    <prop key="pandadoc-oauth-scope">read write</prop>
    <prop key="pandadoc-oauth-authurl">https://app.pandadoc.com/oauth2/authorize</prop>
    <prop key="pandadoc-oauth-accesstokenurl">https://api.pandadoc.com/oauth2/access_token</prop>
    <prop key="pandadoc-oauth-redirecturi">https://apps.mobileforcesoftware.com/mobileforce/oauth_redirect</prop>
    <prop key="pandadoc-oauth-accessmethod">header</prop>
    <prop key="pandadoc-oauth-clientauthmethod">requestparams</prop>

<prop key="pandadoc-auth-type">oauth2</prop>
    <prop key="pandadoc-api-key">PAPIKEY</prop>
    <prop key="pandadoc-wait-seconds-for-draft-status">10</prop>
    <prop key="pandadoc-status-check-internal-seconds">2</prop>
```

HTML, XML

- cpq-signing-enabled - This prop is used to enable either DocuSign or PandaDoc system
- pandadoc-base-url - Default value is https://api.pandadoc.com
- pandadoc-api-key - If auth-type is "api_key", this prop is required
- pandadoc-auth-type - Can be either oauth2 or api_key. Default value is "oauth2"
- pandadoc-wait-seconds-for-draft-status - To send a doc for signature it is a two-step process. We need to create a document and wait for the document to change from "document.uploading" to "document.draft" status. This prop specifies the wait time for the document to change from uploading to draft status. Default value is '10' seconds.
- pandadoc-status-check-interval-seconds - Default value is '2' seconds. Every two seconds an API call will be made to check whether the document has changed from uploading to draft.

# Document Template Setup

For PandaDoc you need to set up two JSON configurations in the document template screen. The JSON can have CPQ specific template string "${}"
- PandaDoc Document JSON - This contains information about the signer and fields. [(Create Document for PDF)](https://developers.pandadoc.com/reference/new-document#create-document-from-pdf)
- PandaDoc Send Email JSON - This has email subject information. [(Send Document)](https://developers.pandadoc.com/reference/send-document)

# PandaDoc setup

PandaDoc supports two types of authentication:

# Authentication

- API key - To get the key, log in to PandaDoc and go to Settings->API & Integration->API (see screenshot)
- OAuth2 - To set up OAuth2 log in to PandaDoc and go to Settings->API & Integration->API->Sandbox API Setup [(My Application)](https://documentation.mobileforcesoftware.com/docs/my_application.jpg)
  - Enter the application name and redirect URL [Redirect URL](https://documentation.mobileforcesoftware.com/docs/oauth2_setup.jpg) [(see screenshot)](https://documentation.mobileforcesoftware.com/docs/oauth2_setup.jpg)

# Webhook setup

Enter the webhook URL as https://apps.mobileforcesoftware.com/cpq/public/client/service/pandaDocWebhook.php [(see screenshot)](https://documentation.mobileforcesoftware.com/docs/webhook_setup.jpg). Please make sure you have selected the metadata checkbox.

# PandaDoc Document JSON

Below is the sample Document JSON

Code snippet

```json
{
    "name": "Sample Document from PDF with Field Tags",
    "recipients": [
        {
            "email": "name@email.com",
            "first_name": "Name",
            "last_name": "LastName",
            "role": "user"
        }
    ],
    "fields": {
        "name": {
            "value": "Jane",
            "role": "user"
        },
        "like": {
            "value": true,
            "role": "user"
        }
    },
    "parse_form_fields": false
}
```

# PandaDoc Send Email JSON

Below is the sample Send Email JSON

Code snippet

```json
{
    "message": "Hello! This document was sent from the PandaDoc API.",
    "silent": true
}
```

# PandaDoc Document Tag

PandaDoc follows inline special text (for e.g. '{signature:user_____}' ) for specifying tags for signing. For more info [click here](https://developers.pandadoc.com/reference/new-document#create-document-from-pdf)

Code snippet

```none
Hello, {text:user:name} Please,​ ​fill​ ​this​ ​form:

Home​ ​address: {textfield:user________________} Date​ ​of​ ​Birth: {date:user__}

Do​ ​you​ ​like​ ​using​ ​APIs? {checkbox*:user:like}

Signature: {signature:user_______} Initials: {initials:user}
```

# PandaDoc Demo App

For testing, ask PandaDoc or your Mobileforce customer success team for a test account

Code snippet

```none
account: someaccount
app: someapp
login: user@email.com
password: pwd
```

# On-boarding New Customer

1. First, the customer has to set up OAuth Application - https://developers.pandadoc.com/reference/authentication-process
2. Update the ADL prop with OAuth Info
3. Update CPQ -> Document Template -> Signature with the right info
4. Update the “PandaDoc Document JSON” (contains information about whom to send email)
5. Update the “PandaDoc Send Email JSON” (contains information about email subject/body)
6. Update the uploaded document template as per the “PandaDoc Document Tag” section.
