diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5760e45..0a7b7b9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,9 @@
All notable changes to this project will be documented in this file.
## 2.2 Changes on 2020-12-01
+#### Added
+- InitialRecurringPayment, RecurringPaymentType and RelatedReceiptId added to PaymentModel
+- Increase Api-Version from 5.6 to 5.7
#### Removed
- VisaCheckout APIs
diff --git a/JudoPayDotNet.sln b/JudoPayDotNet.sln
index 9cad16d..9e3decf 100644
--- a/JudoPayDotNet.sln
+++ b/JudoPayDotNet.sln
@@ -14,6 +14,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionIt
appveyor.yml = appveyor.yml
CHANGELOG.md = CHANGELOG.md
Deploy.md = Deploy.md
+ Readme.md = Readme.md
EndProjectSection
EndProject
Global
diff --git a/JudoPayDotNet/Enums/RecurringPaymentType.cs b/JudoPayDotNet/Enums/RecurringPaymentType.cs
new file mode 100644
index 0000000..1ff9426
--- /dev/null
+++ b/JudoPayDotNet/Enums/RecurringPaymentType.cs
@@ -0,0 +1,20 @@
+namespace JudoPayDotNet.Enums
+{
+ public enum RecurringPaymentType : long
+ {
+ [LocalizedDescription("Unknown")]
+ Unknown = 0,
+
+ ///
+ /// Scheduled regular payment
+ ///
+ [LocalizedDescription("RECURRING ")]
+ Recurring = 1,
+
+ ///
+ /// Unscheduled regular payment
+ ///
+ [LocalizedDescription("MIT")]
+ Mit = 2
+ }
+}
\ No newline at end of file
diff --git a/JudoPayDotNet/Http/VersioningHandler.cs b/JudoPayDotNet/Http/VersioningHandler.cs
index 60d8ad5..5ae3033 100644
--- a/JudoPayDotNet/Http/VersioningHandler.cs
+++ b/JudoPayDotNet/Http/VersioningHandler.cs
@@ -13,7 +13,7 @@ internal class VersioningHandler : DelegatingHandler
{
public const string API_VERSION_HEADER = "api-version";
- internal const string DEFAULT_API_VERSION = "5.6.0.0";
+ internal const string DEFAULT_API_VERSION = "5.7.0.0";
private readonly string _apiVersionValue;
diff --git a/JudoPayDotNet/Models/PaymentModel.cs b/JudoPayDotNet/Models/PaymentModel.cs
index 00367cd..ef58d64 100644
--- a/JudoPayDotNet/Models/PaymentModel.cs
+++ b/JudoPayDotNet/Models/PaymentModel.cs
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
-using JudoPayDotNet.Clients;
+using JudoPayDotNet.Enums;
using Newtonsoft.Json.Linq;
namespace JudoPayDotNet.Models
@@ -183,6 +183,16 @@ protected PaymentModel()
public string AcceptHeaders { get; set; }
// ReSharper restore UnusedAutoPropertyAccessor.Global
+ ///
+ /// Is this transaction the first transaction of a series (has continuous authority
+ /// been granted to the merchant by the card holder).
+ ///
+ /// Mastercard requires that when dealing with continuous authority
+ /// payments this flag identifies the transaction where the card holder gave permission for
+ /// repeat charges.
+ [DataMember(EmitDefaultValue = false)]
+ public bool? InitialRecurringPayment { get; set; }
+
///
/// Indicates that the transaction has been given recurring authorization from the consumer
///
@@ -195,6 +205,18 @@ protected PaymentModel()
[DataMember(EmitDefaultValue = false)]
public string DynamicDescriptor { get; set; }
+ ///
+ /// Enum for Regular Payments (recurring)
+ ///
+ [DataMember(EmitDefaultValue = false)]
+ public RecurringPaymentType? RecurringPaymentType { get; set; }
+
+ ///
+ /// Receipt ID of original authenticated transaction (for recurring payments)
+ ///
+ [DataMember(EmitDefaultValue = false)]
+ public string RelatedReceiptId { get; set; }
+
///
/// Allows you to set HTTP headers on requests
///
diff --git a/JudoPayDotNetIntegrationTests/IntegrationTestsBase.cs b/JudoPayDotNetIntegrationTests/IntegrationTestsBase.cs
index 1ce127c..4f26094 100644
--- a/JudoPayDotNetIntegrationTests/IntegrationTestsBase.cs
+++ b/JudoPayDotNetIntegrationTests/IntegrationTestsBase.cs
@@ -2,11 +2,10 @@
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
-using System.Net.Http.Headers;
-using System.Runtime.Versioning;
using System.Text;
using System.Threading.Tasks;
using JudoPayDotNet;
+using JudoPayDotNet.Enums;
using JudoPayDotNet.Http;
using JudoPayDotNet.Models;
using Newtonsoft.Json;
@@ -29,11 +28,15 @@ protected IntegrationTestsBase()
}
protected CardPaymentModel GetCardPaymentModel(
- string yourConsumerReference = null,
- string cardNumber = "4976000000003436",
- string cv2 = "452",
- string postCode = "TR14 8PA",
- bool? recurringPayment = null,
+ string yourConsumerReference = null,
+ string cardNumber = "4976000000003436",
+ string cv2 = "452",
+ string postCode = "TR14 8PA",
+ bool? initialRecurringPayment = null,
+ bool? recurringPayment = null,
+ string relatedReceiptId = null,
+ RecurringPaymentType? recurringPaymentType = null,
+
string judoId = null)
{
if (string.IsNullOrEmpty(yourConsumerReference))
@@ -41,7 +44,7 @@ protected CardPaymentModel GetCardPaymentModel(
yourConsumerReference = Guid.NewGuid().ToString();
}
- return new CardPaymentModel
+ var ret = new CardPaymentModel
{
JudoId = judoId ?? Configuration.Judoid,
YourConsumerReference = yourConsumerReference,
@@ -54,9 +57,25 @@ protected CardPaymentModel GetCardPaymentModel(
Line1 = "32 Edward Street",
PostCode = postCode,
Town = "Camborne"
- },
- RecurringPayment = recurringPayment
+ }
};
+ if (initialRecurringPayment != null)
+ {
+ ret.InitialRecurringPayment = initialRecurringPayment;
+ }
+ if (recurringPayment != null)
+ {
+ ret.RecurringPayment = recurringPayment;
+ }
+ if (relatedReceiptId != null)
+ {
+ ret.RelatedReceiptId = relatedReceiptId;
+ }
+ if (recurringPaymentType != null)
+ {
+ ret.RecurringPaymentType = recurringPaymentType;
+ }
+ return ret;
}
protected TokenPaymentModel GetTokenPaymentModel(
@@ -302,7 +321,7 @@ protected WebPaymentRequestModel GetWebPaymentRequestModel()
ClientIpAddress = "127.0.0.1",
CompanyName = "Test",
Currency = "GBP",
- ExpiryDate = DateTimeOffset.Now,
+ ExpiryDate = DateTimeOffset.Now.AddMinutes(30),
JudoId = Configuration.Judoid,
PartnerServiceFee = 10,
PaymentCancelUrl = "http://test.com",
diff --git a/JudoPayDotNetIntegrationTests/PaymentTest.cs b/JudoPayDotNetIntegrationTests/PaymentTest.cs
index bfc497a..7e6dbca 100644
--- a/JudoPayDotNetIntegrationTests/PaymentTest.cs
+++ b/JudoPayDotNetIntegrationTests/PaymentTest.cs
@@ -1,5 +1,6 @@
using System;
using System.Threading.Tasks;
+using JudoPayDotNet.Enums;
using JudoPayDotNet.Models;
using NUnit.Framework;
@@ -44,17 +45,59 @@ public async Task ASimplePayment()
[Test]
public async Task ARecurringPayment()
{
- var paymentWithCard = GetCardPaymentModel(recurringPayment: true, judoId: Configuration.Cybersource_Judoid);
+ var initialPaymentWithCard = GetCardPaymentModel(initialRecurringPayment: true, judoId: Configuration.Cybersource_Judoid);
- var response = await JudoPayApiCyberSource.Payments.Create(paymentWithCard);
+ var initialResponse = await JudoPayApiCyberSource.Payments.Create(initialPaymentWithCard);
- Assert.IsNotNull(response);
- Assert.IsFalse(response.HasError);
- Assert.AreEqual("Success", response.Response.Result);
+ Assert.IsNotNull(initialResponse);
+ Assert.IsFalse(initialResponse.HasError);
+ Assert.AreEqual("Success", initialResponse.Response.Result);
- var paymentReceipt = response.Response as PaymentReceiptModel;
- Assert.IsNotNull(paymentReceipt);
- Assert.IsTrue(paymentReceipt.Recurring);
+ var initialPaymentReceipt = initialResponse.Response as PaymentReceiptModel;
+ Assert.IsNotNull(initialPaymentReceipt);
+ Assert.IsNull(initialPaymentReceipt.Recurring);
+
+ var recurringPaymentWithCard = GetCardPaymentModel(initialRecurringPayment: false, recurringPayment: true,
+ recurringPaymentType: RecurringPaymentType.Recurring, relatedReceiptId: "" + initialPaymentReceipt.ReceiptId,
+ judoId: Configuration.Cybersource_Judoid);
+
+ var recurringResponse = await JudoPayApiCyberSource.Payments.Create(recurringPaymentWithCard);
+ Assert.IsNotNull(recurringResponse);
+ Assert.IsFalse(recurringResponse.HasError);
+ Assert.AreEqual("Success", recurringResponse.Response.Result);
+
+ var recurringPaymentReceipt = recurringResponse.Response as PaymentReceiptModel;
+ Assert.IsNotNull(recurringPaymentReceipt);
+ Assert.IsTrue(recurringPaymentReceipt.Recurring);
+ }
+
+ [Test]
+ public async Task AnMitPayment()
+ {
+ var initialPaymentWithCard = GetCardPaymentModel(initialRecurringPayment: true, judoId: Configuration.Cybersource_Judoid);
+
+ var initialResponse = await JudoPayApiCyberSource.Payments.Create(initialPaymentWithCard);
+
+ Assert.IsNotNull(initialResponse);
+ Assert.IsFalse(initialResponse.HasError);
+ Assert.AreEqual("Success", initialResponse.Response.Result);
+
+ var initialPaymentReceipt = initialResponse.Response as PaymentReceiptModel;
+ Assert.IsNotNull(initialPaymentReceipt);
+ Assert.IsNull(initialPaymentReceipt.Recurring);
+
+ var mitPaymentWithCard = GetCardPaymentModel(initialRecurringPayment: false, recurringPayment: true,
+ recurringPaymentType: RecurringPaymentType.Mit, relatedReceiptId: "" + initialPaymentReceipt.ReceiptId,
+ judoId: Configuration.Cybersource_Judoid);
+
+ var mitResponse = await JudoPayApiCyberSource.Payments.Create(mitPaymentWithCard);
+ Assert.IsNotNull(mitResponse);
+ Assert.IsFalse(mitResponse.HasError);
+ Assert.AreEqual("Success", mitResponse.Response.Result);
+
+ var mitPaymentReceipt = mitResponse.Response as PaymentReceiptModel;
+ Assert.IsNotNull(mitPaymentReceipt);
+ Assert.IsTrue(mitPaymentReceipt.Recurring);
}
[Test]
diff --git a/Readme.md b/Readme.md
index 376f34b..5030045 100644
--- a/Readme.md
+++ b/Readme.md
@@ -23,7 +23,7 @@ Install-Package JudoPay.Net
You configure you Judopay API client when invoking the JudoPaymentsFactory.Create method. This has
three parameters; environment (Sandbox for development and testing, and Live for production), and api
token and secret. You set you API token and secret up through our [management dashboard](https://portal.judopay.com)
-after creating an account. You can create a testing account by clicking "Getting Started" in our [documentation](https://www.judopay.com/docs)
+after creating an account. You can create a testing account from [Apply for a Sandbox Account](https://www.judopay.com/apply-sandbox-account)
```c#
var client = JudoPaymentsFactory.Create(JudoPayDotNet.Enums.JudoEnvironment.Sandbox, "", "");
@@ -43,10 +43,10 @@ var cardPaymentModel = new CardPaymentModel
// card details
CardNumber = "4976000000000036",
- ExpiryDate = "1215",
+ ExpiryDate = "12/25",
CV2 = "452",
- // an identifier for your customer
+ // a unique identifier for your customer
YourConsumerReference = "MyCustomer004",
};
```
@@ -60,7 +60,7 @@ client.Payments.Create(cardPaymentModel).ContinueWith(result =>
if (!paymentResult.HasError && paymentResult.Response.Result == "Success")
{
- Console.WriteLine("Payment successful. Transaction Reference {0}", paymentResult.Response.ReceiptId);
+ Console.WriteLine($"Payment successful. Transaction Receipt ID {paymentResult.Response.ReceiptId}");
}
});