Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/api/invoice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl Endpoint for GenerateInvoiceNumber {

type Response = InvoiceNumber;

fn relative_path(&self) -> Cow<str> {
fn relative_path(&self) -> Cow<'_, str> {
Cow::Borrowed("/v2/invoicing/generate-next-invoice-number")
}

Expand Down Expand Up @@ -80,7 +80,7 @@ impl Endpoint for CreateDraftInvoice {

type Response = Invoice;

fn relative_path(&self) -> Cow<str> {
fn relative_path(&self) -> Cow<'_, str> {
Cow::Borrowed("/v2/invoicing/invoices")
}

Expand Down Expand Up @@ -116,7 +116,7 @@ impl Endpoint for GetInvoice {

type Response = Invoice;

fn relative_path(&self) -> Cow<str> {
fn relative_path(&self) -> Cow<'_, str> {
Cow::Owned(format!("/v2/invoicing/invoices/{}", self.invoice_id))
}

Expand Down Expand Up @@ -147,7 +147,7 @@ impl Endpoint for ListInvoices {

type Response = InvoiceList;

fn relative_path(&self) -> Cow<str> {
fn relative_path(&self) -> Cow<'_, str> {
Cow::Borrowed("/v2/invoicing/invoices")
}

Expand Down Expand Up @@ -187,7 +187,7 @@ impl Endpoint for DeleteInvoice {

type Response = ();

fn relative_path(&self) -> Cow<str> {
fn relative_path(&self) -> Cow<'_, str> {
Cow::Owned(format!("/v2/invoicing/invoices/{}", self.invoice_id))
}

Expand Down Expand Up @@ -230,7 +230,7 @@ impl Endpoint for UpdateInvoice {

type Response = Invoice;

fn relative_path(&self) -> Cow<str> {
fn relative_path(&self) -> Cow<'_, str> {
Cow::Owned(format!("/v2/invoicing/invoices/{}", self.invoice.id))
}

Expand Down Expand Up @@ -273,7 +273,7 @@ impl Endpoint for CancelInvoice {

type Response = ();

fn relative_path(&self) -> Cow<str> {
fn relative_path(&self) -> Cow<'_, str> {
Cow::Owned(format!("/v2/invoicing/invoices/{}/cancel", self.invoice_id))
}

Expand Down Expand Up @@ -312,7 +312,7 @@ impl Endpoint for SendInvoice {

type Response = ();

fn relative_path(&self) -> Cow<str> {
fn relative_path(&self) -> Cow<'_, str> {
Cow::Owned(format!("/v2/invoicing/invoices/{}/send", self.invoice_id))
}

Expand Down
8 changes: 4 additions & 4 deletions src/api/orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl Endpoint for CreateOrder {

type Response = Order;

fn relative_path(&self) -> Cow<str> {
fn relative_path(&self) -> Cow<'_, str> {
Cow::Borrowed("/v2/checkout/orders")
}

Expand Down Expand Up @@ -69,7 +69,7 @@ impl Endpoint for ShowOrderDetails {

type Response = Order;

fn relative_path(&self) -> Cow<str> {
fn relative_path(&self) -> Cow<'_, str> {
Cow::Owned(format!("/v2/checkout/orders/{}", self.order_id))
}

Expand Down Expand Up @@ -132,7 +132,7 @@ impl Endpoint for CaptureOrder {

type Response = Order;

fn relative_path(&self) -> Cow<str> {
fn relative_path(&self) -> Cow<'_, str> {
Cow::Owned(format!("/v2/checkout/orders/{}/capture", self.order_id))
}

Expand Down Expand Up @@ -173,7 +173,7 @@ impl Endpoint for AuthorizeOrder {

type Response = Order;

fn relative_path(&self) -> Cow<str> {
fn relative_path(&self) -> Cow<'_, str> {
Cow::Owned(format!("/v2/checkout/orders/{}/authorize", self.order_id))
}

Expand Down
2 changes: 1 addition & 1 deletion src/api/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl Endpoint for GetAuthorizedPayment {

type Response = AuthorizedPaymentDetails;

fn relative_path(&self) -> Cow<str> {
fn relative_path(&self) -> Cow<'_, str> {
Cow::Owned(format!("/v2/payments/authorizations/{}", self.authorization_id))
}

Expand Down
9 changes: 2 additions & 7 deletions src/data/invoice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ pub enum PaymentType {
}

/// The payment mode or method through which the invoicer can accept the payment.
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone)]
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone, Default)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum PaymentMethod {
/// Payments can be received through bank transfers.
Expand All @@ -426,19 +426,14 @@ pub enum PaymentMethod {
/// Payments can be received through debit card payments.
DebitCard,
/// Payments can be received through paypal payments.
#[default]
Paypal,
/// Payments can be received through wire transfer.
WireTransfer,
/// Payments can be received through other modes.
Other,
}

impl Default for PaymentMethod {
fn default() -> Self {
PaymentMethod::Paypal
}
}

/// Payment detail
#[skip_serializing_none]
#[derive(Debug, Serialize, Deserialize, Clone, Builder)]
Expand Down
63 changes: 14 additions & 49 deletions src/data/orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;

/// The intent to either capture payment immediately or authorize a payment for an order after order creation.
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone)]
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone, Default)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum Intent {
/// The merchant intends to capture payment immediately after the customer makes a payment.
#[default]
Capture,
/// The merchant intends to authorize a payment and place funds on hold after the customer makes a payment.
/// Authorized payments are guaranteed for up to three days but are available to capture for up to 29 days.
Expand All @@ -19,12 +20,6 @@ pub enum Intent {
Authorize,
}

impl Default for Intent {
fn default() -> Self {
Intent::Capture
}
}

/// Represents a payer name.
///
/// <https://developer.paypal.com/docs/api/orders/v2/#definition-payer.name>
Expand Down Expand Up @@ -197,22 +192,17 @@ pub struct PlatformFee {
}

/// The funds that are held on behalf of the merchant
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Clone)]
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Clone, Default)]
pub enum DisbursementMode {
/// The funds are released to the merchant immediately.
#[default]
Instant,
/// The funds are held for a finite number of days. The actual duration depends on the region and type of integration.
/// You can release the funds through a referenced payout.
/// Otherwise, the funds disbursed automatically after the specified duration.
Delayed,
}

impl Default for DisbursementMode {
fn default() -> Self {
DisbursementMode::Instant
}
}

/// Any additional payment instructions for PayPal Commerce Platform customers.
#[skip_serializing_none]
#[derive(Debug, Default, Serialize, Deserialize, Clone, Builder)]
Expand All @@ -225,12 +215,13 @@ pub struct PaymentInstruction {
}

/// The item category type.
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone)]
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone, Default)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum ItemCategoryType {
/// Goods that are stored, delivered, and used in their electronic format.
/// This value is not currently supported for API callers that leverage
/// the [PayPal for Commerce Platform](https://www.paypal.com/us/webapps/mpp/commerce-platform) product.
#[default]
DigitalGoods,
/// A tangible item that can be shipped with proof of delivery.
PhysicalGoods,
Expand All @@ -239,12 +230,6 @@ pub enum ItemCategoryType {
Donation,
}

impl Default for ItemCategoryType {
fn default() -> Self {
ItemCategoryType::DigitalGoods
}
}

/// The name of the person to whom to ship the items.
#[skip_serializing_none]
#[derive(Debug, Default, Serialize, Deserialize, Clone)]
Expand Down Expand Up @@ -549,7 +534,7 @@ impl PurchaseUnit {
}

/// The type of landing page to show on the PayPal site for customer checkout.
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone)]
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone, Default)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum LandingPage {
/// When the customer clicks PayPal Checkout, the customer is redirected to a page to log in to PayPal and approve the payment.
Expand All @@ -560,71 +545,51 @@ pub enum LandingPage {
/// When the customer clicks PayPal Checkout, the customer is redirected to either a page to log in to PayPal and approve
/// the payment or to a page to enter credit or debit card and other relevant billing information required to complete the purchase,
/// depending on their previous interaction with PayPal.
#[default]
NoPreference,
}

impl Default for LandingPage {
fn default() -> Self {
LandingPage::NoPreference
}
}

/// The shipping preference
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone)]
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone, Default)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum ShippingPreference {
/// Use the customer-provided shipping address on the PayPal site.
#[default]
GetFromFile,
/// Redact the shipping address from the PayPal site. Recommended for digital goods.
NoShipping,
/// Use the merchant-provided address. The customer cannot change this address on the PayPal site.
SetProvidedAddress,
}

