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 // phpcs:disable PEAR.Commenting
namespace Braintree;
class PayPalPaymentResourceGateway
{
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);
}
public function update($attribs)
{
Util::verifyKeys(self::updateSignature(), $attribs);
$path = $this->_config->merchantPath() . '/paypal/payment_resource';
$response = $this->_http->put($path, ['paypal_payment_resource' => $attribs]);
return $this->_verifyGatewayResponse($response);
}
public static function updateSignature()
{
return [
'amount',
['amountBreakdown' =>
[
'discount',
'handling',
'insurance',
'itemTotal',
'shipping',
'shippingDiscount',
'taxTotal',
],
],
'currencyIsoCode',
'customField',
'description',
['lineItems' =>
[
'commodityCode',
'description',
'discountAmount',
'imageUrl',
'itemType',
'kind',
'name',
'productCode',
'quantity',
'taxAmount',
'totalAmount',
'unitAmount',
'unitOfMeasure',
'unitTaxAmount',
'upcCode',
'upcType',
'url'
],
],
'orderId',
'payeeEmail',
'paymentMethodNonce',
['shipping' =>
[
'company',
'countryCodeAlpha2',
'countryCodeAlpha3',
'countryCodeNumeric',
'countryName',
'extendedAddress',
'firstName',
['internationalPhone' =>
[
'countryCode',
'nationalNumber',
],
],
'lastName',
'locality',
'postalCode',
'region',
'streetAddress',
],
],
['shippingOptions' =>
[
'amount',
'id',
'label',
'selected',
'type',
],
],
];
}
private function _verifyGatewayResponse($response)
{
if (isset($response['paymentMethodNonce'])) {
return new Result\Successful(
PaymentMethodNonce::factory($response['paymentMethodNonce']),
"paymentMethodNonce"
);
} elseif (isset($response['apiErrorResponse'])) {
return new Result\Error($response['apiErrorResponse']);
} else {
throw new Exception\Unexpected(
"Expected address or apiErrorResponse"
);
}
}
// phpcs:ignore PEAR.Commenting.FunctionComment.Missing
public function __toString()
{
return __CLASS__ . '[' .
Util::attributesToString($this->_attributes) . ']';
}
}