Skip to content

Commit

Permalink
fix(NPG-POST-notification): no details for missing required info (#2129)
Browse files Browse the repository at this point in the history
  • Loading branch information
pietro-tota authored Jun 13, 2024
1 parent 16db210 commit a0fc175
Showing 1 changed file with 22 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
<policies>
<inbound>
<base />
<set-variable name="orderIdPathParam" value="@(context.Request.MatchedParameters["orderId"])" />
<set-variable name="walletId" value="@(context.Request.MatchedParameters["walletId"])" />
<set-variable name="npgNotificationRequestBody" value="@((JObject)context.Request.Body.As<JObject>(true))" />
<set-variable name="orderIdBodyParam" value="@((string)((JObject)((JObject)context.Variables["npgNotificationRequestBody"])["operation"])["orderId"])" />
<choose>
<when condition="@(((string)context.Variables["orderIdPathParam"]).Equals((string)context.Variables["orderIdBodyParam"]) != true)">
<return-response>
<set-status code="400" reason="orderId mismatch" />
<set-header name="Content-Type" exists-action="override">
<value>application/json</value>
</set-header>
<set-body>{
<base />
<set-variable name="orderIdPathParam" value="@(context.Request.MatchedParameters["orderId"])" />
<set-variable name="walletId" value="@(context.Request.MatchedParameters["walletId"])" />
<set-variable name="npgNotificationRequestBody" value="@((JObject)context.Request.Body.As<JObject>(true))" />
<set-variable name="orderIdBodyParam" value="@((string)((JObject)((JObject)context.Variables["npgNotificationRequestBody"])["operation"])["orderId"])" />
<choose>
<when condition="@(((string)context.Variables["orderIdPathParam"]).Equals((string)context.Variables["orderIdBodyParam"]) != true)">
<return-response>
<set-status code="400" reason="orderId mismatch" />
<set-header name="Content-Type" exists-action="override">
<value>application/json</value>
</set-header>
<set-body>{
"title": "Unable to handle notification",
"status": 400,
"detail": "orderId mismatch",
}</set-body>
</return-response>
</when>
</choose>
<set-header name="Authorization" exists-action="override">
</return-response>
</when>
</choose>
<set-header name="Authorization" exists-action="override">
<value>
@{
JObject requestBody = (JObject)context.Variables["npgNotificationRequestBody"];
return "Bearer " + (string)requestBody["securityToken"];
}
</value>
</set-header>
</set-header>
<set-body>
@{
JObject requestBody = (JObject)context.Variables["npgNotificationRequestBody"];
Expand All @@ -53,12 +53,13 @@
}
string paymentCircuit = (string)operation["paymentCircuit"];
string paymentMethod = (string)operation["paymentMethod"];
string paymentInstrumentInfo = (string)operation["paymentInstrumentInfo"];
JObject details = null;
if(paymentCircuit == "PAYPAL"){
if(paymentCircuit == "PAYPAL" && !String.IsNullOrEmpty(paymentInstrumentInfo)){
details = new JObject();
details["type"] = "PAYPAL";
details["maskedEmail"] = (string)operation["paymentInstrumentInfo"];
} else if(paymentMethod == "CARD"){
details["maskedEmail"] = paymentInstrumentInfo;
} else if(paymentMethod == "CARD" && !String.IsNullOrEmpty(cardId4)){
details = new JObject();
details["type"] = "CARD";
details["paymentInstrumentGatewayId"] = cardId4;
Expand Down

0 comments on commit a0fc175

Please sign in to comment.