impl Default for ShippingPreference {
fn default() -> Self {
ShippingPreference::GetFromFile
}
}

/// Configures a Continue or Pay Now checkout flow.
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone)]
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone, Default)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum UserAction {
/// After you redirect the customer to the PayPal payment page, a Continue button appears. Use this option when
/// the final amount is not known when the checkout flow is initiated and you want to redirect the customer
/// to the merchant page without processing the payment.
#[default]
Continue,
/// After you redirect the customer to the PayPal payment page, a Pay Now button appears.
/// Use this option when the final amount is known when the checkout is initiated and you want to
/// process the payment immediately when the customer clicks Pay Now.
PayNow,
}

impl Default for UserAction {
fn default() -> Self {
UserAction::Continue
}
}

/// The merchant-preferred payment sources.
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone)]
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Copy, Clone, Default)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum PayeePreferred {
/// Accepts any type of payment from the customer.
#[default]
Unrestricted,
/// Accepts only immediate payment from the customer.
/// For example, credit card, PayPal balance, or instant ACH.
/// Ensures that at the time of capture, the payment does not have the `pending` status.
ImmediatePaymentRequired,
}

impl Default for PayeePreferred {
fn default() -> Self {
PayeePreferred::Unrestricted
}
}

/// A payment method.
#[skip_serializing_none]
#[derive(Debug, Default, Serialize, Deserialize, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub trait Endpoint {
type Response: DeserializeOwned;

/// The endpoint relative path. Must start with a `/`
fn relative_path(&self) -> Cow<str>;
fn relative_path(&self) -> Cow<'_, str>;

/// The request method of this endpoint.
fn method(&self) -> reqwest::Method;
Expand Down