26

In my wp project, I am using Assently for e-signature implementation. Though I have an account and created a pdf form file to be filled by the user I just am not able to proceed a bit. I am finding documentation not clear. Also, I am not clear about what needs to be done so that the user will be shown form to process the transaction.

So, any help/suggestions to proceed forward is appreciated.

I have tried the following based on assently-laravel. But it's asking me to login. What is an error here? Code:

define('ASSENTLY_DEBUG', true);
define('ASSENTLY_KEY', 'key');
define('ASSENTLY_SECRET', 'secret-generated');

include_once('assently/Assently.php');
$assently = new Assently();
$assently->authenticate(ASSENTLY_KEY, ASSENTLY_SECRET);

$url = 'https://test.assently.com/api/v2/createcasefromtemplate';
$default = array(
    'Id' => '5a0e0869-' . rand(1111, 9999) . '-4b79-' . rand(1111, 9999) . '-466ea5cca5ce'
);
$data = array(
    'auth' => $assently->auth(),
    'templateId'    => '0e004e2b-b192-4ce2-8f47-d7a4576d7df6',
    'newCaseId'     => '5a0e0869-' . rand(1111, 9999) . '-4b79-' . rand(1111, 9999) . '-466ea5cca5ce',
    'agentUsername' => ''
);

$data = array(
    'json' => $data
);
$options = array(
    'http' => array(
        'header'  => "Content-type: application/json; charset=utf-8\r\n",
        'method'  => 'POST',
        'content' => http_build_query($data)
    )
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo '<pre>';
print_r($result);
die;
hasumedic
  • 2,069
  • 9
  • 16
samjhana joshi
  • 1,835
  • 4
  • 33
  • 62
  • https://test.assently.com/api#communication What is unclear? – Stefan Oct 10 '17 at 10:33
  • @Stefan I am not able to understand how to show pdf fillable form on click and then complete the whole transaction. – samjhana joshi Oct 10 '17 at 10:55
  • @Stefan can you provide some codes on how to do it or guide me here. – samjhana joshi Oct 11 '17 at 04:33
  • I think it's best to ask a new question and provide some more details. If you want to know how to show a form based on on-click, you should start there. It's good to know that I don't know anything about `Assently` ;-) – Stefan Oct 11 '17 at 07:45
  • you are not sending the authentication in your request. You authenticated but no authentication sent in your request. check it once – rkj Nov 16 '17 at 10:49
  • try removing auth from top data array and put it with json data array. $data = array( 'json' => $data, 'auth' => $assently->auth() ); – rkj Nov 16 '17 at 11:01
  • @RKJ no it's not working :( – samjhana joshi Nov 17 '17 at 03:36

1 Answers1

1

create this class inside assently folder

use Assently\AssentlyCase;
use Exception;

class  CustomAssentlyCase extends AssentlyCase 
{
    public function createFromTemplate($data)
    {
        $default = [
            'newCaseId' => '5a0e0869-'.rand(1111, 9999).'-4b79-'.rand(1111, 9999).'-466ea5cca5ce'
        ];

        $json = array_merge($default, $data);

        try{
            $response = $this->client->post($this->url('createcasefromtemplate'), [
                'auth' => $this->assently->auth(),
                'json' => $json
            ]);

        }catch(Exception $e){
            print_r($e->getMessage());
        }
        return $response;
    }
}

Use

define('ASSENTLY_DEBUG', true);
define('ASSENTLY_KEY', 'key');
define('ASSENTLY_SECRET', 'secret-generated');

include_once('assently/Assently.php');
include_once('assently/CustomAssentlyCase.php');
$assently = new Assently();
$assently->authenticate(ASSENTLY_KEY, ASSENTLY_SECRET);

$data = array(
    'templateId' => '0e004e2b-b192-4ce2-8f47-d7a4576d7df6',
    'newCaseId' => '5a0e0869-'.rand(1111, 9999).'-4b79-'.rand(1111, 9999).'-466ea5cca5ce',
    'agentUsername' => 'agentUsername' // PUT your agent username here it is required
);

$customAssentlyCase = new CustomAssentlyCase($assently);
$result = $customAssentlyCase->createFromTemplate($data);
print_r($result);

Try this, though not tested but should work. Good luck.

rkj
  • 6,768
  • 2
  • 20
  • 27