Streaming is available in most browsers,
and in the WWDC app.
What's new in Wallet and Apple Pay
Discover the redesigned Apple Pay for in-app and web payments and learn how you can incorporate the latest APIs into your app or website. Learn how to add features to your app like coupon codes, improved shipping information, and improvements to the payment detail display screen. And explore changes to Wallet passes, including auto-expiry and multi-pass support for the web.
- Apple Pay on the Web
- Apple Pay on the Web Interactive Demo
- Distributing and updating a pass
- Have a question? Ask with tag wwdc21-10092
- Offering Apple Pay in Your App
- PassKit (Apple Pay and Wallet)
- Search the forums for tag wwdc21-10092
With these simple changes, I can build my app and check out the new shipping methods in the payment sheet. A new row has automatically been added to the payment sheet showing the shipping methods. If I tap the row I'll see both shipping methods that were just added, including the one that supports date ranges. I've also decided that for the festival this year I want to send out coupon codes to all my attendees and add the functionality to redeem them directly through the payment sheet in my app. To do this, there are two main changes that I need to make. Let's head back into the code. The first is when building the PKPaymentRequest. There is a new boolean, supportsCouponCode, that needs to be set to true. There also is a new optional property, couponCode, that you can set on your PKPaymentRequest to prepopulate the coupon field with one of your already valid coupon codes. Next, let's jump down to my class extension that conforms to the PKPaymentAuthorization ControllerDelegate and implement the new protocol method paymentAuthorizationController didChangeCouponCode where I will be able to handle updating my summary items and display errors related to the coupon code entry when a coupon code is entered. The first thing I'm going to need is a helper function that updates our PKPaymentSummaryItems if a valid coupon code is entered. I grab a reference to the first summary item which is our subtotal item. From there, I create a new PKPaymentSummaryItem that lets the user see the discount that was applied. I then create a new summary item for tax and total, and then return the array of them. Now that I have my discount application logic written, I can then write my coupon code validation logic. I first check if my coupon code that the user entered was empty and if it is, just call our completion passing in the unmodified payment summary items. If the entered coupon code matches a valid coupon code, then I use the just created applyDiscount function to return the updated summary items into our CouponCodeUpdate object. For your apps, you'll most likely need to be fetching valid coupon codes from your server at this point. Finally, if the entered coupon code was invalid, I use the new PKPaymentRequest convenience initializer, paymentCouponCodeInvalidError, and supply it a description to be shown directly in the payment sheet. We also have a second convenience initializer for expired coupon codes: paymentCouponCodeExpired ErrorWithLocalizedDescription. I then pass this error into our coupon code update initializer as well as the original SummaryItems. Just like that, I've added support for coupon codes inside my app. Let's check it out. To enter a coupon code, I just need to tap into the summary view and enter a coupon code into the coupon code text field. If I first enter an invalid coupon code, Fest, the error message I supplied is shown directly below the text field. Now if I enter a valid coupon code, FESTIVAL, the payment summary items are immediately updated. Then I just need to select the shipping contact as well as shipping address and my payment request is ready to go.
Looking for something specific? Enter a topic above and jump straight to the good stuff.
An error occurred when submitting your query. Please check your Internet connection and try again.