Im using asp. net API from Connect Square to generate nonce and create a payment. My payment form is loading correctly generating a nonce but not creating paymentrequest. Here is the error response
HTTP Response Not OKSquare.Exceptions.ApiException: HTTP Response Not OK at
Square.Utilities.ApiHelper.RunTaskSynchronously(Task t) at
Square.Apis.PaymentsApi.CreatePayment(CreatePaymentRequest body) at
sqRazorSample.Pages.ProcessPaymentModel.OnPost() in
C:\Users\User\Desktop\csharp_payment\Pages\ProcessPayment.cshtml.cs:line 60
Here is the code at line 60.. payment Creation
public void OnPost()
{
string nonce = Request.Form[“nonce”];
// IPaymentsApi paymentsApi = new PaymentsApi(this.BasePath);
// paymentsApi.Configuration.AccessToken = this.AccessToken;
IPaymentsApi PaymentsApi = client.PaymentsApi;
string uuid = NewIdempotencyKey(); //NewIdempotencyKey();
Money amount = new Money(100, "USD");
CreatePaymentRequest createPaymentRequest = new CreatePaymentRequest(amountMoney: amount, idempotencyKey: uuid, sourceId: nonce);
try
{
var response = PaymentsApi.CreatePayment(createPaymentRequest); \\This is giving error
this.ResultMessage = "Payment complete! " + response;
}
catch (ApiException e)
{
this.ResultMessage = e.Message + e;
}
}
Working in Sandbox environment and localhost. Anyhelp would be appreciated