Example #1
0
 public function addSpecificPaymentPageParameters(Customweb_Payment_Authorization_IOrderContext $orderContext, array $parameters)
 {
     $this->orderContext = $orderContext;
     $this->addIfValueNotNull($parameters, 'COMPANY', Customweb_Saferpay_Util::removeWrongEscaptedChars($orderContext->getBillingCompanyName()));
     $this->addIfValueNotNull($parameters, 'LEGALFORM', $this->guessLegalForm());
     $this->addIfValueNotNull($parameters, 'GENDER', $this->getGender($orderContext->getBillingGender(), $orderContext->getBillingCompanyName()));
     $parameters['FIRSTNAME'] = Customweb_Saferpay_Util::removeWrongEscaptedChars($orderContext->getBillingFirstName());
     $parameters['LASTNAME'] = Customweb_Saferpay_Util::removeWrongEscaptedChars($orderContext->getBillingLastName());
     $parameters['STREET'] = Customweb_Saferpay_Util::removeWrongEscaptedChars($orderContext->getBillingStreet());
     $parameters['ZIP'] = $orderContext->getBillingPostCode();
     $parameters['CITY'] = Customweb_Saferpay_Util::removeWrongEscaptedChars($orderContext->getBillingCity());
     $parameters['COUNTRY'] = $orderContext->getBillingCountryIsoCode();
     $parameters['EMAIL'] = $orderContext->getCustomerEMailAddress();
     $this->addIfValueNotNull($parameters, 'PHONE', $orderContext->getBillingPhoneNumber());
     if ($orderContext->getBillingDateOfBirth() != null) {
         $this->addIfValueNotNull($parameters, 'DATEOFBIRTH', $orderContext->getBillingDateOfBirth()->format('Ymd'));
     }
     $this->addIfValueNotNull($parameters, 'DELIVERY_GENDER', $this->getGender($orderContext->getShippingGender(), ""));
     $parameters['DELIVERY_FIRSTNAME'] = Customweb_Saferpay_Util::removeWrongEscaptedChars($orderContext->getShippingFirstName());
     $parameters['DELIVERY_LASTNAME'] = Customweb_Saferpay_Util::removeWrongEscaptedChars($orderContext->getShippingLastName());
     $parameters['DELIVERY_STREET'] = Customweb_Saferpay_Util::removeWrongEscaptedChars($orderContext->getShippingStreet());
     $parameters['DELIVERY_ZIP'] = $orderContext->getShippingPostCode();
     $parameters['DELIVERY_CITY'] = Customweb_Saferpay_Util::removeWrongEscaptedChars($orderContext->getShippingCity());
     $parameters['DELIVERY_COUNTRY'] = $orderContext->getShippingCountryIsoCode();
     $this->addIfValueNotNull($parameters, 'DELIVERY_PHONE', $orderContext->getShippingPhoneNumber());
     $parameters['LANGID'] = substr($orderContext->getLanguage(), 0, 2);
     //$parameters['IP'] = Customweb_Saferpay_Util::getClientIpAddress();
     return $parameters;
 }
 public function getVisibleFormFields(Customweb_Payment_Authorization_IOrderContext $orderContext, $aliasTransaction, $failedTransaction, $isMoto = false)
 {
     $formBuilder = new Customweb_Payment_Authorization_Method_CreditCard_ElementBuilder();
     // Set field names
     $formBuilder->setCardHolderFieldName(self::FORM_KEY_OWNER_NAME)->setCardNumberFieldName(self::FORM_KEY_CARD_NUMBER)->setCvcFieldName(self::FORM_KEY_CARD_CVC)->setExpiryMonthFieldName(self::FORM_KEY_CARD_EXPIRY_MONTH)->setExpiryYearFieldName(self::FORM_KEY_CARD_EXPIRY_YEAR)->setExpiryYearNumberOfDigits(2);
     // Handle brand selection
     if (strtolower($this->getPaymentMethodName()) == 'creditcard') {
         $brands = $this->getPaymentMethodConfigurationValue('credit_card_brands');
         $formBuilder->setCardHandlerByBrandInformationMap($this->getPaymentInformationMap(), $brands, 'id')->setAutoBrandSelectionActive(true);
     } else {
         $formBuilder->setFixedBrand(true)->setSelectedBrand($this->getPaymentMethodName())->setCardHandlerByBrandInformationMap($this->getPaymentInformationMap(), $this->getPaymentMethodName(), 'id');
     }
     $formBuilder->setCardHolderName($orderContext->getBillingFirstName() . ' ' . $orderContext->getBillingLastName());
     if ($aliasTransaction !== null && $aliasTransaction !== 'new' && $aliasTransaction instanceof Customweb_Saferpay_Authorization_Transaction) {
         $formBuilder->setSelectedExpiryMonth($aliasTransaction->getCardExpiryMonth());
         $formBuilder->setSelectedExpiryYear($aliasTransaction->getCardExpiryYear());
         $params = $aliasTransaction->getAuthorizationParameters();
         $formBuilder->setMaskedCreditCardNumber($params['PAN']);
         $formBuilder->setCardHolderName($aliasTransaction->getOwnerName());
     }
     if ($isMoto) {
         $formBuilder->setCvcFieldName(null);
     }
     return $formBuilder->build();
 }
 /**
  * This method throws an exception in case the shipping and billing address do not match.
  * 
  * @param Customweb_Payment_Authorization_IOrderContext $orderContext
  * @throws Exception
  */
 protected function checkAddresses(Customweb_Payment_Authorization_IOrderContext $orderContext)
 {
     if ($orderContext->getBillingCity() != $orderContext->getShippingCity()) {
         throw new Exception(Customweb_I18n_Translation::__("The billing and shipping address do not match."));
     }
     if ($orderContext->getBillingPostCode() != $orderContext->getShippingPostCode()) {
         throw new Exception(Customweb_I18n_Translation::__("The billing and shipping address do not match."));
     }
     if ($orderContext->getBillingStreet() != $orderContext->getShippingStreet()) {
         throw new Exception(Customweb_I18n_Translation::__("The billing and shipping address do not match."));
     }
     if ($orderContext->getBillingFirstName() != $orderContext->getShippingFirstName()) {
         throw new Exception(Customweb_I18n_Translation::__("The billing and shipping address do not match."));
     }
     if ($orderContext->getBillingLastName() != $orderContext->getShippingLastName()) {
         throw new Exception(Customweb_I18n_Translation::__("The billing and shipping address do not match."));
     }
     if ($orderContext->getBillingCountryIsoCode() != $orderContext->getShippingCountryIsoCode()) {
         throw new Exception(Customweb_I18n_Translation::__("The billing and shipping address do not match."));
     }
     return true;
 }