ApiVersion.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. <?php
  2. /**
  3. * This file is part of the Klarna Core module
  4. *
  5. * (c) Klarna Bank AB (publ)
  6. *
  7. * For the full copyright and license information, please view the NOTICE
  8. * and LICENSE files that were distributed with this source code.
  9. */
  10. namespace Klarna\Core\Config;
  11. use Klarna\Core\Api\VersionInterface;
  12. /**
  13. * Class ApiVersion
  14. *
  15. * @package Klarna\Core\Config
  16. * @SuppressWarnings(PHPMD.TooManyFields)
  17. */
  18. class ApiVersion implements VersionInterface
  19. {
  20. /**
  21. * @var string
  22. */
  23. private $type = 'payments';
  24. /**
  25. * @var string
  26. */
  27. private $code = 'kp_na';
  28. /**
  29. * @var bool
  30. */
  31. private $shipping_callback_support = false;
  32. /**
  33. * @var bool
  34. */
  35. private $merchant_checkbox_support = false;
  36. /**
  37. * @var bool
  38. */
  39. private $date_of_birth_mandatory_support = false;
  40. /**
  41. * @var bool
  42. */
  43. private $phone_mandatory_support = false;
  44. /**
  45. * @var string
  46. */
  47. private $ordermanagement;
  48. /**
  49. * @var bool
  50. */
  51. private $title_mandatory_support = false;
  52. /**
  53. * @var bool
  54. */
  55. private $delayed_push_notification = false;
  56. /**
  57. * @var bool
  58. */
  59. private $partial_payment_disabled = false;
  60. /**
  61. * @var bool
  62. */
  63. private $separate_tax_line = false;
  64. /**
  65. * @var bool
  66. */
  67. private $shipping_in_iframe = false;
  68. /**
  69. * @var bool
  70. */
  71. private $cart_totals_in_iframe = false;
  72. /**
  73. * @var bool
  74. */
  75. private $packstation_support = false;
  76. /**
  77. * @var string
  78. */
  79. private $production_url = 'https://api.klarna.com';
  80. /**
  81. * @var string
  82. */
  83. private $testdrive_url = 'https://api.playground.klarna.com';
  84. /**
  85. * @var bool
  86. */
  87. private $payment_review = false;
  88. /**
  89. * @var string
  90. */
  91. private $label = '';
  92. /**
  93. * ApiVersion constructor.
  94. *
  95. * @param string $type
  96. */
  97. public function __construct($data = [])
  98. {
  99. foreach ($data as $key => $value) {
  100. if (property_exists($this, $key)) {
  101. $this->$key = $value;
  102. }
  103. }
  104. }
  105. /**
  106. * @return bool
  107. */
  108. public function isCartTotalsInIframe()
  109. {
  110. return $this->cart_totals_in_iframe;
  111. }
  112. /**
  113. * @param bool $cart_totals_in_iframe
  114. * @return ApiVersion
  115. */
  116. public function setCartTotalsInIframe($cart_totals_in_iframe)
  117. {
  118. $this->cart_totals_in_iframe = $cart_totals_in_iframe;
  119. return $this;
  120. }
  121. /**
  122. * @return bool
  123. */
  124. public function isPackstationSupport()
  125. {
  126. return $this->packstation_support;
  127. }
  128. /**
  129. * @param bool $packstation_support
  130. * @return ApiVersion
  131. */
  132. public function setPackstationSupport($packstation_support)
  133. {
  134. $this->packstation_support = $packstation_support;
  135. return $this;
  136. }
  137. /**
  138. * @return string
  139. */
  140. public function getType()
  141. {
  142. return $this->type;
  143. }
  144. /**
  145. * @param mixed $type
  146. * @return ApiVersion
  147. */
  148. public function setType($type)
  149. {
  150. $this->type = $type;
  151. return $this;
  152. }
  153. /**
  154. * @return bool
  155. */
  156. public function isShippingCallbackSupport()
  157. {
  158. return $this->shipping_callback_support;
  159. }
  160. /**
  161. * @param mixed $shipping_callback_support
  162. * @return ApiVersion
  163. */
  164. public function setShippingCallbackSupport($shipping_callback_support)
  165. {
  166. $this->shipping_callback_support = $shipping_callback_support;
  167. return $this;
  168. }
  169. /**
  170. * @return bool
  171. */
  172. public function isMerchantCheckboxSupport()
  173. {
  174. return $this->merchant_checkbox_support;
  175. }
  176. /**
  177. * @param mixed $merchant_checkbox_support
  178. * @return ApiVersion
  179. */
  180. public function setMerchantCheckboxSupport($merchant_checkbox_support)
  181. {
  182. $this->merchant_checkbox_support = $merchant_checkbox_support;
  183. return $this;
  184. }
  185. /**
  186. * @return bool
  187. */
  188. public function isDateOfBirthMandatorySupport()
  189. {
  190. return $this->date_of_birth_mandatory_support;
  191. }
  192. /**
  193. * @param mixed $date_of_birth_mandatory_support
  194. * @return ApiVersion
  195. */
  196. public function setDateOfBirthMandatorySupport($date_of_birth_mandatory_support)
  197. {
  198. $this->date_of_birth_mandatory_support = $date_of_birth_mandatory_support;
  199. return $this;
  200. }
  201. /**
  202. * @return bool
  203. */
  204. public function isPhoneMandatorySupport()
  205. {
  206. return $this->phone_mandatory_support;
  207. }
  208. /**
  209. * @param mixed $phone_mandatory_support
  210. * @return ApiVersion
  211. */
  212. public function setPhoneMandatorySupport($phone_mandatory_support)
  213. {
  214. $this->phone_mandatory_support = $phone_mandatory_support;
  215. return $this;
  216. }
  217. /**
  218. * @return string
  219. */
  220. public function getOrdermanagement()
  221. {
  222. return $this->ordermanagement;
  223. }
  224. /**
  225. * @param mixed $ordermanagement
  226. * @return ApiVersion
  227. */
  228. public function setOrdermanagement($ordermanagement)
  229. {
  230. $this->ordermanagement = $ordermanagement;
  231. return $this;
  232. }
  233. /**
  234. * @return bool
  235. */
  236. public function isTitleMandatorySupport()
  237. {
  238. return $this->title_mandatory_support;
  239. }
  240. /**
  241. * @param mixed $title_mandatory_support
  242. * @return ApiVersion
  243. */
  244. public function setTitleMandatorySupport($title_mandatory_support)
  245. {
  246. $this->title_mandatory_support = $title_mandatory_support;
  247. return $this;
  248. }
  249. /**
  250. * @return bool
  251. */
  252. public function isDelayedPushNotification()
  253. {
  254. return $this->delayed_push_notification;
  255. }
  256. /**
  257. * @param mixed $delayed_push_notification
  258. * @return ApiVersion
  259. */
  260. public function setDelayedPushNotification($delayed_push_notification)
  261. {
  262. $this->delayed_push_notification = $delayed_push_notification;
  263. return $this;
  264. }
  265. /**
  266. * @return bool
  267. */
  268. public function isPartialPaymentDisabled()
  269. {
  270. return $this->partial_payment_disabled;
  271. }
  272. /**
  273. * @param mixed $partial_payment_disabled
  274. * @return ApiVersion
  275. */
  276. public function setPartialPaymentDisabled($partial_payment_disabled)
  277. {
  278. $this->partial_payment_disabled = $partial_payment_disabled;
  279. return $this;
  280. }
  281. /**
  282. * @return bool
  283. */
  284. public function isSeparateTaxLine()
  285. {
  286. return $this->separate_tax_line;
  287. }
  288. /**
  289. * @param mixed $separate_tax_line
  290. * @return ApiVersion
  291. */
  292. public function setSeparateTaxLine($separate_tax_line)
  293. {
  294. $this->separate_tax_line = $separate_tax_line;
  295. return $this;
  296. }
  297. /**
  298. * @return bool
  299. */
  300. public function isShippingInIframe()
  301. {
  302. return $this->shipping_in_iframe;
  303. }
  304. /**
  305. * @param mixed $shipping_in_iframe
  306. * @return ApiVersion
  307. */
  308. public function setShippingInIframe($shipping_in_iframe)
  309. {
  310. $this->shipping_in_iframe = $shipping_in_iframe;
  311. return $this;
  312. }
  313. /**
  314. * @param bool $testmode
  315. * @return string
  316. */
  317. public function getUrl($testmode = true)
  318. {
  319. if ($testmode) {
  320. return $this->getTestdriveUrl();
  321. }
  322. return $this->getProductionUrl();
  323. }
  324. /**
  325. * @return string
  326. */
  327. public function getTestdriveUrl()
  328. {
  329. return $this->testdrive_url;
  330. }
  331. /**
  332. * @param mixed $testdrive_url
  333. * @return ApiVersion
  334. */
  335. public function setTestdriveUrl($testdrive_url)
  336. {
  337. $this->testdrive_url = $testdrive_url;
  338. return $this;
  339. }
  340. /**
  341. * @return string
  342. */
  343. public function getProductionUrl()
  344. {
  345. return $this->production_url;
  346. }
  347. /**
  348. * @param mixed $production_url
  349. * @return ApiVersion
  350. */
  351. public function setProductionUrl($production_url)
  352. {
  353. $this->production_url = $production_url;
  354. return $this;
  355. }
  356. /**
  357. * @return bool
  358. */
  359. public function isPaymentReview()
  360. {
  361. return $this->payment_review;
  362. }
  363. /**
  364. * @param bool $payment_review
  365. * @return ApiVersion
  366. */
  367. public function setPaymentReview($payment_review)
  368. {
  369. $this->payment_review = $payment_review;
  370. return $this;
  371. }
  372. /**
  373. * @return string
  374. */
  375. public function getLabel()
  376. {
  377. return $this->label;
  378. }
  379. /**
  380. * @param string $label
  381. * @return ApiVersion
  382. */
  383. public function setLabel($label)
  384. {
  385. $this->label = $label;
  386. return $this;
  387. }
  388. /**
  389. * @return string
  390. */
  391. public function getCode()
  392. {
  393. return $this->code;
  394. }
  395. /**
  396. * @param string $code
  397. * @return ApiVersion
  398. */
  399. public function setCode($code)
  400. {
  401. $this->code = $code;
  402. return $this;
  403. }
  404. }