Invoices.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. <?php
  2. namespace Srmklive\PayPal\Tests\Mocks\Requests;
  3. use GuzzleHttp\Utils;
  4. trait Invoices
  5. {
  6. /**
  7. * @return array
  8. */
  9. private function createInvoiceParams(): array
  10. {
  11. return Utils::jsonDecode('{
  12. "detail": {
  13. "invoice_number": "#123",
  14. "reference": "deal-ref",
  15. "invoice_date": "2018-11-12",
  16. "currency_code": "USD",
  17. "note": "Thank you for your business.",
  18. "term": "No refunds after 30 days.",
  19. "memo": "This is a long contract",
  20. "payment_term": {
  21. "term_type": "NET_10",
  22. "due_date": "2018-11-22"
  23. }
  24. },
  25. "invoicer": {
  26. "name": {
  27. "given_name": "David",
  28. "surname": "Larusso"
  29. },
  30. "address": {
  31. "address_line_1": "1234 First Street",
  32. "address_line_2": "337673 Hillside Court",
  33. "admin_area_2": "Anytown",
  34. "admin_area_1": "CA",
  35. "postal_code": "98765",
  36. "country_code": "US"
  37. },
  38. "email_address": "merchant@example.com",
  39. "phones": [
  40. {
  41. "country_code": "001",
  42. "national_number": "4085551234",
  43. "phone_type": "MOBILE"
  44. }
  45. ],
  46. "website": "www.test.com",
  47. "tax_id": "ABcNkWSfb5ICTt73nD3QON1fnnpgNKBy- Jb5SeuGj185MNNw6g",
  48. "logo_url": "https://example.com/logo.PNG",
  49. "additional_notes": "2-4"
  50. },
  51. "primary_recipients": [
  52. {
  53. "billing_info": {
  54. "name": {
  55. "given_name": "Stephanie",
  56. "surname": "Meyers"
  57. },
  58. "address": {
  59. "address_line_1": "1234 Main Street",
  60. "admin_area_2": "Anytown",
  61. "admin_area_1": "CA",
  62. "postal_code": "98765",
  63. "country_code": "US"
  64. },
  65. "email_address": "bill-me@example.com",
  66. "phones": [
  67. {
  68. "country_code": "001",
  69. "national_number": "4884551234",
  70. "phone_type": "HOME"
  71. }
  72. ],
  73. "additional_info_value": "add-info"
  74. },
  75. "shipping_info": {
  76. "name": {
  77. "given_name": "Stephanie",
  78. "surname": "Meyers"
  79. },
  80. "address": {
  81. "address_line_1": "1234 Main Street",
  82. "admin_area_2": "Anytown",
  83. "admin_area_1": "CA",
  84. "postal_code": "98765",
  85. "country_code": "US"
  86. }
  87. }
  88. }
  89. ],
  90. "items": [
  91. {
  92. "name": "Yoga Mat",
  93. "description": "Elastic mat to practice yoga.",
  94. "quantity": "1",
  95. "unit_amount": {
  96. "currency_code": "USD",
  97. "value": "50.00"
  98. },
  99. "tax": {
  100. "name": "Sales Tax",
  101. "percent": "7.25"
  102. },
  103. "discount": {
  104. "percent": "5"
  105. },
  106. "unit_of_measure": "QUANTITY"
  107. },
  108. {
  109. "name": "Yoga t-shirt",
  110. "quantity": "1",
  111. "unit_amount": {
  112. "currency_code": "USD",
  113. "value": "10.00"
  114. },
  115. "tax": {
  116. "name": "Sales Tax",
  117. "percent": "7.25"
  118. },
  119. "discount": {
  120. "amount": {
  121. "currency_code": "USD",
  122. "value": "5.00"
  123. }
  124. },
  125. "unit_of_measure": "QUANTITY"
  126. }
  127. ],
  128. "configuration": {
  129. "partial_payment": {
  130. "allow_partial_payment": true,
  131. "minimum_amount_due": {
  132. "currency_code": "USD",
  133. "value": "20.00"
  134. }
  135. },
  136. "allow_tip": true,
  137. "tax_calculated_after_discount": true,
  138. "tax_inclusive": false,
  139. "template_id": "TEMP-19V05281TU309413B"
  140. },
  141. "amount": {
  142. "breakdown": {
  143. "custom": {
  144. "label": "Packing Charges",
  145. "amount": {
  146. "currency_code": "USD",
  147. "value": "10.00"
  148. }
  149. },
  150. "shipping": {
  151. "amount": {
  152. "currency_code": "USD",
  153. "value": "10.00"
  154. },
  155. "tax": {
  156. "name": "Sales Tax",
  157. "percent": "7.25"
  158. }
  159. },
  160. "discount": {
  161. "invoice_discount": {
  162. "percent": "5"
  163. }
  164. }
  165. }
  166. }
  167. }', true);
  168. }
  169. /**
  170. * @return array
  171. */
  172. private function updateInvoiceParams(): array
  173. {
  174. return Utils::jsonDecode('{
  175. "id": "INV2-C82X-JNN9-Y6S5-CNXW",
  176. "status": "DRAFT",
  177. "detail": {
  178. "invoice_number": "#123",
  179. "reference": "deal-refernce-update",
  180. "invoice_date": "2018-11-12",
  181. "currency_code": "USD",
  182. "note": "Thank you for your business.",
  183. "term": "No refunds after 30 days.",
  184. "memo": "This is a long contract",
  185. "payment_term": {
  186. "term_type": "NET_10",
  187. "due_date": "2018-11-22"
  188. }
  189. },
  190. "invoicer": {
  191. "name": {
  192. "given_name": "David",
  193. "surname": "Larusso"
  194. },
  195. "address": {
  196. "address_line_1": "1234 First Street",
  197. "address_line_2": "337673 Hillside Court",
  198. "admin_area_2": "Anytown",
  199. "admin_area_1": "CA",
  200. "postal_code": "98765",
  201. "country_code": "US"
  202. },
  203. "email_address": "merchant@example.com",
  204. "phones": [
  205. {
  206. "country_code": "001",
  207. "national_number": "4085551234",
  208. "phone_type": "MOBILE"
  209. }
  210. ],
  211. "website": "www.test.com",
  212. "tax_id": "ABcNkWSfb5ICTt73nD3QON1fnnpgNKBy-Jb5SeuGj185MNNw6g",
  213. "logo_url": "https://example.com/logo.PNG",
  214. "additional_notes": "2-4"
  215. },
  216. "primary_recipients": [
  217. {
  218. "billing_info": {
  219. "name": {
  220. "given_name": "Stephanie",
  221. "surname": "Meyers"
  222. },
  223. "address": {
  224. "address_line_1": "1234 Main Street",
  225. "admin_area_2": "Anytown",
  226. "admin_area_1": "CA",
  227. "postal_code": "98765",
  228. "country_code": "US"
  229. },
  230. "email_address": "bill-me@example.com",
  231. "phones": [
  232. {
  233. "country_code": "001",
  234. "national_number": "4884551234",
  235. "phone_type": "HOME"
  236. }
  237. ],
  238. "additional_info_value": "add-info"
  239. },
  240. "shipping_info": {
  241. "name": {
  242. "given_name": "Stephanie",
  243. "surname": "Meyers"
  244. },
  245. "address": {
  246. "address_line_1": "1234 Main Street",
  247. "admin_area_2": "Anytown",
  248. "admin_area_1": "CA",
  249. "postal_code": "98765",
  250. "country_code": "US"
  251. }
  252. }
  253. }
  254. ],
  255. "items": [
  256. {
  257. "name": "Yoga Mat",
  258. "description": "Elastic mat to practice yoga.",
  259. "quantity": "1",
  260. "unit_amount": {
  261. "currency_code": "USD",
  262. "value": "50.00"
  263. },
  264. "tax": {
  265. "name": "Sales Tax",
  266. "percent": "7.25",
  267. "amount": {
  268. "currency_code": "USD",
  269. "value": "3.27"
  270. }
  271. },
  272. "discount": {
  273. "percent": "5",
  274. "amount": {
  275. "currency_code": "USD",
  276. "value": "2.5"
  277. }
  278. },
  279. "unit_of_measure": "QUANTITY"
  280. },
  281. {
  282. "name": "Yoga t-shirt",
  283. "quantity": "1",
  284. "unit_amount": {
  285. "currency_code": "USD",
  286. "value": "10.00"
  287. },
  288. "tax": {
  289. "name": "Sales Tax",
  290. "percent": "7.25",
  291. "amount": {
  292. "currency_code": "USD",
  293. "value": "0.34"
  294. }
  295. },
  296. "discount": {
  297. "amount": {
  298. "currency_code": "USD",
  299. "value": "5.00"
  300. }
  301. },
  302. "unit_of_measure": "QUANTITY"
  303. }
  304. ],
  305. "configuration": {
  306. "partial_payment": {
  307. "allow_partial_payment": true,
  308. "minimum_amount_due": {
  309. "currency_code": "USD",
  310. "value": "20.00"
  311. }
  312. },
  313. "allow_tip": true,
  314. "tax_calculated_after_discount": true,
  315. "tax_inclusive": false,
  316. "template_id": "TEMP-19V05281TU309413B"
  317. },
  318. "amount": {
  319. "currency_code": "USD",
  320. "value": "74.21",
  321. "breakdown": {
  322. "item_total": {
  323. "currency_code": "USD",
  324. "value": "60.00"
  325. },
  326. "custom": {
  327. "label": "Packing Charges",
  328. "amount": {
  329. "currency_code": "USD",
  330. "value": "10.00"
  331. }
  332. },
  333. "shipping": {
  334. "amount": {
  335. "currency_code": "USD",
  336. "value": "10.00"
  337. },
  338. "tax": {
  339. "name": "Sales Tax",
  340. "percent": "7.25",
  341. "amount": {
  342. "currency_code": "USD",
  343. "value": "0.73"
  344. }
  345. }
  346. },
  347. "discount": {
  348. "item_discount": {
  349. "currency_code": "USD",
  350. "value": "-7.50"
  351. },
  352. "invoice_discount": {
  353. "percent": "5",
  354. "amount": {
  355. "currency_code": "USD",
  356. "value": "-2.63"
  357. }
  358. }
  359. },
  360. "tax_total": {
  361. "currency_code": "USD",
  362. "value": "4.34"
  363. }
  364. }
  365. }
  366. }', true);
  367. }
  368. /**
  369. * @return array
  370. */
  371. private function cancelInvoiceParams(): array
  372. {
  373. return Utils::jsonDecode('{
  374. "subject": "Invoice Cancelled",
  375. "note": "Cancelling the invoice",
  376. "send_to_invoicer": true,
  377. "send_to_recipient": true,
  378. "additional_recipients": [
  379. "user@example.com"
  380. ]
  381. }', true);
  382. }
  383. /**
  384. * @return array
  385. */
  386. private function generateQRCodeInvoiceParams(): array
  387. {
  388. return Utils::jsonDecode('{
  389. "width": 400,
  390. "height": 400
  391. }', true);
  392. }
  393. /**
  394. * @return array
  395. */
  396. private function registerInvoicePaymentParams(): array
  397. {
  398. return Utils::jsonDecode('{
  399. "width": 400,
  400. "height": 400
  401. }', true);
  402. }
  403. /**
  404. * @return array
  405. */
  406. private function refundInvoicePaymentParams(): array
  407. {
  408. return Utils::jsonDecode('{
  409. "method": "BANK_TRANSFER",
  410. "refund_date": "2018-05-21",
  411. "amount": {
  412. "currency_code": "USD",
  413. "value": "5.00"
  414. }
  415. }', true);
  416. }
  417. /**
  418. * @return array
  419. */
  420. private function sendInvoiceParams(): array
  421. {
  422. return Utils::jsonDecode('{
  423. "subject": "Payment due for the invoice #ABC-123",
  424. "note": "Please pay before the due date to avoid incurring late payment charges which will be adjusted in the next bill generated.",
  425. "send_to_invoicer": true,
  426. "additional_recipients": [
  427. "customer-a@example.com",
  428. "customer@example.com"
  429. ]
  430. }', true);
  431. }
  432. /**
  433. * @return array
  434. */
  435. private function sendInvoiceReminderParams(): array
  436. {
  437. return Utils::jsonDecode('{
  438. "subject": "Reminder: Payment due for the invoice #ABC-123",
  439. "note": "Please pay before the due date to avoid incurring late payment charges which will be adjusted in the next bill generated.",
  440. "send_to_invoicer": true,
  441. "additional_recipients": [
  442. "customer-a@example.com",
  443. "customer@example.com"
  444. ]
  445. }', true);
  446. }
  447. }