You are here

public function PayPalPaymentECPaymentMethodController::checkoutURL in PayPal for Payment 7

Returns the redirect URL.

Parameters

string $server: One of the self::NVP_API_SERVER_* constants.

string $token: The PayPal checkout token received from setExpressCheckout.

Return value

string

Throws

InvalidArgumentException

1 call to PayPalPaymentECPaymentMethodController::checkoutURL()
PayPalPaymentECPaymentMethodController::execute in paypal_payment_ec/includes/PayPalPaymentECPaymentMethodController.inc
Execute a payment.

File

paypal_payment_ec/includes/PayPalPaymentECPaymentMethodController.inc, line 124

Class

PayPalPaymentECPaymentMethodController
A PayPal Express Checkout payment method.

Code

public function checkoutURL($server, $token) {
  $urls = array(
    $this::NVP_API_SERVER_PRODUCTION => $this::URL_CHECKOUT_PRODUCTION,
    $this::NVP_API_SERVER_SANDBOX => $this::URL_CHECKOUT_SANDBOX,
  );
  if (isset($urls[$server])) {
    $url = url($urls[$server], array(
      'external' => TRUE,
    ));
  }
  else {
    throw new InvalidArgumentException(t('Server type does not exist.'));
  }
  $options = array(
    'query' => array(
      'cmd' => '_express-checkout',
      'token' => $token,
      // This module requires that users confirm their payments when they are
      // at the Paypal site, and not when they have returned to Drupal.
      'useraction' => 'commit',
    ),
  );
  return url($url, $options + array(
    'external' => TRUE,
  ));
}