From d8e94e6fae00850c9c78e6ed22b0b14ebc03ffcc Mon Sep 17 00:00:00 2001 From: Pro Date: Sat, 22 Jan 2022 19:05:24 +0100 Subject: [PATCH] Update models to correspond to the actual PayPal responses Namely Refund, Authorization and Capture all contain an intermediate "reason" field in their status_details. https://developer.paypal.com/api/orders/v2/#definition-refund_status_details https://developer.paypal.com/api/orders/v2/#definition-authorization_status_details https://developer.paypal.com/api/orders/v2/#definition-capture_status_details --- src/orders.rs | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/src/orders.rs b/src/orders.rs index c446d7c..30843b3 100644 --- a/src/orders.rs +++ b/src/orders.rs @@ -273,14 +273,21 @@ pub enum AuthorizationStatus { Pending, } -/// Details about the status of the authorization. +/// Authorization status reason. #[derive(Debug, Serialize, Deserialize, Eq, PartialEq)] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] -pub enum AuthorizationStatusDetails { +pub enum AuthorizationStatusDetailsReason { /// Authorization is pending manual review. PendingReview, } +/// Details about the status of the authorization. +#[derive(Debug, Serialize, Deserialize, Eq, PartialEq)] +pub struct AuthorizationStatusDetails { + /// The reason why the authorized status is PENDING. + pub reason: AuthorizationStatusDetailsReason, +} + /// A payment authorization. #[derive(Debug, Serialize, Deserialize, Eq, PartialEq)] pub struct AuthorizationWithData { @@ -306,10 +313,10 @@ pub enum CaptureStatus { Refunded, } -/// Details about the captured payment status. +/// Capture status reason. #[derive(Debug, Serialize, Deserialize, Eq, PartialEq)] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] -pub enum CaptureStatusDetails { +pub enum CaptureStatusDetailsReason { /// The payer initiated a dispute for this captured payment with PayPal. BuyerComplaint, /// The captured funds were reversed in response to the payer disputing this captured payment with @@ -338,6 +345,13 @@ pub enum CaptureStatusDetails { VerificationRequired, } +/// Details about the captured payment status. +#[derive(Debug, Serialize, Deserialize, Eq, PartialEq)] +pub struct CaptureStatusDetails { + /// The reason why the captured payment status is PENDING or DENIED. + pub reason: CaptureStatusDetailsReason, +} + /// A captured payment. #[skip_serializing_none] #[derive(Debug, Serialize, Deserialize, Eq, PartialEq)] @@ -360,14 +374,21 @@ pub enum RefundStatus { Completed, } -/// The reason why the refund has the PENDING or FAILED status. +/// Refund status reason. #[derive(Debug, Serialize, Deserialize, Eq, PartialEq)] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] -pub enum RefundStatusDetails { +pub enum RefundStatusDetailsReason { /// The customer's account is funded through an eCheck, which has not yet cleared. Echeck, } +/// Details about the status of the refund. +#[derive(Debug, Serialize, Deserialize)] +pub struct RefundStatusDetails { + /// The reason why the refund has the PENDING or FAILED status. + pub reason: RefundStatusDetailsReason, +} + /// A refund #[derive(Debug, Serialize, Deserialize)] pub struct Refund {