PayPalApiInvoice

Class Invoice.

Defined (1)

The class is defined in the following location(s).

/classes/lib/PayPal/Api/Invoice.php  
  1. class Invoice extends PayPalResourceModel 
  2. /** 
  3. * Unique invoice resource identifier. 
  4. * @param string $id 
  5. *  
  6. * @return $this 
  7. */ 
  8. public function setId($id) 
  9. $this->id = $id; 
  10. return $this; 
  11.  
  12. /** 
  13. * Unique invoice resource identifier. 
  14. * @return string 
  15. */ 
  16. public function getId() 
  17. return $this->id; 
  18.  
  19. /** 
  20. * Unique number that appears on the invoice. If left blank will be auto-incremented from the last number. 25 characters max. 
  21. * @param string $number 
  22. *  
  23. * @return $this 
  24. */ 
  25. public function setNumber($number) 
  26. $this->number = $number; 
  27. return $this; 
  28.  
  29. /** 
  30. * Unique number that appears on the invoice. If left blank will be auto-incremented from the last number. 25 characters max. 
  31. * @return string 
  32. */ 
  33. public function getNumber() 
  34. return $this->number; 
  35.  
  36. /** 
  37. * URI of the invoice resource. 
  38. * @param string $uri 
  39. *  
  40. * @return $this 
  41. */ 
  42. public function setUri($uri) 
  43. $this->uri = $uri; 
  44. return $this; 
  45.  
  46. /** 
  47. * URI of the invoice resource. 
  48. * @return string 
  49. */ 
  50. public function getUri() 
  51. return $this->uri; 
  52.  
  53. /** 
  54. * Status of the invoice. 
  55. * Valid Values: ["DRAFT", "SENT", "PAID", "MARKED_AS_PAID", "CANCELLED", "REFUNDED", "PARTIALLY_REFUNDED", "MARKED_AS_REFUNDED"] 
  56. * @param string $status 
  57. *  
  58. * @return $this 
  59. */ 
  60. public function setStatus($status) 
  61. $this->status = $status; 
  62. return $this; 
  63.  
  64. /** 
  65. * Status of the invoice. 
  66. * @return string 
  67. */ 
  68. public function getStatus() 
  69. return $this->status; 
  70.  
  71. /** 
  72. * Information about the merchant who is sending the invoice. 
  73. * @param \PayPal\Api\MerchantInfo $merchant_info 
  74. *  
  75. * @return $this 
  76. */ 
  77. public function setMerchantInfo($merchant_info) 
  78. $this->merchant_info = $merchant_info; 
  79. return $this; 
  80.  
  81. /** 
  82. * Information about the merchant who is sending the invoice. 
  83. * @return \PayPal\Api\MerchantInfo 
  84. */ 
  85. public function getMerchantInfo() 
  86. return $this->merchant_info; 
  87.  
  88. /** 
  89. * Email address of invoice recipient (required) and optional billing information. (Note: We currently only allow one recipient). 
  90. * @param \PayPal\Api\BillingInfo[] $billing_info 
  91. *  
  92. * @return $this 
  93. */ 
  94. public function setBillingInfo($billing_info) 
  95. $this->billing_info = $billing_info; 
  96. return $this; 
  97.  
  98. /** 
  99. * Email address of invoice recipient (required) and optional billing information. (Note: We currently only allow one recipient). 
  100. * @return \PayPal\Api\BillingInfo[] 
  101. */ 
  102. public function getBillingInfo() 
  103. return $this->billing_info; 
  104.  
  105. /** 
  106. * Append BillingInfo to the list. 
  107. * @param \PayPal\Api\BillingInfo $billingInfo 
  108. * @return $this 
  109. */ 
  110. public function addBillingInfo($billingInfo) 
  111. if (!$this->getBillingInfo()) { 
  112. return $this->setBillingInfo(array($billingInfo)); 
  113. } else { 
  114. return $this->setBillingInfo( 
  115. array_merge($this->getBillingInfo(), array($billingInfo)) 
  116. ); 
  117.  
  118. /** 
  119. * Remove BillingInfo from the list. 
  120. * @param \PayPal\Api\BillingInfo $billingInfo 
  121. * @return $this 
  122. */ 
  123. public function removeBillingInfo($billingInfo) 
  124. return $this->setBillingInfo( 
  125. array_diff($this->getBillingInfo(), array($billingInfo)) 
  126. ); 
  127.  
  128. /** 
  129. * Shipping information for entities to whom items are being shipped. 
  130. * @param \PayPal\Api\ShippingInfo $shipping_info 
  131. *  
  132. * @return $this 
  133. */ 
  134. public function setShippingInfo($shipping_info) 
  135. $this->shipping_info = $shipping_info; 
  136. return $this; 
  137.  
  138. /** 
  139. * Shipping information for entities to whom items are being shipped. 
  140. * @return \PayPal\Api\ShippingInfo 
  141. */ 
  142. public function getShippingInfo() 
  143. return $this->shipping_info; 
  144.  
  145. /** 
  146. * List of items included in the invoice. 100 items max per invoice. 
  147. * @param \PayPal\Api\InvoiceItem[] $items 
  148. *  
  149. * @return $this 
  150. */ 
  151. public function setItems($items) 
  152. $this->items = $items; 
  153. return $this; 
  154.  
  155. /** 
  156. * List of items included in the invoice. 100 items max per invoice. 
  157. * @return \PayPal\Api\InvoiceItem[] 
  158. */ 
  159. public function getItems() 
  160. return $this->items; 
  161.  
  162. /** 
  163. * Append Items to the list. 
  164. * @param \PayPal\Api\InvoiceItem $invoiceItem 
  165. * @return $this 
  166. */ 
  167. public function addItem($invoiceItem) 
  168. if (!$this->getItems()) { 
  169. return $this->setItems(array($invoiceItem)); 
  170. } else { 
  171. return $this->setItems( 
  172. array_merge($this->getItems(), array($invoiceItem)) 
  173. ); 
  174.  
  175. /** 
  176. * Remove Items from the list. 
  177. * @param \PayPal\Api\InvoiceItem $invoiceItem 
  178. * @return $this 
  179. */ 
  180. public function removeItem($invoiceItem) 
  181. return $this->setItems( 
  182. array_diff($this->getItems(), array($invoiceItem)) 
  183. ); 
  184.  
  185. /** 
  186. * Date on which the invoice was enabled. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). 
  187. * @param string $invoice_date 
  188. *  
  189. * @return $this 
  190. */ 
  191. public function setInvoiceDate($invoice_date) 
  192. $this->invoice_date = $invoice_date; 
  193. return $this; 
  194.  
  195. /** 
  196. * Date on which the invoice was enabled. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). 
  197. * @return string 
  198. */ 
  199. public function getInvoiceDate() 
  200. return $this->invoice_date; 
  201.  
  202. /** 
  203. * Optional field to pass payment deadline for the invoice. Either term_type or due_date can be passed, but not both. 
  204. * @param \PayPal\Api\PaymentTerm $payment_term 
  205. *  
  206. * @return $this 
  207. */ 
  208. public function setPaymentTerm($payment_term) 
  209. $this->payment_term = $payment_term; 
  210. return $this; 
  211.  
  212. /** 
  213. * Optional field to pass payment deadline for the invoice. Either term_type or due_date can be passed, but not both. 
  214. * @return \PayPal\Api\PaymentTerm 
  215. */ 
  216. public function getPaymentTerm() 
  217. return $this->payment_term; 
  218.  
  219. /** 
  220. * Invoice level discount in percent or amount. 
  221. * @param \PayPal\Api\Cost $discount 
  222. *  
  223. * @return $this 
  224. */ 
  225. public function setDiscount($discount) 
  226. $this->discount = $discount; 
  227. return $this; 
  228.  
  229. /** 
  230. * Invoice level discount in percent or amount. 
  231. * @return \PayPal\Api\Cost 
  232. */ 
  233. public function getDiscount() 
  234. return $this->discount; 
  235.  
  236. /** 
  237. * Shipping cost in percent or amount. 
  238. * @param \PayPal\Api\ShippingCost $shipping_cost 
  239. *  
  240. * @return $this 
  241. */ 
  242. public function setShippingCost($shipping_cost) 
  243. $this->shipping_cost = $shipping_cost; 
  244. return $this; 
  245.  
  246. /** 
  247. * Shipping cost in percent or amount. 
  248. * @return \PayPal\Api\ShippingCost 
  249. */ 
  250. public function getShippingCost() 
  251. return $this->shipping_cost; 
  252.  
  253. /** 
  254. * Custom amount applied on an invoice. If a label is included then the amount cannot be empty. 
  255. * @param \PayPal\Api\CustomAmount $custom 
  256. *  
  257. * @return $this 
  258. */ 
  259. public function setCustom($custom) 
  260. $this->custom = $custom; 
  261. return $this; 
  262.  
  263. /** 
  264. * Custom amount applied on an invoice. If a label is included then the amount cannot be empty. 
  265. * @return \PayPal\Api\CustomAmount 
  266. */ 
  267. public function getCustom() 
  268. return $this->custom; 
  269.  
  270. /** 
  271. * Indicates whether tax is calculated before or after a discount. If false (the default), the tax is calculated before a discount. If true, the tax is calculated after a discount. 
  272. * @param bool $tax_calculated_after_discount 
  273. *  
  274. * @return $this 
  275. */ 
  276. public function setTaxCalculatedAfterDiscount($tax_calculated_after_discount) 
  277. $this->tax_calculated_after_discount = $tax_calculated_after_discount; 
  278. return $this; 
  279.  
  280. /** 
  281. * Indicates whether tax is calculated before or after a discount. If false (the default), the tax is calculated before a discount. If true, the tax is calculated after a discount. 
  282. * @return bool 
  283. */ 
  284. public function getTaxCalculatedAfterDiscount() 
  285. return $this->tax_calculated_after_discount; 
  286.  
  287. /** 
  288. * A flag indicating whether the unit price includes tax. Default is false 
  289. * @param bool $tax_inclusive 
  290. *  
  291. * @return $this 
  292. */ 
  293. public function setTaxInclusive($tax_inclusive) 
  294. $this->tax_inclusive = $tax_inclusive; 
  295. return $this; 
  296.  
  297. /** 
  298. * A flag indicating whether the unit price includes tax. Default is false 
  299. * @return bool 
  300. */ 
  301. public function getTaxInclusive() 
  302. return $this->tax_inclusive; 
  303.  
  304. /** 
  305. * General terms of the invoice. 4000 characters max. 
  306. * @param string $terms 
  307. *  
  308. * @return $this 
  309. */ 
  310. public function setTerms($terms) 
  311. $this->terms = $terms; 
  312. return $this; 
  313.  
  314. /** 
  315. * General terms of the invoice. 4000 characters max. 
  316. * @return string 
  317. */ 
  318. public function getTerms() 
  319. return $this->terms; 
  320.  
  321. /** 
  322. * Note to the payer. 4000 characters max. 
  323. * @param string $note 
  324. *  
  325. * @return $this 
  326. */ 
  327. public function setNote($note) 
  328. $this->note = $note; 
  329. return $this; 
  330.  
  331. /** 
  332. * Note to the payer. 4000 characters max. 
  333. * @return string 
  334. */ 
  335. public function getNote() 
  336. return $this->note; 
  337.  
  338. /** 
  339. * Bookkeeping memo that is private to the merchant. 150 characters max. 
  340. * @param string $merchant_memo 
  341. *  
  342. * @return $this 
  343. */ 
  344. public function setMerchantMemo($merchant_memo) 
  345. $this->merchant_memo = $merchant_memo; 
  346. return $this; 
  347.  
  348. /** 
  349. * Bookkeeping memo that is private to the merchant. 150 characters max. 
  350. * @return string 
  351. */ 
  352. public function getMerchantMemo() 
  353. return $this->merchant_memo; 
  354.  
  355. /** 
  356. * Full URL of an external image to use as the logo. 4000 characters max. 
  357. * @param string $logo_url 
  358. * @throws \InvalidArgumentException 
  359. * @return $this 
  360. */ 
  361. public function setLogoUrl($logo_url) 
  362. UrlValidator::validate($logo_url, "LogoUrl"); 
  363. $this->logo_url = $logo_url; 
  364. return $this; 
  365.  
  366. /** 
  367. * Full URL of an external image to use as the logo. 4000 characters max. 
  368. * @return string 
  369. */ 
  370. public function getLogoUrl() 
  371. return $this->logo_url; 
  372.  
  373. /** 
  374. * The total amount of the invoice. 
  375. * @param \PayPal\Api\Currency $total_amount 
  376. *  
  377. * @return $this 
  378. */ 
  379. public function setTotalAmount($total_amount) 
  380. $this->total_amount = $total_amount; 
  381. return $this; 
  382.  
  383. /** 
  384. * The total amount of the invoice. 
  385. * @return \PayPal\Api\Currency 
  386. */ 
  387. public function getTotalAmount() 
  388. return $this->total_amount; 
  389.  
  390. /** 
  391. * List of payment details for the invoice. 
  392. * @param \PayPal\Api\PaymentDetail[] $payments 
  393. *  
  394. * @return $this 
  395. */ 
  396. public function setPayments($payments) 
  397. $this->payments = $payments; 
  398. return $this; 
  399.  
  400. /** 
  401. * List of payment details for the invoice. 
  402. * @return \PayPal\Api\PaymentDetail[] 
  403. */ 
  404. public function getPayments() 
  405. return $this->payments; 
  406.  
  407. /** 
  408. * Append PaymentDetails to the list. 
  409. * @param \PayPal\Api\PaymentDetail $paymentDetail 
  410. * @return $this 
  411. */ 
  412. public function addPaymentDetail($paymentDetail) 
  413. if (!$this->getPayments()) { 
  414. return $this->setPayments(array($paymentDetail)); 
  415. } else { 
  416. return $this->setPayments( 
  417. array_merge($this->getPayments(), array($paymentDetail)) 
  418. ); 
  419.  
  420. /** 
  421. * Remove PaymentDetails from the list. 
  422. * @param \PayPal\Api\PaymentDetail $paymentDetail 
  423. * @return $this 
  424. */ 
  425. public function removePaymentDetail($paymentDetail) 
  426. return $this->setPayments( 
  427. array_diff($this->getPayments(), array($paymentDetail)) 
  428. ); 
  429.  
  430. /** 
  431. * List of refund details for the invoice. 
  432. * @param \PayPal\Api\RefundDetail[] $refunds 
  433. *  
  434. * @return $this 
  435. */ 
  436. public function setRefunds($refunds) 
  437. $this->refunds = $refunds; 
  438. return $this; 
  439.  
  440. /** 
  441. * List of refund details for the invoice. 
  442. * @return \PayPal\Api\RefundDetail[] 
  443. */ 
  444. public function getRefunds() 
  445. return $this->refunds; 
  446.  
  447. /** 
  448. * Append RefundDetails to the list. 
  449. * @param \PayPal\Api\RefundDetail $refundDetail 
  450. * @return $this 
  451. */ 
  452. public function addRefundDetail($refundDetail) 
  453. if (!$this->getRefunds()) { 
  454. return $this->setRefunds(array($refundDetail)); 
  455. } else { 
  456. return $this->setRefunds( 
  457. array_merge($this->getRefunds(), array($refundDetail)) 
  458. ); 
  459.  
  460. /** 
  461. * Remove RefundDetails from the list. 
  462. * @param \PayPal\Api\RefundDetail $refundDetail 
  463. * @return $this 
  464. */ 
  465. public function removeRefundDetail($refundDetail) 
  466. return $this->setRefunds( 
  467. array_diff($this->getRefunds(), array($refundDetail)) 
  468. ); 
  469.  
  470. /** 
  471. * Audit information for the invoice. 
  472. * @param \PayPal\Api\Metadata $metadata 
  473. *  
  474. * @return $this 
  475. */ 
  476. public function setMetadata($metadata) 
  477. $this->metadata = $metadata; 
  478. return $this; 
  479.  
  480. /** 
  481. * Audit information for the invoice. 
  482. * @return \PayPal\Api\Metadata 
  483. */ 
  484. public function getMetadata() 
  485. return $this->metadata; 
  486.  
  487. /** 
  488. * Any miscellaneous invoice data. 4000 characters max. 
  489. * @param string $additional_data 
  490. *  
  491. * @return $this 
  492. */ 
  493. public function setAdditionalData($additional_data) 
  494. $this->additional_data = $additional_data; 
  495. return $this; 
  496.  
  497. /** 
  498. * Any miscellaneous invoice data. 4000 characters max. 
  499. * @return string 
  500. */ 
  501. public function getAdditionalData() 
  502. return $this->additional_data; 
  503.  
  504. /** 
  505. * Create a new invoice by passing the details for the invoice, including the merchant_info, to the request URI. 
  506. * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. 
  507. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls 
  508. * @return Invoice 
  509. */ 
  510. public function create($apiContext = null, $restCall = null) 
  511. $payLoad = $this->toJSON(); 
  512. $json = self::executeCall( 
  513. "/v1/invoicing/invoices",  
  514. "POST",  
  515. $payLoad,  
  516. null,  
  517. $apiContext,  
  518. $restCall 
  519. ); 
  520. $this->fromJson($json); 
  521. return $this; 
  522.  
  523. /** 
  524. * Search for a specific invoice or invoices by passing a search object that specifies your search criteria to the request URI. 
  525. * @param Search $search 
  526. * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. 
  527. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls 
  528. * @return InvoiceSearchResponse 
  529. */ 
  530. public static function search($search, $apiContext = null, $restCall = null) 
  531. ArgumentValidator::validate($search, 'search'); 
  532. $payLoad = $search->toJSON(); 
  533. $json = self::executeCall( 
  534. "/v1/invoicing/search",  
  535. "POST",  
  536. $payLoad,  
  537. null,  
  538. $apiContext,  
  539. $restCall 
  540. ); 
  541. $ret = new InvoiceSearchResponse(); 
  542. $ret->fromJson($json); 
  543. return $ret; 
  544.  
  545. /** 
  546. * Send a specific invoice to its intended recipient by passing the invoice ID to the request URI. Optionally, you can specify whether to send the merchant an invoice update notification by using the notify_merchant query parameter. By default, notify_merchant is true. 
  547. * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. 
  548. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls 
  549. * @return bool 
  550. */ 
  551. public function send($apiContext = null, $restCall = null) 
  552. ArgumentValidator::validate($this->getId(), "Id"); 
  553. $payLoad = ""; 
  554. self::executeCall( 
  555. "/v1/invoicing/invoices/{$this->getId()}/send",  
  556. "POST",  
  557. $payLoad,  
  558. null,  
  559. $apiContext,  
  560. $restCall 
  561. ); 
  562. return true; 
  563.  
  564. /** 
  565. * Send a reminder about a specific invoice to its intended recipient by providing the ID of the invoice in the request URI. In addition, pass a notification object that specifies the subject of the reminder and other details in the request JSON. 
  566. * @param Notification $notification 
  567. * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. 
  568. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls 
  569. * @return bool 
  570. */ 
  571. public function remind($notification, $apiContext = null, $restCall = null) 
  572. ArgumentValidator::validate($this->getId(), "Id"); 
  573. ArgumentValidator::validate($notification, 'notification'); 
  574. $payLoad = $notification->toJSON(); 
  575. self::executeCall( 
  576. "/v1/invoicing/invoices/{$this->getId()}/remind",  
  577. "POST",  
  578. $payLoad,  
  579. null,  
  580. $apiContext,  
  581. $restCall 
  582. ); 
  583. return true; 
  584.  
  585. /** 
  586. * Cancel an invoice by passing the invoice ID to the request URI. 
  587. * @param CancelNotification $cancelNotification 
  588. * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. 
  589. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls 
  590. * @return bool 
  591. */ 
  592. public function cancel($cancelNotification, $apiContext = null, $restCall = null) 
  593. ArgumentValidator::validate($this->getId(), "Id"); 
  594. ArgumentValidator::validate($cancelNotification, 'cancelNotification'); 
  595. $payLoad = $cancelNotification->toJSON(); 
  596. self::executeCall( 
  597. "/v1/invoicing/invoices/{$this->getId()}/cancel",  
  598. "POST",  
  599. $payLoad,  
  600. null,  
  601. $apiContext,  
  602. $restCall 
  603. ); 
  604. return true; 
  605.  
  606. /** 
  607. * Mark the status of an invoice as paid by passing the invoice ID to the request URI. In addition, pass a payment detail object that specifies the payment method and other details in the request JSON. 
  608. * @param PaymentDetail $paymentDetail 
  609. * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. 
  610. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls 
  611. * @return bool 
  612. */ 
  613. public function recordPayment($paymentDetail, $apiContext = null, $restCall = null) 
  614. ArgumentValidator::validate($this->getId(), "Id"); 
  615. ArgumentValidator::validate($paymentDetail, 'paymentDetail'); 
  616. $payLoad = $paymentDetail->toJSON(); 
  617. self::executeCall( 
  618. "/v1/invoicing/invoices/{$this->getId()}/record-payment",  
  619. "POST",  
  620. $payLoad,  
  621. null,  
  622. $apiContext,  
  623. $restCall 
  624. ); 
  625. return true; 
  626.  
  627. /** 
  628. * Mark the status of an invoice as refunded by passing the invoice ID to the request URI. In addition, pass a refund-detail object that specifies the type of refund and other details in the request JSON. 
  629. * @param RefundDetail $refundDetail 
  630. * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. 
  631. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls 
  632. * @return bool 
  633. */ 
  634. public function recordRefund($refundDetail, $apiContext = null, $restCall = null) 
  635. ArgumentValidator::validate($this->getId(), "Id"); 
  636. ArgumentValidator::validate($refundDetail, 'refundDetail'); 
  637. $payLoad = $refundDetail->toJSON(); 
  638. self::executeCall( 
  639. "/v1/invoicing/invoices/{$this->getId()}/record-refund",  
  640. "POST",  
  641. $payLoad,  
  642. null,  
  643. $apiContext,  
  644. $restCall 
  645. ); 
  646. return true; 
  647.  
  648. /** 
  649. * Retrieve the details for a particular invoice by passing the invoice ID to the request URI. 
  650. * @param string $invoiceId 
  651. * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. 
  652. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls 
  653. * @return Invoice 
  654. */ 
  655. public static function get($invoiceId, $apiContext = null, $restCall = null) 
  656. ArgumentValidator::validate($invoiceId, 'invoiceId'); 
  657. $payLoad = ""; 
  658. $json = self::executeCall( 
  659. "/v1/invoicing/invoices/$invoiceId",  
  660. "GET",  
  661. $payLoad,  
  662. null,  
  663. $apiContext,  
  664. $restCall 
  665. ); 
  666. $ret = new Invoice(); 
  667. $ret->fromJson($json); 
  668. return $ret; 
  669.  
  670. /** 
  671. * List some or all invoices for a merchant according to optional query string parameters specified. 
  672. * @param array $params 
  673. * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. 
  674. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls 
  675. * @return InvoiceSearchResponse 
  676. */ 
  677. public static function getAll($params = array(), $apiContext = null, $restCall = null) 
  678. ArgumentValidator::validate($params, 'params'); 
  679.  
  680. $allowedParams = array( 
  681. 'page' => 1,  
  682. 'page_size' => 1,  
  683. 'total_count_required' => 1 
  684. ); 
  685.  
  686. $payLoad = ""; 
  687. $json = self::executeCall( 
  688. "/v1/invoicing/invoices/?" . http_build_query(array_intersect_key($params, $allowedParams)),  
  689. "GET",  
  690. $payLoad,  
  691. null,  
  692. $apiContext,  
  693. $restCall 
  694. ); 
  695. $ret = new InvoiceSearchResponse(); 
  696. $ret->fromJson($json); 
  697. return $ret; 
  698.  
  699. /** 
  700. * Fully update an invoice by passing the invoice ID to the request URI. In addition, pass a complete invoice object in the request JSON. Partial updates are not supported. 
  701. * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. 
  702. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls 
  703. * @return Invoice 
  704. */ 
  705. public function update($apiContext = null, $restCall = null) 
  706. ArgumentValidator::validate($this->getId(), "Id"); 
  707. $payLoad = $this->toJSON(); 
  708. $json = self::executeCall( 
  709. "/v1/invoicing/invoices/{$this->getId()}",  
  710. "PUT",  
  711. $payLoad,  
  712. null,  
  713. $apiContext,  
  714. $restCall 
  715. ); 
  716. $this->fromJson($json); 
  717. return $this; 
  718.  
  719. /** 
  720. * Delete a particular invoice by passing the invoice ID to the request URI. 
  721. * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. 
  722. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls 
  723. * @return bool 
  724. */ 
  725. public function delete($apiContext = null, $restCall = null) 
  726. ArgumentValidator::validate($this->getId(), "Id"); 
  727. $payLoad = ""; 
  728. self::executeCall( 
  729. "/v1/invoicing/invoices/{$this->getId()}",  
  730. "DELETE",  
  731. $payLoad,  
  732. null,  
  733. $apiContext,  
  734. $restCall 
  735. ); 
  736. return true; 
  737.  
  738. /** 
  739. * Generate a QR code for an invoice by passing the invoice ID to the request URI. The request generates a QR code that is 500 pixels in width and height. You can change the dimensions of the returned code by specifying optional query parameters. 
  740. * @param array $params 
  741. * @param string $invoiceId 
  742. * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. 
  743. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls 
  744. * @return Image 
  745. */ 
  746. public static function qrCode($invoiceId, $params = array(), $apiContext = null, $restCall = null) 
  747. ArgumentValidator::validate($invoiceId, 'invoiceId'); 
  748. ArgumentValidator::validate($params, 'params'); 
  749.  
  750. $allowedParams = array( 
  751. 'width' => 1,  
  752. 'height' => 1,  
  753. 'action' => 1 
  754. ); 
  755.  
  756. $payLoad = ""; 
  757. $json = self::executeCall( 
  758. "/v1/invoicing/invoices/$invoiceId/qr-code?" . http_build_query(array_intersect_key($params, $allowedParams)),  
  759. "GET",  
  760. $payLoad,  
  761. null,  
  762. $apiContext,  
  763. $restCall 
  764. ); 
  765. $ret = new Image(); 
  766. $ret->fromJson($json); 
  767. return $ret; 
  768.