|
| 1 | +using System.Collections.Generic; |
| 2 | + |
| 3 | +namespace GPWebpayNet.Sdk |
| 4 | +{ |
| 5 | + /// <summary> |
| 6 | + /// Helper class with PR and SR codes values. |
| 7 | + /// </summary> |
| 8 | + public static class ErrorCodesValues |
| 9 | + { |
| 10 | + private static readonly IReadOnlyDictionary<int, string> PRCodes = new Dictionary<int, string>() |
| 11 | + { |
| 12 | + {0, "OK" }, |
| 13 | + {1, "Field too long." }, |
| 14 | + {2, "Field too short." }, |
| 15 | + {3, "Incorrect content of field." }, |
| 16 | + {4, "Field is null." }, |
| 17 | + {5, "Missing required field." }, |
| 18 | + {11, "Unknown merchant." }, |
| 19 | + {14, "Duplicate order number." }, |
| 20 | + {15, "Object not found." }, |
| 21 | + {17, "Amount to deposit exceeds approved amount." }, |
| 22 | + {18, "Total sum of credited amounts exceeded deposited amount." }, |
| 23 | + {20, "Object not in valid state for operation." }, |
| 24 | + {25, "Operation not allowed for user." }, |
| 25 | + {26, "Technical problem in connection to authorization center." }, |
| 26 | + {27, "Incorrect order type." }, |
| 27 | + {28, "Declined in 3D." }, |
| 28 | + {30, "Declined in AC." }, |
| 29 | + {31, "Wrong digest." }, |
| 30 | + {35, "Session expired." }, |
| 31 | + {50, "The cardholder canceled the payment." }, |
| 32 | + {200, "Additional info request." }, |
| 33 | + {1000, "Technical problem." }, |
| 34 | + }; |
| 35 | + |
| 36 | + private static readonly IReadOnlyDictionary<int, string> SRCodes1_5_15_20 = new Dictionary<int, string>() |
| 37 | + { |
| 38 | + {0, string.Empty }, |
| 39 | + {1, "ORDERNUMBER" }, |
| 40 | + {2, "MERCHANTNUMBER" }, |
| 41 | + {6, "AMOUNT" }, |
| 42 | + {7, "CURRENCY" }, |
| 43 | + {8, "DEPOSITFLAG" }, |
| 44 | + {10, "MERORDERNUM" }, |
| 45 | + {11, "CREDITNUMBER" }, |
| 46 | + {12, "OPERATION" }, |
| 47 | + {18, "BATCH" }, |
| 48 | + {22, "ORDER" }, |
| 49 | + {24, "URL" }, |
| 50 | + {25, "MD" }, |
| 51 | + {26, "DESC" }, |
| 52 | + {34, "DIGEST" }, |
| 53 | + }; |
| 54 | + |
| 55 | + private static readonly IReadOnlyDictionary<int, string> SRCodes28 = new Dictionary<int, string>() |
| 56 | + { |
| 57 | + {0, string.Empty }, |
| 58 | + {3000, "Declined in 3D. Cardholder not authenticated in 3D." }, |
| 59 | + {3001, "Authenticated." }, |
| 60 | + {3002, "Not Authenticated in 3D. Issuer or Cardholder not participating in 3D." }, |
| 61 | + {3004, "Not Authenticated in 3D. Issuer not participating or Cardholder not enrolled." }, |
| 62 | + {3005, "Declined in 3D. Technical problem during Cardholder authentication." }, |
| 63 | + {3006, "Declined in 3D. Technical problem during Cardholder authentication." }, |
| 64 | + {3007, "Declined in 3D. Acquirer technical problem. Contact the merchant." }, |
| 65 | + {3008, "Declined in 3D. Unsupported card product." }, |
| 66 | + }; |
| 67 | + |
| 68 | + private static readonly IReadOnlyDictionary<int, string> SRCodes30 = new Dictionary<int, string>() |
| 69 | + { |
| 70 | + {0, string.Empty }, |
| 71 | + {1001, "Declined in AC, Card blocked." }, |
| 72 | + {1002, "Declined in AC, Declined." }, |
| 73 | + {1003, "Declined in AC, Card problem." }, |
| 74 | + {1004, "Declined in AC, Technical problem in authorization process." }, |
| 75 | + {1005, "Declined in AC, Account problem." }, |
| 76 | + }; |
| 77 | + |
| 78 | + /// <summary> |
| 79 | + /// Gets value of PR code |
| 80 | + /// </summary> |
| 81 | + /// <param name="prCode">id of the PR code</param> |
| 82 | + /// <returns>PR code value</returns> |
| 83 | + public static string GetPRCode(int prCode) |
| 84 | + { |
| 85 | + if (PRCodes.TryGetValue(prCode, out string value)) |
| 86 | + { |
| 87 | + return value; |
| 88 | + } |
| 89 | + |
| 90 | + return $"Unknown value for PR code {prCode}"; |
| 91 | + } |
| 92 | + |
| 93 | + /// <summary> |
| 94 | + /// Gets value of SR code |
| 95 | + /// </summary> |
| 96 | + /// <param name="prCode">id of the PR code</param> |
| 97 | + /// <param name="srCode">id of the PR code</param> |
| 98 | + /// <returns>SR code value</returns> |
| 99 | + public static string GetSRCode(int prCode, int srCode) |
| 100 | + { |
| 101 | + IReadOnlyDictionary<int, string> srCodes; |
| 102 | + |
| 103 | + switch (prCode) |
| 104 | + { |
| 105 | + case 1: |
| 106 | + case 2: |
| 107 | + case 3: |
| 108 | + case 4: |
| 109 | + case 5: |
| 110 | + case 15: |
| 111 | + case 20: |
| 112 | + srCodes = SRCodes1_5_15_20; |
| 113 | + break; |
| 114 | + case 28: |
| 115 | + srCodes = SRCodes28; |
| 116 | + break; |
| 117 | + case 30: |
| 118 | + srCodes = SRCodes30; |
| 119 | + break; |
| 120 | + default: |
| 121 | + srCodes = new Dictionary<int, string>(); |
| 122 | + break; |
| 123 | + } |
| 124 | + |
| 125 | + if (srCodes.TryGetValue(srCode, out string value)) |
| 126 | + { |
| 127 | + return value; |
| 128 | + } |
| 129 | + |
| 130 | + return $"Unknown value for PR code {prCode} and SR code {srCode}."; |
| 131 | + } |
| 132 | + } |
| 133 | +} |
0 commit comments