<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Anish Michael on Medium]]></title>
        <description><![CDATA[Stories by Anish Michael on Medium]]></description>
        <link>https://medium.com/@anishmichael?source=rss-236abf6f8473------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ekfT7QdS9DT7aJkMaWtHmA.jpeg</url>
            <title>Stories by Anish Michael on Medium</title>
            <link>https://medium.com/@anishmichael?source=rss-236abf6f8473------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 12:57:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anishmichael/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Integrate Apple Pay in your Ionic mobile app]]></title>
            <link>https://medium.com/@anishmichael/integrate-apple-pay-in-your-ionic-mobile-app-13894eda857e?source=rss-236abf6f8473------2</link>
            <guid isPermaLink="false">https://medium.com/p/13894eda857e</guid>
            <category><![CDATA[apple-pay]]></category>
            <category><![CDATA[cordova]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[ionic]]></category>
            <category><![CDATA[mobile-payments]]></category>
            <dc:creator><![CDATA[Anish Michael]]></dc:creator>
            <pubDate>Thu, 08 Oct 2020 03:14:33 GMT</pubDate>
            <atom:updated>2022-08-09T14:25:35.445Z</atom:updated>
            <content:encoded><![CDATA[<h3>Integrate Apple Pay in your Ionic/Cordova mobile app</h3><h4><strong>Introduction</strong></h4><p>Apple Pay is a mobile payment service offered by Apple Inc. It allows users to make no-contact payments in stores, in apps and even on the web. Here, I am explaining how we can integrate Apple Pay to make payments in any Cordova application.</p><h4>Prerequisites</h4><p>Create a merchant ID in the apple developer <a href="https://developer.apple.com/account/resources/identifiers/list/merchant">account</a> and complete the <a href="https://developer.apple.com/documentation/passkit/apple_pay/setting_up_apple_pay_requirements">configuration</a> with your payment gateway. This <a href="https://www.checkout.com/docs/payments/payment-methods/apple-pay">document </a>will explain how to do it in case of Checkout.com as the payment gateway.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9ox7R11DELFk2E6bOPr2yA.png" /><figcaption>Merchant ID configuration</figcaption></figure><p>Check <strong>Apple Pay Payment Processing</strong> capability and click on the Edit button. Select the merchant ID to be used with the application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*wWIuK7IJRrfiT57Xd-fraQ.png" /><figcaption>App ID configuration</figcaption></figure><h4>Process Flow</h4><p>Let s have a look at the communication between the user, the mobile app, the back-end service and the payment gateway.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*5l8l3xpePEkT9FBXP1VS0w.png" /><figcaption>process flow with <strong>Checkout.com</strong> as the payment gateway</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*Gtpg47JAL_ZGUuzb_47bxA.png" /><figcaption>Open Apple Pay</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*knuLWggPbcwgdsrEAkExbA.png" /><figcaption>Choose the card</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*Xf9vUnuTiTMvPLpEt39zsw.png" /><figcaption>Choose shipping method</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*CKLiWMnIxpmnfe-Z9ZkWgw.png" /><figcaption>Authenticate the transaction</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*GuRPANNK2l7zJa9I21yJhA.png" /><figcaption>Transaction status</figcaption></figure><p>From the above images you will get a clear idea about the process flow. Lets move on to the next step now.</p><h4><strong>Install the plugin</strong></h4><p>Install the plugin using the following commands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*M_krii6S6-18y9qcZY8lQA.png" /></figure><p>Import Apple Pay in your <strong>app.module.ts</strong> and include it in the <strong>providers </strong>list.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*-YKPmtxHK8k_wLjFkJ1dJg.png" /><figcaption>app.module.ts</figcaption></figure><p>Similarly, import Apple Pay in the pages wherever you want to invoke Apple Pay. For e.g. <strong>home.page.ts</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*v4SLnzMPuPyREcbzfcY4lw.png" /><figcaption>home.page.ts</figcaption></figure><h4><strong>Check availability of Apple Pay</strong></h4><p>Use the <strong>canMakePayments()</strong> method available with the Apple Pay plugin to check for the availability of Apple Pay. You can invoke this method in the <strong>ngOnInIt()</strong> of <strong>app.component.ts</strong> or where you want to show the Apple Pay button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*p1lTS87bUjxaN_ND5JpRfg.png" /><figcaption>canMakePayments method</figcaption></figure><blockquote><strong>Note</strong>: You will get an affirmative response from this method if the device supports Apple Pay. Most of the iPhones and iPads support Apple Pay. This doesn’t mean that the user can make payment using Apple Pay. Apple Pay is supported only in some <a href="https://support.apple.com/en-in/HT207957">regions</a> . Here is <a href="https://www.macrumors.com/roundup/apple-pay/#:~:text=After%20installing%20iOS%208.1%20or,one%20in%20with%20the%20camera.">something</a> for a good read.</blockquote><h4><strong>Make the payment</strong></h4><p>Invoke the method <strong>makePaymentRequest()</strong> upon click of the Apple Pay button. This will bring up the ApplePay drawer and the user can authenticate using Touch ID or Face ID.</p><p><strong>Request of </strong><strong>makePaymentRequest()<em> <br></em></strong>We have to pass a JSON object with name as ‘<a href="https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymentrequest"><strong>order</strong></a><strong>’</strong>. An example of the order object is given below.</p><pre>let order: any = {</pre><pre>items: [<br>{ label: &#39;Item 1&#39;, amount: 10.00 },<br>{ label: &#39;Item 2&#39;, amount: 5.00 },<br>{ label: &#39;Next Day Delivery&#39;, amount: 3.99 },<br>{ label: &#39;Store Name&#39;, amount: 18.99 }<br>],<br> <strong><em>/* The list of items in the cart. It will be shown in the apple pay drawer. The last item in the array is expected to be the total amount to be paid with the store name */</em></strong></pre><pre>shippingMethods: [<br>{ identifier: &#39;NextDay&#39;, label: &#39;NextDay&#39;, detail: &#39;Arrives tomorrow by 5pm.&#39;, amount: 3.99 },<br>{ identifier: &#39;Standard&#39;, label: &#39;Standard&#39;, detail: &#39;Arrive by Friday.&#39;, amount: 1.99 }<br>],<br> <strong><em>/* A list of available methods for shipping physical goods. Keep it as an empty array if not required. */</em></strong></pre><pre>merchantIdentifier: &#39;com.company.applicationName&#39;, <strong><em>/* The merchant ID registered in Apple developer account */</em></strong></pre><pre>currencyCode: &#39;USD&#39;, <strong><em>/* The three-letter ISO 4217 currency code for the payment. */</em></strong></pre><pre>countryCode: &#39;US&#39;, <strong><em>/* The merchant’s two-letter ISO 3166 country code. */</em></strong></pre><pre>billingAddressRequirement: [&#39;name&#39;,&#39;email&#39;,&#39;phone&#39;], <strong><em>/* The information required for Billing Address with options name , email , phone or none. */</em></strong></pre><pre>shippingAddressRequirement: &#39;none&#39;, <strong><em>/* The information required for Shipping Address with options name , email , phone or none. */</em></strong></pre><pre>shippingType: &#39;none&#39;, <strong><em>/* Value that indicates how purchased items are to be shipped. */</em></strong></pre><pre>merchantCapabilities: [&#39;3ds&#39;, &#39;debit&#39;, &#39;credit&#39;], <strong><em>/* The payment capabilities supported by the merchant. */</em></strong></pre><pre>supportedNetworks: [&#39;visa&#39;, &#39;masterCard&#39;, &#39;amex&#39;, &#39;discover&#39;],  <br><strong><em>/* The list of payment networks supported by the merchant. */</em></strong></pre><pre>total: { label: &#39;COMPANY, INC.&#39;, amount: 18.99, type: &quot;final&quot; }<br><strong><em>/* label should be the expected business name which comes on users&#39;s bank statement. Amount should be greater than zero. */</em></strong></pre><pre>}</pre><p><strong>Response of </strong><strong>makePaymentRequest()<br></strong>This method will return a response like given below.</p><pre>{<br>   &quot;paymentMethodNetwork&quot;:&quot;MasterCard&quot;,<br>   &quot;paymentMethodDisplayName&quot;:&quot;MasterCard1234&quot;,<br>   &quot;<strong>paymentData</strong>&quot;:&quot;hgasdju...kjhkjQ==&quot;,<br>   &quot;paymentMethodTypeCard&quot;:&quot;debit&quot;,<br>   &quot;transactionIdentifier&quot;:&quot;E01JBSD...KJ5jh6A&quot;<br>}</pre><p>The key <strong>paymentData</strong> is a BASE64 encoded string and when we decode it, we can see a JSON response like given below.</p><pre>{<br>   &quot;version&quot;:&quot;EC_v1&quot;,<br>   &quot;data&quot;:&quot;d6YNW8B...vaVCwRDM=&quot;,<br>   &quot;signature&quot;:&quot;MIAGCSq...AAA==&quot;,<br>   &quot;header&quot;:{<br>      &quot;ephemeralPublicKey&quot;:&quot;MFkwEw...KLA==&quot;,<br>      &quot;publicKeyHash&quot;:&quot;H...I=&quot;,<br>      &quot;transactionId&quot;:&quot;aa...d6&quot;<br>   }<br>}</pre><h4>Payment Gateway Request</h4><p>Invoke the payment gateway request and pass the <strong>paymentData</strong> as parameter to complete the transaction. This <a href="https://developer.apple.com/apple-pay/sandbox-testing/">document </a>will explain how the payment process is completed through Checkout.com.</p><p>You can close the apple pay drawer by invoking the method <strong>completeLastTransaction(response)</strong> with respect to the response from the payment gateway. Accordingly, you can pass any one of these strings (success, failure, invalid-billing-address, invalid-shipping-address, invalid-shipping-contact, require-pin, incorrect-pin, locked-pin) as response string.</p><pre>this.applePay.completeLastTransaction(‘success’);</pre><blockquote><strong>Note </strong>: The Apple Pay drawer should be closed within 30 seconds (<strong><em>completeLastTransaction()</em></strong>should be invoked) once the <strong>makePaymentRequest()</strong> is made. Otherwise it will automatically close with an error alert “Payment failed” and you will not have any control on it. To avoid this scenario, you have to manually close the drawer with an appropriate message before it <a href="https://stackoverflow.com/questions/58463408/how-can-i-increase-the-failure-timeout-of-an-apple-pay-operation">times out</a>.</blockquote><h4>Build Generation</h4><p>While you take the iOS build (.ipa file) make sure that you have added the Apple Pay under the capabilities tab and checked the merchant ID. The merchant ID will be automatically listed if your App ID is properly configured with Apple Pay .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*yDAv74D3NSycjEuWrG51pg.png" /></figure><h4>Testing</h4><p>To test Apple Pay, you will require a sandbox apple account. You can create a sandbox account from the developer <a href="https://appstoreconnect.apple.com/access/testers">portal</a>. Test cards for Apple Pay are available in the apple <a href="https://developer.apple.com/apple-pay/sandbox-testing/">documentation</a>. These cards can be used to test the failure scenario. To test the success scenario you have to get the test cards from your payment gateway documentation. I used checkout.com as the payment gateway and the test cards are mentioned in the <a href="https://www.checkout.com/docs/payments/payment-methods/apple-pay#Apple_Pay_test_cards">documentation </a>under the heading ‘<strong>Apple Pay test cards</strong>’.</p><h4>Conclusion</h4><p>Nowadays almost all the iOS application provides Apple Pay as the payment service. I hope this blog will make it easy for you to integrate Apple Pay in your Cordova application.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13894eda857e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>