trustev/phpclientapi

本包最新版本(v0.3)没有提供许可证信息。

Trustev API的PHP包装器

v0.3 2016-11-03 14:50 UTC

This package is not auto-updated.

Last update: 2024-09-28 18:58:35 UTC


README

⛔ [已弃用]

此库已弃用,您应使用Web API。

http://www.trustev.com/developers

alt text

#Trustev PHP 库

##要求

  • PHP 5.3+

##安装 ####Composer 您可以通过Composer安装它。将其添加到您的composer.json

{
"require" : {
	"trustev/phpclientapi" : "dev-master"
	}
}

然后通过以下方式安装:

composer install

要使用绑定,请使用Composer的自动加载

require_once('vendor/autoload.php');

####下载和解包

  • 只需使用curl命令下载并解包即可

      	$> curl -L https://github.com/Trustev/phpclientapi/tarball/latest | tar zx
    
  • 或者使用wget命令

      	$> wget --no-check-certificate https://github.com/Trustev/phpclientapi/tarball/latest -O - | tar xz
    

使用方法

Trustev API已设计为允许用户完全控制他们向我们发送的信息,同时确保Trustev集成可以在几个简单步骤中完成。

简单Trustev集成

这是一个简单的Trustev集成版本,涉及4个简单步骤。

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

可选集成步骤

我们还提供了详细API端点以更新您案例的特定部分。这些步骤可以在需要时使用。以下是一些示例。

示例:添加客户
// 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);

我们为案例对象的每个子实体提供了类似的功能,即Post(POST)、Update(PUT)和Get(GET)。