|
11 | 11 | using Riskified.SDK.Utils;
|
12 | 12 | using Riskified.SDK.Exceptions;
|
13 | 13 | using Riskified.SDK.Model.OrderCheckoutElements;
|
| 14 | +using System.Text; |
14 | 15 |
|
15 | 16 | namespace Riskified.SDK.Sample
|
16 | 17 | {
|
@@ -141,7 +142,7 @@ public static void SendOrdersToRiskifiedExample()
|
141 | 142 | case "v":
|
142 | 143 | Console.WriteLine("Order Generated with merchant order number: " + orderNum);
|
143 | 144 | order.Id = orderNum.ToString();
|
144 |
| - orderNum++; |
| 145 | + //orderNum++; |
145 | 146 | // sending order for synchronous decision
|
146 | 147 | // it will generate a synchronous response with the decision regarding the order
|
147 | 148 | // (for sync flow only)
|
@@ -292,11 +293,31 @@ public static void SendOrdersToRiskifiedExample()
|
292 | 293 |
|
293 | 294 | if (res != null)
|
294 | 295 | {
|
295 |
| - Console.WriteLine("\n\nOrder sent successfully:" + |
296 |
| - "\nStatus at Riskified: " + res.Status + |
297 |
| - "\nOrder ID received:" + res.Id + |
298 |
| - "\nDescription: " + res.Description + |
299 |
| - "\nWarnings: " + (res.Warnings == null ? "---" : string.Join(" \n", res.Warnings)) + "\n\n"); |
| 296 | + StringBuilder message = new StringBuilder(); |
| 297 | + |
| 298 | + // Basic order information |
| 299 | + message.AppendLine("\nOrder sent successfully:"); |
| 300 | + message.AppendLine($"Status at Riskified: {res.Status}"); |
| 301 | + message.AppendLine($"Order ID received: {res.Id}"); |
| 302 | + message.AppendLine($"Description: {res.Description}"); |
| 303 | + // Conditional policy response |
| 304 | + if (res.PolicyProtect != null && res.PolicyProtect.Policies.Any()) |
| 305 | + { |
| 306 | + //the example only retrieve the first item, in prod env, merchant should implement policy response it in for loop format. |
| 307 | + message.AppendLine($"Policy Response: {res.PolicyProtect.Policies.First().PolicyType}"); |
| 308 | + } |
| 309 | + |
| 310 | + // Warnings or a placeholder if there are no warnings |
| 311 | + if (res.Warnings != null && res.Warnings.Any()) |
| 312 | + { |
| 313 | + message.AppendLine("Warnings: " + string.Join("\n ", res.Warnings)); |
| 314 | + } |
| 315 | + else |
| 316 | + { |
| 317 | + message.AppendLine("Warnings: ---"); |
| 318 | + } |
| 319 | + Console.WriteLine(message.ToString()); |
| 320 | + |
300 | 321 | }
|
301 | 322 | if (accRes != null)
|
302 | 323 | {
|
|
0 commit comments