-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathLinkCreditCard.php
More file actions
executable file
·152 lines (132 loc) · 3.98 KB
/
LinkCreditCard.php
File metadata and controls
executable file
·152 lines (132 loc) · 3.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?php
/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* https://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Plugin\SamplePayment\Service\Method;
use Eccube\Entity\Master\OrderStatus;
use Eccube\Entity\Order;
use Eccube\Exception\ShoppingException;
use Eccube\Repository\Master\OrderStatusRepository;
use Eccube\Service\Payment\PaymentDispatcher;
use Eccube\Service\Payment\PaymentMethodInterface;
use Eccube\Service\Payment\PaymentResult;
use Eccube\Service\PurchaseFlow\PurchaseContext;
use Eccube\Service\PurchaseFlow\PurchaseFlow;
use Plugin\SamplePayment\Entity\PaymentStatus;
use Plugin\SamplePayment\Repository\PaymentStatusRepository;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
/**
* クレジットカード(リンク式)の決済処理を行う
*/
class LinkCreditCard implements PaymentMethodInterface
{
/**
* @var Order
*/
private $Order;
/**
* @var FormInterface
*/
private $form;
/**
* @var OrderStatusRepository
*/
private $orderStatusRepository;
/**
* @var PaymentStatusRepository
*/
private $paymentStatusRepository;
/**
* @var PurchaseFlow
*/
private $purchaseFlow;
/**
* LinkCreditCard constructor.
*
* @param OrderStatusRepository $orderStatusRepository
* @param PaymentStatusRepository $paymentStatusRepository
* @param PurchaseFlow $shoppingPurchaseFlow
*/
public function __construct(
OrderStatusRepository $orderStatusRepository,
PaymentStatusRepository $paymentStatusRepository,
PurchaseFlow $shoppingPurchaseFlow
) {
$this->orderStatusRepository = $orderStatusRepository;
$this->paymentStatusRepository = $paymentStatusRepository;
$this->purchaseFlow = $shoppingPurchaseFlow;
}
/**
* 注文確認画面遷移時に呼び出される.
*
* リンク式は使用しない.
*
* @return PaymentResult|void
*/
public function verify()
{
$result = new PaymentResult();
$result->setSuccess(true);
return $result;
}
/**
* 注文時に呼び出される.
*
* 決済サーバのカード入力画面へリダイレクトする.
*
* @return PaymentDispatcher
*
* @throws ShoppingException
*/
public function apply()
{
// 受注ステータスを決済処理中へ変更
$OrderStatus = $this->orderStatusRepository->find(OrderStatus::PENDING);
$this->Order->setOrderStatus($OrderStatus);
// 決済ステータスを未決済へ変更
$PaymentStatus = $this->paymentStatusRepository->find(PaymentStatus::OUTSTANDING);
$this->Order->setSamplePaymentPaymentStatus($PaymentStatus);
// purchaseFlow::prepareを呼び出し, 購入処理を進める.
$this->purchaseFlow->prepare($this->Order, new PurchaseContext());
// 決済サーバのカード入力画面へリダイレクトする.
$url = '/payment_company?no='.$this->Order->getOrderNo();
$response = new RedirectResponse($url);
$dispatcher = new PaymentDispatcher();
$dispatcher->setResponse($response);
return $dispatcher;
}
/**
* 注文時に呼び出される.
* リンク式の場合, applyで決済サーバのカード入力画面へ遷移するため, checkoutは使用しない.
*
* @return PaymentResult
*/
public function checkout()
{
$result = new PaymentResult();
$result->setSuccess(true);
return $result;
}
/**
* {@inheritdoc}
*/
public function setFormType(FormInterface $form)
{
$this->form = $form;
}
/**
* {@inheritdoc}
*/
public function setOrder(Order $Order)
{
$this->Order = $Order;
}
}