Example #1
0
 /** @return EcommercePaymentRequest*/
 protected function provideMinimalPaymentRequest()
 {
     $paymentRequest = new EcommercePaymentRequest(new FakeShaComposer());
     $paymentRequest->setPspid('123456789');
     $paymentRequest->setOrderid('987654321');
     $paymentRequest->setOgoneUri(EcommercePaymentRequest::TEST);
     // minimal required fields for ogone (together with pspid and orderid)
     $paymentRequest->setCurrency("EUR");
     $paymentRequest->setAmount(100);
     // these fields are actually optional but are good practice to be included
     $paymentRequest->setCustomername("Louis XIV");
     $paymentRequest->setOwnerAddress("1, Rue du Palais");
     $paymentRequest->setOwnerTown("Versailles");
     $paymentRequest->setOwnerZip('2300');
     $paymentRequest->setOwnerCountry("FR");
     $paymentRequest->setEmail("*****@*****.**");
     return $paymentRequest;
 }
 /**
  * @param string $locale
  * @param string $orderId
  * @param string $customerName
  * @param integer $amount Amount in cents
  * @param string $currency Example : EUR
  * @param array $options
  * @param bool $showSubmitButton
  * @return string
  */
 public function getRequestForm($locale, $orderId, $customerName, $amount, $currency = "EUR", $options = array(), $showSubmitButton = true)
 {
     $passphrase = $this->shaIn;
     $shaComposer = new AllParametersShaComposer($passphrase);
     $shaComposer->addParameterFilter(new ShaInParameterFilter());
     //optional
     $paymentRequest = new EcommercePaymentRequest($shaComposer);
     switch ($this->environment) {
         case 'prod':
             $paymentRequest->setOgoneUri(EcommercePaymentRequest::PRODUCTION);
             break;
         default:
             $paymentRequest->setOgoneUri(EcommercePaymentRequest::TEST);
             break;
     }
     $paymentRequest->setPspid($this->pspid);
     $paymentRequest->setCn($customerName);
     $paymentRequest->setOrderid($orderId);
     $paymentRequest->setAmount($amount);
     $paymentRequest->setCurrency($currency);
     // setting options defined in config
     foreach ($this->options as $option => $value) {
         $setter = "set" . $option;
         $paymentRequest->{$setter}($value);
     }
     // setting options defined in method call
     foreach ($options as $option => $value) {
         $setter = "set" . $option;
         $paymentRequest->{$setter}($value);
     }
     $paymentRequest->setLanguage($this->localeToIso($locale));
     $paymentRequest->validate();
     $this->formGenerator->showSubmitButton($showSubmitButton);
     return $this->formGenerator->render($paymentRequest);
 }