{"id":13749711,"url":"https://github.com/hansemannn/titanium-apple-pay","last_synced_at":"2025-07-25T23:09:20.391Z","repository":{"id":142791316,"uuid":"46838505","full_name":"hansemannn/titanium-apple-pay","owner":"hansemannn","description":"💰 Support for iOS Apple Pay in Titanium","archived":false,"fork":false,"pushed_at":"2023-07-26T13:32:27.000Z","size":51507,"stargazers_count":13,"open_issues_count":2,"forks_count":6,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-29T01:12:15.341Z","etag":null,"topics":["apple-pay","ios","javascript","native","titanium"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hansemannn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"hansemannn"}},"created_at":"2015-11-25T05:00:28.000Z","updated_at":"2024-03-04T03:00:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"fc5db7d2-2afa-4bc6-a233-2749683237c9","html_url":"https://github.com/hansemannn/titanium-apple-pay","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansemannn%2Ftitanium-apple-pay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansemannn%2Ftitanium-apple-pay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansemannn%2Ftitanium-apple-pay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansemannn%2Ftitanium-apple-pay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hansemannn","download_url":"https://codeload.github.com/hansemannn/titanium-apple-pay/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249152560,"owners_count":21221273,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apple-pay","ios","javascript","native","titanium"],"created_at":"2024-08-03T07:01:10.656Z","updated_at":"2025-04-15T20:45:12.475Z","avatar_url":"https://github.com/hansemannn.png","language":"Objective-C","funding_links":["https://github.com/sponsors/hansemannn"],"categories":["Objective-C"],"sub_categories":[],"readme":"# Apple Pay in Appcelerator Titanium\n[![Build Status](https://travis-ci.org/hansemannn/titanium-apple-pay.svg?branch=master)](https://travis-ci.org/hansemannn/titanium-apple-pay) [![License](http://hans-knoechel.de/shields/shield-license.svg?v=2)](./LICENSE)  [![Contact](http://hans-knoechel.de/shields/shield-twitter.svg?v=2)](http://twitter.com/hansemannnn)\n\n\u003cimg src=\"assets/titanium-apple-pay.png\" width=\"900\" alt=\"Titanium Apple Pay\" /\u003e\n\n## Summary\nThis module provides access to the native iOS Apply Pay PassKit Framework. Using this module, you can \neasily accept Apple Pay payments using Titanium Mobile. The currently supported payment gateways are [Stripe](https://stripe.com)\nand [Braintree](https://braintreepayments.com), which are recommended by Apple to process payments easily.\n\n## Features\nThe following features are covered:\n- [x] Payment Button\n- [x] Payment Request\n- [x] Payment Dialog\n- [x] Payment backend-gateway using Stripe\n- [x] **All** latest API's, up to iOS 12\n\n## Requirements\n- [x] Titanium Mobile SDK 7.1.1+\n- [x] Xcode 9 or later\n- [x] iOS 9 or later\n\n## Setup\nUnpack the module and place it inside the /modules/iphone folder of your project. \nEdit the modules section of your tiapp.xml file to include this module:\n```xml\n\u003cmodules\u003e\n    \u003cmodule platform=\"iphone\"\u003eti.applepay\u003c/module\u003e\n\u003c/modules\u003e\n```\n\nAfter that, you create an instance of the module by requiring it:\n```js\nvar ApplePay = require('ti.applepay');\n```\n\nBefore you can start using the many different API's, you need to configure the module \nby providing a Stripe / Braintree API-Key (from here). The gateways are determined using constants\nto keep the module open for more payment gateways added in feature releases. \nThe configuration looks like this:\n```js\nApplePay.setupPaymentGateway({\n  name: ApplePay.PAYMENT_GATEWAY_STRIPE, // or: ApplePay.PAYMENT_GATEWAY_BRAINTREE\n  apiKey: '\u003cYOUR_STRIPE_OR_BRAINTREE_API_KEY\u003e'\n});\n```\nYou also need the Entitlements.plist with the merchant group's you want to assign. \nA full tutorial on how to setup the merchant ID's in the developer center can be found [here](https://github.com/hansemannn/applepaydemo).\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003c!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"\u003e\n\u003cplist version=\"1.0\"\u003e\n\u003cdict\u003e\n\t\u003ckey\u003ecom.apple.developer.in-app-payments\u003c/key\u003e\n\t\u003carray\u003e\n\t\t\u003cstring\u003emerchant.de.hansknoechel.paydemo.stripe\u003c/string\u003e\n\t\t\u003cstring\u003emerchant.de.hansknoechel.paydemo.braintree\u003c/string\u003e\n\t\t\u003cstring\u003emerchant.de.hansknoechel.paydemo.chase\u003c/string\u003e\n\t\u003c/array\u003e\n\u003c/dict\u003e\n\u003c/plist\u003e\n```\n\n(Optionally), you can create an 'Apple Pay styled' button by providing the type and style:\n```js\nvar payButton = ApplePay.createPaymentButton({\n    type: ApplePay.PAYMENT_BUTTON_TYPE_BUY,\n    style: ApplePay.PAYMENT_BUTTON_STYLE_WHITE_OUTLINE\n});\npayButton.addEventListener('click', openPaymentDialog);\n```\n\nMake sure to check if ApplePay is set-up by using the `ApplePay.canMakePayments(args)` method or \ndisplay the `ApplePay.openPaymentSetup()`  to let the user setup new cards. Now you're able to setup \nthe payment request using `ApplePay.createPaymentRequest(args)`:\n```js\nvar paymentRequest = ApplePay.createPaymentRequest({\n    merchantIdentifier: 'merchant.com.company.appname',\n    merchantCapabilities: ApplePay.MERCHANT_CAPABILITY_3DS | ApplePay.MERCHANT_CAPABILITY_CREDIT | ApplePay.MERCHANT_CAPABILITY_DEBIT | ApplePay.MERCHANT_CAPABILITY_EMV,\n    countryCode: 'US',\n    currencyCode: 'USD',\n    billingContact: contact,\n    shippingContact: contact,\n    supportedNetworks: [ApplePay.PAYMENT_NETWORK_VISA, ApplePay.PAYMENT_NETWORK_MASTERCARD],\n    requiredShippingAddressFields: ApplePay.ADDRESS_FIELD_POSTAL_ADDRESS,\n    requiredBillingAddressFields: ApplePay.ADDRESS_FIELD_POSTAL_ADDRESS,\n    shippingType: ApplePay.SHIPPING_TYPE_DELIVERY,\n    shippingMethods: shippingMethods,\n    summaryItems: summaryItems,\n    applicationData: {\n        userId: 1337\n    }\n});\n```\n\nAlthough most properties are self-describing, you can find all properties in the official \nApple documentation as well, in addition to the detailed code documentation following in \nthe next chapter.\n\nTo actually show the payment dialog, you can use the ApplePay.createPaymentDialog method:\n```js\nvar paymentDialog = ApplePay.createPaymentDialog({\n    paymentRequest: paymentRequest\n});\npaymentDialog.show();\n```\n\nThere are a couple of payment events you need to implement to respond to changes made in \nthe payment dialog and to finish a payment:\n```js\npaymentDialog.addEventListener('didSelectPayment', didSelectPayment);\npaymentDialog.addEventListener('didSelectShippingContact', didSelectShippingContact);\npaymentDialog.addEventListener('didSelectShippingMethod', didSelectShippingMethod);\npaymentDialog.addEventListener('willAuthorizePayment', didAuthorizePayment);\npaymentDialog.addEventListener('didAuthorizePayment', willAuthorizePayment);\npaymentDialog.addEventListener('close', willClose);\n\nfunction didSelectPayment(e) {\n    e.handler.complete(paymentRequest.summaryItems);\n}\n\nfunction didSelectShippingContact(e) {\n    e.handler.complete(ApplePay.PAYMENT_AUTHORIZATION_STATUS_SUCCESS, paymentRequest.shippingMethods, paymentRequest.summaryItems);\n}\n\nfunction didSelectShippingMethod(e) {\n    e.handler.complete(ApplePay.PAYMENT_AUTHORIZATION_STATUS_SUCCESS, paymentRequest.summaryItems);\n}\n\nfunction willAuthorizePayment() {\n  // Do amazing stuff here, before the payment is authorized.\n}\n\nfunction didAuthorizePayment(e) {\n    // ... Send the encrypted payment data to your backend\n    Ti.API.info('Payment successfully authorized: ' + e.success);\n    \n    e.handler.complete(ApplePay.PAYMENT_AUTHORIZATION_STATUS_SUCCESS);\n}\n```\n\nThe handler needs to call complete to tell the payment dialog to continue processing. For example, \nyou can change the shipping costs depending on the selected shipping contact or decline a payment \nif your backend could not be reached. \n\nThis makes the module as flexible as it needs to be to \nhandle even advanced payments. An example of using the module in a real-world-application can be \nfound in `example/app.js`.\n\n## API Documentation\n\n### PaymentRequest\nA payment request is initialized using the `ApplePay.createPaymentRequest method.\n\n#### Properties\n\n- (`String`) merchantIdentifier: Your merchant identifier, e.g. `merchant.com.company.app`.\n- (`Number`) merchantCapabilities: A bit field of the payment processing constants (`MERCHANT_CAPABILITY_*`) you support.\n- (`String`) countryCode: The two-letter ISO 3166 country code, e.g. `US`.\n- (`String`) currencyCode: The three-letter ISO 4217 currency code, e.g. `USD`.\n- (`Object`) billingContact: An object representing a billing contact. Allowed properties:\n  - (`String`) firstName\n  - (`String`) middleName\n  - (`String`) lastName\n  - (`String`) prefix\n  - (`String`) suffix\n  - (`Object`) address\n  - (`String`) street\n  - (`String`) city\n  - (`String`) zip\n  - (`String`) state\n  - (`String`) country\n  - (`String`) ISOCountryCode\n  - (`String`) subLocality (iOS 10.3+)\n  - (`String`) subAdministrativeArea (iOS 10.3+)\n  - (`String`) email\n  - (`String`) phone\n- (`Object`) shippingContact: An object representing a shipping contact. Allowed properties are same as in billingContact.\n- (`Array`) supportedNetworks: The payment networks that you support, e.g. `[ApplePay.PAYMENT_NETWORK_VISA, ApplePay.PAYMENT_NETWORK_MASTERCARD]`.\n- (`Number`) requiredShippingAddressFields: A bit field of shipping address field constants (`ADDRESS_FIELD_*`) that you need in order to process the transaction.\n- (`Number`) requiredBillingAddressFields: A bit field of billing address field constants (`ADDRESS_FIELD_*`) that you need in order to process the transaction.\n- (`Number) shippingType: The type of shipping used by this request, one of `SHIPPING_TYPE_*`.\n- (`ShippingMethod`) shippingMethods: An array of `ApplePay.ShippingMethod` objects that describe the supported shipping methods.\n- (`[SummaryItem]`) summaryItems: summaryItems: An array of `ApplePay.SummaryItem` objects that summarize the amount of the payment.\n- (`Object`) applicationData: Application-specific data or state, e.g. `{\"userId\": 1337}`\n\n#### Methods\n- (`[PAYMENT_NETWORK_*]`) availableNetworks: Returns the available payment networks. The result is an array of `PAYMENT_NETWORK_*` constants, e.g. `PAYMENT_NETWORK_MASTERCARD`. This method is only available on iOS 10 and later.\n\n### PaymentDialog\nA payment dialog is initialized using the `ApplePay.createPaymentDialog` method.\n\n#### Properties\n- (`PaymentRequest`) paymentRequest. The payment request storing the payment-relevant data.\n\n#### Methods\n- (`void`) open: Opens the payment dialog modally.\n\n#### Events\n- `didSelectPayment`: Tells the application that the payment method has changed and asks for a list of updated summary items.\n- `didSelectShippingContact`: Tells the application that the user selected a shipping address:\n  - (`ShippingContactCompletionHandler`) handler: The completion handler of the shipping contact. Call this in order to proceed with updated \tshipping options based on the new address.\n  - (`Object`) contact: The updated shipping contact. Note that you won’t receive the full shipping address in this step due to privacy restrictions from Apple. You will only receive parts of the address to able \tto calculate the shipping. The complete shipping- and billing-contact infos are available in \tthe `didAuthorizePayment` event.\n- `didSelectShippingMethod`: Tells the application that the user selected a shipping method:\n  - (`ShippingMethodCompletionHandler`) handler: The completion handler of the shipping method. Call this in order to proceed with updated items based on the new shipping method.\n  - (`String`) identifier: The identifier of the new shipping method.\n- `willAuthorizePayment`: Tells the application that the user is authorizing the payment request.\n- `didAuthorizePayment`: Tells the application that the user has authorized the payment request:\n  - (`AuthorizationCompletionHandler`) handler:\tThe completion handler of the authorized payment. Call this in order to finish the transaction after you processed the payment data (e.g. sending it to the server.\n  - (`Boolean`) success: Indicates whether or not the authorization succeeded.\n  - (`Object`) payment:\tAn Object of payment-related data (`paymentNetwork`, `paymentInstrumentName`, `paymentMethod`, `transactionIdentifier`, `shippingContact`, `billingContact` and `paymentData`).\n  - (`Date`) created: The exact timestamp of the time the payment was created (Available when using Stripe). \n  - (`String`) stripeTokenId: The Stripe payment token ID of the processed payment (Available when using Stripe).\n  - (`String`) braintreeNonce: The Braintree nonce token of the processed payment (Available when using Braintree).\n- `close`: Tells the application that payment authorization has completed and the dialog is closed.\n\n### PaymentButton\nA payment button is initialized using the `ApplePay.createPaymentButton` method.\n\n#### Properties\n- (`Number`) type: The button's content, one of `PAYMENT_BUTTON_TYPE_*`. Creation-only.\n- (`Number`) style: The button's appearance, one of `PAYMENT_BUTTON_STYLE_*`.Creation-only.\n- (`Number`) borderRadius: The button's border radius. iOS 12+\n\n#### Events\n- `click`: Tells the application that the payment button was clicked.\n\n### ShippingMethod\nA shipping method is initialized using the `ApplePay.createShippingMethod` method.\n\n#### Properties\n- (`String`) identifier: A unique identifier for the shipping method, used by the app, e.g. \"free_shipping\".\n- (`String`) title: A short, localized description of the shipping method, e.g. \"Free Shipping\".\n- (`String`) description: A user-readable description of the shipping method, e.g. \"3-5 working days\".\n- (`Number`) price: The shipping method's price, e.g. 99.99.\n\n### SummaryItem\nA summary item is initialized using the `ApplePay.createSummaryItem` method.\n\n#### Properties\n- (`Number`) itemType: This property defaults to a `PAYMENT_SUMMARY_ITEM_TYPE_FINAL` type. For a list of possible summary item types, see `PAYMENT_SUMMARY_ITEM_TYPE_*`.\n- (`String`) title: A short, localized description of the summary item.\n- (`Number`) price: The summary item's price. Important: The total price of the shopping cart is not calculated automatically by the native API. You need to take care of the current amount of the shopping cart. The last summary item of your shopping cart normally is the name of your store and the total amount added together.\n\n### Constants\n- `PAYMENT_BUTTON_TYPE_PLAIN`\n- `PAYMENT_BUTTON_TYPE_BUY`\n- `PAYMENT_BUTTON_TYPE_SETUP`\n- `PAYMENT_BUTTON_TYPE_IN_STORE` (iOS 10.0+)\n- `PAYMENT_BUTTON_TYPE_DONATE` (iOS 10.2+)\n- `PAYMENT_BUTTON_TYPE_CHECKOUT` (iOS 12.0+)\n- `PAYMENT_BUTTON_TYPE_SUBSCRIBE` (iOS 12.0+)\n- `PAYMENT_BUTTON_TYPE_BOOK` (iOS 12.0+)\n\n- `PAYMENT_BUTTON_STYLE_BLACK`\n- `PAYMENT_BUTTON_STYLE_WHITE`\n- `PAYMENT_BUTTON_STYLE_WHITE_OUTLINE`\n\n- `PAYMENT_METHOD_TYPE_CREDIT`\n- `PAYMENT_METHOD_TYPE_DEBUT`\n- `PAYMENT_METHOD_TYPE_PREPAID`\n- `PAYMENT_METHOD_TYPE_STORE`\n\n- `PAYMENT_SUMMARY_ITEM_TYPE_PENDING`\n- `PAYMENT_SUMMARY_ITEM_TYPE_FINAL`\n\n- `PAYMENT_AUTHORIZATION_STATUS_SUCCESS`\n- `PAYMENT_AUTHORIZATION_STATUS_FAILURE`\n- `PAYMENT_AUTHORIZATION_STATUS_INVALID_BILLING_POSTAL_ADDRESS`\n- `PAYMENT_AUTHORIZATION_STATUS_INVALID_SHIPPING_POSTAL_ADDRESS`\n- `PAYMENT_AUTHORIZATION_STATUS_INVALID_SHIPPING_CONTACT`\n- `PAYMENT_AUTHORIZATION_STATUS_PIN_REQUIRED` (iOS 9.2+)\n- `PAYMENT_AUTHORIZATION_STATUS_PIN_INCORRECT` (iOS 9.2+)\n- `PAYMENT_AUTHORIZATION_STATUS_PIN_LOCKOUT` (iOS 9.2+)\n\n- `PAYMENT_GATEWAY_NONE`\n- `PAYMENT_GATEWAY_STRIPE`\n- `PAYMENT_GATEWAY_BRAINTREE`\n\n- `PAYMENT_NETWORK_AMEX`\n- `PAYMENT_NETWORK_DISCOVER`\n- `PAYMENT_NETWORK_MASTERCARD`\n- `PAYMENT_NETWORK_VISA`\n- `PAYMENT_NETWORK_PRIVATE_LABEL`\n- `PAYMENT_NETWORK_CHINA_UNION_PAY` (iOS 9.2+)\n- `PAYMENT_NETWORK_INTERAC` (iOS 9.2+)\n- `PAYMENT_NETWORK_JCB` (iOS 10.1+)\n- `PAYMENT_NETWORK_SUICA` (iOS 10.1+)\n- `PAYMENT_NETWORK_ID_CREDIT` (iOS 10.3+)\n- `PAYMENT_NETWORK_QUIC_PAY` (iOS 10.3+)\n- `PAYMENT_NETWORK_CARTE_BANCAIRE` (iOS 10.3+)\n\n- `SHIPPING_TYPE_SHIPPING`\n- `SHIPPING_TYPE_DELIVERY`\n- `SHIPPING_TYPE_SERVICE_PICKUP`\n- `SHIPPING_TYPE_STORE_PICKUP`\n\n- `ADDRESS_FIELD_NONE`\n- `ADDRESS_FIELD_POSTAL_ADDRESS`\n- `ADDRESS_FIELD_PHONE`\n- `ADDRESS_FIELD_EMAIL`\n- `ADDRESS_FIELD_NAME`\n- `ADDRESS_FIELD_ALL`\n\n- `MERCHANT_CAPABILITY_3DS`\n- `MERCHANT_CAPABILITY_CREDIT`\n- `MERCHANT_CAPABILITY_DEBIT`\n- `MERCHANT_CAPABILITY_EMV`\n\n## Author\nHans Knöchel ([@hansemannnn](https://twitter.com/hansemannnn) / [Web](http://hans-knoechel.de))\n\n## Support\nContact me on [Ti.Slack](http://tislack.org)\n\n## License\nApache 2.0\n\n## Contributing\nCode contributions are greatly appreciated, please submit a new [Pull Request](https://github.com/hansemannn/titanium-apple-pay/pull/new/master)!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhansemannn%2Ftitanium-apple-pay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhansemannn%2Ftitanium-apple-pay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhansemannn%2Ftitanium-apple-pay/lists"}