Accept a payment with Link
This guide describes how to accept payments with Link by using the mobile Payment Element.
As Link expands to new countries, we’ll increase the number of funding sources customers can use to match local preferences.
Integrate Stripe’s prebuilt payment UI into the checkout of your iOS app with the PaymentSheet
class.
Clone a demo integration on GitHub.
Set up StripeServer-sideClient-side
First, you need a Stripe account. Register now.
Server-side
This integration requires endpoints on your server that communicate with the Stripe API. Use the Stripe official libraries for access to the Stripe API from your server.
Client-side
Link requires Stripe iOS SDK version 22.7.0 or newer.
The Stripe iOS SDK is open source, fully documented, and compatible with apps supporting iOS 13 or above.
For details on the latest SDK release and past versions, see the Releases page on GitHub. To receive notifications when a new release is published, watch releases for the repository.
When your app starts, configure the SDK with your Stripe publishable key so that it can make requests to the Stripe API.
Create a PaymentIntentServer-side
Instead of passing the entire PaymentIntent object to your app, only return its client secret. The PaymentIntent’s client secret is a unique key that lets you confirm the payment and update card details on the client, without allowing manipulation of sensitive information, like payment amount.
Integrate the mobile Payment ElementClient-side
Before displaying the mobile Payment Element, your checkout page should:
- Show the products being purchased and the total amount
- Collect any required shipping information using the Address Element
- Include a checkout button to present Stripe’s UI
Next, integrate Stripe’s prebuilt payment UI into your app’s checkout with the PaymentSheet
class.
If PaymentSheetResult
is .completed
, inform the user (for example, by displaying an order confirmation screen).
Handle customer logoutClient-side
PaymentSheet
stores some cookies locally to remember the customer across sessions. For example, they’re used when a customer signs into their Link account. These cookies must be deleted if the customer signs out of your app. When that happens, call the PaymentSheet.resetCustomer()
method, and the Stripe SDK will clear the internal state of PaymentSheet
.
import UIKit import StripePaymentSheet class MyViewController: UIViewController { @objc func didTapLogoutButton() { PaymentSheet.resetCustomer() // Other logout logic required by your app } }
Test the integration
Don’t store real user data in test mode Link accounts. Treat them as if they’re publicly available, because these test accounts are associated with your publishable key.
Currently Link only works with credit cards, debit cards, and US bank accounts (for qualifying purchases). To give your customers more payment options at checkout, Stripe is working to add additional funding sources to Link. Periodically test your checkout flow to confirm the look and feel of your payments page is what you expect.
You can create test mode accounts for Link using any valid email address. The following table shows the fixed one-time passcode values that Stripe accepts for authenticating test mode accounts:
Value | Outcome |
---|---|
any other 6 digits not listed below | Success |
000001 | Error, code invalid |
000002 | Error, code expired |
000003 | Error, max attempts exceeded |
For testing specific payment methods, refer to the Payment Element testing examples.
Multiple funding sources
Currently, Link only works with credit cards, debit cards, and US bank accounts for qualifying purchases. But as Stripe adds additional funding sources, Link automatically supports them with instant confirmation for your company’s payments, and the same transaction settlement timeline and guarantees as cards and bank account-funded payments. This adaptive support means that you don’t need to update your integration to let your customers save and reuse their preferred payment method on your domain.
To test that your integration can handle additional funding sources, provide an email in the form of {any_prefix}+multiple_funding_sources@{any_domain}
when you’re testing your check out flow with Link.
Card authentication and 3D Secure
Link supports 3D Secure (3DS) authentication for card payments. 3DS requires customers to complete an additional verification step with the card issuer when paying. Payments that have been successfully authenticated using 3D Secure are covered by a liability shift.
To trigger 3DS authentication challenge flows with Link in test mode, use the following test card with any CVC, postal code, and future expiration date:
In test mode, the authentication process displays a mock authentication page. On that page, you can either authorize or cancel the payment. Authorizing the payment simulates successful authentication and redirects you to the specified return URL. Clicking the Failure button simulates an unsuccessful attempt at authentication.
For more details, refer to the 3D Secure authentication page.
See also
When you’ve finished your integration, you might want to check out these other resources.