Take a Gift Card Payment
Learn how to add a payment method to the application you built using the quickstart project sample in Take a Card Payment with the Web Payments SDK to integrate the Web Payments SDK into your application.
The steps in this topic add code to the application you created from the quickstart project sample. If you haven't created an application using the quickstart, you need to do so before completing the following steps.
You can find the complete quickstart example on GitHub.
The following code attaches the GiftCard method to the page:
Add the following gift card HTML elements to the prerequisite walkthrough form:
Add an
initializeGiftCard
function below theinitializeCard
function in the<script>
tag.In the
DOMContentLoaded eventListener
, add the following code after you initialize theGiftCard
payment method:
Test the application
Navigate to http://localhost:3000/ in your browser.
Success
You see the gift card form rendered on your page.
Add the following code after the
// Checkpoint 2
in theDOMContentLoaded eventListener
function:Update the
handlePaymentMethodSubmission
function to disable thegiftCardButton
when tokenizing and re-enable on a failed payment.
Test the application
Navigate to http://localhost:3000/ in your browser.
Choose the Pay with Gift Card button.
Success
Using the test gift card number (7783 3200 0000 0000), you can complete a payment.
If you need more assistance, contact Developer Support or ask for help in the Developer Forums.