public function deposit(jmsPaymentMethodData $data, $retry = false)
 {
     try {
         $result = $this->getDispatcher()->sessionApprove($this->getAccessKey(), $this->getTestMode(), $data['external_reference_number']);
         $data->setResponseCode($result['status']);
         if ($result['status'] === 'APPROVED') {
             $data->setProcessedAmount($data->getAmount());
         }
     } catch (Exception $e) {
         $data->setReasonCode($e->getMessage());
         $e = jmsPaymentException::fromException($e);
         $e->setPaymentMethodData($data);
         throw $e;
     }
 }
 /**
  * Generates the Express URL which is given to the user in order to approve
  * the payment
  * 
  * @param $data
  * @throws jmsPaymentUserActionRequiredException this is always thrown
  */
 private function generateExpressUrl(jmsPaymentMethodData $data)
 {
     $amount = PayPal::getType('BasicAmountType');
     $amount->setattr('currencyID', $data->getCurrency());
     $amount->setval(number_format($data->getAmount(), 2));
     $expressCheckout = PayPal::getType('SetExpressCheckoutRequestDetailsType');
     $expressCheckout->setNoShipping($data->getValue('no_shipping', 1));
     $expressCheckout->setCancelURL($data->getValue('cancel_url'));
     $expressCheckout->setReturnURL($data->getValue('return_url'));
     $expressCheckout->setPaymentAction('Order');
     $expressCheckout->setOrderDescription($data->getValue('subject'));
     $expressCheckout->setOrderTotal($amount);
     $expressCheckoutRequest = PayPal::getType('SetExpressCheckoutRequestType');
     $expressCheckoutRequest->setVersion(self::API_VERSION);
     $expressCheckoutRequest->setSetExpressCheckoutRequestDetails($expressCheckout);
     $request = $this->getCallerServices()->SetExpressCheckout($expressCheckoutRequest);
     if (Pear::isError($request)) {
         throw new jmsPaymentCommunicationException('Error when retrieving the express URL: ' . $request->getMessage());
     }
     if ($request->Ack !== 'Success') {
         $reasonCode = $this->extractErrors($request->Errors);
         $data->setReasonCode($reasonCode);
         $e = new jmsPaymentException('Error when retrieving the express url: ' . $reasonCode);
         $e->setPaymentMethodData($data);
         throw $e;
     }
     $host = !$this->isDebug() ? 'www.paypal.com' : 'www.sandbox.paypal.com';
     $data->setProcessedAmount($data->getAmount());
     $data->setValue('express_token', $request->Token);
     $data->setValue('express_url', sprintf('https://%s/cgi-bin/webscr?cmd=_express-checkout&token=%s', $host, $request->Token));
     // throw
     $exception = new jmsPaymentUserActionRequiredException(new jmsPaymentUserActionVisitURL($data->getValue('express_url')));
     $exception->setPaymentMethodData($data);
     throw $exception;
 }