public function testFallbackByCountry() { // With 'FallbackCurrencyByCountry', we need to return a single supported currency TestingGenericAdapter::$acceptedCurrencies = array('USD'); TestingGenericAdapter::$fakeGlobals = array('FallbackCurrency' => false, 'FallbackCurrencyByCountry' => true); $this->setUpAdapter(); $this->adapter->addRequestData(array('country' => 'US')); $this->page->validateForm(); $this->assertEquals(100, $this->adapter->getData_Unstaged_Escaped('amount')); $this->assertEquals('USD', $this->adapter->getData_Unstaged_Escaped('currency_code')); }
/** * 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); } }