paypal_rust/resources/enums/order_intent.rs
1use serde::{Deserialize, Serialize};
2
3/// The intent to either capture payment immediately or authorize a payment for an order after order creation.
4#[derive(Copy, Clone, Debug, Default, Deserialize, Serialize, PartialEq, Eq)]
5pub enum OrderIntent {
6 /// The merchant intends to capture payment immediately after the customer makes a payment.
7 #[default]
8 #[serde(rename = "CAPTURE")]
9 Capture,
10 /// The merchant intends to authorize a payment and place funds on hold after the customer makes a payment.
11 /// Authorized payments are best captured within three days of authorization but are available to capture for up to 29 days.
12 /// After the three-day honor period, the original authorized payment expires and you must re-authorize the payment.
13 /// You must make a separate request to capture payments on demand. This intent is not supported when you have more than one
14 /// `purchase_unit` within your order.
15 #[serde(rename = "AUTHORIZE")]
16 Authorize,
17}
18
19impl OrderIntent {
20 pub const fn as_str(self) -> &'static str {
21 match self {
22 Self::Capture => "CAPTURE",
23 Self::Authorize => "AUTHORIZE",
24 }
25 }
26}
27
28impl AsRef<str> for OrderIntent {
29 fn as_ref(&self) -> &str {
30 self.as_str()
31 }
32}
33
34impl std::fmt::Display for OrderIntent {
35 fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
36 self.as_str().fmt(formatter)
37 }
38}