1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Sunnysideup\PaymentHirePurchase; |
4
|
|
|
|
5
|
|
|
use SilverStripe\Core\Config\Config; |
6
|
|
|
use SilverStripe\Forms\FieldList; |
7
|
|
|
use SilverStripe\Forms\Form; |
8
|
|
|
use SilverStripe\Forms\HiddenField; |
9
|
|
|
use SilverStripe\Forms\LiteralField; |
10
|
|
|
use Sunnysideup\Ecommerce\Model\Money\EcommercePayment; |
11
|
|
|
use Sunnysideup\Ecommerce\Model\Order; |
12
|
|
|
use Sunnysideup\Ecommerce\Money\Payment\PaymentResults\EcommercePaymentSuccess; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Payment object representing an Hire Purchase Payment (order online and then complete HP application externally). |
16
|
|
|
* |
17
|
|
|
* @author Nicolaas [at] sunnysideup.co.nz |
18
|
|
|
*/ |
19
|
|
|
class HirePurchasePayment extends EcommercePayment |
20
|
|
|
{ |
21
|
|
|
private static $custom_message_for_in_store_payment = ''; |
22
|
|
|
|
23
|
|
|
private static $logo = 'https://www.creditcapable.co.nz/ccl.png'; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Process the In Store payment method. |
27
|
|
|
* |
28
|
|
|
* @param mixed $data |
29
|
|
|
*/ |
30
|
|
|
public function processPayment($data, Form $form) |
31
|
|
|
{ |
32
|
|
|
$this->Status = EcommercePayment::PENDING_STATUS; |
|
|
|
|
33
|
|
|
$this->Message = Config::inst()->get(HirePurchasePayment::class, 'custom_message_for_hire_purchase_payment'); |
|
|
|
|
34
|
|
|
$this->write(); |
35
|
|
|
|
36
|
|
|
return EcommercePaymentSuccess::create(); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function getPaymentFormFields($amount = 0, ?Order $order = null): FieldList |
40
|
|
|
{ |
41
|
|
|
return new FieldList( |
42
|
|
|
new LiteralField( |
43
|
|
|
'HirePurchasePayment_BeforeMessage', |
44
|
|
|
'<div id="HirePurchasePayment_BeforeMessage"><img src="' . $this->Config()->get('logo') . '" alt="Online Finance provided by credit capable"></div>' |
45
|
|
|
), |
46
|
|
|
new HiddenField('HirePurchase', 'HirePurchase', 0) |
47
|
|
|
); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function getPaymentFormRequirements(): array |
51
|
|
|
{ |
52
|
|
|
return []; |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|