May 17, 2024
cancel
Showing results for 
Search instead for 
Did you mean: 
Help
reneemq
Community Manager
Community Manager

We are excited to announce the release of new capabilities offered by the Marqeta platform's Simulations 2.0 service. Simulations allow you to test functionality in the sandbox environment that would normally be triggered by an external event in a live environment, such as when a purchaser uses a payment card at a point of sale.

 

Simulations 2.0 introduces scalable, extensible support for a wide range of event types. It follows an API-driven approach where the structure of the service is defined by its API schema/specification.

 

With Simulations 2.0, you can replicate all supported transactions from the existising Simulations service using a single endpoint and single type of request object. All the related transaction events can be simulated using an endpoint such as: 

  • /simulations/cardtransactions/*: Simulates transactions involving a card, such as a purchase or a refund back to the card
  • /simulations/directdeposits/*: Simulates event types related to deposit accounts

 

Support has recently been added to Simulations 2.0 for new transaction types such as Refund, Incremental Authorization, and Account Funding, as well as for additional original credit transactions (OCTs), multi-currency transactions, and more.

 

Simulating transactions in the Sandbox

The Marqeta platform’s Simulations 2.0 service is available for testing and feature exploration. You can quickly build, test, provision cards for testing, and simulate transactions in our public sandbox environment. 

The sandbox environment provides a set of endpoints that enable you to simulate various types of common card network transactions, such as authorizations, reversals, and refunds. 

 

Setting up your account

  1. Begin by signing up for a Marqeta sandbox account
  2. Sign in to your sandbox account and set up two-step verification. 
  3. When prompted, create your API sandbox on the Marqeta platform by clicking Create sandbox.

reneemq_0-1697572861576.png

 

Once the sandbox is created, you will be redirected to the API keys page of the Marqeta Dashboard

The API keys page provides you with a sandbox URL and credentials (application token, admin access token) that you will use when communicating with the Marqeta platform to simulate requests on your sandbox. 

reneemq_1-1697572861541.png

 

 

Now follow the steps below to create other prerequisites you will need to simulate various kinds of transaction events in the sandbox environment. 

Creating a user

You can create a user by either running a cURL command or by using Postman.

reneemq_2-1697572861557.png

 

After running the cURL, you should see a response like this:

 

reneemq_3-1697572861529.png

 

 

Save the token generated in the response from the above POST call. This will be your user token, which you must supply later on in some calls to the Marqeta platform.

 

Creating a card product

The sandbox environment is provisioned with a card product called “Reloadable Card”. To create this kind of card, send a GET request to the /cardproducts endpoint and save the token returned in the response. This card product already has a funding type attached to it, so no extra steps are required to create a funding type or fund the card. 

 

reneemq_4-1697572861538.png

 

 

Save the token generated in the response from the above POST call. This will be your  card products token, which you must supply later on in some calls to the Marqeta platform.

 

Creating a card

Next, create a card by making a POST call to the /cards endpoint. In your call, supply the user token and card product token that you generated in the previous steps. 

 

reneemq_5-1697572861543.png

 

 

Save the token generated in the response from the above POST call. This will be your  card token, which you must supply later on in some calls to the Marqeta platform.

 

Simulating transactions

 

Now that you have created all these assets, you are ready to simulate various transaction events using the Marqeta platform's new Simulations 2.0 service. 

Try simulating an authorization event by sending a POST request to the /simulations/cardtransactions/authorization endpoint. Remember to add the card token you generated previously. 

 

reneemq_6-1697572861549.png

 

 

Your response will be similar to that shown below, with the transaction type, status, impacted balance, available balance, and other fields indicated.

 

reneemq_7-1697572861576.png

 

Adding a webhook

You can use webhooks to create and receive notifications for the transactions that take place in your sandbox environment. For example, when a card is used, a webhook is sent with details of the attempted transaction.

In a sandbox environment, there are two ways you can create, configure, and manage webhooks:

In order to receive and inspect the event notification, you must provide a URL that can accept the notification. Beeceptor provides a free online service that allows you to receive and inspect HTTP requests. To use this service, follow these steps:

  1. Go to Beeceptor, create an account, then create an endpoint for receiving requests
  2. Create a webhook endpoint to use with calls made from your sandbox. 
  3. Add the webhook to your sandbox in the URL field of the Webhooks page of the Marqeta Dashboard

 

 

reneemq_8-1697572861544.png

 

 

 

reneemq_9-1697572861530.png

 

Once you have created a webhook for your sandbox and you have subscribed to events, you are ready to simulate another authorization transaction, but this time with an associated webhook. The webhook you created instructs the Marqeta platform to push an event notification of the transaction to the URL you specify. This simulated transaction is initiated by an API call and will receive a response that is identical to the webhook notification. 

Simulate another request, as shown below, to try it out:

 

reneemq_10-1697572861549.png

 

This request simulates a transaction authorization and will trigger the webhook notification. At that point, you should see a response similar to the following:

 

reneemq_11-1697572861566.png

 

Postman Collection

Marqeta's Simulations 2.o service also provides Postman collections for the sandbox environment. You can download the Simulations 2.0 Postman collection file and import the OpenAPI YAML file in Postman using these steps:

  1. In Postman, select Import to open the Import window.
  2. Paste or drag-and-drop the downloaded Simulations 2.0 Postman collection file.
  3. Choose to import the file as a Postman Collection or as OpenAPI 3.0 with a Postman Collection.
  4. Select Import.

reneemq_12-1697572861558.png

 

To learn more about Simulations 2.0

With Simulations 2.0, you can simulate a wide range of transaction events to reliably test your application and shorten your development time. To learn more about Simulation 2.0, see Card Transactions,  Direct Deposits and Postman Collection on Marqeta Docs

 

Take a look at a recording of our Simulations 2.0 webinar here. 

 

Written by Anita Patel, Senior Software Engineer, Core Products at Marqeta. 

 

Developer Newsletter