{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-docs/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["admonition"]},"type":"markdown"},"seo":{"title":"Accept Apple Pay on iOS","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"accept-apple-pay-on-ios","__idx":0},"children":["Accept Apple Pay on iOS"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If you have a native iOS App you can use Tyro Apple Pay SDK to easily accept Apple Pay payments."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"prerequisites","__idx":1},"children":["Prerequisites"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Please familiarise yourself with the guide to ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/online-payments/pay-online/integration-guide/tyro-js"},"children":["Accept an Online Payment"]},", as the steps outlined in this document builds upon the existing knowledge."]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"warning","name":"Warning"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Tyro Apple Pay SDK is internally configured to hit different environments based on your building mode"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["DEBUG: sandbox"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["RELEASE: production"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"integration-steps","__idx":2},"children":["Integration Steps"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"1-configure-your-ios-app","__idx":3},"children":["1. Configure Your iOS App"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Make sure your app is running iOS 16+"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"2-add-tyro-apple-pay-sdk","__idx":4},"children":["2. Add Tyro Apple Pay SDK"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The SDK has been developed as a Swift Package and it is hosted on Github. Open the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/tyro/tyro-pay-api-ios"},"children":["Tyro Pay Api iOS"]}," and follow the step to add it to your project."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"3-add-the-apple-pay-button","__idx":5},"children":["3. Add The Apple Pay Button"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Follow ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://developer.apple.com/design/human-interface-guidelines/apple-pay"},"children":["Apple's guidelines"]}," to add the Apple Pay button to your App's UI."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"4-create-a-tyroapplepay","__idx":6},"children":["4. Create a TyroApplePay"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Create an instance of the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TyroApplePay"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Provide the configuration which includes the merchant identifier you should have previously setup on the Apple developer center."]}]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"Info"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Click ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://developer.apple.com/documentation/passkit_apple_pay_and_wallet/apple_pay/setting_up_apple_pay"},"children":["here"]}," for help setting up your merchant id"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"swift","header":{"controls":{"copy":{}}},"source":"// Swift Sample Code\nlet tyroApplePay = TyroApplePay(config: TyroApplePay.Configuration(\n  merchantIdentifier: \"merchant.tyro-pay-api-sample-app\", // Your merchant id registered for the app on apple developer center\n  allowedCardNetworks: [.visa, .masterCard]\n), layout: TyroApplePay.Layout(\n  totalLabel: \"MerchantName\"\n))\n","lang":"swift"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"5-verify-if-apple-pay-is-available-for-user","__idx":7},"children":["5. Verify if Apple Pay is available for user"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Before you display the Apple Pay button, use the available static methods ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["isApplePayAvailable"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["canSetupCard"]}," to determine if Apple Pay is available for the user."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"swift","header":{"controls":{"copy":{}}},"source":"if TyroApplePay.isApplePayAvailable() {\n  ...\n}\n","lang":"swift"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["or"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"swift","header":{"controls":{"copy":{}}},"source":"if TyroApplePay.canSetupCard([.visa, .masterCard]) {\n  ...\n}\n","lang":"swift"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"6-include-the-paywithapplepaybutton-trigger-the-payment-and-handle-the-results","__idx":8},"children":["6. Include the PayWithApplePayButton, trigger the payment and handle the results"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Obtain the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["paySecret"]}," by creating a PayRequest from your server."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Invoke ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tyroApplePay.startPayment(paySecret: paySecret)"]}," to start Apple Pay."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Handle the results"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"swift","header":{"controls":{"copy":{}}},"source":"// Swift Sample Code\n...\nPayWithApplePayButton {\n  Task.detached { @MainActor in\n    do {\n      let result = try await tyroApplePay.startPayment(paySecret: paySecret)\n\n      switch result {\n      case .cancelled:\n        print(\"ApplePay cancelled\")\n      case .success:\n        print(\"payment successful\")\n      }\n    } catch is TyroApplePayError {\n      print(\"payment failed\")\n    }\n  }\n}\n...\n","lang":"swift"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"error-cases","__idx":9},"children":["Error Cases"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"tyroapplepayerror","__idx":10},"children":["TyroApplePayError"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Error"},"children":["Error"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[".applePayNotReady"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Thrown in case Apple Pay is not ready for the user."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[".failedWith(Error)"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Thrown to handle errors coming from the Apple Pay API."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[".invalidPayRequestStatus"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Thrown when the Pay Request Status validation fails. Valid pay request statuses are: AwaitingPaymentInput, AwaitingAuthentication, Failed."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[".unableToFetchPayRequest"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Thrown when unable to fetch Pay Request."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[".payRequestNotFound"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Throw when unable to find a pay request for the provided pay secret."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[".payRequestFailed"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Thrown when pay request failed."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[".payRequestTimeout"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Thrown when the returned pay request is still processing."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[".unknown"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Thrown when pay request is in an unknown status."]}]}]}]}]}]},"headings":[{"value":"Accept Apple Pay on iOS","id":"accept-apple-pay-on-ios","depth":1},{"value":"Prerequisites","id":"prerequisites","depth":2},{"value":"Integration Steps","id":"integration-steps","depth":2},{"value":"1. Configure Your iOS App","id":"1-configure-your-ios-app","depth":3},{"value":"2. Add Tyro Apple Pay SDK","id":"2-add-tyro-apple-pay-sdk","depth":3},{"value":"3. Add The Apple Pay Button","id":"3-add-the-apple-pay-button","depth":3},{"value":"4. Create a TyroApplePay","id":"4-create-a-tyroapplepay","depth":3},{"value":"5. Verify if Apple Pay is available for user","id":"5-verify-if-apple-pay-is-available-for-user","depth":3},{"value":"6. Include the PayWithApplePayButton, trigger the payment and handle the results","id":"6-include-the-paywithapplepaybutton-trigger-the-payment-and-handle-the-results","depth":3},{"value":"Error Cases","id":"error-cases","depth":2},{"value":"TyroApplePayError","id":"tyroapplepayerror","depth":3}],"frontmatter":{"title":"Accept Apple Pay on iOS","seo":{"title":"Accept Apple Pay on iOS"}},"lastModified":"2026-09-01T06:34:43.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/docs/online-payments/pay-online/integration-guide/apple-pay","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}