Test basic payment requests in Postman
If you’ve already started building your app and know which Payments APIs you want to use, you can use Postman to start testing your production code.
Here are basic QuickBooks Payments API requests and operations you can test in Postman.
Set up Postman
If you haven’t already, get the QuickBooks Payments collections and set up your Postman testing environment. Then come back to this guide.
Get access tokens for Postman
You need to create access tokens to send tests requests. Tokens are valid for 60 minutes.
Test payments requests
Collections give pre-builts requests you can use for your QuickBooks test company. Here are a few you can try:
Create a charge
- In Postman, select the Collections menu.
- Select the Charges folder and then (Post) Charges-Create.
- Review to the Authorization tab. Make sure the Type dropdown is OAuth 2.0 and the Add authorization data to dropdown is Request Headers.
- Select a token from the Access Token dropdown.
- Review the request in the Body tab.
- Select Send.
This creates a new charge and sends a charge request - these are the most common activities for payment processing. Go to the Body tab to see the server response. The charge’s status should be CAPTURED.
Get the status of an existing charge
After you have created a charge, you can check it’s status:
- Open the original charge.
- In the Body tab, review the server response.
- Copy the value for the
id
field. Don’t copy the quotes.
- Select the Collections menu.
- Select the Charges folder and then (GET) Charges-Retrieve.
- In the endpoint, replace <enter_your_charge_id> with the original charge’s value for the
id
field.
- Review to the Authorization tab. Make sure the Type dropdown is OAuth 2.0 and the Add authorization data to dropdown is Request Headers.
- Select a token from the Access Token dropdown.
- Review the request in the Body tab.
- Select Send.
The server response should show details and and the charge’s status as CAPTURED. If the charge was refunded, the status should be REFUNDED.
Refund an existing charge
- Open the charge you want to refund.
- In the Body tab, review the server response.
- Copy the value for the
id
field. Don’t copy the quotes.
- Select the Collections menu.
- Select the Charges folder and then POST Charges-RefundCharge.
- In the endpoint, replace <enter_your_charge_id> with the refund charge’s value for the
id
field.
- Review to the Authorization tab. Make sure the Type dropdown is OAuth 2.0 and the Add authorization data to dropdown is Request Headers.
- Select a token from the Access Token dropdown.
- Go to the Body tab.
- Leave the value in the
amount
field as is to give a full refund. Or, change the value to give a partial refund.
- Select Send.
This refunds the charge. The server response should show the status for both full and partial refunds as ISSUED.
Void a charge
You can void an existing charge as long as its status isn’t completed
.
If it’s already completed, do a full refund for the charge instead.
- Open the charge you want to void.
- Open the Environment Quick Look window.
- Copy the value for the
guid-without-dashes
variable.
- Select the Collections menu.
- Select the Charges folder and then POST Charges-VoidCharge.
- In the endpoint, replace <enter_your_request_charge_id> with the value for the
guid-without-dashes
variable.
- Review to the Authorization tab. Make sure the Type dropdown is OAuth 2.0 and the Add authorization data to dropdown is Request Headers.
- Select a token from the Access Token dropdown.
- Review the request in the Body tab.
- Select Send.
This voids the charge. The server response should show the void’s status as ISSUED.
Save a credit card
- Select the Collections menu.
- Select the Cards folder and then POST Cards-Create.
- In the endpoint, replace <enter_your_customer_id> with the
customer id
for the customer you want to save the card for.
- Review to the Authorization tab. Make sure the Type dropdown is OAuth 2.0 and the Add authorization data to dropdown is Request Headers.
- Select a token from the Access Token dropdown.
- Go to the Body tab.
- In the
number
field, enter the credit card number you want to save.
- Select Send.
This saves the credit card info for the customer id
you put in the endpoint. The server response should show the status as ACTIVE.
Use a saved credit card to create a charge
- Open the saved credit card post.
- In the Body tab, review the server response.
- Copy the value for the
id
field. Don’t copy the quotes.
- Select the Collections menu.
- Select the Charges folder and then POST Charges-CreateFrom CardOnFile.
- Review to the Authorization tab. Make sure the Type dropdown is OAuth 2.0 and the Add authorization data to dropdown is Request Headers.
- Select a token from the Access Token dropdown.
- Go to the Body tab.
- In the
cardOnFile
field, enter the id
for the saved credit card. Note: This is not the actual credit card number.
- Select Send.
This uses the saved credit card to create a new charge. The server response should show the charge’s status as CAPTURED.