Skip to content

Commit

Permalink
Merge pull request #95 from Judopay/2.1
Browse files Browse the repository at this point in the history
2.1
  • Loading branch information
James-Lappin authored May 14, 2018
2 parents ce7a7de + bd74cf9 commit 9668dfc
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 40 deletions.
2 changes: 1 addition & 1 deletion JudoPayDotNet/Http/VersioningHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal class VersioningHandler : DelegatingHandler
{
public const string API_VERSION_HEADER = "api-version";

internal const string DEFAULT_API_VERSION = "5.4.0.0";
internal const string DEFAULT_API_VERSION = "5.5.0.0";

private readonly string _apiVersionValue;

Expand Down
11 changes: 7 additions & 4 deletions JudoPayDotNet/JudoPayDotNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@
</PropertyGroup>
<PropertyGroup Label="Package">
<PackageId>JudoPay.Net</PackageId>
<VersionPrefix>2.0.0</VersionPrefix>
<Version>2.0.0</Version>
<Version>2.1.0</Version>
<Authors>JudoPay</Authors>
<Description>A .Net client for our JudoPay API, allowing you to quickly and easily process payments</Description>
<Copyright>Copyright 2017</Copyright>
<Copyright>Copyright 2018</Copyright>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageLicenseUrl>http://opensource.org/licenses/MIT</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/JudoPay/DotNetSDK</PackageProjectUrl>
<PackageIconUrl>https://www.judopay.com/judo_nuget_icon.png</PackageIconUrl>
<RepositoryUrl>https://github.com/JudoPay/DotNetSDK</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>judo;judopaypayment;gateway;credit;cards;</PackageTags>
<PackageReleaseNotes>Updated to dotnet standard 2.0</PackageReleaseNotes>
<PackageReleaseNotes>
Added Risk information associated with the transaction.
Changed CardType to CardBrand and CardFunding.
Updated to dotnet standard 2.0.
</PackageReleaseNotes>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentValidation" Version="7.5.2" />
Expand Down
22 changes: 21 additions & 1 deletion JudoPayDotNet/Models/CardDetails.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Runtime.Serialization;
using System;
using System.Runtime.Serialization;

namespace JudoPayDotNet.Models
{
Expand Down Expand Up @@ -43,7 +44,26 @@ public class CardDetails
/// The type of the card.
/// </value>
[DataMember]
[Obsolete("Please use CardScheme and CardFunding instead")]
public CardType CardType { get; set; }

/// <summary>
/// Gets or sets the scheme of the card.
/// </summary>
/// <value>
/// Possible values are Visa, Mastercard etc
/// </value>
[DataMember]
public string CardScheme { get; set; }

/// <summary>
/// Gets or sets the funding type of the card.
/// </summary>
/// <value>
/// Possible values are Debit, Credit etc
/// </value>
[DataMember]
public string CardFunding { get; set; }
}
// ReSharper restore UnusedAutoPropertyAccessor.Global
}
12 changes: 8 additions & 4 deletions JudoPayDotNet/Models/PaymentReceiptModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,8 @@ public class PaymentReceiptModel : ITransactionResult
public Consumer Consumer { get; set; }

/// <summary>
/// Gets or sets the consumer.
/// Gets or sets the Device information.
/// </summary>
/// <value>
/// The consumer.
/// </value>
[DataMember]
public Device Device { get; set; }

Expand Down Expand Up @@ -229,7 +226,14 @@ public class PaymentReceiptModel : ITransactionResult

[DataMember(EmitDefaultValue = false)]
public bool? Recurring { get; set; }

/// <summary>
/// Information about the risks associated with the transaction
/// </summary>
[DataMember]
public RiskModel Risks { get; set; }
}

// ReSharper restore UnusedMember.Global
// ReSharper restore UnusedAutoPropertyAccessor.Global
}
26 changes: 26 additions & 0 deletions JudoPayDotNet/Models/RiskModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Runtime.Serialization;

