Skip to content

Commit

Permalink
Merge pull request #81 from buckaroo-it/fix/PS2-1213
Browse files Browse the repository at this point in the history
PS2-1213: Fix missing part of SDD functionalities in SDK
  • Loading branch information
xhanan authored Jul 23, 2024
2 parents b72ce7a + e8f3653 commit 55846a8
Show file tree
Hide file tree
Showing 10 changed files with 419 additions and 0 deletions.
113 changes: 113 additions & 0 deletions BuckarooSdk.Tests/Services/SepaDirectDebit/SepaDirectDebitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,119 @@ public void RefundTest()

var response = request.Execute();
}

[TestMethod]
public void PayRecurrentTest()
{
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,
OriginalTransactionKey = ""
})
.SepaDirectDebit()
.PayRecurrent(new SepaDirectDebitPayRecurrentRequest()
{
CollectDate = "26-12-2023",
});

var paymentResponse = payment.Execute();
}

[TestMethod]
public void PayWithEMandateTest()
{
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()
.PayWithEMandate(new SepaDirectDebitPayWithEmandateRequest()
{
CollectDate = "26-12-2023",
MandateReference = "0Q2D284C4A887F84756A1425A369997xxxx",
});

var paymentResponse = payment.Execute();
}

[TestMethod]
public void AuthorizeTest()
{
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()
.Authorize(new SepaDirectDebitAuthorizeRequest()
{
CustomerAccountName = "Test de Tester",
CustomerIban = "NL29RABO8141336991",
CustomerBic = "ARBNNL22",
MandateReference = "001D284C4A887F84756A1425A369997xxxx",
MandateDate = "26-12-2023"
});

var paymentResponse = payment.Execute();
}

