public function ExpressCheckout::doRequest in Commerce PayPal 8
Performs a PayPal Express Checkout NVP API request.
Parameters
array $nvp_data: The NVP API data array as documented.
\Drupal\commerce_order\Entity\OrderInterface $order: The order entity, or null.
Return value
array PayPal response data.
Overrides ExpressCheckoutInterface::doRequest
See also
https://developer.paypal.com/docs/classic/api/#express-checkout
7 calls to ExpressCheckout::doRequest()
- ExpressCheckout::doCapture in src/
Plugin/ Commerce/ PaymentGateway/ ExpressCheckout.php - DoCapture API Operation (NVP) request.
- ExpressCheckout::doExpressCheckoutDetails in src/
Plugin/ Commerce/ PaymentGateway/ ExpressCheckout.php - GetExpressCheckoutDetails API Operation (NVP) request.
- ExpressCheckout::doRefundTransaction in src/
Plugin/ Commerce/ PaymentGateway/ ExpressCheckout.php - RefundTransaction API Operation (NVP) request.
- ExpressCheckout::doVoid in src/
Plugin/ Commerce/ PaymentGateway/ ExpressCheckout.php - DoVoid API Operation (NVP) request.
- ExpressCheckout::getExpressCheckoutDetails in src/
Plugin/ Commerce/ PaymentGateway/ ExpressCheckout.php - GetExpressCheckoutDetails API Operation (NVP) request.
File
- src/
Plugin/ Commerce/ PaymentGateway/ ExpressCheckout.php, line 783
Class
- ExpressCheckout
- Provides the Paypal Express Checkout payment gateway.
Namespace
Drupal\commerce_paypal\Plugin\Commerce\PaymentGatewayCode
public function doRequest(array $nvp_data, OrderInterface $order = NULL) {
// Add the default name-value pairs to the array.
$configuration = $this
->getConfiguration();
$nvp_data += [
// API credentials.
'USER' => $configuration['api_username'],
'PWD' => $configuration['api_password'],
'SIGNATURE' => $configuration['signature'],
'VERSION' => '124.0',
];
// Allow modules to alter the NVP request.
$event = new ExpressCheckoutRequestEvent($nvp_data, $order);
$this->eventDispatcher
->dispatch(PayPalEvents::EXPRESS_CHECKOUT_REQUEST, $event);
$nvp_data = $event
->getNvpData();
// Make PayPal request.
$request = $this->httpClient
->post($this
->getApiUrl(), [
'form_params' => $nvp_data,
])
->getBody()
->getContents();
parse_str(html_entity_decode($request), $paypal_response);
return $paypal_response;
}