Make declined Payment using CreatePayment method

How to make a failed payments with the CreatePayment function?. I am passing the CustomerId and Source Id as Customer Card Id, and not the cnon:card-nonce-ok and ccof:customer-card-id-ok. Please guide me, I am using C# SDK

Hi @amarv welcome to the forums!

In sandbox, you can pass specific values to test different scenarios, including failures. Take a look here: https://developer.squareup.com/docs/testing/test-values#error-state-values. Please let me know if you have any additional questions or concerns, I’m happy to help!

Yes, Initially I have looked at the page which is mentioned above. But I am trying to process the payment from the saved card details as like below.

‘{
“amount_money”: {
“amount”: 300,
“currency”: “USD”
},
“customer_id”: “YYFKNXCDV0SSNFCXC27J3XFXDW”,
“source_id”: “ccof:eDmUskYKwjmTEXf43GB”,
“autocomplete”: true,
“idempotency_key”: “e89307e8-650e-423b-8ddf-7c6ed23a5286”,
“reference_id”: “63e82ffd-6c32-4f1a-9f36-1d49edb9fc84”
}’

I’m not sure I’m following. Did you use one of the error values to save the card on file?

Our process is, capturing the customer card information from the SQPaymentForm, and used the Customers.CreateCustomerCard method to Create a CardId for future payments. If we provide the values mentioned in the https://developer.squareup.com/docs/testing/test-values#error-state-values during CreateCustomerCard it’s throwing an exception. But when Pass card id via Payment.CreatePayment method it’s not throwing any error. Since the CardId is valid and it’s not fall on any criteria mentioned in the above URL.

I just tested the “911” CVV error one, created a nonce, and passed it to CreatePayment, and it fails with CVV_FAILURE. I created another nonce with “911” CVV, and passed it to CreateCustomerCard and got VERIFY_CVV_FAILURE.

How are you getting a card id, if the CreateCustomerCard is failing?

I would restructure my Question, We are having two screens on the first screen we will capture the Customer Card information will create a card id for future payments, on the second screen collect the amount which needs to be charged and will call the CreatePayment Method.

If I use the CVV as “911”, then screen one it’s self I am getting an exception as “CVV_FAILURE”, because of this I am unable to create a Card Id and navigating into the second screen. Our requirement is the first screen should successfully generate the card Id while using that card in CreatePayment method I need to get an exception.

There’s no way to do this in our sandbox unfortunately. The CreateCustomerCard will verify it’s a real card, and if not, throw an error, so there’s no way to get past it to CreatePayment since it will always produce an error. You can make the error happen on either CreateCustomerCard or CreatePayment, but you can’t make it pass CreateCustomerCard and then pass on CreatePayment at this time.