# Square Card Payment c# example (sqRazorSample) CARD\_DECLINED\_VERIFICATION\_REQUIRED

**URL:** <https://developer.squareup.com/forums/t/square-card-payment-c-example-sqrazorsample-card-declined-verification-required/20065>\
**Category:** Questions\
**Tags:** payments-api, sandbox\
**Created:** [December 12, 2024, 10:48am UTC](https://developer.squareup.com/forums/t/square-card-payment-c-example-sqrazorsample-card-declined-verification-required/20065 "2024-12-12T10:48:56Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![JayYu](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@JayYu](https://developer.squareup.com/forums/u/JayYu)\
**Post date:** [December 12, 2024, 10:48am UTC](https://developer.squareup.com/forums/t/square-card-payment-c-example-sqrazorsample-card-declined-verification-required/20065/1 "2024-12-12T10:48:56Z")

</div>

Hi there, I am new to Square payment development. I am using “\SquarePaymentExamples\connect-examples\v2\csharp\_payment” example to set up the initial testing program locally. I used my SandBox application ID, AccessToken, and also the test payment card  
“Visa 4800 0000 0000 0004 111 No Challenge N/A” as shown in your website.

In “ProcessPayment.cshtml.cs”, if I didn’t hard-code " token = “cnon:card-nonce-ok”;, and used the Token generated based on that test card.

var request = JObject.Parse(await new StreamReader(Request.Body).ReadToEndAsync());  
var token = (String)request[“token”];

I kept having the error “HTTP Response Not OK”  
CARD\_DECLINED\_VERIFICATION\_REQUIRED

| | Name | Value | Type |
| --- | --- | --- | --- |
| ◢ | [0] | {Error : (this.Category = PAYMENT\_METHOD\_ERROR, this.Code = CARD\_DECLINED\_VERIFICATION\_REQUIRED, this.Detail = Authorization error: ‘CARD\_DECLINED\_VERIFICATION\_REQUIRED’, this.Field = null)} | Square.Models.Error |

In the other post, it mentioned about the “issuer requires additional verification through Strong Customer Authentication (SCA).”.  
Is there any existing example of running SCA checking based on the testing card (listed on your website).

---

<div class="post-metadata">

**Author:** ![Square-Dev-AI](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/square-dev-ai/32/2513_2.png) [@Square-Dev-AI](https://developer.squareup.com/forums/u/Square-Dev-AI)\
**Post date:** [December 12, 2024, 10:49am UTC](https://developer.squareup.com/forums/t/square-card-payment-c-example-sqrazorsample-card-declined-verification-required/20065/2 "2024-12-12T10:49:16Z")

</div>

👋 I’m Square Dev AI, here to help answer your question!  
Based on the information you’ve provided, the following documentation will help answer your question:

> **[Sandbox Payments](https://developer.squareup.com/docs/devtools/sandbox/payments)**
>
> A quick reference of test credit card numbers and payment tokens you can use to make test payments with the Square Sandbox.

> **[Verify a Buyer](https://developer.squareup.com/docs/in-app-payments-sdk/verify-buyer)**
>
> Learn how to start an SCA buyer verification, get the resulting verification token, and use that token to complete a payment with the Square Payments API.

> **Additional Documentation**
>
> [Download, Configure, and Run the Client Sample](https://developer.squareup.com/docs/in-app-payments-sdk/quick-start/generate-token)  
> [Card Payments](https://developer.squareup.com/docs/payments-api/take-payments/card-payments)  
> [Strong Customer Authentication](https://developer.squareup.com/docs/sca-overview-iap)

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.  
Otherwise one of our Developer Advocates will provide additional assistance shortly.

---

<div class="post-metadata">

**Author:** ![Square-Dev-AI](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/square-dev-ai/32/2513_2.png) [@Square-Dev-AI](https://developer.squareup.com/forums/u/Square-Dev-AI)\
**Post date:** [December 12, 2024, 5:29pm UTC](https://developer.squareup.com/forums/t/square-card-payment-c-example-sqrazorsample-card-declined-verification-required/20065/3 "2024-12-12T17:29:10Z")

</div>

Yes, Square provides support for Strong Customer Authentication (SCA) through the use of 3D Secure (3DS). This is a standard protocol that can be used to satisfy the requirements of SCA.

In your case, you can use the `verifyBuyer()` function in the Web Payments SDK to start the 3DS flow. This function should be invoked only when the buyer is present and has initiated the transaction.

For more detailed information on how to implement SCA in your application, you can refer to the following guides:

- For Web Payments SDK: [Verify the Buyer When Using a Payment Token](https://developer.squareup.com/docs/web-payments-sdk/verification)

This guide provides step-by-step instructions on how to modify your payment flow to verify a buyer’s identity using additional secure authentication.

_This answer was reviewed by @Bryan-Square._

---

<div class="post-metadata">

**Author:** ![JayYu](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@JayYu](https://developer.squareup.com/forums/u/JayYu)\
**Post date:** [December 13, 2024, 12:24pm UTC](https://developer.squareup.com/forums/t/square-card-payment-c-example-sqrazorsample-card-declined-verification-required/20065/4 "2024-12-13T12:24:51Z")

</div>

thanks for your reply.

I downloaded the “square\_web\_payment\_quickstart” repository to my local. I found the “Card-payment.html” example under the “public/examples” folder.

The “Card-payment.html” contains the bit of codes calling the payments.verifyBuyer( ).

I copied the code and run in my local web application. by stepping into the code, I managed to get the copy of generated verification code “verf:CA4SEIXp9oAVN68N0CZdYMa-2q0gACgC”

When I put all those details AccessToken, LocationID, verification code into the API explorer for a quick test, the c# version code as the following

var tipMoney = new Money.Builder()  
.Amount(100L)  
.Currency(“GBP”)  
.Build();

var body = new CreatePaymentRequest.Builder(sourceId: “cnon:CA4SELvbpDLqdGGYIA9SH48F1FAYASgC”, idempotencyKey: “dd92e167-588d-4f3f-9d99-1e00fc24c632”)  
.TipMoney(tipMoney)  
.LocationId(“LNDNRCGDR85T5”)  
.VerificationToken(“verf:CA4SEIXp9oAVN68N0CZdYMa-2q0gACgC”)  
.AcceptPartialAuthorization(false)  
.Build();

try  
{  
var result = await client.PaymentsApi.CreatePaymentAsync(body: body);  
}  
catch (ApiException e)  
{  
Console.WriteLine(“Failed to make the request”);  
Console.WriteLine($“Response Code: {e.ResponseCode}”);  
Console.WriteLine($“Exception: {e.Message}”);  
}

```auto

I got the error 401 with the message as the following.

{
  "errors": [
    {
      "category": "AUTHENTICATION_ERROR",
      "code": "UNAUTHORIZED",
      "detail": "This request could not be authorized."
    }
  ]
}

Do you know which part might have went wrong? many thanks,
```

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [December 13, 2024, 4:45pm UTC](https://developer.squareup.com/forums/t/square-card-payment-c-example-sqrazorsample-card-declined-verification-required/20065/5 "2024-12-13T16:45:24Z")

</div>

Was the `verification_token` generated with the same `location_id` and the same application? Also was the API Explorer pointing to production or sandbox? 🙂

---

<div class="post-metadata">

**Author:** ![JayYu](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@JayYu](https://developer.squareup.com/forums/u/JayYu)\
**Post date:** [December 16, 2024, 11:05am UTC](https://developer.squareup.com/forums/t/square-card-payment-c-example-sqrazorsample-card-declined-verification-required/20065/6 "2024-12-16T11:05:05Z")

</div>

Hi Bryan,

followed the “ReadMe” doc from “Square\_web\_payment\_quickStart”, I’ve installed node.js locally, and run the npm run dev to launch the local server on [http://localhost:3000](http://localhost:3000);

In the card-payment.html example, I replaced the application id and location id with my sandbox ones  
const appId = ‘sandbox-sq0idb-vr69KK3nLdIrMdNrvJS3Ng’;  
const locationId = ‘LNDNRCGDR85T5’;

I used the buyer details as listed in the example:-  
const verificationDetails = {  
amount: ‘1.00’,  
billingContact: {  
givenName: ‘John’,  
familyName: ‘Doe’,  
email: ‘john.doe@square.example’,  
phone: ‘3214563987’,  
addressLines: [‘123 Main Street’, ‘Apartment 1’],  
city: ‘London’,  
state: ‘LND’,  
countryCode: ‘GB’,  
},  
currencyCode: ‘GBP’,  
intent: ‘CHARGE’,  
};

and the testing card details  
4800 0000 0000 0004

token: cnon:CA4SEA1qZWrKoLg8ufJ9pZSpOIoYASgC  
verificationToken: verf:CA4SECMqwjBBcVbRt6ELMfvokLkgACgB

When I stepped into the code, it seems the error was thrown at the line of  
await fetch(‘/payment’, method: ‘post’, headers: { ‘content-type’: ‘application/json’, })

the details of error as the following:- Response error code: 401.

“Error: Response status code was not ok: 401.  
at new ApiError (C:\Projects\Square\_Web\_Payment\_QuickStart\node\_modules\square\dist\cjs\errors\apiError.js:18:24)  
at C:\Projects\Square\_Web\_Payment\_QuickStart\node\_modules@apimatic\core\lib\http\requestBuilder.js:352:23  
at DefaultRequestBuilder. (C:\Projects\Square\_Web\_Payment\_QuickStart\node\_modules@apimatic\core\lib\http\requestBuilder.js:186:50)  
at step (C:\Projects\Square\_Web\_Payment\_QuickStart\node\_modules\tslib\tslib.js:196:27)  
at Object.next (C:\Projects\Square\_Web\_Payment\_QuickStart\node\_modules\tslib\tslib.js:177:57)  
at fulfilled (C:\Projects\Square\_Web\_Payment\_QuickStart\node\_modules\tslib\tslib.js:167:62)  
at process.processTicksAndRejections (node:internal/process/task\_queues:105:5)”

---

<div class="post-metadata">

**Author:** ![JayYu](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@JayYu](https://developer.squareup.com/forums/u/JayYu)\
**Post date:** [December 16, 2024, 11:52am UTC](https://developer.squareup.com/forums/t/square-card-payment-c-example-sqrazorsample-card-declined-verification-required/20065/7 "2024-12-16T11:52:30Z")

</div>

found the following error details from the command window regarding the payment failure I came across

 ![image](https://global.discourse-cdn.com/square/original/2X/c/c7ee69f51f316a5201101fa1017da0f13797ec96.png)

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [December 16, 2024, 6:23pm UTC](https://developer.squareup.com/forums/t/square-card-payment-c-example-sqrazorsample-card-declined-verification-required/20065/8 "2024-12-16T18:23:20Z")

</div>

Do you have the `src` set to `https://sandbox.web.squarecdn.com/v1/square.js`? 🙂

---

<div class="post-metadata">

**Author:** ![JayYu](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@JayYu](https://developer.squareup.com/forums/u/JayYu)\
**Post date:** [December 17, 2024, 9:39am UTC](https://developer.squareup.com/forums/t/square-card-payment-c-example-sqrazorsample-card-declined-verification-required/20065/9 "2024-12-17T09:39:43Z")

</div>

Yes. I do have

in the header of the testing example page “card-payment.html”.

I also changed currencyCode to “GBP” in “const verificationDetails”. I used a testing UK card “5248 4800 0021 0026”

I cannot find any error details in the Api log.

---

<div class="post-metadata">

**Author:** ![JayYu](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@JayYu](https://developer.squareup.com/forums/u/JayYu)\
**Post date:** [December 17, 2024, 9:57am UTC](https://developer.squareup.com/forums/t/square-card-payment-c-example-sqrazorsample-card-declined-verification-required/20065/10 "2024-12-17T09:57:58Z")

</div>

BTW, once I got the following Square 3d verification form, what kind of OTP code should I put in?

 ![image](https://global.discourse-cdn.com/square/original/2X/5/5d83ab788f2b4b009b7de8243158f0f703a5b056.png)

---

<div class="post-metadata">

**Author:** ![JayYu](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@JayYu](https://developer.squareup.com/forums/u/JayYu)\
**Post date:** [December 17, 2024, 10:18am UTC](https://developer.squareup.com/forums/t/square-card-payment-c-example-sqrazorsample-card-declined-verification-required/20065/11 "2024-12-17T10:18:22Z")

</div>

I changed the “currency” to “GBP” in the server.js file from “web\_payment\_QuickStart”; the “CurrencyCode” to “GBP” in card-payment.html ;

When I debugged in the web browser, the verification token was generated and passed to the fetch(“/payment”).

However, I got the following error from console window regarding CARD\_DECLINED\_VERIFICATION\_REQUIRED

 ![image](https://global.discourse-cdn.com/square/original/2X/1/1d4c8ff7a830307b984802600b094e4abcfc761d.png)

---

<div class="post-metadata">

**Author:** ![JayYu](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@JayYu](https://developer.squareup.com/forums/u/JayYu)\
**Post date:** [December 17, 2024, 11:30am UTC](https://developer.squareup.com/forums/t/square-card-payment-c-example-sqrazorsample-card-declined-verification-required/20065/12 "2024-12-17T11:30:13Z")

</div>

I added the " console.log(payment.verificationToken);" in the server.js file after assigning the verificationToken to the payment request object.

```
// VerificationDetails is part of Secure Card Authentication.
  // This part of the payload is highly recommended (and required for some countries)
  // for 'unauthenticated' payment methods like Cards.
  if (payload.verificationToken) {
    payment.verificationToken = payload.verificationToken;
  }
  
  console.log(payment.verificationToken);

```

As shown from the following screen-shot, the verificationToken was generated and passed to square.js api, but it sill got the card\_declined\_verification\_required.

 ![image](https://global.discourse-cdn.com/square/original/2X/0/01d176fa16e30999ae1eee9bdd07a4b25225043d.png)

Is there something else I missed?? many thanks,

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [December 17, 2024, 5:47pm UTC](https://developer.squareup.com/forums/t/square-card-payment-c-example-sqrazorsample-card-declined-verification-required/20065/13 "2024-12-17T17:47:11Z")

</div>

When the model pops up are you using the test value `123456`? 🙂

---

<div class="post-metadata">

**Author:** ![JayYu](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@JayYu](https://developer.squareup.com/forums/u/JayYu)\
**Post date:** [December 18, 2024, 8:49am UTC](https://developer.squareup.com/forums/t/square-card-payment-c-example-sqrazorsample-card-declined-verification-required/20065/14 "2024-12-18T08:49:34Z")

</div>

Bingo 😃 Yes. I did put some other random numbers.

---

<div class="post-metadata">

**Author:** ![JayYu](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@JayYu](https://developer.squareup.com/forums/u/JayYu)\
**Post date:** [December 18, 2024, 9:08am UTC](https://developer.squareup.com/forums/t/square-card-payment-c-example-sqrazorsample-card-declined-verification-required/20065/15 "2024-12-18T09:08:48Z")

</div>

BTW, another quick question,

regarding the cshar\_payment example under “connect-examples\v2”  
\SquarePaymentExamples\connect-examples\v2\csharp\_payment

Whether c# Square package has the similar verifyBuyer()method under

SquareClient.client.PaymentApi?

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [December 18, 2024, 5:18pm UTC](https://developer.squareup.com/forums/t/square-card-payment-c-example-sqrazorsample-card-declined-verification-required/20065/16 "2024-12-18T17:18:25Z")

</div>

With the Web Payments SDK `verifyBuyer()` is a JavaScript method only for the Web Payments SDK. It’s not included in the the .Net SDK.

Also you may want to instead consider using our [charge and store](https://developer.squareup.com/docs/web-payments/sca-charge-and-store-card-on-file) a card on file with SCA. This will eliminate the `verifyBuyer` call. Also it’s the future of 3DS. We will be deprecating `verifyBuyer` once this goes to GA. 🙂
