Cannot get response back that I can use

Hi, after the best part of a day i’ve yet to understand how to use the response after making a payment. It might not be a Square issue to be fair, more likely my understanding, but I’m stumped.

I can make a payment using the PaymentForm. I can get a confirmation of payment successful. But for the life of me, I cannot understand how to retrieve/read the 200 response sent back.

for instance, this is sent back in the Square API explorer, when testing. I’d like to read these values in my program (.NET / C#).

{
“payment”: {
“id”: “VETjuzjNLIJbwEcjPV4g16G2BXGZY”,
“created_at”: “2021-03-20T17:10:11.374Z”,
“updated_at”: “2021-03-20T17:10:11.608Z”,
“amount_money”: {
“amount”: 100,
“currency”: “GBP”
},
“status”: “COMPLETED”,
“delay_duration”: “PT168H”,
“source_type”: “CARD”,
“card_details”: {
“status”: “CAPTURED”,
“card”: {
“card_brand”: “MASTERCARD”,
“last_4”: “9029”,
“exp_month”: 3,
“exp_year”: 2023,
“fingerprint”: “sq-1-RXc_bzRESnBQ7AZvWC6EjwAp7ZA_CfagP_2-_aVQOTNin2woZ4SF4oksf2WPs1wdgg”,
“card_type”: “CREDIT”,
“prepaid_type”: “NOT_PREPAID”,
“bin”: “540988”
},
“entry_method”: “KEYED”,
“cvv_status”: “CVV_ACCEPTED”,
“avs_status”: “AVS_ACCEPTED”,
“statement_description”: “SQ *DEFAULT TEST ACCOUNT”,
“card_payment_timeline”: {
“authorized_at”: “2021-03-20T17:10:11.483Z”,
“captured_at”: “2021-03-20T17:10:11.608Z”
}
},
“location_id”: “LXNPQGX0RXNMV”,
“order_id”: “QjKyY7NVntS9tnjnRWREz8Vkl58YY”,
“risk_evaluation”: {
“created_at”: “2021-03-20T17:10:11.483Z”,
“risk_level”: “NORMAL”
},
“total_money”: {
“amount”: 100,
“currency”: “GBP”
},
“approved_money”: {
“amount”: 100,
“currency”: “GBP”
},
“receipt_number”: “VETj”,
“receipt_url”: “https://squareupsandbox.com/receipt/preview/VETjuzjNLIJbwEcjPV4g16G2BXGZY”,
“delay_action”: “CANCEL”,
“delayed_until”: “2021-03-27T17:10:11.374Z”,
“version_token”: “XSNCAqBSQGidRGs1S2Ccnhx1OzNzbdo8w7HnuBaISr75o”
}
}

I’m programming in Visual Studio and C#, and have used other payment providers over the years, so not new to programming or accessing payment information (although i’m a novice in javascript).

I could try an “HttpWebRequest” but where is the page that has the 200 response code?

I’ve seen a lot of do this and do that in the docs and the video’s but nothing actually how to.

any pointers in the right direction would be great.

cheers

200 response code will not be in the page it will be in the HttpResponseMessage.StatusCode , you will need to write a class with all the properties you want to read from the JSON response. Something like:

public class SampleClass
{
   [JsonProperty("total_money")]
   public decimal TotalMoney {get; set;}
 [JsonProperty("currency")]
   public string Currency {get; set;}
}
1 Like

To add to the above, we also do have a .NET SDK with built-in classes already that will make it easier to retrieve this information: SDKs and Samples: .NET SDK

2 Likes