Exemplo n.º 1
0
 /**
  * Provides the billing payment card input or current value of the billing card
  *
  * @api `shopp('checkout.billing-card')`
  * @since 1.0
  *
  * @param string     $result  The output
  * @param array      $options The options
  * - **mode**: `input` (input, value) Displays the field `input` or the current value of the property
  * - **mask**: `X` The character used to mask the actual numbers of the card PAN
  * - **autocomplete**: (on, off) Specifies whether an `<input>` element should have autocomplete enabled
  * - **accesskey**: Specifies a shortcut key to activate/focus an element. Linux/Windows: `[Alt]`+`accesskey`, Mac: `[Ctrl]``[Opt]`+`accesskey`
  * - **alt**: Specifies an alternate text for images (only for type="image")
  * - **checked**: Specifies that an `<input>` element should be pre-selected when the page loads (for type="checkbox" or type="radio")
  * - **class**: `paycard` The class attribute specifies one or more class-names for an element
  * - **disabled**: Specifies that an `<input>` element should be disabled
  * - **format**: Specifies special field formatting class names for JS validation
  * - **minlength**: Sets a minimum length for the field enforced by JS validation
  * - **maxlength**: Specifies the maximum number of characters allowed in an `<input>` element
  * - **placeholder**: Specifies a short hint that describes the expected value of an `<input>` element
  * - **readonly**: Specifies that an input field is read-only
  * - **required**: Adds a class that specified an input field must be filled out before submitting the form, enforced by JS
  * - **size**: Specifies the width, in characters, of an `<input>` element
  * - **src**: Specifies the URL of the image to use as a submit button (only for type="image")
  * - **tabindex**: Specifies the tabbing order of an element
  * - **cols**: Specifies the visible width of a `<textarea>`
  * - **rows**: Specifies the visible number of lines in a `<textarea>`
  * - **title**: Specifies extra information about an element
  * - **value**: Specifies the value of an `<input>` element
  * @param ShoppOrder $O       The working object
  * @return string The generated markup or value
  **/
 public static function billing_card($result, $options, $O)
 {
     $card = $O->Billing->card;
     $modes = array('input', 'value');
     $classes = array('paycard');
     $defaults = array('class' => '', 'mode' => 'input', 'mask' => 'X');
     $options = array_merge($defaults, $options);
     if (!in_array($options['mode'], $modes)) {
         $options['mode'] = reset($modes);
     }
     $options['value'] = PayCard::mask($card, $options['mask']);
     $classes[] = $options['class'];
     extract($options, EXTR_SKIP);
     if ('value' == $mode) {
         return $value;
     }
     $options['class'] = join(' ', $classes);
     if (!isset($options['autocomplete'])) {
         $options['autocomplete'] = 'off';
     }
     return '<input type="text" name="billing[card]" id="billing-card" ' . inputattrs($options) . ' />';
 }
Exemplo n.º 2
0
 public function save()
 {
     $new = false;
     if (empty($this->id)) {
         $new = true;
     }
     if (!empty($this->card)) {
         $this->card = PayCard::truncate($this->card);
     }
     parent::save();
 }
Exemplo n.º 3
0
 public function filter($msg)
 {
     if (empty($msg['payid'])) {
         return $msg;
     }
     $msg['payid'] = PayCard::truncate($msg['payid']);
     return $msg;
 }