Skip to content

Commit

Permalink
Merge pull request #226 from jeremyTyriaux/feature/refundTransfertPOST
Browse files Browse the repository at this point in the history
Add Debited funds and Fees property on the transfert refund call from…
  • Loading branch information
alexxmattei authored Jan 14, 2025
2 parents aa7521e + 014af6d commit 4632ca3
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
34 changes: 33 additions & 1 deletion MangoPay.SDK.Tests/BaseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -905,11 +905,43 @@ protected async Task<TransferDTO> GetNewTransfer(WalletDTO walletIn = null)
/// <param name="transfer">Transfer.</param>
/// <returns>Refund instance returned from API.</returns>
protected async Task<RefundDTO> GetNewRefundForTransfer(TransferDTO transfer)
{
var user = await this.GetJohn();
var debitedFunds = new Money
{
Amount = transfer.DebitedFunds.Amount,
Currency = transfer.DebitedFunds.Currency
};
var fees = new Money
{
Amount = transfer.Fees.Amount,
Currency = transfer.Fees.Currency
};

var refund = new RefundTransferPostDTO(user.Id, fees, debitedFunds);

return await this.Api.Transfers.CreateRefundAsync(transfer.Id, refund);
}

/// <summary>Creates partial refund object for Tranfert.</summary>
/// <param name="transfer">Tranfert entity.</param>
/// <returns>Refund instance returned from API.</returns>
protected async Task<RefundDTO> GetPartialRefundForPayIn(TransferDTO transfer)
{
var user = await this.GetJohn();

var refund = new RefundTransferPostDTO(user.Id);
var debitedFunds = new Money
{
Amount = 100,
Currency = transfer.DebitedFunds.Currency
};
var fees = new Money
{
Amount = 10,
Currency = transfer.Fees.Currency
};

var refund = new RefundTransferPostDTO(user.Id, fees, debitedFunds);
return await this.Api.Transfers.CreateRefundAsync(transfer.Id, refund);
}

Expand Down
10 changes: 9 additions & 1 deletion MangoPay.SDK/Entities/POST/RefundTransferPostDTO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@ namespace MangoPay.SDK.Entities.POST
/// <summary>Refund for Transfer POST entity.</summary>
public class RefundTransferPostDTO : EntityPostBase
{
public RefundTransferPostDTO(string authorId)
public RefundTransferPostDTO(string authorId, Money fees, Money debitedFunds)
{
AuthorId = authorId;
Fees = fees;
DebitedFunds = debitedFunds;
}

/// <summary>Author identifier.</summary>
public string AuthorId { get; set; }

/// <summary>Debited funds.</summary>
public Money DebitedFunds { get; set; }

/// <summary>Fees.</summary>
public Money Fees { get; set; }
}
}

0 comments on commit 4632ca3

Please sign in to comment.