forked from LiveCarta/PayPal-PHP-Server-SDK
Automated commit message (#9)
Co-authored-by: PayPalServerSDKs <server-sdks@paypal.com>
This commit is contained in:
@@ -3,12 +3,12 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* PaypalServerSDKLib
|
||||
* PaypalServerSdkLib
|
||||
*
|
||||
* This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
|
||||
*/
|
||||
|
||||
namespace PaypalServerSDKLib\Controllers;
|
||||
namespace PaypalServerSdkLib\Controllers;
|
||||
|
||||
use Core\Request\Parameters\BodyParam;
|
||||
use Core\Request\Parameters\HeaderParam;
|
||||
@@ -16,13 +16,126 @@ use Core\Request\Parameters\QueryParam;
|
||||
use Core\Request\Parameters\TemplateParam;
|
||||
use Core\Response\Types\ErrorType;
|
||||
use CoreInterfaces\Core\Request\RequestMethod;
|
||||
use PaypalServerSDKLib\Exceptions\ErrorException;
|
||||
use PaypalServerSDKLib\Http\ApiResponse;
|
||||
use PaypalServerSDKLib\Models\Order;
|
||||
use PaypalServerSDKLib\Models\OrderAuthorizeResponse;
|
||||
use PaypalServerSdkLib\Exceptions\ErrorException;
|
||||
use PaypalServerSdkLib\Http\ApiResponse;
|
||||
use PaypalServerSdkLib\Models\Order;
|
||||
use PaypalServerSdkLib\Models\OrderAuthorizeResponse;
|
||||
|
||||
class OrdersController extends BaseController
|
||||
{
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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:
|
||||
@@ -43,9 +156,9 @@ class OrdersController extends BaseController
|
||||
->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('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')
|
||||
);
|
||||
|
||||
@@ -80,41 +193,6 @@ class OrdersController extends BaseController
|
||||
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
|
||||
@@ -201,122 +279,6 @@ class OrdersController extends BaseController
|
||||
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
|
||||
@@ -336,10 +298,10 @@ class OrdersController extends BaseController
|
||||
->parameters(
|
||||
TemplateParam::init('id', $options)->extract('id'),
|
||||
HeaderParam::init('Content-Type', 'application/json'),
|
||||
HeaderParam::init('PayPal-Request-Id', $options)->extract('payPalRequestId'),
|
||||
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'),
|
||||
HeaderParam::init('PayPal-Client-Metadata-Id', $options)->extract('paypalClientMetadataId'),
|
||||
HeaderParam::init('PayPal-Auth-Assertion', $options)->extract('paypalAuthAssertion'),
|
||||
BodyParam::init($options)->extract('body')
|
||||
);
|
||||
|
||||
@@ -384,21 +346,60 @@ class OrdersController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds tracking information for an Order.
|
||||
* 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 ordersTrackCreate(array $options): ApiResponse
|
||||
public function ordersGet(array $options): ApiResponse
|
||||
{
|
||||
$_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/v2/checkout/orders/{id}/track')
|
||||
$_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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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'),
|
||||
BodyParam::init($options)->extract('body'),
|
||||
HeaderParam::init('PayPal-Auth-Assertion', $options)->extract('payPalAuthAssertion')
|
||||
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()
|
||||
@@ -413,7 +414,6 @@ class OrdersController extends BaseController
|
||||
'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(
|
||||
|
||||
Reference in New Issue
Block a user