Getting Started with Visa Developer
First time to the Visa Developer Center? Watch this tutorial to learn where to find the Visa APIs th...
By Ahmed Siddiqui, VP of Product Management at Marqeta
The Smart City of the future offers ample challenges. Take mass transit systems, for example. They can get us most of the way from our homes to our destinations, but typically not all the way. Ride sharing companies step in to solve this last mile problem. The transit system and the ride sharing companies operate independently but, for consumers, they are definitely dependent. In a future smart city, we should be able to create the connection for consumers between the two independent systems. Wouldn’t it be great if my transit card rewarded me with credits at a ride sharing company or whatever other means of last mile transportation I use?
Mass transit systems typically operate on proprietary, “closed-loop” systems like the Clipper Card in the San Francisco Bay Area. These transit cards hold a monetary value that can only be spent for transit, and for nothing else, forcing you to have a piece of plastic in your wallet that only serves one purpose. These proprietary systems are contactless in most cases. Why do you need a physical card at all when most modern smartphones have NFC capability? How can we make the transit card truly digital and also be considered a “top-of-wallet” product?
Visa’s Offers API allows us to create offers based off of some spend. For example, you take 5 BART rides, and then you get a $10 transit reward. The Marqeta platform enables you to create virtual cards that you can add to Apple Pay. Marqeta also enables you to control the spend behavior so these offers or rewards can only be spent at specific locations or for specific purposes (like transit).
In the following example, code snippets illustrate how to interact with the Marqeta API. When you are ready to start exploring the API, be sure to modify these snippets to use your own authentication credentials, and be sure to replace all the example tokens with your own, unique values. You can also leave out the token field, and the system will automatically generate a unique token for each new object.
Note: Do not use the same tokens as in these examples. If an object with the same token already exists, the system will handle the request as a duplicate, and your request will not take effect.
--user application_token:master_access_token
curl -i -X POST \ -H 'Content-type: application/json' \ --user application_token:master_access_token \ -d '{ "start_date": "2017-10-21", "token": "SC-DTR-CardProduct", "name": "Smarter City Digital Transit Reward", "config": { "fulfillment": { "payment_instrument": "VIRTUAL_PAN" }, "poi": { "ecommerce": true }, "card_life_cycle": { "activate_upon_issue": true }, "digital_wallet_tokenization": { "provisioning_controls": { "in_app_provisioning": { "enabled": true }, "wallet_provider_card_on_file": { "enabled": true } } } } }' \ 'https://shared-sandbox-api.marqeta.com/v3/cardproducts'
curl -i -X POST \ -H 'Content-type: application/json' \ --user application_token:master_access_token \ -d '{ "token": "SC-DTR-ProgramFundingSource", "name": "SC-DTR-ProgramFundingSource" }' \ 'https://shared-sandbox-api.marqeta.com/v3/fundingsources/program'
curl -i -X POST \ -H 'Content-type: application/json' \ --user application_token:master_access_token \ -d '{ "token": "SC-DTR-TestUser" }' \ 'https://shared-sandbox-api.marqeta.com/v3/users'
curl -i -X POST \ -H 'Content-type: application/json' \ --user application_token:master_access_token \ -d '{ "user_token": "SC-DTR-TestUser", "card_product_token": "SC-DTR-CardProduct", "token": "SC-DTR-TestCard" }' \ 'https://shared-sandbox-api.marqeta.com/v3/cards'
curl -i -X POST \ -H 'Content-type: application/json' \ --user application_token:master_access_token \ -d '{ "user_token": "SC-DTR-TestUser", "amount": "100", "currency_code": "USD", "funding_source_token": "SC-DTR-ProgramFundingSource" }' \ 'https://shared-sandbox-api.marqeta.com/v3/gpaorders'
To demonstrate your Smarter City card in action, you can write a routine that simulates transactions with your test virtual card. Include a counter that increments every time a transaction runs against a fictitious “BART” merchant ID number (mid). When the counter reaches 5, send a request to Visa Offers API to create a ride sharing credit of $10 and then reset the counter to 0.
For example, to simulate transactions at a “BART” merchant with the Marqeta API:
curl -i -X POST \ -H 'Content-type: application/json' \ --user application_token:master_access_token \ -d '{ "amount": "10", "mid": "SC-DTR-BART-Test", "card_token": "SC-DTR-TestCard" }' \ 'https://shared-sandbox-api.marqeta.com/v3/simulate/authorization'
Link: https://www.marqeta.com/api/docs/VhyrNBwAAB0A_WDD/testing
Adding Cards to Apple Pay
With Marqeta's instant issuance feature, you could build a mobile application that both creates the Smarter City Digital Transit Reward virtual card and automatically adds it to an Apple Pay digital wallet on the user’s device.
To add a card to Apple Pay, it must first be tokenized—which is a process that replaces sensitive card data with a token that serves as a reference to the card. You can use the Marqeta API to retrieve the encrypted card data.
curl -i -X POST \ -H 'Content-type: application/json' \ --user application_token:master_access_token \ -d '{ "card_token": "SC-DTR-TestCard", "device_type": "MOBILE_PHONE", "provisioning_app_version": "1.0.0", "certificates": [ "MIIEPDCCA+ =", "MIIDZjCCAw2gAwI==" ], "nonce": "vXWJaBidcTLaJJCF", "nonce_signature": "jD4Aphu+93N2wbBn" }' \ 'https://shared-sandbox-api.marqeta.com/v3/digitalwalletprovisionrequests/applepay'
At this point, you’ll need to integrate with the Apple Pay API. You’ll send the encrypted card data to Apple Pay, and Apple Pay will request a token from the network. After the card network issues the token, Apple Pay stores it on the user’s device, and the card holder can use it to spend their reward credits on a ride sharing app.
Link: (with Apple Pay-specific endpoint used in the code snippet): https://www.marqeta.com/api/docs/WEB4zykAAKUpdPTF/digital-wallets-management
By adding a virtual card directly to a digital wallet, like Apple Pay, you can effectively bypass the need for a proprietary piece of plastic and allow the card holder to use a mobile device as an all-in-one transit card.
Let’s build a smarter transit system for the Smarter City together!
Ahmed Siddiqui is VP of Product Management at Marqeta, the first modern card issuing and core processing platform, powering prepaid, debit and credit cards for the world’s top commerce innovators. He can be reached on Twitter @siddiquiahmed
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
First time to the Visa Developer Center? Watch this tutorial to learn where to find the Visa APIs th...
Watch the recording of my How to Run a Visa Direct Transaction using Python webinar as you follow al...
Learn how to create a project and where to find test data, credentials and sample code. Leave a comm...
We feel that the Visa Developer Center has come full circle since launch in 2016. It hosts many APIs...