[TestMethod]
public void ExtraInfoTest()
{
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()
.PayExtraInfo(new SepaDirectDebitExtraInfoRequest()
{
CustomerAccountName = "John Smith",
CustomerIBAN = "NL13TEST0123456789",
CustomerBic = "TESTNL2A",
MandateReference = "02Q3D175524FCF94C94A23B67E8DCE48E43",
MandateDate = "26-12-2023",
CustomerCode = "test",
CustomerName = "John Smith",
CustomerReferencePartyCode = "",
CustomerReferencePartyName = "",
Street = "Hoofdstraat",
HouseNumber = "5",
HouseNumberSuffix = "",
ZipCode = "844ER",
City = "Utrecht",
Country = "NL",
ContractId = ""
});

var paymentResponse = payment.Execute();
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace BuckarooSdk.Services.SepaDirectDebit
{
public class SepaDirectDebitAuthorizeRequest
{
/// <summary>
/// The name of the accountholder for the account on which the direct debit should be performed.
/// </summary>
public string CustomerAccountName { get; set; }
/// <summary>
/// The IBAN for the customer bank account on which the direct debit will be performed.
/// </summary>
public string CustomerIban { get; set; }
/// <summary>
/// The BIC code for the customer bank account on which the direct debit will be performed.
/// </summary>
public string CustomerBic { get; set; }
/// <summary>
/// The mandate reference for the SEPA Direct Debit. It is possible to provide your own unique reference, or use the mandateID from an Emandate,
/// In any case, the MandateReference should always begin with a three digit prefix which can be found in the General Information on the Buckaroo
/// Plaza (My Buckaroo > General).
/// </summary>
public string MandateReference { get; set; }
/// <summary>
/// The signing date of the mandate (dd-mm-yyyy).
/// </summary>
public string MandateDate { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
namespace BuckarooSdk.Services.SepaDirectDebit
{
public class SepaDirectDebitAuthorizeResponse : ActionResponse
{
public override Constants.Services.ServiceNames ServiceNames => Constants.Services.ServiceNames.SepaDirectDebit;

/// <summary>
/// The BIC code for the customer bank account on which the direct debit will be performed.
/// </summary>
public string CustomerBic { get; set; }
/// <summary>
/// The BIC code for the customer bank account on which the direct debit will be performed.
/// </summary>
public string CustomerIban { get; set; }
/// <summary>
/// The mandate reference used for the direct debit.
/// </summary>
public string MandateReference { get; set; }
/// <summary>
/// The signing date of the mandate that was used.
/// </summary>
public string MandateDate { get; set; }
/// <summary>
/// The expected date on which the direct debit will be collected from the consumer account. This can differ from the input field collectdate,
/// due to a correction for the needed work days to process a direct debit.
/// </summary>
public string CollectDate { get; set; }
/// <summary>
/// Returns the type of direct debit that is going to be performed. Possible values: OnOff: A single directdebit.
/// First: The first of a recurrent sequence. Recurring: The next direct debit in a recurring sequence.
/// </summary>
public string DirectDebitType { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
namespace BuckarooSdk.Services.SepaDirectDebit
{
public class SepaDirectDebitExtraInfoRequest : SepaDirectDebitPayRequest
{
/// The customer ID, giving a unique ID to the customer for the merchant.
/// </summary>
public string CustomerCode { get; set; }
/// <summary>
/// The name of the customer.
/// </summary>
public string CustomerName { get; set; }
/// <summary>
/// The customer referenceparty ID, giving a unique ID to the customer reference party for the merchant.
/// </summary>
public string CustomerReferencePartyCode { get; set; }
/// <summary>
/// The name of the customer reference party. (The person on whose behalf the customer is making a payment)
/// </summary>
public string CustomerReferencePartyName { get; set; }
/// <summary>
/// The street name of the customer.
/// </summary>
public string Street { get; set; }
/// <summary>
/// The house number of the customer.
/// </summary>
public string HouseNumber { get; set; }
/// <summary>
/// The house number suffix of the customer.
/// </summary>
public string HouseNumberSuffix { get; set; }
/// <summary>
/// The zipcode of the customer.
/// </summary>
public string ZipCode { get; set; }
/// <summary>
/// The city of the customer.
/// </summary>
public string City { get; set; }
/// <summary>
/// The country of the customer.
/// </summary>
public string Country { get; set; }
/// <summary>
/// The contract identifier for which the payment is being done.
/// </summary>
public string ContractId { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
namespace BuckarooSdk.Services.SepaDirectDebit
{
public class SepaDirectDebitExtraInfoResponse : ActionResponse
{
public override Constants.Services.ServiceNames ServiceNames => Constants.Services.ServiceNames.SepaDirectDebit;

/// <summary>
/// The BIC code for the customer bank account on which the direct debit should be performed.
/// </summary>
public string CustomerBic { get; set; }
/// <summary>
/// The IBAN for the customer bank account on which the direct debit will be performed.
/// </summary>
public string CustomerIban { get; set; }
/// <summary>
/// The mandate reference used for the direct debit.
/// </summary>
public string MandateReference { get; set; }
/// <summary>
/// The signing date of the mandate that was used.
/// </summary>
public string MandateDate { get; set; }
/// <summary>
/// The expected date on which the direct debit will be collected from the consumer account. This can differ from the input field collectdate,
/// due to a correction for the needed work days to process a direct debit.
/// </summary>
public string CollectDate { get; set; }
/// <summary>
/// Returns the type of direct debit that is going to be performed. Possible values: OnOff: A single directdebit.
/// First: The first of a recurrent sequence. Recurring: The next direct debit in a recurring sequence.
/// </summary>
public string DirectDebitType { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace BuckarooSdk.Services.SepaDirectDebit
{
public class SepaDirectDebitPayRecurrentRequest
{
/// <summary>
/// The date (dd-mm-yyyy) on which the direct debit should be collected from the consumer account.
/// Important note: if combined with Credit Management, the collect date should always precede the due date of the invoice, since you don't want to trigger
/// a reminder step before debiting the customer. If however, the collect date is accidentally set after the due date, then the first reminder step will be postponed
/// till the collect date, but only if it's set within 14 days after the due date.
/// If it's set further than that, then our system will perform another check after 14 days and so on.
/// </summary>
public string CollectDate { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
namespace BuckarooSdk.Services.SepaDirectDebit
{
public class SepaDirectDebitPayRecurrentResponse : ActionResponse
{
public override Constants.Services.ServiceNames ServiceNames => Constants.Services.ServiceNames.SepaDirectDebit;

/// <summary>
/// The mandate reference used for the direct debit.
/// </summary>
public string MandateReference { get; set; }
/// <summary>
/// The signing date of the mandate that was used.
/// </summary>
public string MandateDate { get; set; }
/// <summary>
/// The IBAN for the customer bank account on which the direct debit will be performed.
/// </summary>
public string CustomerIBAN { get; set; }
/// <summary>
/// The BIC code for the customer bank account on which the direct debit should be performed.
/// </summary>
public string CustomerBIC { get; set; }
/// <summary>
/// The expected date on which the direct debit will be collected from the consumer account.
/// This can differ from the input field collectdate, due to a correction for the needed work days to process a direct debit.
/// </summary>
public string CollectDate { get; set; }
/// <summary>
/// Returns the type of direct debit that is going to be performed. Possible values: OnOff: A single directdebit. First: The first of a recurrent sequence.
/// Recurring: The next direct debit in a recurring sequence.
/// </summary>
public string DirectDebitType { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace BuckarooSdk.Services.SepaDirectDebit
{
public class SepaDirectDebitPayWithEmandateRequest
{
/// <summary>
/// This is the MandateID retrieved from a successful Emandate request.
/// </summary>
public string MandateReference { get; set; }
/// <summary>
/// The date (dd-mm-yyyy) on which the direct debit should be collected from the consumer account.
/// Important note: if combined with Credit Management, the collect date should always precede the due date of the invoice, since you don't want to trigger
/// a reminder step before debiting the customer. If however, the collect date is accidentally set after the due date, then the first reminder step will be
/// postponed till the collect date, but only if it's set within 14 days after the due date. If it's set further than that, then our system will perform another
/// check after 14 days and so on.
/// </summary>
public string CollectDate { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
namespace BuckarooSdk.Services.SepaDirectDebit
{
public class SepaDirectDebitPayWithEmandateResponse : ActionResponse
{
public override Constants.Services.ServiceNames ServiceNames => Constants.Services.ServiceNames.SepaDirectDebit;

/// <summary>
/// This is the MandateID from the Emandate.
/// </summary>
public string MandateReference { get; set; }
/// <summary>
/// The signing date of the mandate that was used.
/// </summary>
public string MandateDate { get; set; }
/// <summary>
/// The IBAN number of the customer bank account
/// </summary>
public string CustomerIBAN { get; set; }
/// <summary>
/// The BIC code for the customer bank account on which the direct debit will be performed.
/// </summary>
public string CustomerBIC { get; set; }
/// <summary>
/// The expected date on which the direct debit will be collected from the consumer account.
/// This can differ from the input field collectdate, due to a correction for the needed work days to process a direct debit.
/// </summary>
public string CollectDate { get; set; }
/// <summary>
/// Returns the type of direct debit that is going to be performed. Possible values: OnOff: A single directdebit. First: The first of a recurrent sequence.
/// Recurring: The next direct debit in a recurring sequence.
/// </summary>
public string DirectDebitType { get; set; }
}
}
Loading

0 comments on commit 55846a8

Please sign in to comment.