コード例 #1
0
 /**
  * @param bool $rapidFail if true, render a form as a fail page rather than redirect
  * @param string $failPage either a wiki page title, or a URL to an external wiki
  *                         page title.
  * @param array $data information about the current request.
  *                    language, gateway, payment_method, and payment_submethod must be set
  * @param Psr\Log\LoggerInterface $logger
  * @return string full URL of the fail page, or just form name in case of rapidFail
  */
 private static function getFailPageFromParams($rapidFail, $failPage, $data, LoggerInterface $logger)
 {
     if (isset($data['language'])) {
         $language = $data['language'];
     } else {
         $language = WmfFramework::getLanguageCode();
     }
     // Prefer RapidFail.
     if ($rapidFail) {
         // choose which fail page to go for.
         try {
             $fail_ffname = GatewayFormChooser::getBestErrorForm($data['gateway'], $data['payment_method'], $data['payment_submethod']);
             return $fail_ffname;
         } catch (Exception $e) {
             $logger->error('Cannot determine best error form. ' . $e->getMessage());
         }
     }
     if (filter_var($failPage, FILTER_VALIDATE_URL)) {
         return self::appendLanguageAndMakeURL($failPage, $language);
     }
     // FIXME: either add Special:FailPage to avoid depending on wiki content,
     // or update the content on payments to be consistent with the /lang
     // format of ThankYou pages so we can use appendLanguageAndMakeURL here.
     $failTitle = Title::newFromText($failPage);
     $url = wfAppendQuery($failTitle->getFullURL(), array('uselang' => $language));
     return $url;
 }
コード例 #2
0
 function testGetOneValidForm_CC_SpecificCountry()
 {
     $tests = array(0 => array('country' => 'US', 'payment_method' => 'cc', 'currency' => 'USD', 'expected' => 'cc-vmad'), 1 => array('country' => 'DK', 'payment_method' => 'cc', 'currency' => 'DKK', 'expected' => 'cc-vma'));
     foreach ($tests as $testno => $data) {
         $form = GatewayFormChooser::getOneValidForm($data['country'], $data['currency'], $data['payment_method']);
         $this->assertEquals($data['expected'], $form, "{$form} is not the preferred option for " . $data['payment_method'] . ' in ' . $data['country']);
     }
 }
コード例 #3
0
 protected function addRetryLink(&$data)
 {
     //add data we're going to need for the error page!
     $back_form = $this->gateway->session_getLastFormName();
     $params = array('gateway' => $this->gateway->getIdentifier());
     if (!$this->gateway->session_hasDonorData()) {
         $preserve = $this->gateway->getRetryData();
         $params = array_merge($preserve, $params);
     }
     $data['ffname_retry'] = GatewayFormChooser::buildPaymentsFormURL($back_form, $params);
 }
 /**
  *
  * @covers GatewayAdapter::__construct
  * @covers GatewayAdapter::defineVarMap
  * @covers GatewayAdapter::defineReturnValueMap
  * @covers GatewayAdapter::defineTransactions
  */
 public function testConstructor()
 {
     $options = $this->getDonorTestData();
     $class = $this->testAdapterClass;
     $_SERVER['REQUEST_URI'] = GatewayFormChooser::buildPaymentsFormURL('testytest', array('gateway' => $class::getIdentifier()));
     $gateway = $this->getFreshGatewayObject($options);
     $this->assertInstanceOf(TESTS_ADAPTER_DEFAULT, $gateway);
     $this->resetAllEnv();
     $gateway = $this->getFreshGatewayObject($options = array());
     $this->assertInstanceOf(TESTS_ADAPTER_DEFAULT, $gateway, "Having trouble constructing a blank adapter.");
 }
コード例 #5
0
 /**
  * isValidSpecialForm: Tells us if the ffname supplied is a valid
  * special form for the current gateway.
  * @var string $ffname The form name we want to try
  * @return boolean True if this is a valid special form, otherwise false
  */
 public function isValidSpecialForm($ffname)
 {
     $defn = GatewayFormChooser::getFormDefinition($ffname);
     if (is_array($defn) && DataValidator::value_appears_in($this->getIdentifier(), $defn['gateway']) && array_key_exists('special_type', $defn)) {
         return true;
     }
     return false;
 }