Version: current

     1 <?php
     2
     3 // Способ оплаты Банковский перевод
     4 class ChequePayment extends PaymentMethod {
     5
     6     static $db = array(
     7         'INN' => 'Varchar',
     8         'KPP' => 'Varchar',
     9         'PaymentReceiver' => 'Varchar(255)',
    10         'ReceiverAddress' => 'Varchar(255)',
    11         'ReceiverBank' => 'Varchar(255)',
    12         'ReceiverAccountNumber' => 'Varchar',
    13         'BIK' => 'Varchar',
    14         'BankAccountNumber' => 'Varchar', // Номер счета отделения банка
    15         'BillSign' => 'Varchar(255)', // Подпись счета
    16         'BookerBillSign' => 'Varchar(255)', // Подпись счета бухгалтером
    17         'PaymentTerms' => 'Text', // Подпись счета
    18     );
    19
    20     static $paymentMethodIcons = array(
    21         'cart_payment/img/ChequePayment.png',
    22     );
    23
    24     /*
    25     function PaymentIcon() {
    26         if ($this->IconID) {
    27             return $this->Icon();
    28         }
    29         $t = new Image_Cached(self::$defaultIconPath);
    30         return $t;
    31     }
    32     */
    33
    34     function getPaymentHandler() {
    35         return 'ChequePayment_Handler';
    36     }
    37
    38     public function getCMSFields() {
    39         $fields = parent::getCMSFields();
    40         $tab = $fields->findOrMakeTab('Root.BillCredits', _t('ChequePayment.BillCredits','BillCredits'));
    41         $tab->push(new TextField('INN', $this->owner->fieldLabel('INN')));
    42         $tab->push(new TextField('KPP', $this->owner->fieldLabel('KPP')));
    43         $tab->push(new TextField('BIK', $this->owner->fieldLabel('BIK')));
    44         $tab->push(new TextField('PaymentReceiver', $this->owner->fieldLabel('PaymentReceiver')));
    45         $tab->push(new TextField('ReceiverAccountNumber', $this->owner->fieldLabel('ReceiverAccountNumber')));
    46         $tab->push(new TextField('ReceiverAddress', $this->owner->fieldLabel('ReceiverAddress')));
    47         $tab->push(new TextField('ReceiverBank', $this->owner->fieldLabel('ReceiverBank')));
    48         $tab->push(new TextField('BankAccountNumber', $this->owner->fieldLabel('BankAccountNumber')));
    49         $tab->push(new TextField('BillSign', $this->owner->fieldLabel('BillSign')));
    50         $tab->push(new TextField('BookerBillSign', $this->owner->fieldLabel('BookerBillSign')));
    51         $tab->push(new TextAreaField('PaymentTerms', $this->owner->fieldLabel('PaymentTerms')));
    52         return $fields;
    53     }
    54
    55     function processPayment($payment) {
    56         $payment->Status = 'Pending';
    57         $payment->write();
    58         //$htmlData = $this->owner->renderWith('ChequePayment_bill'); //шаблон квитанции оплаты
    59         $link = $this->paymentLink($payment->ID);
    60         $rs = new Payment_Success($link);
    61         return $rs;
    62     }
    63
    64     // "чистая" ссылка (URL) на оплату
    65     function getClearPaymentLink($payment) {
    66         return Director::absoluteURL(ChequePayment_Handler::print_link($payment->ID));
    67     }
    68 }
    69
    70 class ChequePayment_Handler extends Payment_Handler {
    71
    72     static $URLSegment = 'cheque';
    73
    74     static function print_link($paymentID) {
    75         if ($payment = DataObject::get_by_id('Payment', $paymentID)) {
    76             return self::$URLSegment . '/print_payment?paym_id=' . $payment->HashLink;
    77         }
    78     }
    79
    80     /**
    81      * Manages the Uniteller replies
    82      */
    83     function print_payment() {
    84         if (isset($_GET['paym_id'])) {
    85             $hash = Convert::raw2sql($_GET['paym_id']);
    86             if ($payment = DataObject::get_one('Payment', "HashLink = '{$hash}'")) {
    87                 return $this->customise(array(
    88                     'PaymentType' => $payment->PaymentType(),
    89                     'Payment' => $payment,
    90                 ))->renderWith('ChequePayment_bill');
    91             }
    92         }
    93         return false;
    94     }
    95 }
    96
    97
    98

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -