From 52f88e47fc11db08a4ed4b45aa75e357a56b2f49 Mon Sep 17 00:00:00 2001 From: Ricardo Carneiro Date: Wed, 15 Jul 2020 17:16:32 +0100 Subject: [PATCH 1/2] Add BatchNumber property to Transaction --- .../Entities/Transaction.cs | 112 ++++++++++++------ 1 file changed, 78 insertions(+), 34 deletions(-) diff --git a/src/GlobalPayments.Api/Entities/Transaction.cs b/src/GlobalPayments.Api/Entities/Transaction.cs index dd0f9124..4ed523cc 100644 --- a/src/GlobalPayments.Api/Entities/Transaction.cs +++ b/src/GlobalPayments.Api/Entities/Transaction.cs @@ -3,11 +3,13 @@ using GlobalPayments.Api.Builders; using GlobalPayments.Api.PaymentMethods; -namespace GlobalPayments.Api.Entities { +namespace GlobalPayments.Api.Entities +{ /// /// Transaction response. /// - public class Transaction { + public class Transaction + { /// /// The authorized amount. /// @@ -17,13 +19,16 @@ public class Transaction { /// /// The authorization code provided by the issuer. /// - public string AuthorizationCode { - get { + public string AuthorizationCode + { + get + { if (TransactionReference != null) return TransactionReference.AuthCode; return null; } - set { + set + { if (TransactionReference == null) TransactionReference = new TransactionReference(); TransactionReference.AuthCode = value; @@ -75,13 +80,16 @@ public string AuthorizationCode { /// /// The client transaction ID supplied in the request. /// - public string ClientTransactionId { - get { + public string ClientTransactionId + { + get + { if (TransactionReference != null) return TransactionReference.ClientTransactionId; return null; } - set { + set + { if (TransactionReference == null) TransactionReference = new TransactionReference(); TransactionReference.ClientTransactionId = value; @@ -129,13 +137,16 @@ public string ClientTransactionId { /// /// The order ID supplied in the request. /// - public string OrderId { - get { + public string OrderId + { + get + { if (TransactionReference != null) return TransactionReference.OrderId; return null; } - set { + set + { if (TransactionReference == null) TransactionReference = new TransactionReference(); TransactionReference.OrderId = value; @@ -145,13 +156,16 @@ public string OrderId { /// /// The type of payment made in the request. /// - public PaymentMethodType PaymentMethodType { - get { + public PaymentMethodType PaymentMethodType + { + get + { if (TransactionReference != null) return TransactionReference.PaymentMethodType; return PaymentMethodType.Credit; } - set { + set + { if (TransactionReference == null) TransactionReference = new TransactionReference(); TransactionReference.PaymentMethodType = value; @@ -205,19 +219,33 @@ public PaymentMethodType PaymentMethodType { /// /// The gateway transaction ID of the transaction. /// - public string TransactionId { - get { + public string TransactionId + { + get + { if (TransactionReference != null) return TransactionReference.TransactionId; return null; } - set { + set + { if (TransactionReference == null) TransactionReference = new TransactionReference(); TransactionReference.TransactionId = value; } } + public string BatchNumber + { + get => TransactionReference?.BatchNumber; + set + { + if (TransactionReference == null) + TransactionReference = new TransactionReference(); + TransactionReference.BatchNumber = value; + } + } + /// /// The payment token returned in the transaction. /// @@ -238,9 +266,12 @@ public string TransactionId { /// /// The original payment method type. Defaults to `PaymentMethodType.Credit`. /// - public static Transaction FromId(string transactionId, PaymentMethodType paymentMethodType = PaymentMethodType.Credit) { - return new Transaction { - TransactionReference = new TransactionReference { + public static Transaction FromId(string transactionId, PaymentMethodType paymentMethodType = PaymentMethodType.Credit) + { + return new Transaction + { + TransactionReference = new TransactionReference + { TransactionId = transactionId, PaymentMethodType = paymentMethodType } @@ -255,13 +286,16 @@ public static Transaction FromId(string transactionId, PaymentMethodType payment /// at a later date/time. /// /// The original transaction ID - /// The original transaction's order ID + /// The original transaction's order ID /// /// The original payment method type. Defaults to `PaymentMethodType.Credit`. /// - public static Transaction FromId(string transactionId, string orderId, PaymentMethodType paymentMethodType = PaymentMethodType.Credit) { - return new Transaction { - TransactionReference = new TransactionReference { + public static Transaction FromId(string transactionId, string orderId, PaymentMethodType paymentMethodType = PaymentMethodType.Credit) + { + return new Transaction + { + TransactionReference = new TransactionReference + { TransactionId = transactionId, PaymentMethodType = paymentMethodType, OrderId = orderId @@ -273,7 +307,8 @@ public static Transaction FromId(string transactionId, string orderId, PaymentMe /// Creates an additional authorization against the original transaction. /// /// The additional amount to authorize - public ManagementBuilder AdditionalAuth(decimal? amount = null) { + public ManagementBuilder AdditionalAuth(decimal? amount = null) + { return new ManagementBuilder(TransactionType.Auth) .WithPaymentMethod(TransactionReference) .WithAmount(amount); @@ -283,12 +318,14 @@ public ManagementBuilder AdditionalAuth(decimal? amount = null) { /// Captures the original transaction. /// /// The amount to capture - public ManagementBuilder Capture(decimal? amount = null) { + public ManagementBuilder Capture(decimal? amount = null) + { var builder = new ManagementBuilder(TransactionType.Capture) .WithPaymentMethod(TransactionReference) .WithAmount(amount); - if (MultiCapture) { + if (MultiCapture) + { builder.WithMultiCapture(MultiCaptureSequence.Value, MultiCapturePaymentCount.Value); } return builder; @@ -297,14 +334,16 @@ public ManagementBuilder Capture(decimal? amount = null) { /// /// Edits the original transaction. /// - public ManagementBuilder Edit() { + public ManagementBuilder Edit() + { return new ManagementBuilder(TransactionType.Edit).WithPaymentMethod(TransactionReference); } /// /// Places the original transaction on hold. /// - public ManagementBuilder Hold() { + public ManagementBuilder Hold() + { return new ManagementBuilder(TransactionType.Hold).WithPaymentMethod(TransactionReference); } @@ -312,7 +351,8 @@ public ManagementBuilder Hold() { /// Refunds/returns the original transaction. /// /// The amount to refund/return - public ManagementBuilder Refund(decimal? amount = null) { + public ManagementBuilder Refund(decimal? amount = null) + { return new ManagementBuilder(TransactionType.Refund) .WithPaymentMethod(TransactionReference) .WithAmount(amount); @@ -321,7 +361,8 @@ public ManagementBuilder Refund(decimal? amount = null) { /// /// Releases the original transaction from a hold. /// - public ManagementBuilder Release() { + public ManagementBuilder Release() + { return new ManagementBuilder(TransactionType.Release).WithPaymentMethod(TransactionReference); } @@ -329,7 +370,8 @@ public ManagementBuilder Release() { /// Reverses the original transaction. /// /// The original authorization amount - public ManagementBuilder Reverse(decimal? amount = null) { + public ManagementBuilder Reverse(decimal? amount = null) + { return new ManagementBuilder(TransactionType.Reversal) .WithPaymentMethod(TransactionReference) .WithAmount(amount); @@ -338,13 +380,15 @@ public ManagementBuilder Reverse(decimal? amount = null) { /// /// Voids the original transaction. /// - public ManagementBuilder Void(VoidReason? reason = null) { + public ManagementBuilder Void(VoidReason? reason = null) + { return new ManagementBuilder(TransactionType.Void) .WithPaymentMethod(TransactionReference) .WithVoidReason(reason); } - public ManagementBuilder Increment(decimal? amount = null) { + public ManagementBuilder Increment(decimal? amount = null) + { return new ManagementBuilder(TransactionType.Increment).WithAmount(amount).WithPaymentMethod(TransactionReference); } } From 8cccf4a43393598174fb3692302560db1c892baa Mon Sep 17 00:00:00 2001 From: Ricardo Carneiro Date: Fri, 18 Sep 2020 21:00:47 -0500 Subject: [PATCH 2/2] Add property BatchNumber to Transaction --- src/GlobalPayments.Api/Entities/Transaction.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/GlobalPayments.Api/Entities/Transaction.cs b/src/GlobalPayments.Api/Entities/Transaction.cs index eb629934..579ccf9f 100644 --- a/src/GlobalPayments.Api/Entities/Transaction.cs +++ b/src/GlobalPayments.Api/Entities/Transaction.cs @@ -302,6 +302,17 @@ public string ProcessingCode { } } + public string BatchNumber + { + get => TransactionReference?.BatchNumber; + set + { + if (TransactionReference == null) + TransactionReference = new TransactionReference(); + TransactionReference.BatchNumber = value; + } + } + /// /// The payment token returned in the transaction. ///