コード例 #1
0
 /**
  * @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);
 }