Source of file OrderStatusLogPaymentCheck.php
Size: 3,391 Bytes - Last Modified: 2021-12-23T10:39:35+00:00
/var/www/docs.ssmods.com/process/src/src/Model/Process/OrderStatusLogs/OrderStatusLogPaymentCheck.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 | <?php namespace Sunnysideup\Ecommerce\Model\Process\OrderStatusLogs; use SilverStripe\Forms\CheckboxField; use SilverStripe\Forms\NumericField; use Sunnysideup\Ecommerce\Api\SetThemed; use Sunnysideup\Ecommerce\Model\Process\OrderStatusLog; /** * @Description: We use this payment check class to double check that payment has arrived against * the order placed. We do this independently of Order as a double-check. It is important * that we do this because the main risk in an e-commerce operation is a fake payment. * Any e-commerce operator may set up their own policies on what a payment check * entails exactly. It could include a bank reconciliation or even a phone call to the customer. * it is important here that we do not add any payment details. Rather, all we have is a tickbox * * @authors: Nicolaas [at] Sunny Side Up .co.nz * @package: ecommerce * @sub-package: model */ class OrderStatusLogPaymentCheck extends OrderStatusLog { private static $table_name = 'OrderStatusLogPaymentCheck'; private static $defaults = [ 'InternalUseOnly' => true, ]; private static $db = [ 'PaymentConfirmed' => 'Boolean', ]; private static $searchable_fields = [ 'OrderID' => [ 'field' => NumericField::class, 'title' => 'Order Number', ], 'PaymentConfirmed' => true, ]; private static $summary_fields = [ 'Created' => 'Date', 'Author.Title' => 'Checked by', 'PaymentConfirmedNice' => 'Payment Confirmed', ]; private static $casting = [ 'PaymentConfirmedNice' => 'Varchar', ]; private static $singular_name = 'Payment Confirmation'; private static $plural_name = 'Payment Confirmations'; /** * Standard SS method. * * @param \SilverStripe\Security\Member $member * * @return bool */ public function canDelete($member = null) { return false; } public function PaymentConfirmedNice() { return $this->getPaymentConfirmedNice(); } public function getPaymentConfirmedNice() { if ($this->PaymentConfirmed) { return _t('OrderStatusLog.YES', 'yes'); } return _t('OrderStatusLog.No', 'no'); } public function i18n_singular_name() { return _t('OrderStatusLog.PAYMENTCONFIRMATION', 'Payment Confirmation'); } public function i18n_plural_name() { return _t('OrderStatusLog.PAYMENTCONFIRMATIONS', 'Payment Confirmations'); } /** * @return \SilverStripe\Forms\FieldList */ public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName('Title'); $fields->removeByName('Note'); $fields->addFieldToTab( 'Root.Main', new CheckboxField('PaymentConfirmed', _t('OrderStatusLog.CONFIRMED', 'Payment is confirmed')) ); return $fields; } /** * @return string */ public function CustomerNote() { return $this->getCustomerNote(); } public function getCustomerNote() { if ($this->Author()) { SetThemed::start(); $html = $this->renderWith('Sunnysideup\Ecommerce\Includes\Order_CustomerNote_PaymentCheck'); SetThemed::end(); return $html; } } } |