PHP code example of trustev / phpclientapi

1. Go to this page and download the library: Download trustev/phpclientapi library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

trustev / phpclientapi example snippets





// 1. Set-Up the Trustev Api Client with your user credentials
// If none is specified it defaults to the constants in Settings.php (have a look if you are unsure)
ApiClient::SetUp($userName, $password, $secret, $baseUrl);


// 2. Create your case and POST this Case to the Trustev API.
// You will need two bits of information for this step
// 		SessionId : This is the SessionId that you have received from the Trustev JavaScript (Trustev.js)
//					and transferred server-side.
// 		CaseNumber : This is a number that you use to uniquely identify this Case - we recommend using your internal Order Number for the Case Number. 
					It must be unique per Case request.
$kase = new CaseBase(array(
							'SessionId' => $SessionId,
                             'CaseNumber' => $caseNumber
                             ));
						

// Now add any further information you have. The more you give us, the more accurate 
// our Decisions.
$kase->Customer = new Customer(array(
                                        'FirstName' => "John",
                                        'LastName' => "Doe"
                                    ));


// Post this Case to the Trustev Api
$caseReturn = ApiClient::PostCase($kase);


// 3. You can now get your Decision from Trustev based on the Case you have given us
$decision = ApiClient::GetDecision($caseReturn->Id);


// 4. Now it's up to you what to do with our Decision, and then updating the Case Status with what the order outcome was.
$status = new Status(array(
							'Status' => 0,
							'Comment' => "Order Completed Successfully"
						));
$statusReturn = ApiClient::PostCaseStatus($caseReturn->Id, $status);




// 1. Set-Up the Trustev Api Client with your user credentials
// If none is specified it defaults to the constants in Settings.php (have a look if you are unsure)
ApiClient::SetUp($userName, $password, $secret, $baseUrl);


// 2. Create your case.
// You will need two bits of information for this step
// 		SessionId : This is the SessionId that you have received from the Trustev JavaScript (Trustev.js)
//					and transferred server-side.
// 		CaseNumber : This is a number that you use to uniquely identify this Case - we recommend using your internal Order Number for the Case Number. 
					It must be unique per Case request.
$kase = new CaseBase(array(
							'SessionId' => $SessionId,
                             'CaseNumber' => $caseNumber
                             ));

// 3. Post this Case to the Trustev API
$returnCase = ApiClient::PostCase($kase);


// 4. You may now want to add a Customer to the Case you have already added.
//    First let's create the customer.
$customer = new Customer(array(
                                        'FirstName' => "John",
                                        'LastName' => "Doe"
                                    ));

//    Now we can go ahead and add the Customer to the Case we added earlier.
$returnCustomer = ApiClient::PostCustomer($returnCase->Id, $customer);


// 5. You can now continue as normal and get the Decision of this Case including
//    the new Customer you have added
$decision = ApiClient::GetDecision($returnCase->Id);


// 6. Now it's up to you what to do with our Decision, and then updating the Case Status with what the order outcome was.
$status = new Status(array(
							'Status' => 0,
							'Comment' => "Order Completed Successfully"
						));
$statusReturn = ApiClient::PostCaseStatus($caseReturn->Id, $status);



// 1. Set-Up the Trustev Api Client with your user credentials
// If none is specified it defaults to the constants in Settings.php (have a look if you are unsure)
ApiClient::SetUp($userName, $password, $secret, $baseUrl);


// 2. Create your case.
// You will need two bits of information for this step
// 		SessionId : This is the SessionId that you have received from the Trustev JavaScript (Trustev.js)
//					and transferred server-side.
// 		CaseNumber : This is a number that you use to uniquely identify this Case - we recommend using your internal Order Number for the Case Number. 
					It must be unique per Case request.
$kase = new CaseBase(array(
							'SessionId' => $SessionId,
                             'CaseNumber' => $caseNumber
                             ));
							 
$kase->Transaction = new TransactionBase(array(
							'Currency' => "USD",
                             'TotalTransactionValue' => 10
                             ));


// 3. Post this Case to the Trustev Api
$returnCase = ApiClient::PostCase($kase);


// 4. Now, say the value of this Transaction changes,
//	  We provide the functionality to update the Transaction you have already added.
//	  Just rebuild the Transaction again with the new information
$transaction = new TransactionBase(array(
							'Currency' => "USD",
                             'TotalTransactionValue' => 2000
                             ));

//    Now we can go ahead and add the Transaction to the Case we created earlier.
$returnTransaction = ApiClient::UpdateTransaction($returnCase->Id, $transaction);


// 5. You can now continue as normal and get the Decision of this Case including
//    the updated Transaction you have added.
$decision = ApiClient::GetDecision($returnCase->Id);


// Now it's up to you what to do with our Decision, and then updating the Case Status with what the order outcome was.
$status = new Status(array(
							'Status' => 0,
							'Comment' => "Order Completed Successfully"
						));
$statusReturn = ApiClient::PostCaseStatus($caseReturn->Id, $status);