Classic | Posts: 13

Adding Signatures/Approvals [PHP]

0 votes

I tried the using the following but the code is a bit dated.

https://community.onespan.com/documentation/onespan-sign/codeshare/php-web-form-application-example

 

How to add Signatures required for the document?


Duo_Liang | Posts: 3776

Reply to: Adding Signatures/Approvals [PHP]

1 votes

Hi Classic,

 

Welcome to our community!

I have attached an example in PHP. Simply replace the API Key with your owns and you will be able to create and send a package.

Below package JSON was used in this example:
{
  "roles": [
    {
      "id": "Signer1",
      "signers": [
        {
          "email": "[email protected]",
          "firstName": "John",
          "lastName": "Smith"
        }
      ]
    }
  ],
  "documents": [
    {
      "approvals": [
        {
          "role": "Signer1",
          "fields": [
            {
              "page": 0,
              "top": 100,
              "subtype": "FULLNAME",
              "height": 50,
              "left": 100,
              "width": 200,
              "type": "SIGNATURE"
            }
          ]
        }
      ],
      "name": "Test Document"
    }
  ],
  "name": "PHP Example Package",
  "language": "en",
  "status": "SENT"
}

 

Customize the JSON (schema here) and you can design the package according to your requirement.

 

Duo


Attachments
Classic | Posts: 13

Reply to: Adding Signatures/Approvals [PHP]

0 votes

MOD DELETE


Classic | Posts: 13

Reply to: Adding Signatures/Approvals [PHP]

0 votes

MOD DELETE


Classic | Posts: 13

Reply to: Adding Signatures/Approvals [PHP]

0 votes

MOD DELETE


Classic | Posts: 13

Reply to: Adding Signatures/Approvals [PHP]

0 votes

Thanks for the reply! It guided me in the right direction!


Classic | Posts: 13

Reply to: Adding Signatures/Approvals [PHP]

0 votes

Hi,

Is it possible to get the token and iframe the URL for signer? I am able to get the token using the referenced codebase but having difficulty with your code.


Duo_Liang | Posts: 3776

Reply to: Adding Signatures/Approvals [PHP]

1 votes

I see, when defining package JSON, also set "id" under "signers" array:

    $json = [
       "roles" => [
             [
                "id" => "Signer1", 
                "signers" => [
                   [
                      "email" => "[email protected]", 
                      "firstName" => "John", 
                      "lastName" => "Smith",
                      "id" => "Signer1",
                   ] 
                ] 
             ] 
          ], 
       "documents" => [
                         [
                            "approvals" => [
                               [
                                  "role" => "Signer1", 
                                  "fields" => [
                                     [
                                        "page" => 0, 
                                        "top" => 100, 
                                        "subtype" => "FULLNAME", 
                                        "height" => 50, 
                                        "left" => 100, 
                                        "width" => 200, 
                                        "type" => "SIGNATURE" 
                                     ] 
                                  ] 
                               ] 
                            ], 
                            "name" => "Test Document" 
                         ] 
                      ], 
       "name" => "PHP Example Package", 
       "language" => "en", 
       "status" => "SENT" 
    ]; 

 

I've attached an updated code.

 

Duo


Attachments
Classic | Posts: 13

Reply to: Adding Signatures/Approvals [PHP]

0 votes

Hi Duo,

 

Thank you.

 

Is it possible to upload a second document and use the approval on that document page 0 versus counting how many pages in the initial document?


Duo_Liang | Posts: 3776

Reply to: Adding Signatures/Approvals [PHP]

1 votes

Hi Classic,

 

If you don't know the exact location to place signatures/fields before hand, there are many options to follow:
(1)You can use extraction methods like Text Tags or Document Extraction to automatically place signatures and fields

(2)Or you can use either Position Extraction or Text Anchors to locate the field, then reference the field in JSON

Among above four solutions,

#1 Document Extraction and Position Extraction use PDF form fields,

#2 Text Tags and Text Anchors use the text, hence they can be used in any supported file types,

#3 Document Extraction, Position Extraction and Text Tags requires your doc team to add specific form/tag in the document, while Text Anchors can use the existing content in the document, thus can be used when you don't have access to modify the document.

 

On top of above four options, upload a second document with signature on page 0 also works. In that case, if you are making document 1 accept only, and document 2 with signature, the package JSON could look like below:

{
  "roles": [
    {
      "id": "Signer1",
      "signers": [
        {
          "email": "[email protected]",
          "firstName": "John",
          "lastName": "Smith",
          "id": "Signer1"
        }
      ]
    }
  ],
  "documents": [
    {
      "approvals": [
        {
          "role": "Signer1",
          "fields": []
        }
      ],
      "name": "Document1"
    },

    {
      "approvals": [
        {
          "role": "Signer1",
          "fields": [
            {
              "page": 0,
              "top": 100,
              "subtype": "FULLNAME",
              "height": 50,
              "left": 100,
              "width": 200,
              "type": "SIGNATURE"
            }
          ]
        }
      ],
      "name": "Document2"
    }

  ],
  "name": "Example Package",
  "language": "en",
  "description": "New Package",
  "status": "SENT"
}

 

Duo


Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off