/**
  * Creates and returns the HTML form for initialising the
  * Postfinance Mobile payment.
  *
  * Fields:
  *  - Mandatory:
  *      currency    ISO 4217 currency code (only CHF for the time being)
  *      amount      Amount in cents (2.50 CHF = 250)
  *      orderid     Unique order ID
  *      webuser     The Mobilesolutions webuser name
  *      sign        SHA-1 Signature
  *      urlsuccess  Target URL after successful payment
  *      urlerror    Target URL after failed payment
  *  - Optional:
  *      customparam     Parameters to be appended to the success or error URL
  *      ijustwanttotest Enables the test mode if present
  * @param   integer   $amount           The order amount in cents
  * @param   integer   $order_id         The order ID
  * @param   string    $customparam      The optional custom parameter(s)
  * @param   boolean   $ijustwanttotest  Enable test mode if true
  * @return  mixed                       The HTML form on success, false
  *                                      otherwise
  * @static
  */
 static function getForm($amount, $order_id, $customparam = '', $ijustwanttotest = null)
 {
     global $_ARRAYLANG, $_CONFIG;
     if (!isset($ijustwanttotest)) {
         $ijustwanttotest = \Cx\Core\Setting\Controller\Setting::getValue('postfinance_mobile_ijustwanttotest', 'Shop');
     }
     if (empty($amount)) {
         self::$arrError[] = sprintf($_ARRAYLANG['TXT_SHOP_POSTFINANCE_MOBILE_ERROR_INVALID_AMOUNT'], $amount);
         return false;
     }
     if (empty($order_id)) {
         self::$arrError[] = sprintf($_ARRAYLANG['TXT_SHOP_POSTFINANCE_MOBILE_ERROR_INVALID_ORDER_ID'], $order_id);
         return false;
     }
     $currency = \Cx\Modules\Shop\Controller\Currency::getActiveCurrencyCode();
     if (empty($currency)) {
         self::$arrError[] = $_ARRAYLANG['TXT_SHOP_POSTFINANCE_MOBILE_ERROR_FAILED_TO_DETERMINE_ACTIVE_CURRENCY'];
         return false;
     }
     $webuser = \Cx\Core\Setting\Controller\Setting::getValue('postfinance_mobile_webuser', 'Shop');
     if (empty($webuser)) {
         self::$arrError[] = $_ARRAYLANG['TXT_SHOP_POSTFINANCE_MOBILE_ERROR_FAILED_TO_DETERMINE_WEBUSER'];
         return false;
     }
     $sign = \Cx\Core\Setting\Controller\Setting::getValue('postfinance_mobile_sign', 'Shop');
     if (empty($sign)) {
         self::$arrError[] = $_ARRAYLANG['TXT_SHOP_POSTFINANCE_MOBILE_ERROR_FAILED_TO_DETERMINE_SIGNATURE'];
         return false;
     }
     $signature = hash_hmac('sha1', $amount . $currency . $order_id . $webuser, pack('H*', $sign));
     $urlsuccess = Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'success')->toString() . '?handler=mobilesolutions&result=1' . '&order_id=' . $order_id;
     $urlerror = Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'success')->toString() . '?handler=mobilesolutions&result=0' . '&order_id=' . $order_id;
     /*
     Live URIs:
     https://postfinance.mobilesolutions.ch/webshop/handyzahlung
     http://api.smsserv.ch/webshop/handyzahlung
     
     Test URIs:
     https://postfinance.mobilesolutions.ch/shoptest/handyzahlung
     http://api.smsserv.ch/shoptest/handyzahlung
     
     On the testing environment, use the flag "ijustwanttotest", the mobile
     phone number 079 999 99 99, and the security code 12345678 to enforce
     a successful payment.  Any other numbers will produce a failed transaction.
     */
     return $_ARRAYLANG['TXT_ORDER_LINK_PREPARED'] . "<br/><br/>\n" . '<form name="postfinancemobile" method="post" ' . 'action="' . ($ijustwanttotest ? 'https://postfinance.mobilesolutions.ch/shoptest/handyzahlung' : 'https://postfinance.mobilesolutions.ch/webshop/handyzahlung') . '">' . "\n" . '<input type="hidden" name="currency" value="' . $currency . '" />' . "\n" . '<input type="hidden" name="amount" value="' . $amount . '" />' . "\n" . '<input type="hidden" name="orderid" value="' . $order_id . '" />' . "\n" . '<input type="hidden" name="webuser" value="' . $webuser . '" />' . "\n" . '<input type="hidden" name="sign" value="' . $signature . '" />' . "\n" . '<input type="hidden" name="urlsuccess" value="' . $urlsuccess . '" />' . "\n" . '<input type="hidden" name="urlerror" value="' . $urlerror . '" />' . "\n" . ($customparam ? '<input type="hidden" name="customparam" value="' . urlencode($customparam) . '" />' . "\n" : '') . ($ijustwanttotest ? '<input type="hidden" name="ijustwanttotest" value="1" />' . "\n" : '') . '<input type="submit" name="bsubmit" value="' . $_ARRAYLANG['TXT_SHOP_POSTFINANCE_MOBILE_SUBMIT'] . '" />' . "\n" . '</form>' . "\n";
 }