Quantcast
Channel: Square Developer Forums - Latest topics
Viewing all articles
Browse latest Browse all 1325

Java SDK just gives generic error message

$
0
0

I am using Square Java SDK to develop my application. I am using OAuth to obtain access tokens for sellers and make requests on behalf of sellers. When I try to create a payment request on behalf of a seller using the OAuth token of the test seller account, I get a generic API Exception and it only prints HTTP NOT OK. It is hard to debug what exactly is causing this as the error message is just NOT OK and nothing else. I am using the default test account that’s assigned, which I assume has PAYMENTS_WRITE permission for me, I have also tried with another test I created with the PAYMENTS_WRITE grant type, but I am still getting the same error. Refer to the following lines of code that I am using to rest:

SquareClient client = new SquareClient.Builder()
                        .environment(Environment.SANDBOX)
                        .customUrl("https://connect.squareupsandbox.com")
                        .bearerAuthCredentials(new BearerAuthModel
                         .Builder("SELLER_OAUTH_TOKEN").build())
                    .build();
Money amountMoney = new Money(100L, "USD");
PaymentsApi paymentsApi = client.getPaymentsApi();
CreatePaymentRequest createPaymentRequest = new CreatePaymentRequest
                .Builder("cnon:card-nonce-ok", UUID)
                  .autocomplete(false)
                  .amountMoney(amountMoney)
                  .customerId("CUSTOMER_ID")
            .build();
CreatePaymentResponse createPaymentResponse = paymentsApi.createPayment(createPaymentRequest);

All I am getting is an API exception with the message HTTP NOT OK, is there a way I could look deep into this exception and find out the root cause?

3 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 1325

Trending Articles