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;
     }
 }
 /**
  * Deposits a transaction
  * @throws jmsPaymentApprovalExpiredException
  * @throws jmsPaymentCommunicationException
  * @see plugins/jmsPaymentPlugin/lib/method/jmsPaymentMethod#deposit($data, $retry)
  */
 public function deposit(jmsPaymentMethodData $data, $retry = false)
 {
     $amount = PayPal::getType('BasicAmountType');
     $amount->setattr('currencyID', $data->getCurrency());
     $amount->setval(number_format($data->getAmount(), 2));
     $captureRequest = Paypal::getType('DoCaptureRequestType');
     $captureRequest->setAmount($amount);
     $captureRequest->setAuthorizationId($data->getValue('external_reference_number'));
     $captureRequest->setCompleteType('Complete');
     if ($data->hasValue('note')) {
         $captureRequest->setNote($data->getValue('note'));
     }
     $result = $this->getCallerServices()->DoCapture($captureRequest);
     if (Pear::isError($result)) {
         throw new jmsPaymentCommunicationException('Error while capturing payment: ' . $result->getMessage());
     }
     if ($result->Ack !== 'Success') {
         throw new jmsPaymentCommunicationException('Error ' . $result->Ack . ' while capturing.');
     }
     $response = $result->getDoCaptureResponseDetails();
     $paymentInfo = $response->getPaymentInfo();
     $data->setResponseCode($paymentInfo->PaymentStatus);
     $data->setProcessedAmount($data->getAmount());
     // process the payment status
     switch ($paymentInfo->PaymentStatus) {
         case 'Expired':
             $e = new jmsPaymentApprovalExpiredException();
             $e->setPaymentMethodData($data);
             throw $e;
         case 'Completed':
             return $data;
         case 'Pending':
             $e = new jmsPaymentException('Payment is still pending; reason: ' . $paymentInfo->PendingReason);
             $data->setReasonCode($paymentInfo->PendingReason);
             $e->setPaymentMethodData($data);
             throw $e;
         default:
             // TODO: Some more processing as to what went wrong exactly
             $e = new jmsPaymentException('Payment could not be completed. Status: ' . $paymentInfo->PaymentStatus);
             $e->setPaymentMethodData($data);
             throw $e;
     }
 }