/**
  * Create Paytrail payment object for E1 API version. E1 API requires following fields:
  * - First name
  * - Last name
  * - Email
  * - Street address
  * - Post code
  * - Post office
  * - Country
  * - Product title
  * - Product quantity
  * - Product price
  * - Tax (VAT)
  *
  * @link http://docs.paytrail.com/en/ch05s02.html#idp140474540882720
  * @param array $params name value pair of form data
  * @param Verkkomaksut_Module_Rest_Urlset $urlset Paytrail object holding all return URLs
  * @param string $component name of CiviCRM component that is using this Payment Processor (contribute, event)
  * @return Verkkomaksut_Module_Rest_Payment Paytrail payment object
  */
 private function &createE1PaymentObject(&$params, $urlset, $component)
 {
     $orderNumber = $params['invoiceID'];
     $price = (double) $params['amount'];
     // An object is created to model payer’s data
     $contact = new Verkkomaksut_Module_Rest_Contact($this->paytrailConfig->get("e1.{$component}.value.firstName"), $this->paytrailConfig->get("e1.{$component}.value.lastName"), $this->paytrailConfig->get("e1.{$component}.value.email"), $this->paytrailConfig->get("e1.{$component}.value.streetAddress"), $this->paytrailConfig->get("e1.{$component}.value.postalCode"), $this->paytrailConfig->get("e1.{$component}.value.city"), $this->paytrailConfig->get("e1.{$component}.value.country"), $this->paytrailConfig->get("e1.{$component}.value.telephone"), $this->paytrailConfig->get("e1.{$component}.value.mobile"), $this->paytrailConfig->get("e1.{$component}.value.companyName"));
     // Payment creation
     $payment = new Verkkomaksut_Module_Rest_Payment_E1($orderNumber, $urlset, $contact);
     //Set optional description. This is only visible in Paytrail Merchant admin panel.
     $description = $this->paytrailConfig->get("e1.{$component}.value.firstName") . " " . $this->paytrailConfig->get("e1.{$component}.value.lastName") . ". " . $this->paytrailConfig->get("e1.{$component}.value.productTitle") . ". " . $this->paytrailConfig->get("e1.{$component}.value.productPrice") . " €";
     $payment->setDescription($description);
     // Adding one or more product rows to the payment
     $payment->addProduct($this->paytrailConfig->get("e1.{$component}.value.productTitle"), $this->paytrailConfig->get("e1.{$component}.value.productCode"), $this->paytrailConfig->get("e1.{$component}.value.productQuantity"), $this->paytrailConfig->get("e1.{$component}.value.productPrice"), $this->paytrailConfig->get("e1.{$component}.value.productVat"), $this->paytrailConfig->get("e1.{$component}.value.productDiscountPercentage"), $this->paytrailConfig->get("e1.{$component}.value.productType"));
     return $payment;
 }
 /**
  * Returns all rows from civicrm_paytrail_payment_processor_config table.
  * Listens URL civicrm/paytrail/settings/ajax/getConfig.
  */
 public static function getConfig()
 {
     $configHelper = new CRM_Paytrail_ConfigHelper();
     echo json_encode(array_merge($configHelper->getDefaultValues(), $configHelper->getAllDatabaseConfigs()));
     CRM_Utils_System::civiExit();
 }