public function process($data)
 {
     parent::process($data);
     $this->postData['METHOD'] = 'SetExpressCheckout';
     // Add return and cancel urls
     $this->postData['RETURNURL'] = $this->returnURL;
     $this->postData['CANCELURL'] = $this->cancelURL;
     $response = $this->postPaymentData($data);
     if ($response->getStatusCode() != '200') {
         return PaymentGateway_Failure($response);
     } else {
         if ($token = $this->getToken($response)) {
             // If Authorization successful, redirect to PayPal to complete the payment
             Controller::curr()->redirect(self::get_paypal_redirect_url() . "?cmd=_express-checkout&token={$token}");
         } else {
             // Otherwise, return failure message
             $errorList = $this->getErrors($response);
             return new PaymentGateway_Failure(null, null, $errorList);
         }
     }
 }
 /**
  * @see PayPalGateway::process()
  */
 public function process($data)
 {
     parent::process($data);
     $this->postData['METHOD'] = 'DoDirectPayment';
     // Add credit card data. May have to parse the data to fit PayPal's format
     $ccTypeMap = $this->creditCardTypeIDMapping();
     $this->postData['CREDITCARDTYPE'] = $ccTypeMap[$data['CreditCardType']];
     $this->postData['ACCT'] = $data['CardNumber'];
     $this->postData['EXPDATE'] = $data['MonthExpiry'] . $data['YearExpiry'];
     $this->postData['CVV2'] = $data['Cvc2'];
     $this->postData['FIRSTNAME'] = $data['FirstName'];
     $this->postData['LASTNAME'] = $data['LastName'];
     // Add optional parameters
     $this->postData['IP'] = isset($data['IP']) ? $data['IP'] : $_SERVER['REMOTE_ADDR'];
     // Post the data to PayPal server
     $response = $this->postPaymentData($this->postData);
     if ($response->getStatusCode() != '200') {
         // Cannot connect to PayPal server
         return new PaymentGateway_Failure($response);
     } else {
         $responseArr = $this->parseResponse($response);
         if (!isset($responseArr['ACK'])) {
             return new PaymentGateway_Failure();
         } else {
             switch ($responseArr['ACK']) {
                 case self::SUCCESS_CODE:
                 case self::SUCCESS_WARNING:
                     return new PaymentGateway_Success();
                     break;
                 case self::FAILURE_CODE:
                     $errorList = $this->getErrors($response);
                     return new PaymentGateway_Failure(null, null, $errorList);
                     break;
                 default:
                     return new PaymentGateway_Failure();
                     break;
             }
         }
     }
 }