<?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 Sulaiman Farajallah on Medium]]></title>
        <description><![CDATA[Stories by Sulaiman Farajallah on Medium]]></description>
        <link>https://medium.com/@slemankamel?source=rss-4acb5ab17efa------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*mXBoNKnYoovhHkaUtju2QQ.jpeg</url>
            <title>Stories by Sulaiman Farajallah on Medium</title>
            <link>https://medium.com/@slemankamel?source=rss-4acb5ab17efa------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 13:57:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@slemankamel/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[Integrating Hyperpay into a Flutter project.]]></title>
            <link>https://slemankamel.medium.com/integrating-hyperpay-into-a-flutter-project-1d643ab47e77?source=rss-4acb5ab17efa------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d643ab47e77</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[hyperpay]]></category>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[Sulaiman Farajallah]]></dc:creator>
            <pubDate>Thu, 15 Oct 2020 12:15:37 GMT</pubDate>
            <atom:updated>2020-10-19T15:43:23.951Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X9HWKN3Q1p76UEBFKXdsSw.png" /></figure><p>Since this is my first article, get a cup of tea and let’s earn money together.</p><p>Most developers at some stage will need to integrate a powerful payment gateway like HyperPay, which seems to be a common obstacle for many of you, so this tutorial will be about just that. Without further ado, let us dig right in:</p><h3><strong>General requirements:</strong></h3><p>&gt;A general Idea of <a href="https://hyperpay.docs.oppwa.com/tutorials/mobile-sdk">mobile SDK</a></p><p>&gt;Hyperpay SDK Libraries (ask your backend to deliver you with them but for the purpose of this tutorial, I have uploaded them <a href="https://drive.google.com/drive/folders/1-HHUXPQaJaaDm1m2Lw4H9gUbAGMK8kE3?usp=sharing">on my drive</a>)</p><p>&gt;Test Credit Card :</p><p>4111111111111111 05/21 cvv2 123 (Success)<br>5204730000002514 05/22 cvv2 251 (Fail)</p><p>You can find test values for <strong>credit cards</strong> and <strong>bank accounts</strong> in <a href="https://hyperpay.docs.oppwa.com/reference/parameters#testing">Testing Guide</a>.</p><h3>Setting up in iOS</h3><h4><strong>Requirements:</strong></h4><ul><li>Xcode 10 and iOS 12 SDK</li><li>iOS 9.0+ deployment target</li></ul><p>If you don’t have any IOS background, me neither!! but don’t worry because we will do it step by step together and make it works!.</p><p><strong>Step 1</strong>: Preparation</p><ul><li>First, from your Xcode choose file -&gt; open -&gt; inside your flutter project you will find (Runner.xcodeproj) inside an ios folder, open it.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*C0kTaGsXf9VUfVcG269QKA.png" /></figure><ul><li>Second, drag the two files, <em>OPPWAMobile.framework</em> and <em>OPPWAMobile-Resources.bundle,</em> into the <em>Frameworks </em>folder, make sure you have the option <em>Copy items if needed </em>checked.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h6bdX5dbpBy4TLD-PmOXng.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*iz-uznLJf1F-FrAFODmoXA.png" /></figure><p><strong>Confirm that these two Build Settings are both enabled</strong>:</p><p>In the -&gt;Targets-&gt;Runner-&gt;<em>Build Settings</em> section, make sure that you have these two settings enabled.</p><ul><li>Enable Modules (C and Objective-C)</li><li>Link Frameworks Automatically</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h84fG3lG0j_xASIMGjSfmA.png" /></figure><p>and the same thing for (Link Frameworks Automatically).</p><p><strong>Step 2</strong>: Build a native bridge iOS</p><ul><li>Open your Flutter project and let’s Writing some custom platform-specific code (You can find a great Tutorials in <a href="https://flutter.dev/docs/development/platform-integration/platform-channels?tab=android-channel-java-tab">official documents</a>).</li><li>To start working with SDK we need our app to request a <strong>checkout ID</strong> from <strong>our server.</strong></li></ul><blockquote>In my case, I will work on my current real project to save some time.</blockquote><p>After I received the checkout Id, I need to create a channel and send through it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lpxO6whvXX4XBuWgJw_B8Q.png" /></figure><p>The client and host sides of a channel are connected through a channel name passed in the channel constructor.</p><p>Inside _getPaymentResponse, I request a checkout Id and send it as an argument in “getPaymentMethod”, consequently, we need to go back to Xcode now.</p><p><strong>Step 3</strong>: Adding code in IOS.</p><p><em>We can now import the framework with:</em></p><pre><strong>#import &lt;OPPWAMobile/OPPWAMobile.h&gt;</strong></pre><p>We are integrating SDK to the <strong>Swift</strong> app, if you like to see who it works you can see the Apple guide <a href="https://developer.apple.com/documentation/swift/imported_c_and_objective-c_apis/importing_objective-c_into_swift">Importing Objective-C into Swift</a>.</p><p>Without going deeper, what all we need just import the Framework in (Runner-Bridging-Header.h) inside Runner Folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*SqnK6G1EwW6hxixBh3XoeA.png" /></figure><p>That’s all.</p><ul><li>Open the AppDelegate.swift located under <strong>Runner &gt; Runner</strong> in the Project navigator.</li><li>Override the application:didFinishLaunchingWithOptions: function and create a FlutterMethodChannel tied to your channel name.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4tta9FEb0O6QLokgu9iALg.png" /></figure><p>Now let’s add the following as a new method at the bottom of AppDelegate.swiftand inside it we need to Initialize Payment Provider with test mode and Define the settings for the checkout screen. hence, InitializingOPPCheckoutSettings,allows us to control the information that is shown to the shopper.</p><pre><strong>let</strong> provider = <strong>OPPPaymentProvider</strong>(mode: <strong>OPPProviderMode</strong>.test)</pre><pre><strong>let</strong> checkoutSettings = <strong>OPPCheckoutSettings</strong>()<br><br><em>// Set available payment brands for your shop</em><br>checkoutSettings.paymentBrands = [&quot;VISA&quot;,  &quot;DIRECTDEBIT_SEPA&quot;, &quot;MASTER&quot;]<br><br><em>// Set shopper result URL</em><br>checkoutSettings.shopperResultURL = &quot;com.companyname.appname.payments://result&quot;</pre><ul><li>Initialize OPPCheckoutProvider with the received <strong>checkout ID</strong> and created <strong>settings</strong>.</li></ul><pre><strong>let</strong> args = call.arguments <strong>as</strong>? Dictionary&lt;String, <strong>Any</strong>&gt;</pre><pre><strong>let</strong> checkoutId = (args?[&quot;checkoutId&quot;] <strong>as</strong>? String)!</pre><pre><strong>let</strong> checkoutProvider = OPPCheckoutProvider(paymentProvider: provider, checkoutID: checkoutId , settings: checkoutSettings)</pre><ul><li>Please Note: as I mentioned above in <strong><em>step 2. </em></strong><em>I sent the checkout Id as an argument and now I am using it here (</em>checkoutId).</li></ul><p>Then, to <strong>open the payment page</strong> and <strong>implement the callbacks</strong>.</p><pre>checkoutProvider?.presentCheckout(forSubmittingTransactionCompletionHandler: { (transaction, error) <strong>in</strong></pre><pre><strong>guard</strong> <strong>let</strong> transaction = transaction <strong>else</strong> {</pre><pre>// Handle invalid transaction, check error</pre><pre>result(FlutterError(code: &quot;UNAVAILABLE ELSE&quot;,</pre><pre>message: &quot;Payemt info unavailable&quot;,</pre><pre>details: <strong>nil</strong>))</pre><pre><strong>return</strong></pre><pre>}</pre><pre><strong>if</strong> transaction.type == .synchronous {</pre><pre>// If a transaction is synchronous, just request the payment status</pre><pre>// You can use transaction.resourcePath or just checkout ID to do it</pre><pre>result(transaction.resourcePath)</pre><pre>} <strong>else</strong> <strong>if</strong> transaction.type == .asynchronous {</pre><pre>// The SDK opens transaction.redirectUrl in a browser</pre><pre>// See &#39;Asynchronous Payments&#39; guide for more details</pre><pre>result(transaction.redirectURL?.absoluteString)</pre><pre>} <strong>else</strong> {</pre><pre>// Executed in case of failure of the transaction for any reason</pre><pre>result(FlutterError(code: &quot;UNAVAILABLE Else&quot;,</pre><pre>message: error.debugDescription,</pre><pre>details: <strong>nil</strong>))</pre><pre>}</pre><pre>}, cancelHandler: {</pre><pre>// Executed if the shopper closes the payment page prematurely</pre><pre>result(FlutterError(code: &quot;UNAVAILABLE Error&quot;,</pre><pre>message: &quot;Executed if the shopper closes the payment page prematurely&quot;,</pre><pre>details: <strong>nil</strong>))</pre><pre>})</pre><ul><li>To wrap our Ideas, the method should look like this and I already passed 2 arguments.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*77hp1go24L2iV7beOIDUzw.png" /></figure><blockquote>we almost have done for IOS, just one more easy step!</blockquote><p>let’s go back to ( paymentChannel.setMethodCallHandler) above and add this code.</p><pre><strong>guard</strong> call.method == &quot;getPaymentMetod&quot; <strong>else</strong> {</pre><pre>result(FlutterMethodNotImplemented)</pre><pre><strong>return</strong></pre><pre>}</pre><pre><strong>self</strong>.recivePayment(result: result , call: call)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1cSJ252bzBeaxq8LMGq_GQ.png" /></figure><p>Let’s take a look !!</p><p><a href="https://drive.google.com/file/d/1geuAe9c0hOtzJM5EOy-f6rUfyiLwEUe0/view?usp=sharing">Screen Recording 2020-10-14 at 2.19.07.mov</a></p><p>That’s good so far.</p><p>Oops !! I need another cup of tea!!</p><h3>Setting up in Android</h3><h4>Requirements:</h4><ul><li><a href="https://developer.android.com/studio/index.html">Android Studio</a></li><li>The Mobile SDK is designed to work with Android 4.4 (API Level 19) and up</li></ul><h4>Installing SDK</h4><p><strong>Step 1</strong>: First, from your Android studio choose -&gt; open an existing android studio project-&gt; inside your flutter project -&gt; open android file.</p><p><strong>Step 2</strong> : Import oppwa.mobile.aar into your project.(File-&gt;New-&gt;Module-&gt; Select import .jar/aar package -&gt;Select your .aar file from location)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*60VAgQXRQyBBi3Co3kwWpA.png" /></figure><ul><li>We can see module is added but not configured with app module yet.</li></ul><p>Step 3 : File-&gt;Go to Project Structure-&gt; Depndecies -&gt; Go to app module and press ‘+’ icon-&gt;Select 3rd option Module dependency-&gt; Select newly added .arr module(<strong>oppwa.mobile-2.46.0.)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T4R8_xSApZsjVXBPF62dEQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IJ33qXtGOE8akrIaNBj3og.png" /></figure><ol><li>Add the following dependencies to your build.gradle(Module App):</li></ol><pre>implementation &#39;com.android.support:support-v4:29.0.0&#39;<br>implementation &#39;com.android.support:appcompat-v7:29.0.0&#39;<br>implementation &#39;com.android.support:design:29.0.0&#39;<br>implementation &#39;com.android.support:customtabs:29.0.0&#39;<br>implementation &#39;com.google.android.gms:play-services-wallet:16.0.1&#39;</pre><p>2. Open your AndroidManifest.xml</p><ul><li>declare this namespace in the &lt;manifest&gt; element: xmlns:tools=&quot;http://schemas.android.com/tools&quot;.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JRX_KeusXWs8gMvGBrRm2g.png" /></figure><ul><li>declare the connect service within the application tag:</li></ul><pre>&lt;service<br>    android:name=&quot;com.oppwa.mobile.connect.service.ConnectService&quot;<br>    android:exported=&quot;false&quot;/&gt;</pre><pre>&lt;activity<br>    tools:replace=&quot;android:theme&quot;<br>    android:name=&quot;com.oppwa.mobile.connect.checkout.dialog.CheckoutActivity&quot;<br>    android:theme=&quot;@style/Theme.Checkout.Light&quot;<br>    android:windowSoftInputMode=&quot;adjustPan&quot;<br>    android:exported=&quot;false&quot;<br>    android:launchMode=&quot;singleTop&quot;/&gt;</pre><ul><li>Make sure you set the tools:replace=&quot;android:theme&quot; attribute for the CheckoutActivity.</li></ul><p><strong>Step 4:</strong> Build a Native Bridge Android</p><p>As I mentioned before on step 2 in the IOS section I already prepared the channel and method to get a checkout Id.</p><ul><li>Open the MainActivity.java file located in the <strong>java</strong> folder in the Project view.</li><li>Next, create a MethodChannel and set a MethodCallHandler inside the configureFlutterEngine() method. Make sure to use the same channel name as was used on the Flutter client side.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EMWUghgWIACNLLYfqeGNTg.png" /></figure><ul><li>Now, add the needed imports at the top of the file:</li></ul><pre><strong>import </strong>io.flutter.embedding.android.FlutterActivity;<br><strong>import </strong>io.flutter.embedding.engine.FlutterEngine;<br><strong>import </strong>io.flutter.plugin.common.MethodChannel;<br><strong>import </strong>androidx.annotation.NonNull;<br><br><strong>import </strong>java.util.LinkedHashSet;<br><strong>import </strong>java.util.Set;<br><strong>import </strong>com.oppwa.mobile.connect.checkout.meta.CheckoutSettings;<br><strong>import </strong>com.oppwa.mobile.connect.provider.Connect;<br><strong>import </strong>android.content.Intent;<br><strong>import </strong>com.oppwa.mobile.connect.checkout.dialog.CheckoutActivity;<br><strong>import </strong>com.oppwa.mobile.connect.provider.Transaction;<br><strong>import </strong>com.oppwa.mobile.connect.provider.TransactionType;<br><strong>import </strong>com.oppwa.mobile.connect.exception.PaymentError;<br><br><strong>import </strong>io.flutter.plugin.common.MethodCall;</pre><p>Now let’s add the following as a new method at the bottom of MainActivity.Java and inside it we need to define the settings for the checkout screen and Initialize CheckoutSettings with received <strong>checkout ID </strong>to<strong> </strong>controls in the information that is shown to the shopper</p><ul><li>Configure the Checkout Settings</li></ul><pre>Set&lt;String&gt; paymentBrands = <strong>new </strong>LinkedHashSet&lt;String&gt;();<br><br>paymentBrands.add(<strong>&quot;VISA&quot;</strong>);<br>paymentBrands.add(<strong>&quot;MASTER&quot;</strong>);<br>paymentBrands.add(<strong>&quot;DIRECTDEBIT_SEPA&quot;</strong>);<br><br>CheckoutSettings checkoutSettings = <strong>new </strong>CheckoutSettings(call.argument(<strong>&quot;checkoutId&quot;</strong>), paymentBrands, Connect.ProviderMode.<strong><em>TEST</em></strong>);<br><br><em>// Set shopper result URL<br></em>checkoutSettings.setShopperResultUrl(<strong>&quot;companyname://result&quot;</strong>);</pre><ul><li>Please Note: as I mentioned above in <strong><em>step 2 in IOS Section . </em></strong><em>I sent the checkout Id as an argument and now I am using it here (</em>call.argument(<strong>“checkoutId”</strong>)).</li><li>Set up the Intent and start the checkout activity:</li></ul><pre>Intent intent = checkoutSettings.createCheckoutActivityIntent(<strong>this</strong>);<br>startActivityForResult(intent, CheckoutActivity.<strong><em>REQUEST_CODE_CHECKOUT</em></strong>);</pre><ul><li>To wrap our Ideas, the method should look like this and take notice I already passed an argument.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mJM1beWI7pqIUKPx9hnqig.png" /></figure><ul><li>Finally, override onActivityResult to get notified when the checkout process is done.</li><li>To get a value from onActivityResult and return it through our channel we need to declare a variable in our MainActivity class.</li></ul><pre>MethodChannel.Result <strong>_result  </strong>; </pre><ul><li>Then add onActivityResult</li></ul><pre>@Override<br><strong>protected void </strong>onActivityResult(<strong>int </strong>requestCode, <strong>int </strong>resultCode, Intent data) {<br>    <strong>switch </strong>(resultCode) {<br>        <strong>case </strong>CheckoutActivity.<strong><em>RESULT_OK</em></strong>:<br>            <em>/* transaction completed */<br>            </em>Transaction transaction = data.getParcelableExtra(CheckoutActivity.<strong><em>CHECKOUT_RESULT_TRANSACTION</em></strong>);<br><br>            <em>/* resource path if needed */<br>            </em>String resourcePath = data.getStringExtra(CheckoutActivity.<strong><em>CHECKOUT_RESULT_RESOURCE_PATH</em></strong>);<br><br>            <strong>if </strong>(transaction.getTransactionType() == TransactionType.<strong><em>SYNC</em></strong>) {<br>                <em>/* check the result of synchronous transaction */<br>                </em><strong>_result</strong>.success(transaction.getAlipaySignedOrderInfo());<br>            } <strong>else </strong>{<br>                <em>/* wait for the asynchronous transaction callback in the onNewIntent() */<br>                </em><strong>_result</strong>.success(transaction.getAlipaySignedOrderInfo());<br>            }<br><br>            <strong>break</strong>;<br>        <strong>case </strong>CheckoutActivity.<strong><em>RESULT_CANCELED</em></strong>:<br>            <em>/* shopper canceled the checkout process */<br>            </em><strong>_result</strong>.error(<strong>&quot;UNAVAILABLE&quot;</strong>, <strong>&quot;shopper canceled the checkout process&quot;</strong>, <strong>null</strong>);<br>            <strong>break</strong>;<br>        <strong>case </strong>CheckoutActivity.<strong><em>RESULT_ERROR</em></strong>:<br>            <em>/* error occurred */<br>            </em><strong>_result</strong>.error(<strong>&quot;UNAVAILABLE&quot;</strong>, CheckoutActivity.<strong><em>CHECKOUT_RESULT_ERROR</em></strong>, <strong>null</strong>);<br>            PaymentError error = data.getParcelableExtra(CheckoutActivity.<strong><em>CHECKOUT_RESULT_ERROR</em></strong>);<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vJLBGNso0k8_BrkBrN5G1g.png" /></figure><blockquote>we almost have done for Android, just one more easy step!</blockquote><p>let’s go back to (setMethodCallHandler) above and add this code.</p><pre><em>// Note: this method is invoked on the main thread.<br>// </em><strong><em>TODO<br></em></strong><em>// Note: this method is invoked on the main thread.<br></em><strong>if </strong>(call.<strong>method</strong>.equals(<strong>&quot;getPaymentMetod&quot;</strong>)) {<br>    <strong>_result </strong>= result ;<br>    recivePayment(call);<br>} <strong>else </strong>{<br>    result.notImplemented();<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xk9z-N2vdgHAs5dkIFJx-g.png" /></figure><p>Let’s take a look !!</p><p><a href="https://drive.google.com/file/d/1ea6M9smS4o7AsR_F3rWJrbXxqJCPxmCb/view?usp=sharing">Screen Recording 2020-10-15 at 2.15.17.mov</a></p><p>That’s all.</p><ul><li>After the users put in their payment information, SDK will process and return the data to resourcePath for checking of payment status.</li></ul><p>For now, there are many scenarios can happen and it depends in your backend, for my case after the process is done I send another request contains the checkout id I already used to our server and our backend check if the process is done without any problems, as a result, our backend will clear my cart and I will refresh my cart to clear it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WFBLgTBgErl7JVS8nDdkXg.png" /></figure><p>This is my scenario.</p><p><a href="https://drive.google.com/file/d/1oKMKo1WD4CWmUMA53izD6c4jeDqbSgA2/view?usp=sharing">Screen Recording 2020-10-19 at 18.27.42.mov</a></p><h3>Go to Production!!</h3><blockquote>Don’t Forget to change From Test to Live.</blockquote><p>After all, this is my first article and I’m a quite sure it’s not perfect but I will do my best in the next one, in addition, I hope I didn’t forget anything and everything is clear. <br>I am always eager-to-learn and I’m sure there are many so I am happy to take this first step and share my knowledge.</p><p>If my article was useful and it will help you to earn some money, Donate to buy another cup of tea.</p><p><a href="https://www.paypal.com/donate?hosted_button_id=B6YNPQY84K88E">Donate to slemankamelfa@gmail.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d643ab47e77" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>