Skip to content

Commit

Permalink
checkout denied update
Browse files Browse the repository at this point in the history
  • Loading branch information
Omri Mosseri committed Jul 25, 2016
1 parent d582fdf commit 4682cad
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 17 deletions.
18 changes: 13 additions & 5 deletions Riskified.SDK.Sample/OrderTransmissionExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,20 @@ private static OrderCheckoutDenied GenerateOrderCheckoutDenied(int orderNum)
{
var authorizationError = new AuthorizationError(
createdAt: new DateTime(2013, 12, 8, 14, 12, 12, DateTimeKind.Local), // make sure to initialize DateTime with the correct timezone
errorCode: AuthorizationErrorCode.RiskSystemDeclined,
message: "Risk System Declined.");

var orderCheckoutDenied = new OrderCheckoutDenied(orderNum, authorizationError);

errorCode: AuthorizationErrorCode.CardDeclined,
message: "Card was Declined.");

var payments = new CreditCardPaymentDetails(
avsResultCode: "Y",
cvvResultCode: "n",
creditCardBin: "124580",
creditCardCompany: "Visa",
creditCardNumber: "XXXX-XXXX-XXXX-4242",
creditCardToken: "2233445566778899");
payments.AuthorizationError = authorizationError;

var orderCheckoutDenied = new OrderCheckoutDenied(orderNum.ToString());
orderCheckoutDenied.PaymentDetails = payments;

return orderCheckoutDenied;

Expand Down
23 changes: 15 additions & 8 deletions Riskified.SDK/Model/OrderCheckoutDenied.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,36 @@

namespace Riskified.SDK.Model
{
public class OrderCheckoutDenied : AbstractOrder
public class OrderCheckoutDenied : OrderBase
{
/// <summary>
/// Create a checkout denied
/// @Deprecated - Create a checkout denied (deprecated constructor, please use PaymentDetails.AuthorizationError)
/// </summary>
/// <param name="merchantOrderId">The unique id of the order at the merchant systems</param>
/// <param name="authorizationError">An object describing the failed result of an authorization attempt by a payment gateway</param>
public OrderCheckoutDenied(int merchantOrderId, AuthorizationError authorizationError)
public OrderCheckoutDenied(string merchantOrderId, AuthorizationError authorizationError)
: base(merchantOrderId)
{
this.AuthorizationError = authorizationError;
}

/// <summary>
/// Create a checkout denied
/// </summary>
/// <param name="merchantOrderId">The unique id of the order at the merchant systems</param>
public OrderCheckoutDenied(string merchantOrderId)
: base(merchantOrderId)
{
}

public override void Validate(Validations validationType = Validations.Weak)
{
base.Validate(validationType);

InputValidators.ValidateObjectNotNull(AuthorizationError, "Authorization Error");
AuthorizationError.Validate(validationType);


}

/// <summary>
/// @Deprecated property, please use PaymentDetails.AuthorizationError
/// </summary>
[JsonProperty(PropertyName = "authorization_error")]
public AuthorizationError AuthorizationError { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public AuthorizationError(DateTime createdAt, AuthorizationErrorCode errorCode,

public void Validate(Validations validationType = Validations.Weak)
{
InputValidators.ValidateDateNotDefault(CreatedAt.Value, "Created At");
InputValidators.ValidateObjectNotNull(ErrorCode, "Error Code");

}
Expand Down
4 changes: 4 additions & 0 deletions Riskified.SDK/Model/OrderElements/CreditCardPaymentDetails.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Newtonsoft.Json;
using Riskified.SDK.Exceptions;
using Riskified.SDK.Model.OrderCheckoutElements;
using Riskified.SDK.Utils;

namespace Riskified.SDK.Model.OrderElements
Expand Down Expand Up @@ -64,6 +65,9 @@ public void Validate(Validations validationType = Validations.Weak)

[JsonProperty(PropertyName = "credit_card_token")]
public string CreditCardToken { get; set; }

[JsonProperty(PropertyName = "authorization_error")]
public AuthorizationError AuthorizationError { get; set; }
}

}
5 changes: 4 additions & 1 deletion Riskified.SDK/Model/OrderElements/PaypalPaymentDetails.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Newtonsoft.Json;
using Riskified.SDK.Exceptions;
using Riskified.SDK.Model.OrderCheckoutElements;
using Riskified.SDK.Utils;

namespace Riskified.SDK.Model.OrderElements
Expand Down Expand Up @@ -62,6 +63,8 @@ public void Validate(Validations validationType = Validations.Weak)
[JsonProperty(PropertyName = "pending_reason")]
public string PendingReason { get; set; }


[JsonProperty(PropertyName = "authorization_error")]
public AuthorizationError AuthorizationError { get; set; }

}
}
4 changes: 2 additions & 2 deletions Riskified.SDK/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.5.5")]
[assembly: AssemblyFileVersion("2.0.5.5")]
[assembly: AssemblyVersion("2.0.6.0")]
[assembly: AssemblyFileVersion("2.0.6.0")]

0 comments on commit 4682cad

Please sign in to comment.