PHP Classes
PHP Classes
elePHPant
Icontem

How to Integrate a Print-to-Mail PHP API into Your Software to Send PDF Statements via the Post Office - Docusend PHP package blog

Recommend this page to a friend!
  All package blogs All package blogs   Docusend PHP Docusend PHP   Blog Docusend PHP package blog   RSS 1.0 feed RSS 2.0 feed   Blog How to Integrate a Pr...  
  Post a comment Post a comment   See comments See comments (0)   Trackbacks (0)  

Author:

Updated on: 2018-11-08

Posted on:

Package: Docusend PHP

Many companies need to deliver printed documents via postal mail like for instances bills, invoices and other types of documents to be made available to the company customers in paper.

DocuSend provides a Web services API that addresses this need by allowing businesses to generate the documents to be delivered via Post Office and then the company takes care of printing and delivering the documents via the United States Postal Service.

Read this article to learn how you can benefit from the DocuSend services, so you can integrate the delivery of printed documents in a PHP application that implement parts of the businesses that need to deliver those documents by postal mail.




Why the Delivery of Printed Documents by Postal Mail is Still Important in 2018?

Recent surveys, show that over 70% of US households prefer to receive invoices and statements through postal mail over email attachments.

In addition, it is a legal requirement to send some types communication via United States Postal Mail, like for instance, certain financial documents, legal notices, or service change notices.

As much as we might wish we could just send emails for everything, spam and phishing concerns make sending sensitive documents by US mail safer and more reliable than email, which is why a large majority of your users' clients may prefer it.

Also, many states have legal requirements that certain documents must be sent via the Post Office, and these may even have to be sent certified. That fact that your clients may not be able to use email to save postage and time has been a nuisance in the past, but not anymore.

The normal approach is to have the user print them internally and then go through the process of manually folding, stuffing, stamping, and delivering them to a postal facility. That causes a sequential vortex because they need a correctly configured printer, and they have to keep inventory for stamps, envelopes, paper, etc.

The DocuSend cloud service sends their documents directly to a U.S. Postal delivery center for them as easily, if not easier, than sending an email. The DocuSend service provides a simple REST API to work with it.

This article shows you how to setup a simple REST API that gives your users the option to send documents via US mail as easily as sending email, either with a menu option or a "Send US Mail" button.

How to Start Sending Print Documents for Postal Mail Delivery using PHP

To get started with the API, go this page to create an account with DocuSend. This is a master account. All additional accounts will be associated with this one. This is important to you because DocuSend pays a royalty of 4 cents per envelope that is mailed to those who integrate with them.

After you have signed up, you will be given credentials to use in your integration. You will also have an engineer assigned to help you, although it is simple enough that you probably won't need much help, if any.

You can retrieve the most up-to-date wrapper class for the REST API from GitHub. This wrapper handles how to send things to the server and get them back much easier than writing your own.

Once you have added this wrapper to your application, you have a few tasks to perform.

How to Setup the Parameters to Access the DocuSend API

API requests should be sent to Sandbox API Endpoint:  http://sandbox.docusend.biz/incoming/api

Set the right parameters in lib/connection.php

$testServer = "http://sandbox.docusend.biz/incoming/api";
$UserEmail = "name@anydomain.com";
$UserPassword = "Testing";

How to Setup New Company Clients

If your application is used by many different companies, those companies will most likely want their own account with DocuSend. This is easy to provide.

require_once ('lib/DocusendAPI.php');
require_once ('lib/connection.php');
$api = new DocusendAPI($testServer, $UserEmail, $UserPassword);

echo "<br>Create new company<br>";
$aParms = array(
    'CompanyName' => 'Interpal Group',
    'Address1' => '141 Elm Street',
    'Address2' => 'Suite 01',
    'City'=>'Anytown',
    'State'=>'AL',
    'ZipCode'=>'14471',
    'CompanyPhone'=>'5550407',
    'Email'=>'name@domain.com',
    'FullName'=>'John Smith',
    'Password' => 'testing');

$result = $api->PostCompany($aParms);
print_r($result);

if ($api->httpcode == 201) {
    $login = json_decode($result, true);
    $newLogin = $login['Email'];
    $newPassword = $login['Password'];


You will used $newLogin and $newPassword to login in as the new company into the API.

How to Send a Print Document for Delivery

require_once ('lib/DocusendAPI.php');
require_once ('lib/connection.php');
$api = new DocusendAPI($testServer, $UserEmail, $UserPassword);

$results = $api->PostJob("C:\\Testing\\Issues\\Invoice.PDF", 0, 0, 0);
$aJob = json_decode($results, true);

if (isset($aJob['ID']))
    $jobID = $aJob['ID'];
while ($jobID) {
    $results = $api->GetJob($jobID);
    $aJob = json_decode($results, true);
    if (isset($aJob['ChargeAmount']))
        break;
}
echo "Job Finished " . print_r($aJob, true);

How Pay for Documents to be Sent via Postal Mail

require_once ('lib/DocusendAPI.php');
require_once ('lib/connection.php');
$api = new DocusendAPI($testServer, $UserEmail, $UserPassword);

$aCreditCard = array(
    'CompanyName' => 'Interpal Group',
    'Address1' => '141 Elm Street',
    'Address2' => 'Suite 01',
    'City' => 'Anytown',
    'State' => 'Alabama',
    'Zipcode' => '14471',
    'Country' => 'CR',
    'Phone' => '5550407',
    'Email' => 'name@anydomain.com',
    'CreditCardNumber' => '6011000000000012',
    'ExpirationMonth' => '02',
    'ExpirationYear' => '2025',
    'CCV' => '123',
    'FullName' => 'John Smith',
    'QuickPay' => 0);
$result= $api->GetPay();
$aPay = json_decode($result, true);
if (!empty($aPay['AmountDue']) && $aPay['AmountDue']>0.00 ) {
    $payment = $api->PutPay("Credit Card", $aPay['AmountDue'], $aCreditCard);
    var_dump($payment);
}

How to Save Your Customers Money While You Can Make Money by Sending Postal Mail via DocuSend

Setting up the DocuSend REST API will make life much easier for your customers and save them at least 50% over processing their mailings manually.

At the same time, you can also make more money by earning 4 cents per envelope that your customers want to deliver by postal mail. With as little time as it takes to implement the DocuSend API, it can also make you more money for you too as PHP developer.

There are many other features available in the DocuSend API, such as certified mail and foreign mail.  If there are any you’re looking for that are not listed on our website, talk to us as we may well be able to address your needs.

For now watch more videos in DocuSend site, so you can learn more about the benefits of these services.




You need to be a registered user or login to post a comment

1,512,413 PHP developers registered to the PHP Classes site.
Be One of Us!

Login Immediately with your account on:

FacebookGmail
HotmailStackOverflow
GitHubYahoo


Comments:

No comments were submitted yet.




  Post a comment Post a comment   See comments See comments (0)   Trackbacks (0)  
  All package blogs All package blogs   Docusend PHP Docusend PHP   Blog Docusend PHP package blog   RSS 1.0 feed RSS 2.0 feed   Blog How to Integrate a Pr...