Skip to content

Commit

Permalink
Merge pull request arlyon#400 from victorcrimea/master
Browse files Browse the repository at this point in the history
Implement transfer reversal
  • Loading branch information
arlyon authored Jul 6, 2023
2 parents 0a1aa69 + ae95478 commit a088ccd
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ mod core {
pub mod placeholders;
pub mod setup_intent_ext;
pub mod token_ext;
pub mod transfer_reversal_ext;
}

#[path = "resources"]
Expand Down Expand Up @@ -97,6 +98,7 @@ pub use {
account_ext::*,
balance_transaction_ext::*,
charge_ext::*,
transfer_reversal_ext::*,
customer_ext::*,
payment_intent_ext::*,
payment_source::*,
Expand Down
35 changes: 35 additions & 0 deletions src/resources/transfer_reversal_ext.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use serde::Deserialize;
use serde::Serialize;

use crate::client::{Client, Response};
use crate::params::Metadata;
use crate::resources::TransferReversal;
use crate::TransferId;

/// The set of parameters that can be used when doing transfer reversal.
///
/// For more details see <https://stripe.com/docs/api/transfer_reversals/create>.
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct CreateTransferReversal {
#[serde(skip_serializing_if = "Option::is_none")]
pub amount: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub metadata: Option<Metadata>,
#[serde(skip_serializing_if = "Option::is_none")]
pub refund_application_fee: Option<bool>,
}

impl TransferReversal {
/// Create Transfer Reversal
///
/// For more details see <https://stripe.com/docs/api/transfer_reversals/create>.
pub fn create(
client: &Client,
transfer: &TransferId,
params: CreateTransferReversal,
) -> Response<TransferReversal> {
client.post_form(&format!("/transfers/{}/reversals", transfer), params)
}
}

0 comments on commit a088ccd

Please sign in to comment.