Using the Add Payment Card Widget (Beta)
Note
This feature is currently in beta and subject to change. To learn more about the Beta program for this feature, contact your Marqeta representative.Marqeta provides a customizable Add Payment Card widget that you can integrate with your website or mobile application as part of a disbursement solution. This widget allows users to enter information—such as the card number and cardholder name—about a payment card that was not issued by Marqeta. The widget then validates and delivers these details to the Marqeta platform. Your end user can push funds to the card as a Push-to-Card disbursement using your web or mobile application.
You can embed the Add Payment Card widget inline as an iframe in your web applications. The widget complies with the Payment Card Industry Data Security Standard (PCI DSS), which defines the security and protocol standards for organizations that store, transmit, or process card data. If you have already obtained PCI Compliance certification, using this widget in your web applications is optional.
At the end of this guide, you should understand:
-
What the Add Payment Card widget is and when you need to use it.
-
How to create a customized Add Payment Card widget to integrate with your web application.
-
How the input to the widget is validated.
Note
The Add Payment Card widget reduces your burden of achieving data security compliance by providing a PCI-compliant way to allow end users to perform certain actions; however, you have additional responsibilities regarding data security for other elements of your end-user experience. Contact your Marqeta representative for details.
Associated endpoints
Copy section link
To add a payment card to the Marqeta platform without using the Add Payment Card widget, use the following endpoint and method:
-
POST
/pushtocards/paymentcard
For more information, see the Create Push-to-Card payment card API reference.
Prerequisites
Copy section link
-
Read the Core API Quick Start.
-
Have a parent web application in which to integrate the widget. This application must use HTTPS.
Concepts
Copy section link
Data security compliance
Copy section link
You must comply with PCI DSS data security requirements if you want to store, transmit, or process sensitive card data such as the cardholder’s primary account number (PAN), personal identification number (PIN), and card expiration date. The process of becoming PCI DSS certified to store, transmit, and process such data directly is both time consuming and expensive. The Add Payment Card widget handles the encrypted transmission of sensitive card data, and can help you comply with some aspects of the PCI compliance burden. Marqeta is PCI-Level 1 compliant, and securely handles the unencrypted, sensitive card data.
Push-to-Card disbursements
Copy section link
The Add Payment Card widget enables end users to add cards not issued by Marqeta to the Marqeta platform. After you have added a card using the Add Payment Card widget, you can create Push-to-Card disbursements. A Push-to-Card disbursement is an original credit transaction (OCT) that enables end users to draw funds from your Push-to-Card funding reserve balance and send them in near real time to an external, non-Marqeta payment card. These disbursements are not linked to any purchase.
Note
The Add Payment Card widget does not allow your end user to disburse funds to a payment card. The end user must complete this task using your parent application.
Widget implementation
Copy section link
The Add Payment Card widget is a customizable iframe that enables the end user to provide sensitive data to the Marqeta platform. When you embed a widget in your application, your servers never store, transmit, or process the data so you are not required to be PCI DSS compliant. Embed the iframe in the parent page of your web application where you want the functionality of the widget to occur. You configure the iframe by passing query parameters in the iframe’s source URL, then the Marqeta platform processes the iframe.
Tip
Embed the iframe using a web element when adding the widget to a mobile application. This applies to both Android and iOS.Your parent web application should render the Add Payment Card widget after the end user chooses to add a new payment card from a page in the parent web application. Each time the end user adds a new payment card to the Marqeta platform using the Add Payment Card widget, the parent website must render a new instance of the Add Payment Card widget. The Add Payment Card widget validates the end user’s input, then displays a success message after adding the new payment card to the Marqeta platform.
The Add Payment Card widget applies to many use cases. For example, a contracting company that needs an alternative method to pay their non-exempt employees might use this widget to enable these employees to identify a non-Marqeta debit card as their preferred method of payment.
Warning
Your application must provide a login method to authenticate the end user. Widgets do not provide user authentication; they only validate that the user-entered data matches the data on the Marqeta platform.
Widget customization
Copy section link
Before integrating widgets into your application, you must submit your customized style attributes to Marqeta. Marqeta provides the Marqeta Widget Style Preview page as a testing ground for you to determine how you want your widgets to look.
The following styles are customizable:
Style Category | Attributes and Values |
---|---|
Global styles |
|
Form labels |
|
Headers |
|
Button styles |
|
Error message styles |
Errors are displayed either above the widget in a flash-message style list or underneath the input boxes to which they apply.
|
iframe size |
|
Any global styles you define are overridden by more specific style category declarations. For example, if you define a font stack in both the Global Styles category and the Button Styles category, the fonts of the Button Styles stack will apply to the buttons. Other styles are unaffected by this declaration.
iframe parameters
Copy section link
The Add Payment Card widget is accessible from base URLs for both the private sandbox and production environments.
Depending on your environment, use one of the following base URLs as the source of the iframe:
Environment | Widget | Base URL |
---|---|---|
Sandbox |
Add Payment Card |
|
Production |
Add Payment Card |
Using query parameters, you can customize the message displayed upon successful completion of the widget’s task.
Build your iframe content for the widget by adding the appropriate query parameters:
Fields | Description |
---|---|
application_id
string
|
The application ID for use with widgets, obtained from Marqeta in Step 2. NOTE: This value is not required when calling endpoints related to the Marqeta.js JavaScript library such as Allowable Values: A valid application ID. |
one_time_token
string
|
User’s one-time authentication token, generated via Allowable Values: A valid one-time authentication token. |
user_token
string
|
Existing user token.
Send a Allowable Values: A valid user token. |
success_url
string
|
HTTPS URL of the page that is loaded in the iframe upon successful completion. The When calling a widget in an iframe, make sure the page provided does not set the X-Frame-Options to If the Allowable Values: A valid URL. |
display_headers
boolean
|
If set to Allowable Values:
Default value: |
Validation and error handling
Copy section link
The one-time user authentication token you create expires 120 minutes from when the widget appears on-screen. The end user must complete the widget’s task during this period.
After the end user enters the payment card data in the Add Payment Card widget and selects Submit, the widget performs a number of validations before sending the data to Marqeta’s servers.
Field Name | Required? | Validations |
---|---|---|
Name on card |
Required |
|
Card number |
Required |
WARNING: Not all cards are eligible for OCT disbursements. The widget will inform the end user if the card number entered cannot receive funds this way. |
CVV |
Required |
|
Expiration date |
Required |
|
Street address |
Required |
|
City |
Required |
|
State |
Required |
|
Postal code |
Required |
|
The Add Payment Card widget allows the end user to make up to five attempts to submit the widget. After reaching five attempts, the widget displays an error message and must be rendered again with a new one-time authentication token. The end user must re-enter the payment card details because the input in the widget is not retained.
Warning
There is no way for the widget to inform the parent web page in the event of an error. If the widget encounters an error, the end user must refresh the parent web page. Consider providing instructions to the end user on how to do this.
Tutorial
Copy section link
This tutorial shows you how to customize the Add Payment Card widget and integrate it with a web application in your private sandbox environment.
To customize the Add Payment Card widget for a production environment, see the Samples section below.
Step 1 — Define the widget style attributes
Copy section link
Go to the Marqeta Widget Style Preview page to configure and preview the widget’s styles. Choose attributes that match your web application. Send the finalized styles to Marqeta for implementation when you are ready to integrate a widget into your production environment.
Step 2 — Obtain an application ID from Marqeta
Copy section link
Contact your Marqeta representative to obtain an application ID, which is a value used specifically for embedding the Add Payment Card widget. This value is typically provided when you begin working with Marqeta.
Step 3 — Obtain a user token
Copy section link
Obtain an existing user token by sending a GET
request to /users
.
Note
If you were using the Add Payment Card widget in a production scenario, this token would be the user token of whatever user is logged into your application.
Step 4 — Generate a one-time user authentication token
Copy section link
Configure your application to send a POST
request to /users/auth/onetime
to generate a one-time user authentication token for the logged-in user.
The single-use access token you create for the logged-in user is valid for one request only, and expires five minutes after it is generated.
See the Return single-use token section of the Users page for more information about this endpoint.
The following is an example of a cURL request that generates a one-time user authentication token:
Warning
After the one-time token is redeemed to render the parent web page, it cannot be reused. If the widget times out or the parent web page is refreshed by the end user, a new one-time token must be generated and passed to the iframe.
Step 5 — Add query parameters to the iframe
Copy section link
Build the iframe content for the widget by adding the appropriate query parameters from the table in the "iframe parameters" section.
Step 6 — Embed the iframe in the parent website
Copy section link
Embed the iframe in the parent website, using the following as the iframe’s source: https://widgets-sandbox.marqeta.com/add_payment_card. Since the iframe is requesting an HTTPS domain, the parent website URL must also use the HTTPS protocol.
When completed, the HTML for the iframe should resemble the following:
<iframe src="https://widgets-sandbox.marqeta.com/add_payment_card?one_time_token=11111111-1111-1111-1111-111111111111&user_token=22222222-2222-2222-2222-222222222222&application_id=33333333-3333-3333-3333-333333333333&success_url=https://yoursite.com/success_widget.html&display_headers=false"></iframe>
Samples
Copy section link
Below is another iframe you can create by following the tutorial’s steps. In this sample, a success URL is specified and the headers are disabled. The base URL reflects that the iframe is used in a production environment.
Add Payment Card widget, production environment
Copy section link
<iframe src="https://widgets.marqeta.com/add_payment_card?one_time_token=11111111-1111-1111-1111-111111111111&user_token=22222222-2222-2222-2222-222222222222&application_id=33333333-3333-3333-3333-333333333333&success_url=https://yoursite.com/success_widget.html&display_headers=false">