2017-10-10 18 views
9

Trong dự án wp của tôi, tôi đang sử dụng Assently để triển khai chữ ký điện tử. Mặc dù tôi có một tài khoản và đã tạo một tệp biểu mẫu pdf để người dùng điền vào nhưng tôi không thể tiến hành một chút. Tôi đang tìm tài liệu không rõ ràng. Ngoài ra tôi không rõ ràng về những gì cần phải được thực hiện để người dùng sẽ được hiển thị biểu mẫu để xử lý giao dịch.cách tích hợp Assi api cho giao dịch chữ ký điện tử trong PHP

Vì vậy, bất kỳ trợ giúp/đề xuất nào để tiến hành đều được đánh giá cao.

Tôi đã thử các bước sau dựa trên assently-laravel. Nhưng nó yêu cầu tôi đăng nhập. Lỗi ở đây là gì? 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; 
+0

https://test.assently.com/api#communication Điều gì không rõ ràng? – Stefan

+0

@Stefan Tôi không thể hiểu cách hiển thị biểu mẫu có thể điền pdf khi nhấp và sau đó hoàn thành toàn bộ giao dịch. –

+0

@Stefan bạn có thể cung cấp một số mã về cách thực hiện hoặc hướng dẫn tôi tại đây không. –

Trả lời

0

tạo lớp này bên trong thư mục assently

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; 
    } 
} 

Sử dụng

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); 

Hãy thử điều này, mặc dù chưa được thử nghiệm nhưng nên làm việc. Chúc may mắn.

Các vấn đề liên quan