Skip to content

Commit 6d084d9

Browse files
BPP-360 : Afterpay refund RefundType (#42)
* Added RefundType parameter to Afterpay refund * Added refund tests for types Undefined, Return and Refund * RefundType on article
1 parent 8eb21e8 commit 6d084d9

4 files changed

Lines changed: 70 additions & 11 deletions

File tree

BuckarooSdk.Tests/Mocks/Afterpay.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,13 @@ internal class Afterpay
149149

150150
};
151151

152-
internal static AfterpayRefundRequest AfterpayRefundMock => new AfterpayRefundRequest()
152+
internal static AfterpayRefundRequest AfterpayRefundMock(string refundType) => new AfterpayRefundRequest()
153153
{
154-
Articles = new BuckarooSdk.Services.ParameterGroupCollection<Article>("Article")
154+
Articles = new BuckarooSdk.Services.ParameterGroupCollection<Article>("Article")
155155
{
156156
new Article()
157157
{
158+
RefundType = refundType,
158159
Description = "Blue Toy Car",
159160
GrossUnitPrice = "10.00",
160161
VatPercentage = "21",

BuckarooSdk.Tests/Services/Afterpay/AfterpayTests.cs

Lines changed: 65 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
using BuckarooSdk.DataTypes.RequestBases;
22
using BuckarooSdk.Logging;
3-
using BuckarooSdk.Tests.Constants;
3+
using BuckarooSdk.Services.Afterpay;
44
using Microsoft.VisualStudio.TestTools.UnitTesting;
55
using System;
6-
using System.Diagnostics;
76
using System.Globalization;
8-
using BuckarooSdk.Services.Afterpay;
9-
using BuckarooSdk.DataTypes.ParameterGroups.Afterpay;
7+
using BuckarooSdk.Tests.Constants;
108

119
namespace BuckarooSdk.Tests.Services.Afterpay
1210
{
@@ -53,6 +51,7 @@ public void CancelAuthorizeTest()
5351
// Process.Start(response.RequiredAction.RedirectURL);
5452
// Console.WriteLine(response.BuckarooSdkLogger.GetFullLog());
5553
}
54+
5655
[TestMethod]
5756
public void PayTest()
5857
{
@@ -81,8 +80,9 @@ public void PayTest()
8180
// Process.Start(response.RequiredAction.RedirectURL);
8281
// Console.WriteLine(response.BuckarooSdkLogger.GetFullLog());
8382
}
83+
8484
[TestMethod]
85-
public void RefundTest()
85+
public void RefundUndefinedTest()
8686
{
8787
var request =
8888
this._buckarooClient.CreateRequest(new StandardLogger()) // Create a request.
@@ -102,13 +102,72 @@ public void RefundTest()
102102
Order = $"SDK_{ TestName }_{ DateTime.Now.Ticks }",
103103
})
104104
.Afterpay() // Choose the paymentmethod you want to use
105-
.Refund(Mocks.Afterpay.AfterpayRefundMock); // choose the action you want to use and provide the payment method specific info.
105+
.Refund(Mocks.Afterpay.AfterpayRefundMock("Undefined")); // choose the action you want to use and provide the payment method specific info.
106106

107107
var response = request.Execute();
108108

109109
// Process.Start(response.RequiredAction.RedirectURL);
110110
// Console.WriteLine(response.BuckarooSdkLogger.GetFullLog());
111111
}
112+
113+
[TestMethod]
114+
public void RefundReturnTest()
115+
{
116+
var request =
117+
this._buckarooClient.CreateRequest(new StandardLogger()) // Create a request.
118+
.Authenticate(TestSettings.WebsiteKey, TestSettings.SecretKey, false, new CultureInfo("nl-NL"))
119+
.TransactionRequest() // One of the request type options.
120+
.SetBasicFields(new TransactionBase // The transactionbase contains the base information of a transaction.
121+
{
122+
Currency = "EUR",
123+
Description = $"SDK_{ TestName }_{ DateTime.Now.Ticks }",
124+
ReturnUrl = TestSettings.ReturnUrl,
125+
ReturnUrlCancel = TestSettings.ReturnUrlCancel,
126+
ReturnUrlError = TestSettings.ReturnUrlError,
127+
ReturnUrlReject = TestSettings.ReturnUrlReject,
128+
Invoice = $"SDK_{ TestName }_{ DateTime.Now.Ticks }",
129+
OriginalTransactionKey = "",
130+
AmountCredit = 2,
131+
Order = $"SDK_{ TestName }_{ DateTime.Now.Ticks }",
132+
})
133+
.Afterpay() // Choose the paymentmethod you want to use
134+
.Refund(Mocks.Afterpay.AfterpayRefundMock("Return")); // choose the action you want to use and provide the payment method specific info.
135+
136+
var response = request.Execute();
137+
138+
// Process.Start(response.RequiredAction.RedirectURL);
139+
// Console.WriteLine(response.BuckarooSdkLogger.GetFullLog());
140+
}
141+
142+
[TestMethod]
143+
public void RefundTest()
144+
{
145+
var request =
146+
this._buckarooClient.CreateRequest(new StandardLogger()) // Create a request.
147+
.Authenticate(TestSettings.WebsiteKey, TestSettings.SecretKey, false, new CultureInfo("nl-NL"))
148+
.TransactionRequest() // One of the request type options.
149+
.SetBasicFields(new TransactionBase // The transactionbase contains the base information of a transaction.
150+
{
151+
Currency = "EUR",
152+
Description = $"SDK_{ TestName }_{ DateTime.Now.Ticks }",
153+
ReturnUrl = TestSettings.ReturnUrl,
154+
ReturnUrlCancel = TestSettings.ReturnUrlCancel,
155+
ReturnUrlError = TestSettings.ReturnUrlError,
156+
ReturnUrlReject = TestSettings.ReturnUrlReject,
157+
Invoice = $"SDK_{ TestName }_{ DateTime.Now.Ticks }",
158+
OriginalTransactionKey = "",
159+
AmountCredit = 2,
160+
Order = $"SDK_{ TestName }_{ DateTime.Now.Ticks }",
161+
})
162+
.Afterpay() // Choose the paymentmethod you want to use
163+
.Refund(Mocks.Afterpay.AfterpayRefundMock("Refund")); // choose the action you want to use and provide the payment method specific info.
164+
165+
var response = request.Execute();
166+
167+
// Process.Start(response.RequiredAction.RedirectURL);
168+
// Console.WriteLine(response.BuckarooSdkLogger.GetFullLog());
169+
}
170+
112171
[TestMethod]
113172
public void AuthorizeTest()
114173
{

BuckarooSdk/DataTypes/ParameterGroups/Afterpay/Article.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ public class Article : ParameterGroup
1616
/// </summary>
1717
public string Type { get; set; }
1818
public string UnitCode { get; set; }
19+
public string RefundType { get; set; }
1920
}
2021
}

BuckarooSdk/Services/Afterpay/AfterpayRefundRequest.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,5 @@ namespace BuckarooSdk.Services.Afterpay
55
public class AfterpayRefundRequest
66
{
77
public ParameterGroupCollection<Article> Articles { get; set; }
8-
9-
10-
}
8+
}
119
}

0 commit comments

Comments
 (0)