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
This commit is contained in:
Pro 2022-01-22 19:05:24 +01:00
parent 2e8803d2e5
commit d8e94e6fae

View file

@ -273,14 +273,21 @@ pub enum AuthorizationStatus {
Pending, Pending,
} }
/// Details about the status of the authorization. /// Authorization status reason.
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq)] #[derive(Debug, Serialize, Deserialize, Eq, PartialEq)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum AuthorizationStatusDetails { pub enum AuthorizationStatusDetailsReason {
/// Authorization is pending manual review. /// Authorization is pending manual review.
PendingReview, 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. /// A payment authorization.
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq)] #[derive(Debug, Serialize, Deserialize, Eq, PartialEq)]
pub struct AuthorizationWithData { pub struct AuthorizationWithData {
@ -306,10 +313,10 @@ pub enum CaptureStatus {
Refunded, Refunded,
} }
/// Details about the captured payment status. /// Capture status reason.
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq)] #[derive(Debug, Serialize, Deserialize, Eq, PartialEq)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum CaptureStatusDetails { pub enum CaptureStatusDetailsReason {
/// The payer initiated a dispute for this captured payment with PayPal. /// The payer initiated a dispute for this captured payment with PayPal.
BuyerComplaint, BuyerComplaint,
/// The captured funds were reversed in response to the payer disputing this captured payment with /// The captured funds were reversed in response to the payer disputing this captured payment with
@ -338,6 +345,13 @@ pub enum CaptureStatusDetails {
VerificationRequired, 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. /// A captured payment.
#[skip_serializing_none] #[skip_serializing_none]
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq)] #[derive(Debug, Serialize, Deserialize, Eq, PartialEq)]
@ -360,14 +374,21 @@ pub enum RefundStatus {
Completed, Completed,
} }
/// The reason why the refund has the PENDING or FAILED status. /// Refund status reason.
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq)] #[derive(Debug, Serialize, Deserialize, Eq, PartialEq)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[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. /// The customer's account is funded through an eCheck, which has not yet cleared.
Echeck, 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 /// A refund
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
pub struct Refund { pub struct Refund {