|
| 1 | +namespace Axepta.SDK; |
| 2 | + |
| 3 | +/// <summary> |
| 4 | +/// Represents a payment transaction, encapsulating details such as service ID, amount, currency, |
| 5 | +/// order information, customer details, and redirection URLs for successful, failed, or general outcomes. |
| 6 | +/// This record focuses on capturing essential information required to generate a payment link. |
| 7 | +/// </summary> |
| 8 | +public sealed record GeneratePaymentLink |
| 9 | +{ |
| 10 | + private int _amount; |
| 11 | + |
| 12 | + /// <summary> |
| 13 | + /// Gets or sets the service ID associated with the payment. This is a unique identifier for the service involved in the payment. |
| 14 | + /// </summary> |
| 15 | + [JsonPropertyName("serviceId")] |
| 16 | + public string? ServiceId { get; private set; } |
| 17 | + |
| 18 | + /// <summary> |
| 19 | + /// Gets or sets the payment amount. The setter converts the input amount from a major currency unit (e.g., dollars) to a minor unit (e.g., cents). |
| 20 | + /// </summary> |
| 21 | + [JsonPropertyName("amount")] |
| 22 | + public required int Amount |
| 23 | + { |
| 24 | + get => _amount; |
| 25 | + set => _amount = value * 100; |
| 26 | + } |
| 27 | + |
| 28 | + /// <summary> |
| 29 | + /// Gets or sets the currency code for the payment, following the ISO 4217 standard. |
| 30 | + /// </summary> |
| 31 | + [StringLength(3)] |
| 32 | + [JsonPropertyName("currency")] |
| 33 | + public required Currency Currency { get; init; } |
| 34 | + |
| 35 | + /// <summary> |
| 36 | + /// Gets or sets the unique identifier for the payment order, which can be used for tracking and referencing the transaction. |
| 37 | + /// </summary> |
| 38 | + [StringLength(100)] |
| 39 | + [RegularExpression(AllowedCharactersPatterns.ADDITIONAL_ALLOWED_CHARACTERS_PATTERN)] |
| 40 | + [JsonPropertyName("orderId")] |
| 41 | + public required string OrderId { get; init; } |
| 42 | + |
| 43 | + /// <summary> |
| 44 | + /// Gets or sets the URL to which the user is redirected after a successful payment. This URL is used for post-transaction navigation. |
| 45 | + /// </summary> |
| 46 | + [StringLength(300)] |
| 47 | + [Url] |
| 48 | + [JsonPropertyName("successReturnUrl")] |
| 49 | + public required string SuccessReturnUrl { get; init; } |
| 50 | + |
| 51 | + /// <summary> |
| 52 | + /// Gets or sets the URL to which the user is redirected after a failed payment. This provides a means to handle unsuccessful transactions. |
| 53 | + /// </summary> |
| 54 | + [StringLength(300)] |
| 55 | + [Url] |
| 56 | + [JsonPropertyName("failureReturnUrl")] |
| 57 | + public required string FailureReturnUrl { get; init; } |
| 58 | + |
| 59 | + /// <summary> |
| 60 | + /// Gets or sets a general return URL for the payment, used for redirecting the user after the transaction is processed, regardless of the outcome. |
| 61 | + /// </summary> |
| 62 | + [StringLength(300)] |
| 63 | + [Url] |
| 64 | + [JsonPropertyName("returnUrl")] |
| 65 | + public required string ReturnUrl { get; init; } |
| 66 | + |
| 67 | + /// <summary> |
| 68 | + /// Gets or sets the customer's information, essential for processing the payment and for record-keeping purposes. |
| 69 | + /// </summary> |
| 70 | + [JsonPropertyName("customer")] |
| 71 | + public required Customer Customer { get; init; } |
| 72 | + |
| 73 | + /// <summary> |
| 74 | + /// Gets or sets the title associated with the payment. This can be a description or label for the payment, and can be null. |
| 75 | + /// </summary> |
| 76 | + [StringLength(255)] |
| 77 | + [RegularExpression(AllowedCharactersPatterns.ADDITIONAL_ALLOWED_CHARACTERS_PATTERN)] |
| 78 | + [JsonPropertyName("title")] |
| 79 | + public string? Title { get; init; } |
| 80 | + |
| 81 | + /// <summary> |
| 82 | + /// Gets or sets the expiration date and time of the transaction. If not specified, the transaction remains valid indefinitely. |
| 83 | + /// Transactions not completed by this timestamp will be automatically cancelled. |
| 84 | + /// </summary> |
| 85 | + [JsonPropertyName("activeTo")] |
| 86 | + public DateTime? ActiveTo { get; init; } |
| 87 | + |
| 88 | + internal void SetServiceId(string serviceId) |
| 89 | + => ServiceId = serviceId; |
| 90 | +} |
0 commit comments