Server : Apache System : Linux 145.162.205.92.host.secureserver.net 5.14.0-611.45.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Apr 1 05:56:53 EDT 2026 x86_64 User : tradze ( 1001) PHP Version : 8.1.34 Disable Function : NONE Directory : /home/tradze/www/vendor/braintree/braintree_php/lib/Braintree/ |
<?php
namespace Braintree;
/**
* Braintree CreditCardVerificationGateway module
* Creates and manages CreditCardVerifications
*/
class CreditCardVerificationGateway
{
private $_gateway;
private $_config;
private $_http;
// phpcs:ignore PEAR.Commenting.FunctionComment.Missing
public function __construct($gateway)
{
$this->_gateway = $gateway;
$this->_config = $gateway->config;
$this->_config->assertHasAccessTokenOrKeys();
$this->_http = new Http($gateway->config);
}
/**
* Creates a credit card verification using the given +attributes+.
*
* @param array $attributes containing request parameters
*
* @return Result\Successful|Result\Error
*/
public function create($attributes)
{
$queryPath = $this->_config->merchantPath() . "/verifications";
$response = $this->_http->post($queryPath, ['verification' => $attributes]);
return $this->_verifyGatewayResponse($response);
}
private function _verifyGatewayResponse($response)
{
if (isset($response['verification'])) {
return new Result\Successful(
CreditCardVerification::factory($response['verification'])
);
} elseif (isset($response['apiErrorResponse'])) {
return new Result\Error($response['apiErrorResponse']);
} else {
throw new Exception\Unexpected(
"Expected transaction or apiErrorResponse"
);
}
}
/**
* Retrieve a credit card verification
*
* @param array $query search parameters
* @param array $ids of verifications to search
*
* @return Array of CreditCardVerification objects
*/
public function fetch($query, $ids)
{
$criteria = [];
foreach ($query as $term) {
$criteria[$term->name] = $term->toparam();
}
$criteria["ids"] = CreditCardVerificationSearch::ids()->in($ids)->toparam();
$criteria["verification_type"] = ["credit_card"];
$path = $this->_config->merchantPath() . '/verifications/advanced_search';
$response = $this->_http->post($path, ['search' => $criteria]);
return Util::extractattributeasarray(
$response['creditCardVerifications'],
'verification'
);
}
/**
* Returns a ResourceCollection of customers matching the search query.
*
* @param mixed $query search query
*
* @return ResourceCollection
*/
public function search($query)
{
$criteria = [];
foreach ($query as $term) {
$criteria[$term->name] = $term->toparam();
}
$criteria["verification_type"] = ["credit_card"];
$path = $this->_config->merchantPath() . '/verifications/advanced_search_ids';
$response = $this->_http->post($path, ['search' => $criteria]);
$pager = [
'object' => $this,
'method' => 'fetch',
'methodArgs' => [$query]
];
return new ResourceCollection($response, $pager);
}
}