paypal_rs/data/invoice.rs
1//! Paypal object definitions used in the invoice api.
2
3use crate::{data::common::LinkDescription, data::common::*};
4use derive_builder::Builder;
5use serde::{Deserialize, Serialize};
6use serde_with::skip_serializing_none;
7
8/// Paypal File reference
9#[derive(Debug, Serialize, Deserialize, Clone)]
10pub struct FileReference {
11 /// The ID of the referenced file.
12 pub id: String,
13 /// The reference URL for the file.
14 pub reference_url: String,
15 /// Content type
16 pub content_type: String,
17 /// The date and time when the file was created
18 pub create_time: chrono::DateTime<chrono::Utc>,
19 /// The size of the file, in bytes.
20 pub size: String,
21}
22
23#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Clone)]
24#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
25/// The payment term type.
26pub enum PaymentTermType {
27 /// The payment for the invoice is due upon receipt of the invoice.
28 DueOnReceipt,
29 /// The payment for the invoice is due on the date specified in the invoice.
30 DueOnDateSpecified,
31 /// The payment for the invoice is due in 10 days.
32 Net10,
33 /// The payment for the invoice is due in 15 days.
34 Net15,
35 /// The payment for the invoice is due in 30 days.
36 Net30,
37 /// The payment for the invoice is due in 45 days.
38 Net45,
39 /// The payment for the invoice is due in 60 days.
40 Net60,
41 /// The payment for the invoice is due in 90 days.
42 Net90,
43 /// The invoice has no payment due date.
44 NoDueDate,
45}
46
47/// The payment due date for the invoice.
48#[derive(Debug, Serialize, Deserialize, Clone)]
49pub struct PaymentTerm {
50 /// The payment term. Payment can be due upon receipt, a specified date, or in a set number of days
51 pub term_type: PaymentTermType,
52 /// The date when the invoice payment is due,
53 pub due_date: Option<chrono::NaiveDate>,
54}
55
56/// Flow type
57#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Clone)]
58#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
59/// The flow variation
60pub enum FlowType {
61 /// The invoice sent to multiple recipients.
62 MultipleRecipientsGroup,
63 /// The invoice sent as a batch.
64 Batch,
65 /// The regular invoice sent to single recipient.
66 RegularSingle,
67}
68
69/// Metadata about a resource
70#[skip_serializing_none]
71#[derive(Debug, Serialize, Deserialize, Default, Clone)]
72pub struct Metadata {
73 /// The date and time when the resource was created
74 pub create_time: Option<chrono::DateTime<chrono::Utc>>,
75 /// The email address of the account that created the resource.
76 pub created_by: Option<String>,
77 /// The date and time when the resource was last edited
78 pub last_update_time: Option<chrono::DateTime<chrono::Utc>>,
79 /// The email address of the account that last edited the resource.
80 pub last_updated_by: Option<chrono::DateTime<chrono::Utc>>,
81 /// The date and time when the resource was canceled
82 pub cancel_time: Option<chrono::DateTime<chrono::Utc>>,
83 /// The actor who canceled the resource.
84 pub cancelled_by: Option<chrono::DateTime<chrono::Utc>>,
85 /// The date and time when the resource was first sent
86 pub first_sent_time: Option<chrono::DateTime<chrono::Utc>>,
87 /// The date and time when the resource was last sent
88 pub last_sent_time: Option<chrono::DateTime<chrono::Utc>>,
89 /// The email address of the account that last sent the resource.
90 pub last_sent_by: Option<String>,
91 /// The flow variation that created this invoice
92 pub created_by_flow: Option<FlowType>,
93 /// The URL for the invoice payer view hosted on paypal.com.
94 pub recipient_view_url: Option<String>,
95 /// The URL for the invoice merchant view hosted on paypal.com
96 pub invoicer_view_url: Option<String>,
97}
98
99/// The details of the invoice. Includes the invoice number, date, payment terms, and audit metadata.
100#[skip_serializing_none]
101#[derive(Debug, Serialize, Deserialize, Default, Clone, Builder)]
102#[builder(setter(strip_option), default)]
103pub struct InvoiceDetail {
104 /// The reference data. Includes a post office (PO) number.
105 pub reference: Option<String>,
106 /// The three-character ISO-4217 currency code that identifies the currency.
107 pub currency_code: Currency,
108 /// A note to the invoice recipient. Also appears on the invoice notification email.
109 pub note: Option<String>,
110 /// The general terms of the invoice. Can include return or cancellation policy and other terms and conditions.
111 pub terms_and_conditions: Option<String>,
112 /// A private bookkeeping memo for the user.
113 pub memo: Option<String>,
114 /// An array of PayPal IDs for the files that are attached to an invoice.
115 pub attachments: Option<Vec<FileReference>>,
116 /// The invoice number. Default is the number that is auto-incremented number from the last number.
117 pub invoice_number: Option<String>,
118 /// The invoice date as specificed by the sender
119 pub invoice_date: Option<chrono::NaiveDate>,
120 /// The payment due date for the invoice.
121 pub payment_term: Option<PaymentTerm>,
122 /// The audit metadata
123 pub metadata: Option<Metadata>,
124}
125
126/// A name to be used as recipient, etc.
127#[skip_serializing_none]
128#[derive(Debug, Serialize, Deserialize, Default, Clone, Builder)]
129#[builder(setter(strip_option, into), default)]
130pub struct Name {
131 /// The prefix, or title, to the party's name.
132 pub prefix: Option<String>,
133 /// When the party is a person, the party's given, or first, name.
134 pub given_name: Option<String>,
135 /// When the party is a person, the party's surname or family name.
136 /// Also known as the last name. Required when the party is a person.
137 /// Use also to store multiple surnames including the matronymic, or mother's, surname.
138 pub surname: Option<String>,
139 /// When the party is a person, the party's middle name. Use also to store multiple middle names including the patronymic, or father's, middle name.
140 pub middle_name: Option<String>,
141 /// The suffix for the party's name.
142 pub suffix: Option<String>,
143 /// DEPRECATED. The party's alternate name. Can be a business name, nickname,
144 /// or any other name that cannot be split into first, last name. Required when the party is a business.
145 pub alternate_full_name: Option<String>,
146 /// When the party is a person, the party's full name.
147 pub full_name: Option<String>,
148}
149
150/// Phone information
151#[skip_serializing_none]
152#[derive(Debug, Serialize, Deserialize, Default, Clone)]
153pub struct PhoneDetail {
154 /// The country calling code (CC), in its canonical international E.164 numbering plan format.
155 pub country_code: String,
156 /// The national number, in its canonical international E.164 numbering plan format.
157 pub national_number: String,
158 /// The extension number.
159 pub extension_number: Option<String>,
160 /// The phone type.
161 pub phone_type: Option<PhoneType>,
162}
163
164/// The invoicer information.
165#[skip_serializing_none]
166#[derive(Debug, Serialize, Deserialize, Default, Clone, Builder)]
167#[builder(setter(strip_option), default)]
168pub struct InvoicerInfo {
169 /// Required. The business name of the party.
170 pub business_name: Option<String>,
171 /// The first and Last name of the recipient.
172 pub name: Option<Name>,
173 /// The invoicer email address, which must be listed in the user's PayPal profile.
174 /// If you omit this value, notifications are sent from and to the primary email address but do not appear on the invoice.
175 pub email_address: Option<String>,
176 /// An array of invoicer's phone numbers. The invoicer can choose to hide the phone number on the invoice.
177 pub phones: Option<Vec<PhoneDetail>>,
178 /// The invoicer's website.
179 pub website: Option<String>,
180 /// The invoicer's tax ID.
181 pub tax_id: Option<String>,
182 /// Any additional information. Includes business hours.
183 pub additional_notes: Option<String>,
184 /// The full URL to an external logo image. The logo image must not be larger than 250 pixels wide by 90 pixels high.
185 pub logo_url: Option<String>,
186}
187
188/// Billing information
189#[skip_serializing_none]
190#[derive(Debug, Serialize, Deserialize, Default, Clone)]
191pub struct BillingInfo {
192 /// Required. The business name of the party.
193 pub business_name: String,
194 /// The first and Last name of the recipient.
195 pub name: Option<Name>,
196 /// The address of the recipient.
197 pub address: Option<Address>,
198 /// The invoice recipient email address. If you omit this value, the invoice is payable and a notification email is not sent.
199 pub email_address: Option<String>,
200 /// The invoice recipient's phone numbers. Extension number is not supported.
201 pub phones: Option<Vec<PhoneDetail>>,
202 /// Any additional information about the recipient. Maximum length: 40.
203 pub additional_info: Option<String>,
204 /// The language in which to show the invoice recipient's email message. Used only when the recipient does not have a PayPal account
205 pub language: Option<String>,
206}
207
208/// Contact information
209#[skip_serializing_none]
210#[derive(Debug, Serialize, Deserialize, Clone)]
211pub struct ContactInformation {
212 /// Required. The business name of the party.
213 pub business_name: String,
214 /// The first and Last name of the recipient.
215 pub name: Option<Name>,
216 /// The address of the recipient.
217 pub address: Option<Address>,
218}
219
220/// Recipient information
221#[skip_serializing_none]
222#[derive(Debug, Serialize, Deserialize, Default, Clone)]
223pub struct RecipientInfo {
224 /// The billing information for the invoice recipient. Includes name, address, email, phone, and language.
225 pub billing_info: Option<BillingInfo>,
226 /// The recipient's shipping information. Includes the user's contact information, which includes name and address.
227 pub shipping_info: Option<ContactInformation>,
228}
229
230/// Tax information
231#[skip_serializing_none]
232#[derive(Debug, Serialize, Deserialize, Clone)]
233pub struct Tax {
234 /// The name of the tax applied on the invoice items.
235 pub name: String,
236 /// The tax rate. Value is from 0 to 100. Supports up to five decimal places.
237 pub percent: String,
238 /// The calculated tax amount. The tax amount is added to the item total.
239 pub amount: Option<Money>,
240}
241
242/// Discount information
243#[derive(Debug, Serialize, Deserialize, Clone, Builder, Default)]
244#[builder(setter(strip_option, into), default)]
245pub struct Discount {
246 /// The discount as a percentage value. Value is from 0 to 100. Supports up to five decimal places.
247 pub percent: Option<String>,
248 /// The invoice level discount amount. Value is from 0 to 1000000. Supports up to two decimal places.
249 pub amount: Option<Box<Amount>>,
250}
251
252/// The unit of measure for the invoiced item.
253#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Clone)]
254#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
255pub enum UnitOfMeasure {
256 /// The unit of measure is quantity. This invoice template is typically used for physical goods.
257 Quantity,
258 /// The unit of measure is hours. This invoice template is typically used for services.
259 Hours,
260 /// The unit of measure is amount. This invoice template is typically used when only amount is required.
261 Amount,
262}
263
264/// Item information
265#[skip_serializing_none]
266#[derive(Debug, Serialize, Deserialize, Clone, Builder)]
267#[builder(setter(strip_option, into))]
268pub struct Item {
269 /// The ID of the invoice line item.
270 /// Read only.
271 #[builder(default)]
272 pub id: Option<String>,
273 /// The item name for the invoice line item.
274 pub name: String,
275 /// The item description for the invoice line item.
276 #[builder(default)]
277 pub description: Option<String>,
278 /// The quantity of the item that the invoicer provides to the payer. Value is from -1000000 to 1000000. Supports up to five decimal places.
279 pub quantity: String,
280 /// The unit price of the item. This does not include tax and discount. Value is from -1000000 to 1000000. Supports up to two decimal places.
281 pub unit_amount: Money,
282 /// The tax associated with the item. The tax amount is added to the item total. Value is from 0 to 100. Supports up to five decimal places.
283 #[builder(default)]
284 pub tax: Option<Tax>,
285 /// The date when the item or service was provided, in Internet date and time format.
286 #[builder(default)]
287 pub item_date: Option<chrono::DateTime<chrono::Utc>>,
288 /// Discount as a percent or amount at invoice level. The invoice discount amount is subtracted from the item total.
289 #[builder(default)]
290 pub discount: Option<Discount>,
291 /// The unit of measure for the invoiced item. For AMOUNT the unit_amount and quantity are not shown on the invoice.
292 #[builder(default)]
293 pub unit_of_measure: Option<UnitOfMeasure>,
294}
295
296/// The partial payment details.
297#[skip_serializing_none]
298#[derive(Debug, Serialize, Deserialize, Clone, Default, Builder)]
299#[builder(setter(strip_option, into), default)]
300pub struct PartialPayment {
301 /// Indicates whether the invoice allows a partial payment. If false, the invoice must be paid in full. If true, the invoice allows partial payments.
302 pub allow_partial_payment: Option<bool>,
303 /// The minimum amount allowed for a partial payment. Valid only when allow_partial_payment is true.
304 pub minimum_amount_due: Option<Money>,
305}
306
307/// The invoice configuration details. Includes partial payment, tip, and tax calculated after discount.
308#[skip_serializing_none]
309#[derive(Debug, Serialize, Deserialize, Clone, Default, Builder)]
310#[builder(setter(strip_option, into), default)]
311pub struct Configuration {
312 /// Indicates whether the tax is calculated before or after a discount. If false, the tax is calculated before a discount. If true, the tax is calculated after a discount.
313 pub tax_calculated_after_discount: Option<bool>,
314 /// Indicates whether the unit price includes tax.
315 pub tax_inclusive: Option<bool>,
316 /// Indicates whether the invoice enables the customer to enter a tip amount during payment.
317 /// If true, the invoice shows a tip amount field so that the customer can enter a tip amount. If false, the invoice does not show a tip amount field.
318 pub allow_tip: Option<bool>,
319 /// The partial payment details. Includes the minimum amount that the invoicer wants the payer to pay.
320 pub partial_payment: Option<PartialPayment>,
321 /// The template ID. The template determines the layout of the invoice. Includes which fields to show and hide. Default: PayPal system template.
322 pub template_id: Option<String>,
323}
324
325/// The discount
326#[skip_serializing_none]
327#[derive(Debug, Default, Serialize, Deserialize, Clone, Builder)]
328#[builder(setter(strip_option, into), default)]
329pub struct AggregatedDiscount {
330 /// The discount as a percent or amount at invoice level. The invoice discount amount is subtracted from the item total.
331 pub invoice_discount: Option<Discount>,
332 /// The discount as a percent or amount at item level. The item discount amount is subtracted from each item amount.
333 pub item_discount: Option<Money>,
334}
335
336/// The shipping fee
337#[derive(Debug, Default, Serialize, Deserialize, Clone, Builder)]
338#[builder(setter(strip_option, into), default)]
339pub struct ShippingCost {
340 /// The shipping amount. Value is from 0 to 1000000. Supports up to two decimal places.
341 pub amount: Option<Money>,
342 /// The tax associated with the shipping.
343 pub tax: Option<Tax>,
344}
345
346/// The custom amount to apply to an invoice
347#[skip_serializing_none]
348#[derive(Debug, Default, Serialize, Deserialize, Clone, Builder)]
349#[builder(setter(strip_option, into))]
350pub struct CustomAmount {
351 /// The label to the custom amount of the invoice.
352 pub label: String,
353 /// The custom amount value. Value is from -1000000 to 1000000. Supports up to two decimal places.
354 #[builder(default)]
355 pub amount: Option<Money>,
356}
357
358/// The breakdown of the amount. Breakdown provides details such as total item amount, total tax amount, custom amount, shipping and discounts, if any.
359#[skip_serializing_none]
360#[derive(Debug, Default, Serialize, Deserialize, Clone, Builder)]
361#[builder(setter(strip_option, into), default)]
362pub struct Breakdown {
363 /// The subtotal for all items. Must equal the sum of (items[].unit_amount * items[].quantity) for all items.
364 pub item_total: Option<Money>,
365 /// The discount can be at the item or invoice level, or both. Can be applied as a percent or amount. If you provide both amount and percent, amount takes precedent.
366 pub discount: Option<AggregatedDiscount>,
367 /// The aggregated amount of the item and shipping taxes.
368 pub tax_total: Option<Money>,
369 /// The shipping fee for all items. Includes tax on shipping.
370 pub shipping: Option<ShippingCost>,
371 /// The custom amount to apply to an invoice. If you include a label, you must include the custom amount.
372 pub custom: Option<CustomAmount>,
373}
374
375/// Represents an amount of money.
376#[skip_serializing_none]
377#[derive(Debug, Default, Serialize, Deserialize, Clone, Builder)]
378#[builder(setter(strip_option, into))]
379pub struct Amount {
380 /// The [three-character ISO-4217 currency code](https://developer.paypal.com/docs/integration/direct/rest/currency-codes/) that identifies the currency.
381 pub currency_code: Currency,
382 /// The value, which might be:
383 /// - An integer for currencies like JPY that are not typically fractional.
384 /// - A decimal fraction for currencies like TND that are subdivided into thousandths.
385 ///
386 /// For the required number of decimal places for a currency code, see [Currency Codes](https://developer.paypal.com/docs/api/reference/currency-codes/).
387 pub value: String,
388 /// The breakdown of the amount. Breakdown provides details such as total item amount, total tax amount, custom amount, shipping and discounts, if any.
389 #[builder(default)]
390 pub breakdown: Option<Breakdown>,
391}
392
393impl Amount {
394 /// Creates a new amount with the required values.
395 pub fn new(currency_code: Currency, value: &str) -> Self {
396 Amount {
397 currency_code,
398 value: value.into(),
399 breakdown: None,
400 }
401 }
402}
403
404/// The payment type in an invoicing flow
405#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone)]
406#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
407pub enum PaymentType {
408 /// The payment type is PayPal.
409 Paypal,
410 /// The payment type is an external cash or a check payment.
411 External,
412}
413
414/// The payment mode or method through which the invoicer can accept the payment.
415#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone)]
416#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
417pub enum PaymentMethod {
418 /// Payments can be received through bank transfers.
419 BankTransfer,
420 /// Payments can be received as cash.
421 Cash,
422 /// Payments can be received as check.
423 Check,
424 /// Payments can be received through credit card payments.
425 CreditCard,
426 /// Payments can be received through debit card payments.
427 DebitCard,
428 /// Payments can be received through paypal payments.
429 Paypal,
430 /// Payments can be received through wire transfer.
431 WireTransfer,
432 /// Payments can be received through other modes.
433 Other,
434}
435
436impl Default for PaymentMethod {
437 fn default() -> Self {
438 PaymentMethod::Paypal
439 }
440}
441
442/// Payment detail
443#[skip_serializing_none]
444#[derive(Debug, Serialize, Deserialize, Clone, Builder)]
445#[builder(setter(strip_option, into))]
446pub struct PaymentDetail {
447 /// The payment type in an invoicing flow which can be PayPal or an external cash or check payment.
448 #[builder(default)]
449 pub r#type: Option<PaymentType>,
450 /// The ID for a PayPal payment transaction. Required for the PAYPAL payment type.
451 #[builder(default)]
452 pub payment_id: Option<String>,
453 /// The date when the invoice was paid, in Internet date and time format.
454 #[builder(default)]
455 pub payment_date: Option<chrono::DateTime<chrono::Utc>>,
456 /// The payment mode or method through which the invoicer can accept the payment.
457 pub method: PaymentMethod,
458 /// A note associated with an external cash or check payment.
459 #[builder(default)]
460 pub note: Option<String>,
461 /// The payment amount to record against the invoice. If you omit this parameter, the total invoice amount is marked as paid. This amount cannot exceed the amount due.
462 #[builder(default)]
463 pub amount: Option<Money>,
464 /// The recipient's shipping information. Includes the user's contact information, which includes name and address.
465 #[builder(default)]
466 pub shipping_info: Option<ContactInformation>,
467}
468
469/// Payments registered against the invoice
470#[skip_serializing_none]
471#[derive(Debug, Default, Serialize, Deserialize, Clone, Builder)]
472#[builder(setter(strip_option, into), default)]
473pub struct Payments {
474 /// The aggregated payment amounts against this invoice.
475 /// Read only.
476 pub paid_amount: Option<Money>,
477 /// An array of payment details for the invoice. The payment details of the invoice like payment type, method, date, discount and transaction type.
478 /// Read only.
479 pub transactions: Option<Vec<PaymentDetail>>,
480}
481
482/// Refund details
483#[skip_serializing_none]
484#[derive(Debug, Serialize, Deserialize, Clone, Builder)]
485#[builder(setter(strip_option, into))]
486pub struct RefundDetail {
487 /// The PayPal refund type. Indicates whether the refund was paid through PayPal or externally in the invoicing flow.
488 #[builder(default)]
489 pub r#type: Option<PaymentType>,
490 /// The ID for a PayPal payment transaction. Required for the PAYPAL payment type.
491 #[builder(default)]
492 pub refund_id: Option<String>,
493 /// The date when the invoice was refunded, in Internet date format.
494 #[builder(default)]
495 pub refund_date: Option<chrono::DateTime<chrono::Utc>>,
496 /// The amount to record as refunded. If you omit the amount, the total invoice paid amount is recorded as refunded.
497 #[builder(default)]
498 pub amount: Option<Money>,
499 /// The payment mode or method through which the invoicer can accept the payments.
500 pub method: PaymentMethod,
501}
502
503/// List of refunds
504#[skip_serializing_none]
505#[derive(Debug, Serialize, Deserialize, Default, Clone, Builder)]
506#[builder(setter(strip_option, into), default)]
507pub struct Refunds {
508 /// The aggregated refund amounts.
509 /// Read only.
510 pub refund_amount: Option<Money>,
511 /// An array of refund details for the invoice. Includes the refund type, date, amount, and method.
512 /// Read only.
513 pub transactions: Option<Vec<RefundDetail>>,
514}
515
516/// The status of the invoice
517#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone)]
518#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
519pub enum Status {
520 /// The invoice is in draft state. It is not yet sent to the payer.
521 Draft,
522 /// The invoice has been sent to the payer. The payment is awaited from the payer.
523 Sent,
524 /// The invoice is scheduled on a future date. It is not yet sent to the payer.
525 Scheduled,
526 /// The payer has paid for the invoice.
527 Paid,
528 /// The invoice is marked as paid by the invoicer.
529 MarkedAsPaid,
530 /// The invoice has been cancelled by the invoicer.
531 Cancelled,
532 /// The invoice has been refunded by the invoicer.
533 Refunded,
534 /// The payer has partially paid for the invoice.
535 PartiallyPaid,
536 /// The invoice has been partially refunded by the invoicer.
537 PartiallyRefunded,
538 /// The invoice is marked as refunded by the invoicer.
539 MarkedAsRefunded,
540 /// The invoicer is yet to receive the payment from the payer for the invoice.
541 Unpaid,
542 /// The invoicer is yet to receive the payment for the invoice. It is under pending review.
543 PaymentPending,
544}
545
546/// An invoice payload
547#[skip_serializing_none]
548#[derive(Debug, Serialize, Deserialize, Default, Clone, Builder)]
549#[builder(setter(strip_option), default)]
550pub struct InvoicePayload {
551 /// The details of the invoice. Includes the invoice number, date, payment terms, and audit metadata.
552 pub detail: InvoiceDetail,
553 /// The invoicer information. Includes the business name, email, address, phone, fax, tax ID, additional notes, and logo URL.
554 pub invoicer: Option<InvoicerInfo>,
555 /// The billing and shipping information. Includes name, email, address, phone and language.
556 pub primary_recipient: Option<Vec<RecipientInfo>>,
557 /// An array of one or more CC: emails to which notifications are sent.
558 /// If you omit this parameter, a notification is sent to all CC: email addresses that are part of the invoice.
559 pub additional_recipients: Option<Vec<String>>,
560 /// An array of invoice line item information.
561 pub items: Vec<Item>,
562 /// The invoice configuration details. Includes partial payment, tip, and tax calculated after discount.
563 pub configuration: Option<Configuration>,
564 /// The invoice amount summary of item total, discount, tax total and shipping..
565 pub amount: Option<Amount>,
566 /// List of payments registered against the invoice.
567 pub payments: Option<Payments>,
568 /// List of refunds against this invoice. The invoicing refund details includes refund type, date, amount, and method.
569 pub refunds: Option<Refunds>,
570}
571
572/// Definition: <https://developer.paypal.com/docs/api/invoicing/v2/#invoices_get>
573#[skip_serializing_none]
574#[derive(Debug, Serialize, Deserialize, Clone, Builder)]
575#[builder(setter(strip_option, into))]
576pub struct Invoice {
577 /// The ID of the invoice.
578 pub id: String,
579 /// The parent ID to an invoice that defines the group invoice to which the invoice is related.
580 #[builder(default)]
581 pub parent_id: Option<String>,
582 /// The status of the invoice.
583 pub status: Status,
584 /// The details of the invoice. Includes the invoice number, date, payment terms, and audit metadata.
585 pub detail: InvoiceDetail,
586 /// The invoicer information. Includes the business name, email, address, phone, fax, tax ID, additional notes, and logo URL.
587 #[builder(default)]
588 pub invoicer: Option<InvoicerInfo>,
589 /// The billing and shipping information. Includes name, email, address, phone and language.
590 #[builder(default)]
591 pub primary_recipients: Option<Vec<RecipientInfo>>,
592 /// An array of one or more CC: emails to which notifications are sent.
593 /// If you omit this parameter, a notification is sent to all CC: email addresses that are part of the invoice.
594 #[builder(default)]
595 pub additional_recipients: Option<Vec<String>>,
596 /// An array of invoice line item information.
597 #[builder(default)]
598 pub items: Option<Vec<Item>>,
599 /// The invoice configuration details. Includes partial payment, tip, and tax calculated after discount.
600 #[builder(default)]
601 pub configuration: Option<Configuration>,
602 /// The invoice amount summary of item total, discount, tax total and shipping..
603 pub amount: Amount,
604 /// The due amount, which is the balance amount outstanding after payments.
605 #[builder(default)]
606 pub due_amount: Option<Money>,
607 /// The amount paid by the payer as gratuity to the invoicer.
608 #[builder(default)]
609 pub gratuity: Option<Money>,
610 /// List of payments registered against the invoice..
611 #[builder(default)]
612 pub payments: Option<Payments>,
613 /// List of refunds against this invoice. The invoicing refund details includes refund type, date, amount, and method.
614 #[builder(default)]
615 pub refunds: Option<Refunds>,
616 /// An array of request-related HATEOAS links.
617 #[builder(default)]
618 pub links: Option<Vec<LinkDescription>>,
619}
620
621/// A invoice list
622#[derive(Debug, Serialize, Deserialize, Clone, Builder)]
623#[builder(setter(into))]
624pub struct InvoiceList {
625 /// Total items
626 pub total_items: i32,
627 /// Total pages
628 pub total_pages: i32,
629 /// The invoices
630 pub items: Vec<Invoice>,
631 /// HATEOAS links
632 pub links: Vec<LinkDescription>,
633}
634
635/// Cancel invoice reason
636#[skip_serializing_none]
637#[derive(Debug, Serialize, Deserialize, Default, Clone, Builder)]
638#[builder(setter(strip_option, into), default)]
639pub struct CancelReason {
640 /// The subject of the email that is sent as a notification to the recipient.
641 pub subject: Option<String>,
642 /// A note to the payer.
643 pub note: Option<String>,
644 /// Indicates whether to send a copy of the email to the merchant.
645 pub send_to_invoicer: Option<bool>,
646 /// Indicates whether to send a copy of the email to the recipient.
647 pub send_to_recipient: Option<bool>,
648 /// An array of one or more CC: emails to which notifications are sent.
649 /// If you omit this parameter, a notification is sent to all CC: email addresses that are part of the invoice.
650 pub additional_recipients: Option<Vec<String>>,
651}
652
653/// QR pay action
654pub const QR_ACTION_PAY: &str = "pay";
655/// QR details action
656pub const QR_ACTION_DETAILS: &str = "details";
657
658/// QR creation parameters
659#[derive(Debug, Serialize, Deserialize, Default, Clone, Builder)]
660pub struct QRCodeParams {
661 /// The width, in pixels, of the QR code image. Value is from 150 to 500.
662 pub width: i32,
663 /// The height, in pixels, of the QR code image. Value is from 150 to 500.
664 pub height: i32,
665 /// The type of URL for which to generate a QR code. Valid values are pay and details.
666 ///
667 /// Check QR_ACTION_PAY and QR_ACTION_DETAILS constants
668 pub action: Option<String>,
669}
670
671/// Used to record a payment.
672#[skip_serializing_none]
673#[derive(Debug, Serialize, Deserialize, Default, Clone, Builder)]
674pub struct RecordPaymentPayload {
675 /// The payment id.
676 pub payment_id: Option<String>,
677 /// The payment date
678 pub payment_date: Option<chrono::DateTime<chrono::Utc>>,
679 /// The payment method.
680 pub method: PaymentMethod,
681 /// A note.
682 pub note: Option<String>,
683 /// The amount.
684 pub amount: Amount,
685 /// The shipping info.
686 pub shipping_info: Option<ContactInformation>,
687}
688
689/// Send Invoice Payload
690#[skip_serializing_none]
691#[derive(Debug, Serialize, Deserialize, Default, Builder, Clone)]
692pub struct SendInvoicePayload {
693 /// An array of one or more CC: emails to which notifications are sent.
694 /// If you omit this parameter, a notification is sent to all CC: email addresses that are part of the invoice.
695 pub additional_recipients: Option<Vec<String>>,
696 /// A note to the payer.
697 pub note: Option<String>,
698 /// Indicates whether to send a copy of the email to the merchant.
699 pub send_to_invoicer: Option<bool>,
700 /// Indicates whether to send a copy of the email to the recipient.
701 pub send_to_recipient: Option<bool>,
702 /// The subject of the email that is sent as a notification to the recipient.
703 pub subject: Option<String>,
704}