namespace JudoPayDotNet.Models
{
[DataContract(Name = "Risks", Namespace = "")]
public class RiskModel
{
/// <summary>
/// The merchant suggestion from the amount of risk associated with the transaction
/// </summary>
/// <value>
/// Possible values include Allow, Block, Review
/// </value>
[DataMember]
public string MerchantSuggestion { get; set; }

/// <summary>
/// If AVS is submitted, this will contain the postcode check result
/// </summary>
/// <value>
/// Possible values include PASSED, NOTCHECKED and FAILED
/// </value>
[DataMember]
public string PostcodeCheck { get; set; }
}
}
85 changes: 56 additions & 29 deletions JudoPayDotNetIntegrationTests/PaymentTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,44 @@ namespace JudoPayDotNetIntegrationTests
public class PaymentTest : IntegrationTestsBase
{
[Test]
public void ASimplePayment()
public async Task ASimplePayment()
{
var paymentWithCard = GetCardPaymentModel();

var result = JudoPayApi.Payments.Create(paymentWithCard);
var response = result.Result;
var response = await JudoPayApi.Payments.Create(paymentWithCard);

Assert.IsNotNull(response);
Assert.IsFalse(response.HasError);
Assert.AreEqual("Success", response.Response.Result);

var receipt = response.Response as PaymentReceiptModel;
Assert.That(receipt, Is.Not.Null);
Assert.That(receipt.CardDetails, Is.Not.Null, "Missing carddetails property on receipt");
Assert.That(receipt.CardDetails.CardLastfour, Is.Not.Empty);
Assert.That(receipt.CardDetails.EndDate, Is.Not.Empty);
Assert.That(receipt.CardDetails.CardScheme, Is.EqualTo("Visa"));
Assert.That(receipt.CardDetails.CardFunding, Is.EqualTo("Debit"));
Assert.That(receipt.Message, Does.Match("AuthCode: \\d{6}"), $"Result message on receipt not in correct format AuthCode: xxxxxx. Was {receipt.Message}");
Assert.That(receipt.MerchantName, Is.Not.Empty);
Assert.That(receipt.AppearsOnStatementAs, Is.Not.Empty);
Assert.That(receipt.CreatedAt, Is.Not.Null);
Assert.That(receipt.NetAmount, Is.GreaterThan(0));
Assert.That(receipt.Amount, Is.GreaterThan(0));
Assert.That(receipt.Currency, Is.EqualTo("GBP"));

Assert.That(receipt.Risks.PostcodeCheck, Is.EqualTo("PASSED"));
Assert.That(receipt.Risks.MerchantSuggestion, Is.EqualTo("Allow"));
}

[Test]
[Ignore("Till recurring flag is exposed on partnerapi")]
public void ARecurringPayment()
public async Task ARecurringPayment()
{
var paymentWithCard = GetCardPaymentModel(recurringPayment: true, judoId: Configuration.Cybersource_Judoid);

var judoPay = UseCybersourceGateway();

var result = judoPay.Payments.Create(paymentWithCard);
var response = result.Result;
var response = await judoPay.Payments.Create(paymentWithCard);

Assert.IsNotNull(response);
Assert.IsFalse(response.HasError);
Expand All @@ -41,13 +57,12 @@ public void ARecurringPayment()
}

[Test]
public void ATokenPayment()
public async Task ATokenPayment()
{
var consumerReference = Guid.NewGuid().ToString();

var paymentWithCard = GetCardPaymentModel(consumerReference);

var response = JudoPayApi.Payments.Create(paymentWithCard).Result;
var response = await JudoPayApi.Payments.Create(paymentWithCard);

Assert.IsNotNull(response);
Assert.IsFalse(response.HasError);
Expand All @@ -62,29 +77,42 @@ public void ATokenPayment()
var cardToken = receipt.CardDetails.CardToken;

var paymentWithToken = GetTokenPaymentModel(cardToken, consumerReference, 26);

response = JudoPayApi.Payments.Create(paymentWithToken).Result;

paymentWithToken = GetTokenPaymentModel(cardToken, consumerReference, 27);

response = JudoPayApi.Payments.Create(paymentWithToken).Result;
response = await JudoPayApi.Payments.Create(paymentWithToken);

Assert.IsNotNull(response);
Assert.IsFalse(response.HasError);
Assert.AreEqual("Success", response.Response.Result);

var cardTokenReceipt = response.Response as PaymentReceiptModel;
Assert.That(cardTokenReceipt, Is.Not.Null);
Assert.That(cardTokenReceipt.CardDetails, Is.Not.Null, "Missing carddetails property on receipt");
Assert.That(cardTokenReceipt.CardDetails.CardLastfour, Is.Not.Empty);
Assert.That(cardTokenReceipt.CardDetails.EndDate, Is.Not.Empty);
Assert.That(cardTokenReceipt.CardDetails.CardScheme, Is.EqualTo("Visa"));
Assert.That(cardTokenReceipt.CardDetails.CardFunding, Is.EqualTo("Debit"));
Assert.That(cardTokenReceipt.Message, Does.Match("AuthCode: \\d{6}"), $"Result message on receipt not in correct format AuthCode: xxxxxx. Was {cardTokenReceipt.Message}");
Assert.That(cardTokenReceipt.MerchantName, Is.Not.Empty);
Assert.That(cardTokenReceipt.AppearsOnStatementAs, Is.Not.Empty);
Assert.That(cardTokenReceipt.CreatedAt, Is.Not.Null);
Assert.That(cardTokenReceipt.NetAmount, Is.GreaterThan(0));
Assert.That(cardTokenReceipt.Amount, Is.GreaterThan(0));
Assert.That(cardTokenReceipt.Currency, Is.EqualTo("GBP"));

Assert.That(receipt.Risks.PostcodeCheck, Is.EqualTo("PASSED"));
Assert.That(receipt.Risks.MerchantSuggestion, Is.EqualTo("Allow"));
}

[Test]
[Ignore("Till recurring flag is exposed on partnerapi")]
public void ATokenRecurringPayment()
public async Task ATokenRecurringPayment()
{
var consumerReference = Guid.NewGuid().ToString();

var paymentWithCard = GetCardPaymentModel(consumerReference, recurringPayment: true, judoId: Configuration.Cybersource_Judoid);

var judoPay = UseCybersourceGateway();

var response = judoPay.Payments.Create(paymentWithCard).Result;
var response = await judoPay.Payments.Create(paymentWithCard);

Assert.IsNotNull(response);
Assert.IsFalse(response.HasError);
Expand All @@ -100,11 +128,11 @@ public void ATokenRecurringPayment()
}

[Test]
public void AOneTimePayment()
public async Task AOneTimePayment()
{
var oneTimePaymentModel = GetOneTimePaymentModel().Result;

var response = JudoPayApi.Payments.Create(oneTimePaymentModel).Result;
var response = await JudoPayApi.Payments.Create(oneTimePaymentModel);

Assert.IsNotNull(response);
Assert.IsFalse(response.HasError);
Expand All @@ -116,39 +144,38 @@ public void AOneTimePayment()
}

[Test]
public void ADeclinedCardPayment()
public async Task ADeclinedCardPayment()
{
var paymentWithCard = GetCardPaymentModel("432438862", "4221690000004963", "125");

var response = JudoPayApi.Payments.Create(paymentWithCard).Result;
var response = await JudoPayApi.Payments.Create(paymentWithCard);

Assert.IsNotNull(response);
Assert.IsFalse(response.HasError);
Assert.AreEqual("Declined", response.Response.Result);
}

[Test]
public void DeDuplicationTest()
public async Task DeDuplicationTest()
{
var paymentWithCard = GetCardPaymentModel("432438862");

var response1 = JudoPayApi.Payments.Create(paymentWithCard).Result;
var response2 = JudoPayApi.Payments.Create(paymentWithCard).Result;
var response1 = await JudoPayApi.Payments.Create(paymentWithCard);

var response2 = await JudoPayApi.Payments.Create(paymentWithCard);

Assert.AreEqual(response1.Response.ReceiptId, response2.Response.ReceiptId);
}

[Test]
public void VisaCheckoutPayment()
public async Task VisaCheckoutPayment()
{
var callId = "2535293917395986901";
var encKey = "DL1znS1YD0D4L518up18ibGQK25jPiklD0k58PQQc775n/AOeBrXD292I1ywmXVjW10ngTGhuCW4ifEBfr1vxEe4vXHg7oXDY7+pO1tvNDV3G4Fkmy0Q3H8ieZ1RfD2y";
var encPaymentData = "EuWD12Sem0WTNRbIsCG6ATsABxssMvbPvFbR8SqK1Jj7YeU6a7s9Bs2Gk7I94E9p6ghEvl/wePm9nhamebj7vBzdLj/ezOqBgl41JUNq+uhRfS5zB9+7nAZkldwpT9TaLECbb+4JY1W9osUoZXL7XtnKz+OTeBG3apnjDomVf9kaNpbu0RkQFzclTyoeeODTDtpoZ+lqumR1E7yr/LsG5JtM+GvAdoULSgX3Xc4IaCRCWbGwKZaTm8PadXuyPiZXpcRCZd0I0KBDj8RGHW7wl3rPfpx4SxB4YMBieJNFbdj/AU2hWnU8fYEtgPaWKaA31a4csHFvQSBsmGAuJLEQ7CKb63k1EZV7rMJR/If/jNz17gtVHWjaEb/SNHybHe7MzDkmjhODfFR+ceaHb9b/NwD1X9QGBXSwrXwMZR06vdyao//T44NbhhfPngGORSz47sHx2o40ECIfo5HGB/BbZO48Sl61pNKommEjEj0JabbzOqNEdA7IJkf1I1eO0bPTW41Vd84Fgofe2aKy2987lPhMnJdHFaslo6DS8cclF7LySQWYjOZNSL+0tW9hLLV1DO1H0xvYA7CsvHyutyDxTVtiOkl5+MKeAzRsaWQTC4sbxrgWZjYbxGCeWOWED+xQRSeJmY1J4hpUjB7jwGymekBXVfiHvwM9sAgZ2+EU95j6kRYciKhLOMgYH68wRJqHR4wR4rjxiHrjwZARqnG/5vwYZ9qvJxyKUkE+lcMNLK8x18tT4N1nm2oPW08GnbkRXmr2SFnv3RwuxbIOyaKIJrNjeQ0ybG4+taQcd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= GetVisaCheckoutPaymentModel(callId, encKey, encPaymentData);

var result = JudoPayApi.Payments.Create(paymentWithCard);
var response = result.Result;
var response = await JudoPayApi.Payments.Create(paymentWithCard);

Assert.IsNotNull(response);
Assert.IsFalse(response.HasError);
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 2.0.{build}
version: 2.1.{build}
image: Visual Studio 2017
skip_branch_with_pr: true
# if wanting to publish the package internally
Expand Down

0 comments on commit 9668dfc

Please sign in to comment.