protected function renderResponse(PaymentResult $result)
 {
     // FIXME: This workaround can be deleted once we convert
     // these two result pages to render using normal templates.
     if ($result->getForm() === 'end-bt') {
         $this->displayBankTransferInformation();
     } elseif ($result->getForm() === 'end-obt') {
         $this->displayOnlineBankTransferInformation();
     } else {
         parent::renderResponse($result);
     }
 }
 public function doPayment()
 {
     $ctid = $this->getData_Unstaged_Escaped('contribution_tracking_id');
     $this->normalizeOrderID($ctid);
     $this->addRequestData(array('order_id' => $ctid));
     if ($this->getData_Unstaged_Escaped('recurring')) {
         $resultData = $this->do_transaction('DonateRecurring');
     } else {
         $country = $this->getData_Unstaged_Escaped('country');
         if (in_array($country, $this->getGlobal('XclickCountries'))) {
             $resultData = $this->do_transaction('DonateXclick');
         } else {
             $resultData = $this->do_transaction('Donate');
         }
     }
     return PaymentResult::fromResults($resultData, $this->getFinalStatus());
 }
 /**
  * Take UI action suggested by the payment result
  */
 protected function renderResponse(PaymentResult $result)
 {
     if ($result->isFailed()) {
         $this->logger->info('Displaying fail page for failed PaymentResult');
         $this->displayFailPage();
     } elseif ($url = $result->getRedirect()) {
         $this->adapter->logPending();
         $this->getOutput()->redirect($url);
     } elseif ($url = $result->getIframe()) {
         // Show a form containing an iframe.
         // Well, that's sketchy.  See TODO in renderIframe: we should
         // accomplish this entirely by passing an iframeSrcUrl parameter
         // to the template.
         $this->displayForm();
         $this->renderIframe($url);
     } elseif ($form = $result->getForm()) {
         // Show another form.
         $this->adapter->addRequestData(array('ffname' => $form));
         $this->displayForm();
     } elseif ($errors = $result->getErrors()) {
         // FIXME: Creepy.  Currently, the form inspects adapter errors.  Use
         // the stuff encapsulated in PaymentResult instead.
         foreach ($this->adapter->getTransactionResponse()->getErrors() as $code => $transactionError) {
             $message = $transactionError['message'];
             $error = array();
             if (!empty($transactionError['context'])) {
                 $error[$transactionError['context']] = $message;
             } else {
                 if (strpos($code, 'internal') === 0) {
                     $error['retryMsg'][$code] = $message;
                 } else {
                     $error['general'][$code] = $message;
                 }
             }
             $this->adapter->addManualError($error);
         }
         $this->displayForm();
     } else {
         // Success.
         $thankYouPage = ResultPages::getThankYouPage($this->adapter);
         $this->logger->info("Displaying thank you page {$thankYouPage} for successful PaymentResult.");
         $this->getOutput()->redirect($thankYouPage);
     }
 }
 /**
  * Note that the Amazon adapter is somewhat unique in that it uses a third
  * party SDK to make all processor API calls.  Since we're never calling
  * do_transaction and friends, we synthesize a PaymentTransactionResponse
  * to hold any errors returned from the SDK.
  */
 public function doPayment()
 {
     $this->client = $this->getPwaClient();
     $this->transaction_response = new PaymentTransactionResponse();
     if ($this->session_getData('sequence')) {
         $this->regenerateOrderID();
     }
     try {
         if ($this->getData_Unstaged_Escaped('recurring') === '1') {
             $this->confirmBillingAgreement();
             $this->authorizeAndCapturePayment(true);
         } else {
             $this->confirmOrderReference();
             $this->authorizeAndCapturePayment(false);
         }
     } catch (ResponseProcessingException $ex) {
         $this->handleErrors($ex, $this->transaction_response);
     }
     $this->incrementSequenceNumber();
     return PaymentResult::fromResults($this->transaction_response, $this->getFinalStatus());
 }
 public function doPayment()
 {
     if ($this->getData_Unstaged_Escaped('recurring')) {
         // Build the billing agreement and get a token to redirect.
         $resultData = $this->do_transaction('SetExpressCheckout_recurring');
     } else {
         // Returns a token which we use to build a redirect URL into the
         // PayPal flow.
         $resultData = $this->do_transaction('SetExpressCheckout');
     }
     return PaymentResult::fromResults($resultData, $this->getFinalStatus());
 }
 function doPayment()
 {
     return PaymentResult::fromResults($this->do_transaction('donate'), $this->getFinalStatus());
 }
 /**
  * Build a PaymentResult object from adapter results
  *
  * @param PaymentTransactionResponse $response processed response object
  * @param string $finalStatus final transaction status.
  *
  * @return PaymentResult
  */
 public static function fromResults(PaymentTransactionResponse $response, $finalStatus)
 {
     if ($finalStatus === FinalStatus::FAILED) {
         return PaymentResult::newFailure($response->getErrors());
     }
     if (!$response) {
         return PaymentResult::newEmpty();
     }
     if ($response->getErrors()) {
         // TODO: We will probably want the ability to refresh to a new form
         // as well and display errors at the same time.
         return PaymentResult::newRefresh($response->getErrors());
     }
     if ($response->getRedirect()) {
         return PaymentResult::newRedirect($response->getRedirect());
     }
     return PaymentResult::newSuccess();
 }
 /**
  * Cancel a subscription
  *
  * Uses the adapter's internal order ID.
  *
  * @return PaymentResult
  */
 public function cancelSubscription()
 {
     // Try to cancel, in case no payment attempts have been made or all
     // payment attempts can be canceled
     $response = $this->do_transaction('CANCEL_ORDER');
     if (!$response->getCommunicationStatus()) {
         // If we can't cancel, end it to disallow future attempts
         $response = $this->do_transaction('END_ORDER');
         if (!$response->getCommunicationStatus()) {
             return PaymentResult::fromResults($response, FinalStatus::FAILED);
         }
     }
     return PaymentResult::fromResults($response, FinalStatus::COMPLETE);
 }
 function doPayment()
 {
     // If this is not our first NewInvoice call, get a fresh order ID
     if ($this->session_getData('sequence')) {
         $this->regenerateOrderID();
     }
     $transaction_result = $this->do_transaction('NewInvoice');
     $this->runAntifraudFilters();
     if ($this->getValidationAction() !== 'process') {
         $this->finalizeInternalStatus(FinalStatus::FAILED);
     }
     $result = PaymentResult::fromResults($transaction_result, $this->getFinalStatus());
     return $result;
 }