Create payment response does not return full object

I’m using the quickstart app to test creating payments in the sandbox. I have it working but the paymentResponse.json() does not have all the objects that should be there. I’m only receiving the id, status, receiptUrl, and orderID. I’m trying to get the card information but it’s not there. Is there something I’m missing? It looks good when I run it throught the api on your examples but not in the quickstart.

Thanks,

Jeff

:wave: 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:

Additional Documentation

Sandbox Payments
Test in the Sandbox
Make your First API Call

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.

The Quickstart app is designed to provide a simplified example of how to integrate the Square In-App Payments SDK. It’s possible that not all fields are included in the response within the Quickstart app. If you need to access more detailed information, such as card details, you may need to modify the Quickstart app or build a more complex application that makes use of the full capabilities of the Square APIs.

Please note that for security reasons, Square does not provide full card details in the API response. Only limited card information (like the last 4 digits, card brand, and expiration date) is included in the card_details field of the Payment object.

This answer was reviewed by @Bryan-Square.

Bryan,

I’m new to Square so I don’t know what you mean. The quickstart guide is using the payments API. How am I supposed to modify it so that it returns what it should?

Thanks,

Jeff

You can modify the server.js file code to have it return any of the fields you want from the payment object:

 send(res, statusCode, {
        success: true,
        payment: {
          id: result.payment.id,
          status: result.payment.status,
          receiptUrl: result.payment.receiptUrl,
          orderId: result.payment.orderId,
        },
      });
    } catch (ex) {
      if (ex instanceof ApiError) {
        // likely an error in the request. don't retry
        logger.error(ex.errors);
        bail(ex);
      } else {
        // IDEA: send to error reporting service
        logger.error(`Error creating payment on attempt ${attempt}: ${ex}`);
        throw ex; // to attempt retry
      }
    }
  });
}

:slightly_smiling_face:

Bryan,

Awesome, thanks for the help! I would not have figured that out on my own.

Thanks,

Jeff