forked from LiveCarta/PayPal-PHP-Server-SDK
Automated commit message
This commit is contained in:
52
src/Controllers/BaseController.php
Normal file
52
src/Controllers/BaseController.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* PayPalRESTAPIsLib
|
||||
*
|
||||
* This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
|
||||
*/
|
||||
|
||||
namespace PayPalRESTAPIsLib\Controllers;
|
||||
|
||||
use Core\ApiCall;
|
||||
use Core\Client;
|
||||
use Core\Request\RequestBuilder;
|
||||
use Core\Response\ResponseHandler;
|
||||
|
||||
/**
|
||||
* Base controller
|
||||
*/
|
||||
class BaseController
|
||||
{
|
||||
/**
|
||||
* Client instance
|
||||
*
|
||||
* @var Client
|
||||
*/
|
||||
private $client;
|
||||
|
||||
public function __construct(Client $client)
|
||||
{
|
||||
$this->client = $client;
|
||||
}
|
||||
|
||||
protected function execute(RequestBuilder $requestBuilder, ?ResponseHandler $responseHandler = null)
|
||||
{
|
||||
return (new ApiCall($this->client))
|
||||
->requestBuilder($requestBuilder)
|
||||
->responseHandler($responseHandler ?? $this->responseHandler())
|
||||
->execute();
|
||||
}
|
||||
|
||||
protected function requestBuilder(string $requestMethod, string $path): RequestBuilder
|
||||
{
|
||||
return new RequestBuilder($requestMethod, $path);
|
||||
}
|
||||
|
||||
protected function responseHandler(): ResponseHandler
|
||||
{
|
||||
return $this->client->getGlobalResponseHandler();
|
||||
}
|
||||
}
|
||||
60
src/Controllers/OAuthAuthorizationController.php
Normal file
60
src/Controllers/OAuthAuthorizationController.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* PayPalRESTAPIsLib
|
||||
*
|
||||
* This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
|
||||
*/
|
||||
|
||||
namespace PayPalRESTAPIsLib\Controllers;
|
||||
|
||||
use Core\Request\Parameters\AdditionalFormParams;
|
||||
use Core\Request\Parameters\FormParam;
|
||||
use Core\Request\Parameters\HeaderParam;
|
||||
use Core\Response\Types\ErrorType;
|
||||
use CoreInterfaces\Core\Request\RequestMethod;
|
||||
use PayPalRESTAPIsLib\Exceptions\OAuthProviderException;
|
||||
use PayPalRESTAPIsLib\Http\ApiResponse;
|
||||
use PayPalRESTAPIsLib\Models\OAuthToken;
|
||||
|
||||
class OAuthAuthorizationController extends BaseController
|
||||
{
|
||||
/**
|
||||
* Create a new OAuth 2 token.
|
||||
*
|
||||
* @param array $options Array with all options for search
|
||||
* @param array|null $fieldParameters Additional optional form parameters are supported by this
|
||||
* endpoint
|
||||
*
|
||||
* @return ApiResponse Response from the API call
|
||||
*/
|
||||
public function requestToken(array $options, array $fieldParameters = null): ApiResponse
|
||||
{
|
||||
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/v1/oauth2/token')
|
||||
->parameters(
|
||||
FormParam::init('grant_type', 'client_credentials'),
|
||||
HeaderParam::init('Authorization', $options)->extract('authorization'),
|
||||
FormParam::init('scope', $options)->extract('scope'),
|
||||
AdditionalFormParams::init($fieldParameters)
|
||||
);
|
||||
|
||||
$_resHandler = $this->responseHandler()
|
||||
->throwErrorOn(
|
||||
'400',
|
||||
ErrorType::init('OAuth 2 provider returned an error.', OAuthProviderException::class)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'401',
|
||||
ErrorType::init(
|
||||
'OAuth 2 provider says client authentication failed.',
|
||||
OAuthProviderException::class
|
||||
)
|
||||
)
|
||||
->type(OAuthToken::class)
|
||||
->returnApiResponse();
|
||||
|
||||
return $this->execute($_reqBuilder, $_resHandler);
|
||||
}
|
||||
}
|
||||
488
src/Controllers/OrdersController.php
Normal file
488
src/Controllers/OrdersController.php
Normal file
@@ -0,0 +1,488 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* PayPalRESTAPIsLib
|
||||
*
|
||||
* This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
|
||||
*/
|
||||
|
||||
namespace PayPalRESTAPIsLib\Controllers;
|
||||
|
||||
use Core\Request\Parameters\BodyParam;
|
||||
use Core\Request\Parameters\HeaderParam;
|
||||
use Core\Request\Parameters\QueryParam;
|
||||
use Core\Request\Parameters\TemplateParam;
|
||||
use Core\Response\Types\ErrorType;
|
||||
use CoreInterfaces\Core\Request\RequestMethod;
|
||||
use PayPalRESTAPIsLib\Exceptions\ErrorException;
|
||||
use PayPalRESTAPIsLib\Http\ApiResponse;
|
||||
use PayPalRESTAPIsLib\Models\Order;
|
||||
use PayPalRESTAPIsLib\Models\OrderAuthorizeResponse;
|
||||
|
||||
class OrdersController extends BaseController
|
||||
{
|
||||
/**
|
||||
* Creates an order. Merchants and partners can add Level 2 and 3 data to payments to reduce risk and
|
||||
* payment processing costs. For more information about processing payments, see <a href="https:
|
||||
* //developer.paypal.com/docs/checkout/advanced/processing/">checkout</a> or <a href="https:
|
||||
* //developer.paypal.com/docs/multiparty/checkout/advanced/processing/">multiparty checkout</a>.
|
||||
* <blockquote><strong>Note:</strong> For error handling and troubleshooting, see <a href="https:
|
||||
* //developer.paypal.com/api/rest/reference/orders/v2/errors/#create-order">Orders v2 errors</a>.
|
||||
* </blockquote>
|
||||
*
|
||||
* @param array $options Array with all options for search
|
||||
*
|
||||
* @return ApiResponse Response from the API call
|
||||
*/
|
||||
public function ordersCreate(array $options): ApiResponse
|
||||
{
|
||||
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/v2/checkout/orders')
|
||||
->auth('Oauth2')
|
||||
->parameters(
|
||||
HeaderParam::init('Content-Type', 'application/json'),
|
||||
BodyParam::init($options)->extract('body'),
|
||||
HeaderParam::init('PayPal-Request-Id', $options)->extract('payPalRequestId'),
|
||||
HeaderParam::init('PayPal-Partner-Attribution-Id', $options)->extract('payPalPartnerAttributionId'),
|
||||
HeaderParam::init('PayPal-Client-Metadata-Id', $options)->extract('payPalClientMetadataId'),
|
||||
HeaderParam::init('Prefer', $options)->extract('prefer', 'return=minimal')
|
||||
);
|
||||
|
||||
$_resHandler = $this->responseHandler()
|
||||
->throwErrorOn(
|
||||
'400',
|
||||
ErrorType::init(
|
||||
'Request is not well-formed, syntactically incorrect, or violates schema.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'401',
|
||||
ErrorType::init(
|
||||
'Authentication failed due to missing authorization header, or invalid auth' .
|
||||
'entication credentials.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'422',
|
||||
ErrorType::init(
|
||||
'The requested action could not be performed, semantically incorrect, or fa' .
|
||||
'iled business validation.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn('0', ErrorType::init('The error response.', ErrorException::class))
|
||||
->type(Order::class)
|
||||
->returnApiResponse();
|
||||
|
||||
return $this->execute($_reqBuilder, $_resHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows details for an order, by ID.<blockquote><strong>Note:</strong> For error handling and
|
||||
* troubleshooting, see <a href="https://developer.paypal.com/api/rest/reference/orders/v2/errors/#get-
|
||||
* order">Orders v2 errors</a>.</blockquote>
|
||||
*
|
||||
* @param array $options Array with all options for search
|
||||
*
|
||||
* @return ApiResponse Response from the API call
|
||||
*/
|
||||
public function ordersGet(array $options): ApiResponse
|
||||
{
|
||||
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/v2/checkout/orders/{id}')
|
||||
->auth('Oauth2')
|
||||
->parameters(
|
||||
TemplateParam::init('id', $options)->extract('id'),
|
||||
QueryParam::init('fields', $options)->extract('fields')
|
||||
);
|
||||
|
||||
$_resHandler = $this->responseHandler()
|
||||
->throwErrorOn(
|
||||
'401',
|
||||
ErrorType::init(
|
||||
'Authentication failed due to missing authorization header, or invalid auth' .
|
||||
'entication credentials.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn('404', ErrorType::init('The specified resource does not exist.', ErrorException::class))
|
||||
->throwErrorOn('0', ErrorType::init('The error response.', ErrorException::class))
|
||||
->type(Order::class)
|
||||
->returnApiResponse();
|
||||
|
||||
return $this->execute($_reqBuilder, $_resHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an order with a `CREATED` or `APPROVED` status. You cannot update an order with the
|
||||
* `COMPLETED` status.<br/><br/>To make an update, you must provide a `reference_id`. If you omit this
|
||||
* value with an order that contains only one purchase unit, PayPal sets the value to `default` which
|
||||
* enables you to use the path: <code>\"/purchase_units/@reference_id=='default'/{attribute-or-
|
||||
* object}\"</code>. Merchants and partners can add Level 2 and 3 data to payments to reduce risk and
|
||||
* payment processing costs. For more information about processing payments, see <a href="https:
|
||||
* //developer.paypal.com/docs/checkout/advanced/processing/">checkout</a> or <a href="https:
|
||||
* //developer.paypal.com/docs/multiparty/checkout/advanced/processing/">multiparty checkout</a>.
|
||||
* <blockquote><strong>Note:</strong> For error handling and troubleshooting, see <a href="https:
|
||||
* //developer.paypal.com/api/rest/reference/orders/v2/errors/#patch-order">Orders v2 errors</a>.
|
||||
* </blockquote>Patchable attributes or objects:
|
||||
* <br/><br/><table><thead><th>Attribute</th><th>Op</th><th>Notes</th></thead><tbody><tr><td><code>inte
|
||||
* nt</code></td><td>replace</td><td></td></tr><tr><td><code>payer</code></td><td>replace,
|
||||
* add</td><td>Using replace op for <code>payer</code> will replace the whole <code>payer</code> object
|
||||
* with the value sent in request.</td></tr><tr><td><code>purchase_units</code></td><td>replace,
|
||||
* add</td><td></td></tr><tr><td><code>purchase_units[].custom_id</code></td><td>replace, add,
|
||||
* remove</td><td></td></tr><tr><td><code>purchase_units[].description</code></td><td>replace, add,
|
||||
* remove</td><td></td></tr><tr><td><code>purchase_units[].payee.
|
||||
* email</code></td><td>replace</td><td></td></tr><tr><td><code>purchase_units[].shipping.
|
||||
* name</code></td><td>replace, add</td><td></td></tr><tr><td><code>purchase_units[].shipping.
|
||||
* email_address</code></td><td>replace, add</td><td></td></tr><tr><td><code>purchase_units[].shipping.
|
||||
* phone_number</code></td><td>replace, add</td><td></td></tr><tr><td><code>purchase_units[].shipping.
|
||||
* options</code></td><td>replace, add</td><td></td></tr><tr><td><code>purchase_units[].shipping.
|
||||
* address</code></td><td>replace, add</td><td></td></tr><tr><td><code>purchase_units[].shipping.
|
||||
* type</code></td><td>replace, add</td><td></td></tr><tr><td><code>purchase_units[].
|
||||
* soft_descriptor</code></td><td>replace, remove</td><td></td></tr><tr><td><code>purchase_units[].
|
||||
* amount</code></td><td>replace</td><td></td></tr><tr><td><code>purchase_units[].
|
||||
* items</code></td><td>replace, add, remove</td><td></td></tr><tr><td><code>purchase_units[].
|
||||
* invoice_id</code></td><td>replace, add, remove</td><td></td></tr><tr><td><code>purchase_units[].
|
||||
* payment_instruction</code></td><td>replace</td><td></td></tr><tr><td><code>purchase_units[].
|
||||
* payment_instruction.disbursement_mode</code></td><td>replace</td><td>By default,
|
||||
* <code>disbursement_mode</code> is <code>INSTANT</code>.</td></tr><tr><td><code>purchase_units[].
|
||||
* payment_instruction.payee_receivable_fx_rate_id</code></td><td>replace, add,
|
||||
* remove</td><td></td></tr><tr><td><code>purchase_units[].payment_instruction.
|
||||
* platform_fees</code></td><td>replace, add, remove</td><td></td></tr><tr><td><code>purchase_units[].
|
||||
* supplementary_data.airline</code></td><td>replace, add,
|
||||
* remove</td><td></td></tr><tr><td><code>purchase_units[].supplementary_data.
|
||||
* card</code></td><td>replace, add, remove</td><td></td></tr><tr><td><code>application_context.
|
||||
* client_configuration</code></td><td>replace, add</td><td></td></tr></tbody></table>
|
||||
*
|
||||
* @param array $options Array with all options for search
|
||||
*
|
||||
* @return ApiResponse Response from the API call
|
||||
*/
|
||||
public function ordersPatch(array $options): ApiResponse
|
||||
{
|
||||
$_reqBuilder = $this->requestBuilder(RequestMethod::PATCH, '/v2/checkout/orders/{id}')
|
||||
->auth('Oauth2')
|
||||
->parameters(
|
||||
TemplateParam::init('id', $options)->extract('id'),
|
||||
HeaderParam::init('Content-Type', 'application/json'),
|
||||
BodyParam::init($options)->extract('body')
|
||||
);
|
||||
|
||||
$_resHandler = $this->responseHandler()
|
||||
->throwErrorOn(
|
||||
'400',
|
||||
ErrorType::init(
|
||||
'Request is not well-formed, syntactically incorrect, or violates schema.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'401',
|
||||
ErrorType::init(
|
||||
'Authentication failed due to missing authorization header, or invalid auth' .
|
||||
'entication credentials.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn('404', ErrorType::init('The specified resource does not exist.', ErrorException::class))
|
||||
->throwErrorOn(
|
||||
'422',
|
||||
ErrorType::init(
|
||||
'The requested action could not be performed, semantically incorrect, or fa' .
|
||||
'iled business validation.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn('0', ErrorType::init('The error response.', ErrorException::class))
|
||||
->returnApiResponse();
|
||||
|
||||
return $this->execute($_reqBuilder, $_resHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Payer confirms their intent to pay for the the Order with the given payment source.
|
||||
*
|
||||
* @param array $options Array with all options for search
|
||||
*
|
||||
* @return ApiResponse Response from the API call
|
||||
*/
|
||||
public function ordersConfirm(array $options): ApiResponse
|
||||
{
|
||||
$_reqBuilder = $this->requestBuilder(
|
||||
RequestMethod::POST,
|
||||
'/v2/checkout/orders/{id}/confirm-payment-source'
|
||||
)
|
||||
->auth('Oauth2')
|
||||
->parameters(
|
||||
TemplateParam::init('id', $options)->extract('id'),
|
||||
HeaderParam::init('Content-Type', 'application/json'),
|
||||
HeaderParam::init('PayPal-Client-Metadata-Id', $options)->extract('payPalClientMetadataId'),
|
||||
HeaderParam::init('Prefer', $options)->extract('prefer', 'return=minimal'),
|
||||
BodyParam::init($options)->extract('body')
|
||||
);
|
||||
|
||||
$_resHandler = $this->responseHandler()
|
||||
->throwErrorOn(
|
||||
'400',
|
||||
ErrorType::init(
|
||||
'Request is not well-formed, syntactically incorrect, or violates schema.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'403',
|
||||
ErrorType::init('Authorization failed due to insufficient permissions.', ErrorException::class)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'422',
|
||||
ErrorType::init(
|
||||
'The requested action could not be performed, semantically incorrect, or fa' .
|
||||
'iled business validation.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn('500', ErrorType::init('An internal server error has occurred.', ErrorException::class))
|
||||
->throwErrorOn('0', ErrorType::init('The error response.', ErrorException::class))
|
||||
->type(Order::class)
|
||||
->returnApiResponse();
|
||||
|
||||
return $this->execute($_reqBuilder, $_resHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Authorizes payment for an order. To successfully authorize payment for an order, the buyer must
|
||||
* first approve the order or a valid payment_source must be provided in the request. A buyer can
|
||||
* approve the order upon being redirected to the rel:approve URL that was returned in the HATEOAS
|
||||
* links in the create order response.<blockquote><strong>Note:</strong> For error handling and
|
||||
* troubleshooting, see <a href="https://developer.paypal.
|
||||
* com/api/rest/reference/orders/v2/errors/#authorize-order">Orders v2 errors</a>.</blockquote>
|
||||
*
|
||||
* @param array $options Array with all options for search
|
||||
*
|
||||
* @return ApiResponse Response from the API call
|
||||
*/
|
||||
public function ordersAuthorize(array $options): ApiResponse
|
||||
{
|
||||
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/v2/checkout/orders/{id}/authorize')
|
||||
->auth('Oauth2')
|
||||
->parameters(
|
||||
TemplateParam::init('id', $options)->extract('id'),
|
||||
HeaderParam::init('Content-Type', 'application/json'),
|
||||
HeaderParam::init('PayPal-Request-Id', $options)->extract('payPalRequestId'),
|
||||
HeaderParam::init('Prefer', $options)->extract('prefer', 'return=minimal'),
|
||||
HeaderParam::init('PayPal-Client-Metadata-Id', $options)->extract('payPalClientMetadataId'),
|
||||
HeaderParam::init('PayPal-Auth-Assertion', $options)->extract('payPalAuthAssertion'),
|
||||
BodyParam::init($options)->extract('body')
|
||||
);
|
||||
|
||||
$_resHandler = $this->responseHandler()
|
||||
->throwErrorOn(
|
||||
'400',
|
||||
ErrorType::init(
|
||||
'Request is not well-formed, syntactically incorrect, or violates schema.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'401',
|
||||
ErrorType::init(
|
||||
'Authentication failed due to missing authorization header, or invalid auth' .
|
||||
'entication credentials.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'403',
|
||||
ErrorType::init(
|
||||
'The authorized payment failed due to insufficient permissions.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn('404', ErrorType::init('The specified resource does not exist.', ErrorException::class))
|
||||
->throwErrorOn(
|
||||
'422',
|
||||
ErrorType::init(
|
||||
'The requested action could not be performed, semantically incorrect, or fa' .
|
||||
'iled business validation.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn('500', ErrorType::init('An internal server error has occurred.', ErrorException::class))
|
||||
->throwErrorOn('0', ErrorType::init('The error response.', ErrorException::class))
|
||||
->type(OrderAuthorizeResponse::class)
|
||||
->returnApiResponse();
|
||||
|
||||
return $this->execute($_reqBuilder, $_resHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Captures payment for an order. To successfully capture payment for an order, the buyer must first
|
||||
* approve the order or a valid payment_source must be provided in the request. A buyer can approve the
|
||||
* order upon being redirected to the rel:approve URL that was returned in the HATEOAS links in the
|
||||
* create order response.<blockquote><strong>Note:</strong> For error handling and troubleshooting, see
|
||||
* <a href="https://developer.paypal.com/api/rest/reference/orders/v2/errors/#capture-order">Orders v2
|
||||
* errors</a>.</blockquote>
|
||||
*
|
||||
* @param array $options Array with all options for search
|
||||
*
|
||||
* @return ApiResponse Response from the API call
|
||||
*/
|
||||
public function ordersCapture(array $options): ApiResponse
|
||||
{
|
||||
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/v2/checkout/orders/{id}/capture')
|
||||
->auth('Oauth2')
|
||||
->parameters(
|
||||
TemplateParam::init('id', $options)->extract('id'),
|
||||
HeaderParam::init('Content-Type', 'application/json'),
|
||||
HeaderParam::init('PayPal-Request-Id', $options)->extract('payPalRequestId'),
|
||||
HeaderParam::init('Prefer', $options)->extract('prefer', 'return=minimal'),
|
||||
HeaderParam::init('PayPal-Client-Metadata-Id', $options)->extract('payPalClientMetadataId'),
|
||||
HeaderParam::init('PayPal-Auth-Assertion', $options)->extract('payPalAuthAssertion'),
|
||||
BodyParam::init($options)->extract('body')
|
||||
);
|
||||
|
||||
$_resHandler = $this->responseHandler()
|
||||
->throwErrorOn(
|
||||
'400',
|
||||
ErrorType::init(
|
||||
'Request is not well-formed, syntactically incorrect, or violates schema.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'401',
|
||||
ErrorType::init(
|
||||
'Authentication failed due to missing authorization header, or invalid auth' .
|
||||
'entication credentials.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'403',
|
||||
ErrorType::init(
|
||||
'The authorized payment failed due to insufficient permissions.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn('404', ErrorType::init('The specified resource does not exist.', ErrorException::class))
|
||||
->throwErrorOn(
|
||||
'422',
|
||||
ErrorType::init(
|
||||
'The requested action could not be performed, semantically incorrect, or fa' .
|
||||
'iled business validation.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn('500', ErrorType::init('An internal server error has occurred.', ErrorException::class))
|
||||
->throwErrorOn('0', ErrorType::init('The error response.', ErrorException::class))
|
||||
->type(Order::class)
|
||||
->returnApiResponse();
|
||||
|
||||
return $this->execute($_reqBuilder, $_resHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds tracking information for an Order.
|
||||
*
|
||||
* @param array $options Array with all options for search
|
||||
*
|
||||
* @return ApiResponse Response from the API call
|
||||
*/
|
||||
public function ordersTrackCreate(array $options): ApiResponse
|
||||
{
|
||||
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/v2/checkout/orders/{id}/track')
|
||||
->auth('Oauth2')
|
||||
->parameters(
|
||||
TemplateParam::init('id', $options)->extract('id'),
|
||||
HeaderParam::init('Content-Type', 'application/json'),
|
||||
BodyParam::init($options)->extract('body'),
|
||||
HeaderParam::init('PayPal-Auth-Assertion', $options)->extract('payPalAuthAssertion')
|
||||
);
|
||||
|
||||
$_resHandler = $this->responseHandler()
|
||||
->throwErrorOn(
|
||||
'400',
|
||||
ErrorType::init(
|
||||
'Request is not well-formed, syntactically incorrect, or violates schema.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'403',
|
||||
ErrorType::init('Authorization failed due to insufficient permissions.', ErrorException::class)
|
||||
)
|
||||
->throwErrorOn('404', ErrorType::init('The specified resource does not exist.', ErrorException::class))
|
||||
->throwErrorOn(
|
||||
'422',
|
||||
ErrorType::init(
|
||||
'The requested action could not be performed, semantically incorrect, or fa' .
|
||||
'iled business validation.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn('500', ErrorType::init('An internal server error has occurred.', ErrorException::class))
|
||||
->throwErrorOn('0', ErrorType::init('The error response.', ErrorException::class))
|
||||
->type(Order::class)
|
||||
->returnApiResponse();
|
||||
|
||||
return $this->execute($_reqBuilder, $_resHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates or cancels the tracking information for a PayPal order, by ID. Updatable attributes or
|
||||
* objects:
|
||||
* <br/><br/><table><thead><th>Attribute</th><th>Op</th><th>Notes</th></thead><tbody></tr><tr><td><code
|
||||
* >items</code></td><td>replace</td><td>Using replace op for <code>items</code> will replace the
|
||||
* entire <code>items</code> object with the value sent in request.
|
||||
* </td></tr><tr><td><code>notify_payer</code></td><td>replace,
|
||||
* add</td><td></td></tr><tr><td><code>status</code></td><td>replace</td><td>Only patching status to
|
||||
* CANCELLED is currently supported.</td></tr></tbody></table>
|
||||
*
|
||||
* @param array $options Array with all options for search
|
||||
*
|
||||
* @return ApiResponse Response from the API call
|
||||
*/
|
||||
public function ordersTrackersPatch(array $options): ApiResponse
|
||||
{
|
||||
$_reqBuilder = $this->requestBuilder(
|
||||
RequestMethod::PATCH,
|
||||
'/v2/checkout/orders/{id}/trackers/{tracker_id}'
|
||||
)
|
||||
->auth('Oauth2')
|
||||
->parameters(
|
||||
TemplateParam::init('id', $options)->extract('id'),
|
||||
TemplateParam::init('tracker_id', $options)->extract('trackerId'),
|
||||
HeaderParam::init('Content-Type', 'application/json'),
|
||||
BodyParam::init($options)->extract('body')
|
||||
);
|
||||
|
||||
$_resHandler = $this->responseHandler()
|
||||
->throwErrorOn(
|
||||
'400',
|
||||
ErrorType::init(
|
||||
'Request is not well-formed, syntactically incorrect, or violates schema.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'403',
|
||||
ErrorType::init('Authorization failed due to insufficient permissions.', ErrorException::class)
|
||||
)
|
||||
->throwErrorOn('404', ErrorType::init('The specified resource does not exist.', ErrorException::class))
|
||||
->throwErrorOn(
|
||||
'422',
|
||||
ErrorType::init(
|
||||
'The requested action could not be performed, semantically incorrect, or fa' .
|
||||
'iled business validation.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn('500', ErrorType::init('An internal server error has occurred.', ErrorException::class))
|
||||
->throwErrorOn('0', ErrorType::init('The error response.', ErrorException::class))
|
||||
->returnApiResponse();
|
||||
|
||||
return $this->execute($_reqBuilder, $_resHandler);
|
||||
}
|
||||
}
|
||||
442
src/Controllers/PaymentsController.php
Normal file
442
src/Controllers/PaymentsController.php
Normal file
@@ -0,0 +1,442 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* PayPalRESTAPIsLib
|
||||
*
|
||||
* This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
|
||||
*/
|
||||
|
||||
namespace PayPalRESTAPIsLib\Controllers;
|
||||
|
||||
use Core\Request\Parameters\BodyParam;
|
||||
use Core\Request\Parameters\HeaderParam;
|
||||
use Core\Request\Parameters\TemplateParam;
|
||||
use Core\Response\Types\ErrorType;
|
||||
use CoreInterfaces\Core\Request\RequestMethod;
|
||||
use PayPalRESTAPIsLib\Exceptions\ErrorException;
|
||||
use PayPalRESTAPIsLib\Http\ApiResponse;
|
||||
use PayPalRESTAPIsLib\Models\CapturedPayment;
|
||||
use PayPalRESTAPIsLib\Models\PaymentAuthorization;
|
||||
use PayPalRESTAPIsLib\Models\Refund;
|
||||
|
||||
class PaymentsController extends BaseController
|
||||
{
|
||||
/**
|
||||
* Shows details for an authorized payment, by ID.
|
||||
*
|
||||
* @param string $authorizationId The ID of the authorized payment for which to show details.
|
||||
*
|
||||
* @return ApiResponse Response from the API call
|
||||
*/
|
||||
public function authorizationsGet(string $authorizationId): ApiResponse
|
||||
{
|
||||
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/v2/payments/authorizations/{authorization_id}')
|
||||
->auth('Oauth2')
|
||||
->parameters(TemplateParam::init('authorization_id', $authorizationId));
|
||||
|
||||
$_resHandler = $this->responseHandler()
|
||||
->throwErrorOn(
|
||||
'401',
|
||||
ErrorType::init(
|
||||
'Authentication failed due to missing authorization header, or invalid auth' .
|
||||
'entication credentials.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'403',
|
||||
ErrorType::init(
|
||||
'The request failed because the caller has insufficient permissions.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'404',
|
||||
ErrorType::init('The request failed because the resource does not exist.', ErrorException::class)
|
||||
)
|
||||
->throwErrorOn('500', ErrorType::init('The request failed because an internal server error occurred.'))
|
||||
->throwErrorOn('0', ErrorType::init('The error response.', ErrorException::class))
|
||||
->type(PaymentAuthorization::class)
|
||||
->returnApiResponse();
|
||||
|
||||
return $this->execute($_reqBuilder, $_resHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Captures an authorized payment, by ID.
|
||||
*
|
||||
* @param array $options Array with all options for search
|
||||
*
|
||||
* @return ApiResponse Response from the API call
|
||||
*/
|
||||
public function authorizationsCapture(array $options): ApiResponse
|
||||
{
|
||||
$_reqBuilder = $this->requestBuilder(
|
||||
RequestMethod::POST,
|
||||
'/v2/payments/authorizations/{authorization_id}/capture'
|
||||
)
|
||||
->auth('Oauth2')
|
||||
->parameters(
|
||||
TemplateParam::init('authorization_id', $options)->extract('authorizationId'),
|
||||
HeaderParam::init('Content-Type', 'application/json'),
|
||||
HeaderParam::init('PayPal-Request-Id', $options)->extract('payPalRequestId'),
|
||||
HeaderParam::init('Prefer', $options)->extract('prefer', 'return=minimal'),
|
||||
BodyParam::init($options)->extract('body')
|
||||
);
|
||||
|
||||
$_resHandler = $this->responseHandler()
|
||||
->throwErrorOn(
|
||||
'400',
|
||||
ErrorType::init(
|
||||
'The request failed because it is not well-formed or is syntactically incor' .
|
||||
'rect or violates schema.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'401',
|
||||
ErrorType::init(
|
||||
'Authentication failed due to missing authorization header, or invalid auth' .
|
||||
'entication credentials.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'403',
|
||||
ErrorType::init(
|
||||
'The request failed because the caller has insufficient permissions.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'404',
|
||||
ErrorType::init('The request failed because the resource does not exist.', ErrorException::class)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'409',
|
||||
ErrorType::init(
|
||||
'The server has detected a conflict while processing this request.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'422',
|
||||
ErrorType::init(
|
||||
'The request failed because it is semantically incorrect or failed business validation.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn('500', ErrorType::init('The request failed because an internal server error occurred.'))
|
||||
->throwErrorOn('0', ErrorType::init('The error response.', ErrorException::class))
|
||||
->type(CapturedPayment::class)
|
||||
->returnApiResponse();
|
||||
|
||||
return $this->execute($_reqBuilder, $_resHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reauthorizes an authorized PayPal account payment, by ID. To ensure that funds are still available,
|
||||
* reauthorize a payment after its initial three-day honor period expires. Within the 29-day
|
||||
* authorization period, you can issue multiple re-authorizations after the honor period expires.
|
||||
* <br/><br/>If 30 days have transpired since the date of the original authorization, you must create
|
||||
* an authorized payment instead of reauthorizing the original authorized payment.<br/><br/>A
|
||||
* reauthorized payment itself has a new honor period of three days.<br/><br/>You can reauthorize an
|
||||
* authorized payment from 4 to 29 days after the 3-day honor period. The allowed amount depends on
|
||||
* context and geography, for example in US it is up to 115% of the original authorized amount, not to
|
||||
* exceed an increase of $75 USD.<br/><br/>Supports only the `amount` request parameter.
|
||||
* <blockquote><strong>Note:</strong> This request is currently not supported for Partner use cases.
|
||||
* </blockquote>
|
||||
*
|
||||
* @param array $options Array with all options for search
|
||||
*
|
||||
* @return ApiResponse Response from the API call
|
||||
*/
|
||||
public function authorizationsReauthorize(array $options): ApiResponse
|
||||
{
|
||||
$_reqBuilder = $this->requestBuilder(
|
||||
RequestMethod::POST,
|
||||
'/v2/payments/authorizations/{authorization_id}/reauthorize'
|
||||
)
|
||||
->auth('Oauth2')
|
||||
->parameters(
|
||||
TemplateParam::init('authorization_id', $options)->extract('authorizationId'),
|
||||
HeaderParam::init('Content-Type', 'application/json'),
|
||||
HeaderParam::init('PayPal-Request-Id', $options)->extract('payPalRequestId'),
|
||||
HeaderParam::init('Prefer', $options)->extract('prefer', 'return=minimal'),
|
||||
BodyParam::init($options)->extract('body')
|
||||
);
|
||||
|
||||
$_resHandler = $this->responseHandler()
|
||||
->throwErrorOn(
|
||||
'400',
|
||||
ErrorType::init(
|
||||
'The request failed because it is not well-formed or is syntactically incor' .
|
||||
'rect or violates schema.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'401',
|
||||
ErrorType::init(
|
||||
'Authentication failed due to missing authorization header, or invalid auth' .
|
||||
'entication credentials.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'403',
|
||||
ErrorType::init(
|
||||
'The request failed because the caller has insufficient permissions.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'404',
|
||||
ErrorType::init('The request failed because the resource does not exist.', ErrorException::class)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'422',
|
||||
ErrorType::init(
|
||||
'The request failed because it either is semantically incorrect or failed b' .
|
||||
'usiness validation.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn('500', ErrorType::init('The request failed because an internal server error occurred.'))
|
||||
->throwErrorOn('0', ErrorType::init('The error response.', ErrorException::class))
|
||||
->type(PaymentAuthorization::class)
|
||||
->returnApiResponse();
|
||||
|
||||
return $this->execute($_reqBuilder, $_resHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Voids, or cancels, an authorized payment, by ID. You cannot void an authorized payment that has been
|
||||
* fully captured.
|
||||
*
|
||||
* @param array $options Array with all options for search
|
||||
*
|
||||
* @return ApiResponse Response from the API call
|
||||
*/
|
||||
public function authorizationsVoid(array $options): ApiResponse
|
||||
{
|
||||
$_reqBuilder = $this->requestBuilder(
|
||||
RequestMethod::POST,
|
||||
'/v2/payments/authorizations/{authorization_id}/void'
|
||||
)
|
||||
->auth('Oauth2')
|
||||
->parameters(
|
||||
TemplateParam::init('authorization_id', $options)->extract('authorizationId'),
|
||||
HeaderParam::init('PayPal-Auth-Assertion', $options)->extract('payPalAuthAssertion'),
|
||||
HeaderParam::init('Prefer', $options)->extract('prefer', 'return=minimal')
|
||||
);
|
||||
|
||||
$_resHandler = $this->responseHandler()
|
||||
->throwErrorOn(
|
||||
'400',
|
||||
ErrorType::init(
|
||||
'The request failed because it is not well-formed or is syntactically incor' .
|
||||
'rect or violates schema.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'401',
|
||||
ErrorType::init(
|
||||
'Authentication failed due to missing authorization header, or invalid auth' .
|
||||
'entication credentials.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'403',
|
||||
ErrorType::init(
|
||||
'The request failed because the caller has insufficient permissions.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'404',
|
||||
ErrorType::init('The request failed because the resource does not exist.', ErrorException::class)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'409',
|
||||
ErrorType::init(
|
||||
'The request failed because a previous call for the given resource is in progress.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'422',
|
||||
ErrorType::init(
|
||||
'The request failed because it either is semantically incorrect or failed b' .
|
||||
'usiness validation.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn('500', ErrorType::init('The request failed because an internal server error occurred.'))
|
||||
->throwErrorOn('0', ErrorType::init('The error response.', ErrorException::class))
|
||||
->nullableType()
|
||||
->type(PaymentAuthorization::class)
|
||||
->returnApiResponse();
|
||||
|
||||
return $this->execute($_reqBuilder, $_resHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows details for a captured payment, by ID.
|
||||
*
|
||||
* @param string $captureId The PayPal-generated ID for the captured payment for which to show
|
||||
* details.
|
||||
*
|
||||
* @return ApiResponse Response from the API call
|
||||
*/
|
||||
public function capturesGet(string $captureId): ApiResponse
|
||||
{
|
||||
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/v2/payments/captures/{capture_id}')
|
||||
->auth('Oauth2')
|
||||
->parameters(TemplateParam::init('capture_id', $captureId));
|
||||
|
||||
$_resHandler = $this->responseHandler()
|
||||
->throwErrorOn(
|
||||
'401',
|
||||
ErrorType::init(
|
||||
'Authentication failed due to missing authorization header, or invalid auth' .
|
||||
'entication credentials.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'403',
|
||||
ErrorType::init(
|
||||
'The request failed because the caller has insufficient permissions.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'404',
|
||||
ErrorType::init('The request failed because the resource does not exist.', ErrorException::class)
|
||||
)
|
||||
->throwErrorOn('500', ErrorType::init('The request failed because an internal server error occurred.'))
|
||||
->throwErrorOn('0', ErrorType::init('The error response.', ErrorException::class))
|
||||
->type(CapturedPayment::class)
|
||||
->returnApiResponse();
|
||||
|
||||
return $this->execute($_reqBuilder, $_resHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Refunds a captured payment, by ID. For a full refund, include an empty payload in the JSON request
|
||||
* body. For a partial refund, include an <code>amount</code> object in the JSON request body.
|
||||
*
|
||||
* @param array $options Array with all options for search
|
||||
*
|
||||
* @return ApiResponse Response from the API call
|
||||
*/
|
||||
public function capturesRefund(array $options): ApiResponse
|
||||
{
|
||||
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/v2/payments/captures/{capture_id}/refund')
|
||||
->auth('Oauth2')
|
||||
->parameters(
|
||||
TemplateParam::init('capture_id', $options)->extract('captureId'),
|
||||
HeaderParam::init('Content-Type', 'application/json'),
|
||||
HeaderParam::init('PayPal-Request-Id', $options)->extract('payPalRequestId'),
|
||||
HeaderParam::init('Prefer', $options)->extract('prefer', 'return=minimal'),
|
||||
HeaderParam::init('PayPal-Auth-Assertion', $options)->extract('payPalAuthAssertion'),
|
||||
BodyParam::init($options)->extract('body')
|
||||
);
|
||||
|
||||
$_resHandler = $this->responseHandler()
|
||||
->throwErrorOn(
|
||||
'400',
|
||||
ErrorType::init(
|
||||
'The request failed because it is not well-formed or is syntactically incor' .
|
||||
'rect or violates schema.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'401',
|
||||
ErrorType::init(
|
||||
'Authentication failed due to missing authorization header, or invalid auth' .
|
||||
'entication credentials.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'403',
|
||||
ErrorType::init(
|
||||
'The request failed because the caller has insufficient permissions.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'404',
|
||||
ErrorType::init('The request failed because the resource does not exist.', ErrorException::class)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'409',
|
||||
ErrorType::init(
|
||||
'The request failed because a previous call for the given resource is in progress.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'422',
|
||||
ErrorType::init(
|
||||
'The request failed because it either is semantically incorrect or failed b' .
|
||||
'usiness validation.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn('500', ErrorType::init('The request failed because an internal server error occurred.'))
|
||||
->throwErrorOn('0', ErrorType::init('The error response.', ErrorException::class))
|
||||
->type(Refund::class)
|
||||
->returnApiResponse();
|
||||
|
||||
return $this->execute($_reqBuilder, $_resHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows details for a refund, by ID.
|
||||
*
|
||||
* @param string $refundId The PayPal-generated ID for the refund for which to show details.
|
||||
*
|
||||
* @return ApiResponse Response from the API call
|
||||
*/
|
||||
public function refundsGet(string $refundId): ApiResponse
|
||||
{
|
||||
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/v2/payments/refunds/{refund_id}')
|
||||
->auth('Oauth2')
|
||||
->parameters(TemplateParam::init('refund_id', $refundId));
|
||||
|
||||
$_resHandler = $this->responseHandler()
|
||||
->throwErrorOn(
|
||||
'401',
|
||||
ErrorType::init(
|
||||
'Authentication failed due to missing authorization header, or invalid auth' .
|
||||
'entication credentials.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'403',
|
||||
ErrorType::init(
|
||||
'The request failed because the caller has insufficient permissions.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'404',
|
||||
ErrorType::init('The request failed because the resource does not exist.', ErrorException::class)
|
||||
)
|
||||
->throwErrorOn('500', ErrorType::init('The request failed because an internal server error occurred.'))
|
||||
->throwErrorOn('0', ErrorType::init('The error response.', ErrorException::class))
|
||||
->type(Refund::class)
|
||||
->returnApiResponse();
|
||||
|
||||
return $this->execute($_reqBuilder, $_resHandler);
|
||||
}
|
||||
}
|
||||
260
src/Controllers/VaultController.php
Normal file
260
src/Controllers/VaultController.php
Normal file
@@ -0,0 +1,260 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* PayPalRESTAPIsLib
|
||||
*
|
||||
* This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
|
||||
*/
|
||||
|
||||
namespace PayPalRESTAPIsLib\Controllers;
|
||||
|
||||
use Core\Request\Parameters\BodyParam;
|
||||
use Core\Request\Parameters\HeaderParam;
|
||||
use Core\Request\Parameters\QueryParam;
|
||||
use Core\Request\Parameters\TemplateParam;
|
||||
use Core\Response\Types\ErrorType;
|
||||
use CoreInterfaces\Core\Request\RequestMethod;
|
||||
use PayPalRESTAPIsLib\Exceptions\ErrorException;
|
||||
use PayPalRESTAPIsLib\Http\ApiResponse;
|
||||
use PayPalRESTAPIsLib\Models\CustomerVaultPaymentTokensResponse;
|
||||
use PayPalRESTAPIsLib\Models\PaymentTokenResponse;
|
||||
use PayPalRESTAPIsLib\Models\SetupTokenResponse;
|
||||
|
||||
class VaultController extends BaseController
|
||||
{
|
||||
/**
|
||||
* Creates a Payment Token from the given payment source and adds it to the Vault of the associated
|
||||
* customer.
|
||||
*
|
||||
* @param array $options Array with all options for search
|
||||
*
|
||||
* @return ApiResponse Response from the API call
|
||||
*/
|
||||
public function paymentTokensCreate(array $options): ApiResponse
|
||||
{
|
||||
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/v3/vault/payment-tokens')
|
||||
->auth('Oauth2')
|
||||
->parameters(
|
||||
HeaderParam::init('PayPal-Request-Id', $options)->extract('payPalRequestId'),
|
||||
HeaderParam::init('Content-Type', 'application/json'),
|
||||
BodyParam::init($options)->extract('body')
|
||||
);
|
||||
|
||||
$_resHandler = $this->responseHandler()
|
||||
->throwErrorOn(
|
||||
'400',
|
||||
ErrorType::init(
|
||||
'Request is not well-formed, syntactically incorrect, or violates schema.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'403',
|
||||
ErrorType::init('Authorization failed due to insufficient permissions.', ErrorException::class)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'404',
|
||||
ErrorType::init(
|
||||
'Request contains reference to resources that do not exist.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'422',
|
||||
ErrorType::init(
|
||||
'The requested action could not be performed, semantically incorrect, or fa' .
|
||||
'iled business validation.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn('500', ErrorType::init('An internal server error has occurred.', ErrorException::class))
|
||||
->type(PaymentTokenResponse::class)
|
||||
->returnApiResponse();
|
||||
|
||||
return $this->execute($_reqBuilder, $_resHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all payment tokens for a customer.
|
||||
*
|
||||
* @param array $options Array with all options for search
|
||||
*
|
||||
* @return ApiResponse Response from the API call
|
||||
*/
|
||||
public function customerPaymentTokensGet(array $options): ApiResponse
|
||||
{
|
||||
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/v3/vault/payment-tokens')
|
||||
->auth('Oauth2')
|
||||
->parameters(
|
||||
QueryParam::init('customer_id', $options)->extract('customerId'),
|
||||
QueryParam::init('page_size', $options)->extract('pageSize', 5),
|
||||
QueryParam::init('page', $options)->extract('page', 1),
|
||||
QueryParam::init('total_required', $options)->extract('totalRequired', false)
|
||||
);
|
||||
|
||||
$_resHandler = $this->responseHandler()
|
||||
->throwErrorOn(
|
||||
'400',
|
||||
ErrorType::init(
|
||||
'Request is not well-formed, syntactically incorrect, or violates schema.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'403',
|
||||
ErrorType::init('Authorization failed due to insufficient permissions.', ErrorException::class)
|
||||
)
|
||||
->throwErrorOn('500', ErrorType::init('An internal server error has occurred.', ErrorException::class))
|
||||
->type(CustomerVaultPaymentTokensResponse::class)
|
||||
->returnApiResponse();
|
||||
|
||||
return $this->execute($_reqBuilder, $_resHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a readable representation of vaulted payment source associated with the payment token id.
|
||||
*
|
||||
* @param string $id ID of the payment token.
|
||||
*
|
||||
* @return ApiResponse Response from the API call
|
||||
*/
|
||||
public function paymentTokensGet(string $id): ApiResponse
|
||||
{
|
||||
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/v3/vault/payment-tokens/{id}')
|
||||
->auth('Oauth2')
|
||||
->parameters(TemplateParam::init('id', $id));
|
||||
|
||||
$_resHandler = $this->responseHandler()
|
||||
->throwErrorOn(
|
||||
'403',
|
||||
ErrorType::init('Authorization failed due to insufficient permissions.', ErrorException::class)
|
||||
)
|
||||
->throwErrorOn('404', ErrorType::init('The specified resource does not exist.', ErrorException::class))
|
||||
->throwErrorOn(
|
||||
'422',
|
||||
ErrorType::init(
|
||||
'The requested action could not be performed, semantically incorrect, or fa' .
|
||||
'iled business validation.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn('500', ErrorType::init('An internal server error has occurred.', ErrorException::class))
|
||||
->type(PaymentTokenResponse::class)
|
||||
->returnApiResponse();
|
||||
|
||||
return $this->execute($_reqBuilder, $_resHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the payment token associated with the payment token id.
|
||||
*
|
||||
* @param string $id ID of the payment token.
|
||||
*
|
||||
* @return ApiResponse Response from the API call
|
||||
*/
|
||||
public function paymentTokensDelete(string $id): ApiResponse
|
||||
{
|
||||
$_reqBuilder = $this->requestBuilder(RequestMethod::DELETE, '/v3/vault/payment-tokens/{id}')
|
||||
->auth('Oauth2')
|
||||
->parameters(TemplateParam::init('id', $id));
|
||||
|
||||
$_resHandler = $this->responseHandler()
|
||||
->throwErrorOn(
|
||||
'400',
|
||||
ErrorType::init(
|
||||
'Request is not well-formed, syntactically incorrect, or violates schema.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'403',
|
||||
ErrorType::init('Authorization failed due to insufficient permissions.', ErrorException::class)
|
||||
)
|
||||
->throwErrorOn('500', ErrorType::init('An internal server error has occurred.', ErrorException::class))
|
||||
->returnApiResponse();
|
||||
|
||||
return $this->execute($_reqBuilder, $_resHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Setup Token from the given payment source and adds it to the Vault of the associated
|
||||
* customer.
|
||||
*
|
||||
* @param array $options Array with all options for search
|
||||
*
|
||||
* @return ApiResponse Response from the API call
|
||||
*/
|
||||
public function setupTokensCreate(array $options): ApiResponse
|
||||
{
|
||||
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/v3/vault/setup-tokens')
|
||||
->auth('Oauth2')
|
||||
->parameters(
|
||||
HeaderParam::init('PayPal-Request-Id', $options)->extract('payPalRequestId'),
|
||||
HeaderParam::init('Content-Type', 'application/json'),
|
||||
BodyParam::init($options)->extract('body')
|
||||
);
|
||||
|
||||
$_resHandler = $this->responseHandler()
|
||||
->throwErrorOn(
|
||||
'400',
|
||||
ErrorType::init(
|
||||
'Request is not well-formed, syntactically incorrect, or violates schema.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'403',
|
||||
ErrorType::init('Authorization failed due to insufficient permissions.', ErrorException::class)
|
||||
)
|
||||
->throwErrorOn(
|
||||
'422',
|
||||
ErrorType::init(
|
||||
'The requested action could not be performed, semantically incorrect, or fa' .
|
||||
'iled business validation.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn('500', ErrorType::init('An internal server error has occurred.', ErrorException::class))
|
||||
->type(SetupTokenResponse::class)
|
||||
->returnApiResponse();
|
||||
|
||||
return $this->execute($_reqBuilder, $_resHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a readable representation of temporarily vaulted payment source associated with the setup
|
||||
* token id.
|
||||
*
|
||||
* @param string $id ID of the setup token.
|
||||
*
|
||||
* @return ApiResponse Response from the API call
|
||||
*/
|
||||
public function setupTokensGet(string $id): ApiResponse
|
||||
{
|
||||
$_reqBuilder = $this->requestBuilder(RequestMethod::GET, '/v3/vault/setup-tokens/{id}')
|
||||
->auth('Oauth2')
|
||||
->parameters(TemplateParam::init('id', $id));
|
||||
|
||||
$_resHandler = $this->responseHandler()
|
||||
->throwErrorOn(
|
||||
'403',
|
||||
ErrorType::init('Authorization failed due to insufficient permissions.', ErrorException::class)
|
||||
)
|
||||
->throwErrorOn('404', ErrorType::init('The specified resource does not exist.', ErrorException::class))
|
||||
->throwErrorOn(
|
||||
'422',
|
||||
ErrorType::init(
|
||||
'The requested action could not be performed, semantically incorrect, or fa' .
|
||||
'iled business validation.',
|
||||
ErrorException::class
|
||||
)
|
||||
)
|
||||
->throwErrorOn('500', ErrorType::init('An internal server error has occurred.', ErrorException::class))
|
||||
->type(SetupTokenResponse::class)
|
||||
->returnApiResponse();
|
||||
|
||||
return $this->execute($_reqBuilder, $_resHandler);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user