Invoices.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888
  1. <?php
  2. namespace Srmklive\PayPal\Tests\Mocks\Responses;
  3. use GuzzleHttp\Utils;
  4. trait Invoices
  5. {
  6. /**
  7. * @return array
  8. */
  9. private function mockGenerateInvoiceNumberResponse(): array
  10. {
  11. return Utils::jsonDecode('{
  12. "invoice_number": "ee0044"
  13. }', true);
  14. }
  15. /**
  16. * @return array
  17. */
  18. private function mockCreateInvoicesResponse(): array
  19. {
  20. return Utils::jsonDecode('{
  21. "id": "INV2-Z56S-5LLA-Q52L-CPZ5",
  22. "status": "DRAFT",
  23. "detail": {
  24. "invoice_number": "#123",
  25. "reference": "deal-ref",
  26. "invoice_date": "2018-11-12",
  27. "currency_code": "USD",
  28. "note": "Thank you for your business.",
  29. "term": "No refunds after 30 days.",
  30. "memo": "This is a long contract",
  31. "payment_term": {
  32. "term_type": "NET_10",
  33. "due_date": "2018-11-22"
  34. },
  35. "metadata": {
  36. "create_time": "2018-11-12T08:00:20Z",
  37. "recipient_view_url": "https://www.api.paypal.com/invoice/p#Z56S5LLAQ52LCPZ5",
  38. "invoicer_view_url": "https://www.api.paypal.com/invoice/details/INV2-Z56S-5LLA-Q52L-CPZ5"
  39. }
  40. },
  41. "invoicer": {
  42. "name": {
  43. "given_name": "David",
  44. "surname": "Larusso"
  45. },
  46. "address": {
  47. "address_line_1": "1234 First Street",
  48. "address_line_2": "337673 Hillside Court",
  49. "admin_area_2": "Anytown",
  50. "admin_area_1": "CA",
  51. "postal_code": "98765",
  52. "country_code": "US"
  53. },
  54. "email_address": "merchant@example.com",
  55. "phones": [
  56. {
  57. "country_code": "001",
  58. "national_number": "4085551234",
  59. "phone_type": "MOBILE"
  60. }
  61. ],
  62. "website": "https://example.com",
  63. "tax_id": "ABcNkWSfb5ICTt73nD3QON1fnnpgNKBy-Jb5SeuGj185MNNw6g",
  64. "logo_url": "https://example.com/logo.PNG",
  65. "additional_notes": "2-4"
  66. },
  67. "primary_recipients": [
  68. {
  69. "billing_info": {
  70. "name": {
  71. "given_name": "Stephanie",
  72. "surname": "Meyers"
  73. },
  74. "address": {
  75. "address_line_1": "1234 Main Street",
  76. "admin_area_2": "Anytown",
  77. "admin_area_1": "CA",
  78. "postal_code": "98765",
  79. "country_code": "US"
  80. },
  81. "email_address": "bill-me@example.com",
  82. "phones": [
  83. {
  84. "country_code": "001",
  85. "national_number": "4884551234",
  86. "phone_type": "HOME"
  87. }
  88. ],
  89. "additional_info_value": "add-info"
  90. },
  91. "shipping_info": {
  92. "name": {
  93. "given_name": "Stephanie",
  94. "surname": "Meyers"
  95. },
  96. "address": {
  97. "address_line_1": "1234 Main Street",
  98. "admin_area_2": "Anytown",
  99. "admin_area_1": "CA",
  100. "postal_code": "98765",
  101. "country_code": "US"
  102. }
  103. }
  104. }
  105. ],
  106. "items": [
  107. {
  108. "name": "Yoga Mat",
  109. "description": "Elastic mat to practice yoga.",
  110. "quantity": "1",
  111. "unit_amount": {
  112. "currency_code": "USD",
  113. "value": "50.00"
  114. },
  115. "tax": {
  116. "name": "Sales Tax",
  117. "percent": "7.25",
  118. "amount": {
  119. "currency_code": "USD",
  120. "value": "3.27"
  121. }
  122. },
  123. "discount": {
  124. "percent": "5",
  125. "amount": {
  126. "currency_code": "USD",
  127. "value": "2.5"
  128. }
  129. },
  130. "unit_of_measure": "QUANTITY"
  131. },
  132. {
  133. "name": "Yoga T Shirt",
  134. "quantity": "1",
  135. "unit_amount": {
  136. "currency_code": "USD",
  137. "value": "10.00"
  138. },
  139. "tax": {
  140. "name": "Sales Tax",
  141. "percent": "7.25",
  142. "amount": {
  143. "currency_code": "USD",
  144. "value": "0.34"
  145. }
  146. },
  147. "discount": {
  148. "amount": {
  149. "currency_code": "USD",
  150. "value": "5.00"
  151. }
  152. },
  153. "unit_of_measure": "QUANTITY"
  154. }
  155. ],
  156. "configuration": {
  157. "partial_payment": {
  158. "allow_partial_payment": true,
  159. "minimum_amount_due": {
  160. "currency_code": "USD",
  161. "value": "20.00"
  162. }
  163. },
  164. "allow_tip": true,
  165. "tax_calculated_after_discount": true,
  166. "tax_inclusive": false,
  167. "template_id": "TEMP-19V05281TU309413B"
  168. },
  169. "amount": {
  170. "currency_code": "USD",
  171. "value": "74.21",
  172. "breakdown": {
  173. "item_total": {
  174. "currency_code": "USD",
  175. "value": "60.00"
  176. },
  177. "custom": {
  178. "label": "Packing Charges",
  179. "amount": {
  180. "currency_code": "USD",
  181. "value": "10.00"
  182. }
  183. },
  184. "shipping": {
  185. "amount": {
  186. "currency_code": "USD",
  187. "value": "10.00"
  188. },
  189. "tax": {
  190. "name": "Sales Tax",
  191. "percent": "7.25",
  192. "amount": {
  193. "currency_code": "USD",
  194. "value": "0.73"
  195. }
  196. }
  197. },
  198. "discount": {
  199. "item_discount": {
  200. "currency_code": "USD",
  201. "value": "-7.50"
  202. },
  203. "invoice_discount": {
  204. "percent": "5",
  205. "amount": {
  206. "currency_code": "USD",
  207. "value": "-2.63"
  208. }
  209. }
  210. },
  211. "tax_total": {
  212. "currency_code": "USD",
  213. "value": "4.34"
  214. }
  215. }
  216. },
  217. "due_amount": {
  218. "currency_code": "USD",
  219. "value": "74.21"
  220. },
  221. "links": [
  222. {
  223. "href": "https://api.paypal.com/v2/invoicing/invoices/INV2-Z56S-5LLA-Q52L-CPZ5",
  224. "rel": "self",
  225. "method": "GET"
  226. },
  227. {
  228. "href": "https://api.paypal.com/v2/invoicing/invoices/INV2-Z56S-5LLA-Q52L-CPZ5/send",
  229. "rel": "send",
  230. "method": "POST"
  231. },
  232. {
  233. "href": "https://api.paypal.com/v2/invoicing/invoices/INV2-Z56S-5LLA-Q52L-CPZ5/update",
  234. "rel": "replace",
  235. "method": "PUT"
  236. },
  237. {
  238. "href": "https://api.paypal.com/v2/invoicing/invoices/INV2-Z56S-5LLA-Q52L-CPZ5",
  239. "rel": "delete",
  240. "method": "DELETE"
  241. },
  242. {
  243. "href": "https://api.paypal.com/v2/invoicing/invoices/INV2-Z56S-5LLA-Q52L-CPZ5/payments",
  244. "rel": "record-payment",
  245. "method": "POST"
  246. },
  247. {
  248. "href": "https://api.paypal.com/v2/invoicing/invoices/INV2-Z56S-5LLA-Q52L-CPZ5/generate-qr-code",
  249. "rel": "qr-code",
  250. "method": "POST"
  251. }
  252. ]
  253. }', true);
  254. }
  255. /**
  256. * @return array
  257. */
  258. private function mockListInvoicesResponse(): array
  259. {
  260. return Utils::jsonDecode('{
  261. "total_items": 2,
  262. "total_pages": 1,
  263. "items": [
  264. {
  265. "id": "INV2-Z56S-5LLA-Q52L-CPZ5",
  266. "status": "DRAFT",
  267. "detail": {
  268. "invoice_number": "#123",
  269. "reference": "deal-ref",
  270. "invoice_date": "2018-11-12",
  271. "currency_code": "USD",
  272. "note": "Thank you for your business.",
  273. "term": "No refunds after 30 days.",
  274. "memo": "This is a long contract",
  275. "payment_term": {
  276. "term_type": "NET_10",
  277. "due_date": "2018-11-22"
  278. },
  279. "metadata": {
  280. "create_time": "2018-11-12T08:00:20Z",
  281. "recipient_view_url": "https://www.paypal.com/invoice/p/#Z56S5LLAQ52LCPZ5",
  282. "invoicer_view_url": "https://www.paypal.com/invoice/details/INV2-Z56S-5LLA-Q52L-CPZ5"
  283. }
  284. },
  285. "invoicer": {
  286. "email_address": "merchant@example.com"
  287. },
  288. "primary_recipients": [
  289. {
  290. "billing_info": {
  291. "email_address": "bill-me@example.com"
  292. }
  293. }
  294. ],
  295. "amount": {
  296. "currency_code": "USD",
  297. "value": "74.21"
  298. },
  299. "links": [
  300. {
  301. "href": "https://api.paypal.com/v2/invoicing/invoices/INV2-Z56S-5LLA-Q52L-CPZ5",
  302. "rel": "self",
  303. "method": "GET"
  304. },
  305. {
  306. "href": "https://api.paypal.com/v2/invoicing/invoices/INV2-Z56S-5LLA-Q52L-CPZ5/send",
  307. "rel": "send",
  308. "method": "POST"
  309. },
  310. {
  311. "href": "https://api.paypal.com/v2/invoicing/invoices/INV2-Z56S-5LLA-Q52L-CPZ5",
  312. "rel": "replace",
  313. "method": "PUT"
  314. },
  315. {
  316. "href": "https://api.paypal.com/v2/invoicing/invoices/INV2-Z56S-5LLA-Q52L-CPZ5",
  317. "rel": "delete",
  318. "method": "DELETE"
  319. }
  320. ]
  321. },
  322. {
  323. "id": "INV2-NP6M-C9A8-ZBDA-3TEX",
  324. "status": "SCHEDULED",
  325. "detail": {
  326. "invoice_number": "0001",
  327. "invoice_date": "2018-05-14",
  328. "currency_code": "USD",
  329. "payment_term": {
  330. "due_date": "2018-05-15"
  331. },
  332. "metadata": {
  333. "create_time": "2018-05-15T17:24:12Z"
  334. }
  335. },
  336. "invoicer": {
  337. "email_address": "merchant@example.com"
  338. },
  339. "primary_recipients": [
  340. {
  341. "billing_info": {
  342. "email_address": "recipient@example.com"
  343. }
  344. }
  345. ],
  346. "amount": {
  347. "currency_code": "USD",
  348. "value": "32.00"
  349. },
  350. "links": [
  351. {
  352. "href": "https://api.paypal.com/v2/invoicing/invoices/INV2-NP6M-C9A8-ZBDA-3TEX",
  353. "rel": "self",
  354. "method": "GET"
  355. },
  356. {
  357. "href": "https://api.paypal.com/v2/invoicing/invoices/INV2-NP6M-C9A8-ZBDA-3TEX",
  358. "rel": "replace",
  359. "method": "PUT"
  360. },
  361. {
  362. "href": "https://api.paypal.com/v2/invoicing/invoices/INV2-NP6M-C9A8-ZBDA-3TEX",
  363. "rel": "delete",
  364. "method": "DELETE"
  365. },
  366. {
  367. "href": "https://api.paypal.com/v2/invoicing/invoices/INV2-NP6M-C9A8-ZBDA-3TEX/payments",
  368. "rel": "record-payment",
  369. "method": "POST"
  370. }
  371. ]
  372. }
  373. ],
  374. "links": [
  375. {
  376. "href": "https://api.paypal.com/v2/invoicing/invoices?page=1&page_size=20&total_required=false",
  377. "rel": "self",
  378. "method": "GET"
  379. }
  380. ]
  381. }', true);
  382. }
  383. /**
  384. * @return array
  385. */
  386. private function mockUpdateInvoicesResponse(): array
  387. {
  388. return Utils::jsonDecode('{
  389. "id": "INV2-C82X-JNN9-Y6S5-CNXW",
  390. "status": "DRAFT",
  391. "detail": {
  392. "invoice_number": "#123",
  393. "reference": "deal-refernce-update",
  394. "invoice_date": "2018-11-12",
  395. "currency_code": "USD",
  396. "note": "Thank you for your business.",
  397. "term": "No refunds after 30 days.",
  398. "memo": "This is a long contract",
  399. "payment_term": {
  400. "term_type": "NET_10",
  401. "due_date": "2018-11-22"
  402. },
  403. "metadata": {
  404. "create_time": "2018-11-12T08:00:20Z",
  405. "recipient_view_url": "https://www.api.paypal.com/invoice/p#Z56S5LLAQ52LCPZ5",
  406. "invoicer_view_url": "https://www.api.paypal.com/invoice/details/INV2-Z56S-5LLA-Q52L-CPZ5"
  407. }
  408. },
  409. "invoicer": {
  410. "name": {
  411. "given_name": "David",
  412. "surname": "Larusso"
  413. },
  414. "address": {
  415. "address_line_1": "1234 First Street",
  416. "address_line_2": "337673 Hillside Court",
  417. "admin_area_2": "Anytown",
  418. "admin_area_1": "CA",
  419. "postal_code": "98765",
  420. "country_code": "US"
  421. },
  422. "email_address": "merchant@example.com",
  423. "phones": [
  424. {
  425. "country_code": "001",
  426. "national_number": "4085551234",
  427. "phone_type": "MOBILE"
  428. }
  429. ],
  430. "website": "https://example.com",
  431. "tax_id": "ABcNkWSfb5ICTt73nD3QON1fnnpgNKBy-Jb5SeuGj185MNNw6g",
  432. "logo_url": "https://example.com/logo.PNG",
  433. "additional_notes": "2-4"
  434. },
  435. "primary_recipients": [
  436. {
  437. "billing_info": {
  438. "name": {
  439. "given_name": "Stephanie",
  440. "surname": "Meyers"
  441. },
  442. "address": {
  443. "address_line_1": "1234 Main Street",
  444. "admin_area_2": "Anytown",
  445. "admin_area_1": "CA",
  446. "postal_code": "98765",
  447. "country_code": "US"
  448. },
  449. "email_address": "bill-me@example.com",
  450. "phones": [
  451. {
  452. "country_code": "001",
  453. "national_number": "4884551234",
  454. "phone_type": "HOME"
  455. }
  456. ],
  457. "additional_info_value": "add-info"
  458. },
  459. "shipping_info": {
  460. "name": {
  461. "given_name": "Stephanie",
  462. "surname": "Meyers"
  463. },
  464. "address": {
  465. "address_line_1": "1234 Main Street",
  466. "admin_area_2": "Anytown",
  467. "admin_area_1": "CA",
  468. "postal_code": "98765",
  469. "country_code": "US"
  470. }
  471. }
  472. }
  473. ],
  474. "items": [
  475. {
  476. "name": "Yoga Mat",
  477. "description": "Elastic mat to practice yoga.",
  478. "quantity": "1",
  479. "unit_amount": {
  480. "currency_code": "USD",
  481. "value": "50.00"
  482. },
  483. "tax": {
  484. "name": "Sales Tax",
  485. "percent": "7.25",
  486. "amount": {
  487. "currency_code": "USD",
  488. "value": "3.27"
  489. }
  490. },
  491. "discount": {
  492. "percent": "5",
  493. "amount": {
  494. "currency_code": "USD",
  495. "value": "2.5"
  496. }
  497. },
  498. "unit_of_measure": "QUANTITY"
  499. },
  500. {
  501. "name": "Yoga t-shirt",
  502. "quantity": "1",
  503. "unit_amount": {
  504. "currency_code": "USD",
  505. "value": "10.00"
  506. },
  507. "tax": {
  508. "name": "Sales Tax",
  509. "percent": "7.25",
  510. "amount": {
  511. "currency_code": "USD",
  512. "value": "0.34"
  513. }
  514. },
  515. "discount": {
  516. "amount": {
  517. "currency_code": "USD",
  518. "value": "5.00"
  519. }
  520. },
  521. "unit_of_measure": "QUANTITY"
  522. }
  523. ],
  524. "configuration": {
  525. "partial_payment": {
  526. "allow_partial_payment": true,
  527. "minimum_amount_due": {
  528. "currency_code": "USD",
  529. "value": "20.00"
  530. }
  531. },
  532. "allow_tip": true,
  533. "tax_calculated_after_discount": true,
  534. "tax_inclusive": false,
  535. "template_id": "TEMP-19V05281TU309413B"
  536. },
  537. "amount": {
  538. "currency_code": "USD",
  539. "value": "74.21",
  540. "breakdown": {
  541. "item_total": {
  542. "currency_code": "USD",
  543. "value": "60.00"
  544. },
  545. "custom": {
  546. "label": "Packing Charges",
  547. "amount": {
  548. "currency_code": "USD",
  549. "value": "10.00"
  550. }
  551. },
  552. "shipping": {
  553. "amount": {
  554. "currency_code": "USD",
  555. "value": "10.00"
  556. },
  557. "tax": {
  558. "name": "Sales Tax",
  559. "percent": "7.25",
  560. "amount": {
  561. "currency_code": "USD",
  562. "value": "0.73"
  563. }
  564. }
  565. },
  566. "discount": {
  567. "item_discount": {
  568. "currency_code": "USD",
  569. "value": "-7.50"
  570. },
  571. "invoice_discount": {
  572. "percent": "5",
  573. "amount": {
  574. "currency_code": "USD",
  575. "value": "-2.63"
  576. }
  577. }
  578. },
  579. "tax_total": {
  580. "currency_code": "USD",
  581. "value": "4.34"
  582. }
  583. }
  584. },
  585. "due_amount": {
  586. "currency_code": "USD",
  587. "value": "74.21"
  588. },
  589. "links": [
  590. {
  591. "href": "https://api.paypal.com/v2/invoicing/invoices/INV2-Z56S-5LLA-Q52L-CPZ5",
  592. "rel": "self",
  593. "method": "GET"
  594. },
  595. {
  596. "href": "https://api.paypal.com/v2/invoicing/invoices/INV2-Z56S-5LLA-Q52L-CPZ5/send",
  597. "rel": "send",
  598. "method": "POST"
  599. },
  600. {
  601. "href": "https://api.paypal.com/v2/invoicing/invoices/INV2-Z56S-5LLA-Q52L-CPZ5/update",
  602. "rel": "replace",
  603. "method": "PUT"
  604. },
  605. {
  606. "href": "https://api.paypal.com/v2/invoicing/invoices/INV2-Z56S-5LLA-Q52L-CPZ5",
  607. "rel": "delete",
  608. "method": "DELETE"
  609. }
  610. ]
  611. }', true);
  612. }
  613. /**
  614. * @return array
  615. */
  616. private function mockGetInvoicesResponse(): array
  617. {
  618. return Utils::jsonDecode('{
  619. "id": "INV2-Z56S-5LLA-Q52L-CPZ5",
  620. "status": "DRAFT",
  621. "detail": {
  622. "invoice_number": "#123",
  623. "reference": "deal-ref",
  624. "invoice_date": "2018-11-12",
  625. "currency_code": "USD",
  626. "note": "Thank you for your business.",
  627. "term": "No refunds after 30 days.",
  628. "memo": "This is a long contract",
  629. "payment_term": {
  630. "term_type": "NET_10",
  631. "due_date": "2018-11-22"
  632. },
  633. "metadata": {
  634. "create_time": "2018-11-12T08:00:20Z",
  635. "recipient_view_url": "https://www.paypal.com/invoice/p/#Z56S5LLAQ52LCPZ5",
  636. "invoicer_view_url": "https://www.paypal.com/invoice/details/INV2-Z56S-5LLA-Q52L-CPZ5"
  637. }
  638. },
  639. "invoicer": {
  640. "name": {
  641. "given_name": "David",
  642. "surname": "Larusso"
  643. },
  644. "address": {
  645. "address_line_1": "1234 First Street",
  646. "address_line_2": "337673 Hillside Court",
  647. "admin_area_2": "Anytown",
  648. "admin_area_1": "CA",
  649. "postal_code": "98765",
  650. "country_code": "US"
  651. },
  652. "email_address": "merchant@example.com",
  653. "phones": [
  654. {
  655. "country_code": "001",
  656. "national_number": "4085551234",
  657. "phone_type": "MOBILE"
  658. }
  659. ],
  660. "website": "https://example.com",
  661. "tax_id": "ABcNkWSfb5ICTt73nD3QON1fnnpgNKBy-Jb5SeuGj185MNNw6g",
  662. "logo_url": "https://example.com/logo.PNG",
  663. "additional_notes": "2-4"
  664. },
  665. "primary_recipients": [
  666. {
  667. "billing_info": {
  668. "name": {
  669. "given_name": "Stephanie",
  670. "surname": "Meyers"
  671. },
  672. "address": {
  673. "address_line_1": "1234 Main Street",
  674. "admin_area_2": "Anytown",
  675. "admin_area_1": "CA",
  676. "postal_code": "98765",
  677. "country_code": "US"
  678. },
  679. "email_address": "bill-me@example.com",
  680. "phones": [
  681. {
  682. "country_code": "001",
  683. "national_number": "4884551234",
  684. "phone_type": "HOME"
  685. }
  686. ],
  687. "additional_info_value": "add-info"
  688. },
  689. "shipping_info": {
  690. "name": {
  691. "given_name": "Stephanie",
  692. "surname": "Meyers"
  693. },
  694. "address": {
  695. "address_line_1": "1234 Main Street",
  696. "admin_area_2": "Anytown",
  697. "admin_area_1": "CA",
  698. "postal_code": "98765",
  699. "country_code": "US"
  700. }
  701. }
  702. }
  703. ],
  704. "items": [
  705. {
  706. "name": "Yoga Mat",
  707. "description": "Elastic mat to practice yoga.",
  708. "quantity": "1",
  709. "unit_amount": {
  710. "currency_code": "USD",
  711. "value": "50.00"
  712. },
  713. "tax": {
  714. "name": "Sales Tax",
  715. "percent": "7.25",
  716. "amount": {
  717. "currency_code": "USD",
  718. "value": "3.27"
  719. }
  720. },
  721. "discount": {
  722. "percent": "5",
  723. "amount": {
  724. "currency_code": "USD",
  725. "value": "2.5"
  726. }
  727. },
  728. "unit_of_measure": "QUANTITY"
  729. },
  730. {
  731. "name": "Yoga T Shirt",
  732. "quantity": "1",
  733. "unit_amount": {
  734. "currency_code": "USD",
  735. "value": "10.00"
  736. },
  737. "tax": {
  738. "name": "Sales Tax",
  739. "percent": "7.25",
  740. "amount": {
  741. "currency_code": "USD",
  742. "value": "0.34"
  743. }
  744. },
  745. "discount": {
  746. "amount": {
  747. "currency_code": "USD",
  748. "value": "5.00"
  749. }
  750. },
  751. "unit_of_measure": "QUANTITY"
  752. }
  753. ],
  754. "configuration": {
  755. "partial_payment": {
  756. "allow_partial_payment": true,
  757. "minimum_amount_due": {
  758. "currency_code": "USD",
  759. "value": "20.00"
  760. }
  761. },
  762. "allow_tip": true,
  763. "tax_calculated_after_discount": true,
  764. "tax_inclusive": false,
  765. "template_id": "TEMP-19V05281TU309413B"
  766. },
  767. "amount": {
  768. "currency_code": "USD",
  769. "value": "74.21",
  770. "breakdown": {
  771. "item_total": {
  772. "currency_code": "USD",
  773. "value": "60.00"
  774. },
  775. "custom": {
  776. "label": "Packing Charges",
  777. "amount": {
  778. "currency_code": "USD",
  779. "value": "10.00"
  780. }
  781. },
  782. "shipping": {
  783. "amount": {
  784. "currency_code": "USD",
  785. "value": "10.00"
  786. },
  787. "tax": {
  788. "name": "Sales Tax",
  789. "percent": "7.25",
  790. "amount": {
  791. "currency_code": "USD",
  792. "value": "0.73"
  793. }
  794. }
  795. },
  796. "discount": {
  797. "item_discount": {
  798. "currency_code": "USD",
  799. "value": "-7.50"
  800. },
  801. "invoice_discount": {
  802. "percent": "5",
  803. "amount": {
  804. "currency_code": "USD",
  805. "value": "-2.63"
  806. }
  807. }
  808. },
  809. "tax_total": {
  810. "currency_code": "USD",
  811. "value": "4.34"
  812. }
  813. }
  814. },
  815. "due_amount": {
  816. "currency_code": "USD",
  817. "value": "74.21"
  818. },
  819. "links": [
  820. {
  821. "href": "https://api.paypal.com/v2/invoicing/invoices/INV2-Z56S-5LLA-Q52L-CPZ5",
  822. "rel": "self",
  823. "method": "GET"
  824. },
  825. {
  826. "href": "https://api.paypal.com/v2/invoicing/invoices/INV2-Z56S-5LLA-Q52L-CPZ5/send",
  827. "rel": "send",
  828. "method": "POST"
  829. },
  830. {
  831. "href": "https://api.paypal.com/v2/invoicing/invoices/INV2-Z56S-5LLA-Q52L-CPZ5",
  832. "rel": "replace",
  833. "method": "PUT"
  834. },
  835. {
  836. "href": "https://api.paypal.com/v2/invoicing/invoices/INV2-Z56S-5LLA-Q52L-CPZ5",
  837. "rel": "delete",
  838. "method": "DELETE"
  839. },
  840. {
  841. "href": "https://api.paypal.com/v2/invoicing/invoices/INV2-Z56S-5LLA-Q52L-CPZ5/payments",
  842. "rel": "record-payment",
  843. "method": "POST"
  844. },
  845. {
  846. "href": "https://api.paypal.com/v2/invoicing/invoices/INV2-Z56S-5LLA-Q52L-CPZ5/generate-qr-code",
  847. "rel": "qr-code",
  848. "method": "POST"
  849. }
  850. ]
  851. }', true);
  852. }
  853. /**
  854. * @return string
  855. */
  856. private function mockGenerateInvoiceQRCodeResponse(): string
  857. {
  858. return '--95dbdbed-7536-4c24-b5ca-bcdbc0006612 Content-Disposition: form-data; name="image" Content-Type: application/octet-stream iVBORw0KGgoAAAANSUhEUgAAAJYAAACWAQAAAAAUekxPAAABxUlEQVR42u2WMY7kIBBFq0VA1n0BS1yDjCvZF7DxBdxXIuMaSFzAzgiQaz6t9mxLm1AbrCYYy4H1AlT1f9XHxH89lX7Z/2KJKN3CMIW6FCInYplLPtisoU6FTyHzti6RN5tPm+5ixrtTp0uP8g8s744eMS1yxvikNEOJz966GPTLaOL1fmjaxfAkaLCy2t2Hl10sPUIaNY1araFhCat3TbODDPkZ68Ii1sqfX62c1rzP62W8uWG0aiMaxSyvpS4hez2MzXkZg+FL4NNCwku/XtZ8g/Be550+Pe9jWj0x41rt1ngZyxzYa+NpmDjNMlYx1yhhs2glM8vY3IQ3qGWz9Tqvk7F3cGyYNd3KQDKGSWFGDjFNIZ8yhuWgR8gb5jR8+9bJ8rPUCd3oYbY4VcQqaWSYWRGcdnhnSS+D6lhKJIE5+JrTXtaquDtzuuypXrV0stRKwLAUzFodnYjxERP28ihtLw8WsbQE7JbxCD9SmxMxfsUYpiZ7lxYWMewltzuqKMz4n13tYi3vl6jW2FJQynBH+Za7Zie6sZRhNVXLTkqTmGUE5xSRu5dv3Qz3uYdj0bwkFLGWfxxoJMXx28tO9vu/9oPYF0bR/hBeOiwMAAAAAElFTkSuQmCC --95dbdbed-7536-4c24-b5ca-bcdbc0006612--';
  859. }
  860. /**
  861. * @return array
  862. */
  863. private function mockInvoiceRegisterPaymentResponse(): array
  864. {
  865. return Utils::jsonDecode('{
  866. "payment_id": "EXTR-86F38350LX4353815"
  867. }', true);
  868. }
  869. /**
  870. * @return array
  871. */
  872. private function mockInvoiceRefundPaymentResponse(): array
  873. {
  874. return Utils::jsonDecode('{
  875. "refund_id": "EXTR-2LG703375E477444T"
  876. }', true);
  877. }
  878. }