-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from buckaroo-it/feature/PS2-557_AddSepaDirect…
…Debit_ForCreateCombinedInvoice .NET SDK: Add SEPA DirectDebit for CreateCombinedInvoice
- Loading branch information
Showing
10 changed files
with
189 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
BuckarooSdk.Tests/Services/SepaDirectDebit/SepaDirectDebitTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using BuckarooSdk.DataTypes.RequestBases; | ||
using BuckarooSdk.Services.SepaDirectDebit; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System; | ||
using System.Globalization; | ||
|
||
namespace BuckarooSdk.Tests.Services.SepaDirectDebit | ||
{ | ||
[TestClass] | ||
public class SepaDirectDebitTests | ||
{ | ||
private SdkClient _sdkClient; | ||
|
||
[TestInitialize] | ||
public void Setup() | ||
{ | ||
this._sdkClient = new SdkClient(Constants.TestSettings.Logger); | ||
} | ||
|
||
[TestMethod] | ||
public void PayTest() | ||
{ | ||
var payment = this._sdkClient.CreateRequest() | ||
.Authenticate(Constants.TestSettings.WebsiteKey, Constants.TestSettings.SecretKey, false, new CultureInfo("nl-NL")) | ||
.TransactionRequest() | ||
.SetBasicFields(new TransactionBase | ||
{ | ||
Currency = "EUR", | ||
AmountDebit = 0.02m, | ||
Invoice = $"SDK_TEST_{DateTime.Now.Ticks}", | ||
Description = "SEPADIRECTDEBIT_PAY_SDK_UNITTEST", | ||
StartRecurrent = true, | ||
|
||
}) | ||
.SepaDirectDebit() | ||
.Pay(new SepaDirectDebitPayRequest() | ||
{ | ||
MandateReference = "0012652668455265", | ||
MandateDate = "16-12-2023", | ||
CustomerBic = "INGBNL2A", | ||
CustomerAccountName = "Tester Test", | ||
CollectDate = "26-12-2023", | ||
}); | ||
|
||
var paymentResponse = payment.Execute(); | ||
} | ||
|
||
[TestMethod] | ||
public void RefundTest() | ||
{ | ||
var request = this._sdkClient.CreateRequest() | ||
.Authenticate(Constants.TestSettings.WebsiteKey, Constants.TestSettings.SecretKey, false, new CultureInfo("nl-NL")) | ||
.TransactionRequest() | ||
.SetBasicFields(new TransactionBase | ||
{ | ||
AmountCredit = 0.02m, | ||
Currency = "EUR", | ||
Invoice = "", | ||
OriginalTransactionKey = "", | ||
Description = "SEPADIRECTDEBIT_REFUND_SDK_UNITTEST", | ||
|
||
}) | ||
.SepaDirectDebit() | ||
.Refund(new SepaDirectDebitRefundRequest() | ||
{ | ||
}); | ||
|
||
var response = request.Execute(); | ||
} | ||
} | ||
} | ||
|
4 changes: 2 additions & 2 deletions
4
BuckarooSdk.Tests/Services/SimpleSepaDirectDebit/SimpleSepaDirectDebitTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
BuckarooSdk/Services/SepaDirectDebit/SepaDirectDebitPayRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace BuckarooSdk.Services.SepaDirectDebit | ||
{ | ||
public class SepaDirectDebitPayRequest | ||
{ | ||
public string CollectDate { get; set; } | ||
public string CustomerAccountName { get; set; } | ||
public string CustomerIBAN { get; set; } | ||
public string CustomerBic { get; set; } | ||
public string MandateReference { get; set; } | ||
public string MandateDate { get; set; } | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
BuckarooSdk/Services/SepaDirectDebit/SepaDirectDebitPayResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
|
||
namespace BuckarooSdk.Services.SepaDirectDebit | ||
{ | ||
public class SepaDirectDebitPayResponse : ActionResponse | ||
{ | ||
public override Constants.Services.ServiceNames ServiceNames => Constants.Services.ServiceNames.SepaDirectDebit; | ||
/// <summary> | ||
/// The date the mandate has been registered | ||
/// </summary> | ||
public DateTime MandateDate { get; set; } | ||
/// <summary> | ||
/// The type of direct debit that will be processed. | ||
/// </summary> | ||
public string DirectDebitType { get; set; } | ||
/// <summary> | ||
/// The date the mandate has been registered. | ||
/// </summary> | ||
public DateTime CollectDate { get; set; } | ||
/// <summary> | ||
/// The mandate reference number. | ||
/// </summary> | ||
public string MandateReference { get; set; } | ||
/// <summary> | ||
/// The IBAN of the customers account. | ||
/// </summary> | ||
public string CustomerIban { get; set; } | ||
/// <summary> | ||
/// The BIC of the customers account. | ||
/// </summary> | ||
public string CustomerBic { get; set; } | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
BuckarooSdk/Services/SepaDirectDebit/SepaDirectDebitRefundRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace BuckarooSdk.Services.SepaDirectDebit | ||
{ | ||
public class SepaDirectDebitRefundRequest | ||
{ | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
BuckarooSdk/Services/SepaDirectDebit/SepaDirectDebitRefundResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace BuckarooSdk.Services.SepaDirectDebit | ||
{ | ||
public class SepaDirectDebitRefundResponse | ||
{ | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
BuckarooSdk/Services/SepaDirectDebit/SepaDirectDebitTransaction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using BuckarooSdk.Transaction; | ||
|
||
namespace BuckarooSdk.Services.SepaDirectDebit | ||
{ | ||
public class SepaDirectDebitTransaction | ||
{ | ||
/// <summary> | ||
/// The configured transaction | ||
/// </summary> | ||
private ConfiguredTransaction ConfiguredTransaction { get; set; } | ||
|
||
internal SepaDirectDebitTransaction(ConfiguredTransaction configuredTransaction) | ||
{ | ||
this.ConfiguredTransaction = configuredTransaction; | ||
} | ||
|
||
/// <summary> | ||
/// The pay function creates a configured transaction with an SepaDirectDebitPayRequest, | ||
/// that is ready to be executed. | ||
/// </summary> | ||
/// <param name="request">An SepaDirectDebitPayRequest</param> | ||
/// <returns></returns> | ||
public ConfiguredServiceTransaction Pay(SepaDirectDebitPayRequest request) | ||
{ | ||
var parameters = ServiceHelper.CreateServiceParameters(request); | ||
var configuredServiceTransaction = new ConfiguredServiceTransaction(this.ConfiguredTransaction.BaseTransaction); | ||
configuredServiceTransaction.BaseTransaction.AddService("SepaDirectDebit", parameters, "pay"); | ||
|
||
return configuredServiceTransaction; | ||
} | ||
/// <summary> | ||
/// The refund function creates a configured transaction with an SepaDirectDebitRefundRequest, | ||
/// that is ready to be executed. | ||
/// </summary> | ||
/// <param name="request">An SepaDirectDebitRefundRequest</param> | ||
/// <returns></returns> | ||
public ConfiguredServiceTransaction Refund(SepaDirectDebitRefundRequest request) | ||
{ | ||
var parameters = ServiceHelper.CreateServiceParameters(request); | ||
var configuredServiceTransaction = new ConfiguredServiceTransaction(this.ConfiguredTransaction.BaseTransaction); | ||
configuredServiceTransaction.BaseTransaction.AddService("SepaDirectDebit", parameters, "refund"); | ||
|
||
return configuredServiceTransaction; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters