Accepting bank card payments in iOS applications

  • Tutorial
Following the previously developed SDKs for the Windows Universal App ( which we already talked about on Habré ) and node.js, in May we developed and published SDKs for iOS. About which iOS applications can accept payments through a third-party payment service, why this is necessary and how to integrate a payment service into a mobile application, read under the cat. And also - delicious fresh statistics on the share of mobile users in PayOnline payment traffic over the past 3 years. Only for residents of HabrHabr!




Before moving on to a detailed review of the Payment SDK for iOS and discussing the specific requirements of the App Store, we want to share with you PayOnline statistics on mobile payments over the past three years.

Explosion of mobile traffic in 2013 - 2015


When in the early 2010s we launched the product for receiving payments from mobile devices and from Pay-Mobile mobile applications , we did not even suspect how wild growth mobile traffic will show in the next few years.

Today, a story about the beginning of the era of mobile commerce rushes from each iron, but it is difficult to obtain adequate, accurate, and most importantly, localized statistics on Russia. Entering Google’s query “iOS share in Russia”, we get a lot of approximate figures based on world statistics and device sales figures according to reports from major retail chains.

Fortunately, we process tens of thousands of payments every day and have access to real indicators of why Russians pay online. Today we will show you the data from 2013 to 2015, for which a few percent of payments from mobile devices turned into a fifth of our payment traffic.

In 2013, mobile traffic grew more than 2 times faster than “desktop”, and in 2014 - more than 6 times. And, apparently, in the coming years this movement cannot be stopped. The diagram below shows the indicators of mobile traffic over the past 3 years, divided by key mobile operating systems.

Note that these numbers are distributed by devices from which payments via PayOnline were successfully completed. Pure commercial traffic without the admixture of Internet surfers and users of free applications :)



Going to the PayOnline Payment SDK for iOS


Payment SDK for iOS applications allows developers to easily and easily integrate the acceptance of bank card payments into a mobile application. Why the developer of the Payment SDK application can be found in the material that we published on the blog earlier this year .

What is the most important thing? The main thing is that by integrating payment acceptance using the SDK for iOS, you will avoid WebView. All elements of the payment process are embedded in the mobile application and are customized for its design.

Explaining in a nutshell: the SDK avoids diving into the abysses of integration with a payment gateway, implementing the 3-D Secure security protocol and other inappropriate spending of time and effort. But before moving on to integration issues, it’s worth understanding Apple’s difficult rules regarding third-party payment services in applications.

What applications in general can accept payments in iOS applications not through the App Store?


The question of whether it is possible to accept payments in iOS applications at all worries the minds of developers and owners for several years, causing numerous discussions.

To understand this issue, we turned to the original source - “App Store Review Guidelines”, chapter 11 “Purchasing and currencies”.

Read the source
Purchasing and currencies
11.1 Apps that unlock or enable additional features or functionality with mechanisms other than the App Store will be rejected
11.2 Apps utilizing a system other than the In-App Purchase API (IAP) to purchase content, functionality, or services in an App will be rejected
11.3 Apps using IAP to purchase physical goods or goods and services used outside of the App will be rejected
11.4 Apps that use IAP to purchase credits or other currencies must consume those credits within the App
11.5 Apps that use IAP to purchase credits or other currencies that expire will be rejected
11.6 Content subscriptions using IAP must last a minimum of 7 days and be available to the user from all of their iOS devices
11.7 Apps that use IAP to purchase items must assign the correct Purchasability type
11.8 Apps that use IAP to purchase access to built-in capabilities provided by iOS, such as the camera or the gyroscope, will be rejected
11.9 Apps containing content or services that expire after a limited time will be rejected, except for specific approved content (eg films, television programs, music, books)
11.10 Insurance Apps must be free, in legal-compliance in the regions distributed, and cannot use IAP
11.11 In general, the more expensive your App, the more thoroughly we will review it
11.12 Apps offering subscriptions must do so using IAP, Apple will share the same 70/30 revenue split with developers for these purchases, as set forth in the Program License Agreement
11.13 Apps that link to external mechanisms for purchases or subscriptions to be used in the App, such as a “buy” button that goes to a web site to purchase a digital book, will be rejected
11.14 Apps can read or play approved content (specifically magazines, newspapers, books, audio, music, video and cloud storage) that is subscribed to or purchased outside of the App, as long as there is no button or external link in the App to purchase the approved content. Apple will only receive a portion of revenues for content purchased inside the App
11.15 Apps may only use auto-renewing subscriptions for periodicals (newspapers, magazines), business Apps (enterprise, productivity, professional creative, cloud storage), and media Apps (video , audio, voice), or the App will be rejected
11.16 Apps may enable additional approved features or functionality when used in combination with specific approved physical products (such as a toy) as long as the additional features and functionality are either completely dependent on such hardware (for example an App that is used to control a telescope) or also available through the App without the physical products, such as by way of reward for achievement or by use of IAP
11.17 Apps may facilitate transmission of approved virtual currencies provided that they do so in compliance with all state and federal laws for the territories in which the app functions

If you do not go into the literal translation, the essence of the requirements of Apple is as follows: all goods and services of the virtual and digital plan must be paid through the App Store. Otherwise, the application will be deleted.

Thus, our Payment SDK will not be able to use the owners of gaming, entertainment applications, sellers of digital content, etc. The issue of virtual goods is borderline, but more often it is also decided in favor of accepting payments through the App Store. For example, the online store of digital books LitRes accepts payments in the application on Android through PayOnline, but on iOS through the App Store.

Another thing is if you made a mobile application for your online store, travel agency or ticket office. The result of a transaction between you and your buyer is a physical product or physical document confirming the right to use the service. In this case, you can safely integrate payment acceptance through a third-party payment service and quickly receive funds to your bank account without losing time and money on the bad commission of the App Store.

How does the PayOnline Payment SDK for iOS work?


To connect the SDK, you need to add the libPayOnlineSdk.a library and the PayOnlineSdk folder containing header files to the project (you can download the library here ).

To complete the payment you need:

1. Create a PayOnlineConfiguration configuration object.
Code example:

PayOnlineConfiguration *payOnlineConfiguration = [PayOnlineConfiguration configurationWithMerchantId:12345 privateKey: @"12-34-5"];

2. Implement the methods of the PayOnlineDelegate protocol.
Code example:

@implementation ViewController
...
#pragma mark - PayOnlineDelegate methods
(void)payOnlineSuccess:(PayOnlinePayResponse *)response { // платеж прошел успешно }
(void)payOnlineDeclined:(PayOnlinePayResponse *)response { // платеж отклонен }
// необходима проверка 3DS
(void)payOnlineThreeDsRequired:(PayOnlinePayResponse *)response { // создаем и показываем встроенный браузер UIWebView *webView = [[UIWebView alloc] initWithFrame:self.view.bounds]; [self.view addSubview:webView]; // открываем страницу банка-эмитента во встроенном браузере [self.processing navigateToAcsUrl:response delegate:self webView:webView]; }
(void)payOnlineError:(PayOnlineError *)error { // ошибка }
@end

3. Create a payment object PayOnlinePayRequest.
Code example:

PayOnlinePayRequest *payRequest = [[PayOnlinePayRequest alloc] init];
payRequest.email = @"test@payonline.com";
payRequest.cardNumber = @"4444333322221111";
payRequest.ip = @"127.0.0.1";
payRequest.cardExpMonth = 1;
payRequest.cardExpYear = 2015;
payRequest.cardHolderName = @"NAME SURNAME";
payRequest.cardCvv = 123;
payRequest.amount = [NSDecimalNumber decimalNumberWithString:@"120.00"];
payRequest.currency = PayOnlineCurrencyRub;
payRequest.orderId = @"order12345";

4. Create a PayOnlineProcessing object based on the configuration of the runtime and call the pay method.
Code example:

PayOnlineProcessing *processing = [PayOnlineProcessing processingWithConfig:payOnlineConfiguration]; 
[processing pay:payRequest delegate:payOnlineDelegate];

5. The pay method will end with a call to one of the payOnlineDelegate methods.

Implementation Example - Ural Airlines Mobile Application for iOS


One of the first customers of our company, using the SDK to integrate a payment service into a mobile application for iOS, was Ural Airlines.



If you want to see how the process of booking and paying for an in-app purchase ticket happens, click here
It all starts with entering the flight parameters:



in the search results, select the appropriate flight:



Confirm the number of passengers and cost:



Enter passenger



data : And payer data. PayOnline will send a payment receipt to the entered email address immediately after the payment is completed:



After that, the ticket will be booked so that at the time you make the payment, no one will buy your ticket directly “in front of you” (which can be especially offensive if the ticket was the last one):



And finally, the payment. As you can see, the design of the payment form is no different from the design of the remaining screens of the mobile application. A concise form allows you to minimize the proportion of failures at the payment stage:



The payment processing screen also corresponds to the overall design of the application:



We did not complete the payment completion screen, since at that time Yekaterinburg no one was planning to fly :)
But the monitoring data daily reports successful payments through the application.


What besides technical integration?


Entity


Only a legal entity or individual entrepreneur can enter into an agreement with PayOnline.

Website


The easiest way is to enable payment acceptance in a mobile application if you already have an online store or other commercial site. During the connection of receiving payments through the processing center (or through the bank directly), you will be given the so-called “terminal” - the identifier of your site. The vast majority of banks in Russia do not work directly with mobile applications. They are connected after the site and an additional terminal is issued to the application.

Therefore, if you do not have a website, for a painless and easy connection to accept payments in applications, you will need to make a simple business card site that meets the minimum requirements.

Commission rate


The commission rate is determined individually depending on the turnover of payments in the application and the level of risk with your business segment. The logic is clear: higher turnover - lower rate, higher risk - higher rate.

Payouts


Funds are transferred to your bank account on the 2nd or 6th day (depending on the selected base payment product).

That's all we wanted to tell you today about the Payment SDK for iOS and the specifics of setting up payment acceptance in iOS mobile applications. We will be happy to answer your questions in the comments!

Also popular now: