MethodInterface.php 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Payment\Model;
  7. use Magento\Framework\DataObject;
  8. use Magento\Quote\Api\Data\CartInterface;
  9. /**
  10. * Payment interface
  11. * @api
  12. * @since 100.0.2
  13. */
  14. interface MethodInterface
  15. {
  16. /**
  17. * Different payment actions.
  18. */
  19. const ACTION_ORDER = 'order';
  20. const ACTION_AUTHORIZE = 'authorize';
  21. const ACTION_AUTHORIZE_CAPTURE = 'authorize_capture';
  22. /**
  23. * Different payment method checks.
  24. */
  25. const CHECK_USE_FOR_COUNTRY = 'country';
  26. const CHECK_USE_FOR_CURRENCY = 'currency';
  27. const CHECK_USE_CHECKOUT = 'checkout';
  28. const CHECK_USE_INTERNAL = 'internal';
  29. const CHECK_ORDER_TOTAL_MIN_MAX = 'total';
  30. const CHECK_ZERO_TOTAL = 'zero_total';
  31. const GROUP_OFFLINE = 'offline';
  32. /**
  33. * Retrieve payment method code
  34. *
  35. * @return string
  36. *
  37. */
  38. public function getCode();
  39. /**
  40. * Retrieve block type for method form generation
  41. *
  42. * @return string
  43. *
  44. * @deprecated 100.0.2
  45. */
  46. public function getFormBlockType();
  47. /**
  48. * Retrieve payment method title
  49. *
  50. * @return string
  51. *
  52. */
  53. public function getTitle();
  54. /**
  55. * Store id setter
  56. * @param int $storeId
  57. * @return void
  58. */
  59. public function setStore($storeId);
  60. /**
  61. * Store id getter
  62. * @return int
  63. */
  64. public function getStore();
  65. /**
  66. * Check order availability
  67. *
  68. * @return bool
  69. *
  70. */
  71. public function canOrder();
  72. /**
  73. * Check authorize availability
  74. *
  75. * @return bool
  76. *
  77. */
  78. public function canAuthorize();
  79. /**
  80. * Check capture availability
  81. *
  82. * @return bool
  83. *
  84. */
  85. public function canCapture();
  86. /**
  87. * Check partial capture availability
  88. *
  89. * @return bool
  90. *
  91. */
  92. public function canCapturePartial();
  93. /**
  94. * Check whether capture can be performed once and no further capture possible
  95. *
  96. * @return bool
  97. *
  98. */
  99. public function canCaptureOnce();
  100. /**
  101. * Check refund availability
  102. *
  103. * @return bool
  104. *
  105. */
  106. public function canRefund();
  107. /**
  108. * Check partial refund availability for invoice
  109. *
  110. * @return bool
  111. *
  112. */
  113. public function canRefundPartialPerInvoice();
  114. /**
  115. * Check void availability
  116. * @return bool
  117. *
  118. */
  119. public function canVoid();
  120. /**
  121. * Using internal pages for input payment data
  122. * Can be used in admin
  123. *
  124. * @return bool
  125. */
  126. public function canUseInternal();
  127. /**
  128. * Can be used in regular checkout
  129. *
  130. * @return bool
  131. */
  132. public function canUseCheckout();
  133. /**
  134. * Can be edit order (renew order)
  135. *
  136. * @return bool
  137. *
  138. */
  139. public function canEdit();
  140. /**
  141. * Check fetch transaction info availability
  142. *
  143. * @return bool
  144. *
  145. */
  146. public function canFetchTransactionInfo();
  147. /**
  148. * Fetch transaction info
  149. *
  150. * @param InfoInterface $payment
  151. * @param string $transactionId
  152. * @return array
  153. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  154. *
  155. */
  156. public function fetchTransactionInfo(InfoInterface $payment, $transactionId);
  157. /**
  158. * Retrieve payment system relation flag
  159. *
  160. * @return bool
  161. *
  162. */
  163. public function isGateway();
  164. /**
  165. * Retrieve payment method online/offline flag
  166. *
  167. * @return bool
  168. *
  169. */
  170. public function isOffline();
  171. /**
  172. * Flag if we need to run payment initialize while order place
  173. *
  174. * @return bool
  175. *
  176. */
  177. public function isInitializeNeeded();
  178. /**
  179. * To check billing country is allowed for the payment method
  180. *
  181. * @param string $country
  182. * @return bool
  183. */
  184. public function canUseForCountry($country);
  185. /**
  186. * Check method for processing with base currency
  187. *
  188. * @param string $currencyCode
  189. * @return bool
  190. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  191. */
  192. public function canUseForCurrency($currencyCode);
  193. /**
  194. * Retrieve block type for display method information
  195. *
  196. * @return string
  197. *
  198. * @deprecated 100.0.2
  199. */
  200. public function getInfoBlockType();
  201. /**
  202. * Retrieve payment information model object
  203. *
  204. * @return InfoInterface
  205. * @throws \Magento\Framework\Exception\LocalizedException
  206. *
  207. * @deprecated 100.0.2
  208. */
  209. public function getInfoInstance();
  210. /**
  211. * Retrieve payment information model object
  212. *
  213. * @param InfoInterface $info
  214. * @return void
  215. *
  216. * @deprecated 100.0.2
  217. */
  218. public function setInfoInstance(InfoInterface $info);
  219. /**
  220. * Validate payment method information object
  221. *
  222. * @return $this
  223. * @throws \Magento\Framework\Exception\LocalizedException
  224. *
  225. */
  226. public function validate();
  227. /**
  228. * Order payment abstract method
  229. *
  230. * @param InfoInterface $payment
  231. * @param float $amount
  232. * @return $this
  233. *
  234. */
  235. public function order(\Magento\Payment\Model\InfoInterface $payment, $amount);
  236. /**
  237. * Authorize payment abstract method
  238. *
  239. * @param InfoInterface $payment
  240. * @param float $amount
  241. * @return $this
  242. *
  243. */
  244. public function authorize(\Magento\Payment\Model\InfoInterface $payment, $amount);
  245. /**
  246. * Capture payment abstract method
  247. *
  248. * @param InfoInterface $payment
  249. * @param float $amount
  250. * @return $this
  251. *
  252. */
  253. public function capture(\Magento\Payment\Model\InfoInterface $payment, $amount);
  254. /**
  255. * Refund specified amount for payment
  256. *
  257. * @param InfoInterface $payment
  258. * @param float $amount
  259. * @return $this
  260. *
  261. */
  262. public function refund(\Magento\Payment\Model\InfoInterface $payment, $amount);
  263. /**
  264. * Cancel payment abstract method
  265. *
  266. * @param InfoInterface $payment
  267. * @return $this
  268. *
  269. */
  270. public function cancel(\Magento\Payment\Model\InfoInterface $payment);
  271. /**
  272. * Void payment abstract method
  273. *
  274. * @param InfoInterface $payment
  275. * @return $this
  276. *
  277. */
  278. public function void(\Magento\Payment\Model\InfoInterface $payment);
  279. /**
  280. * Whether this method can accept or deny payment
  281. * @return bool
  282. *
  283. */
  284. public function canReviewPayment();
  285. /**
  286. * Attempt to accept a payment that us under review
  287. *
  288. * @param InfoInterface $payment
  289. * @return false
  290. * @throws \Magento\Framework\Exception\LocalizedException
  291. *
  292. */
  293. public function acceptPayment(InfoInterface $payment);
  294. /**
  295. * Attempt to deny a payment that us under review
  296. *
  297. * @param InfoInterface $payment
  298. * @return false
  299. * @throws \Magento\Framework\Exception\LocalizedException
  300. *
  301. */
  302. public function denyPayment(InfoInterface $payment);
  303. /**
  304. * Retrieve information from payment configuration
  305. *
  306. * @param string $field
  307. * @param int|string|null|\Magento\Store\Model\Store $storeId
  308. *
  309. * @return mixed
  310. */
  311. public function getConfigData($field, $storeId = null);
  312. /**
  313. * Assign data to info model instance
  314. *
  315. * @param DataObject $data
  316. * @return $this
  317. *
  318. */
  319. public function assignData(DataObject $data);
  320. /**
  321. * Check whether payment method can be used
  322. *
  323. * @param CartInterface|null $quote
  324. * @return bool
  325. *
  326. */
  327. public function isAvailable(CartInterface $quote = null);
  328. /**
  329. * Is active
  330. *
  331. * @param int|null $storeId
  332. * @return bool
  333. *
  334. */
  335. public function isActive($storeId = null);
  336. /**
  337. * Method that will be executed instead of authorize or capture
  338. * if flag isInitializeNeeded set to true
  339. *
  340. * @param string $paymentAction
  341. * @param object $stateObject
  342. *
  343. * @return $this
  344. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  345. *
  346. */
  347. public function initialize($paymentAction, $stateObject);
  348. /**
  349. * Get config payment action url
  350. * Used to universalize payment actions when processing payment place
  351. *
  352. * @return string
  353. *
  354. */
  355. public function getConfigPaymentAction();
  356. }