📜 ⬆️ ⬇️

The Story Of An API: How We Turned Frankenstein Into A Handsome Boy

What is needed to build an ecosystem of non-banking services, and indeed any such ecosystem? Master data storage and processing system, as well as API. In this post we will examine two versions of the API created by us - the first and successful one - and we’ll discuss in detail what their important differences are from each other.



To create an ecosystem of non-banking services, the key product of Sberbank's Digital Corporate Bank Division was chosen - the Internet Bank for corporate clients of Sberbank Business Online. Accordingly, the fintech API for the ecosystem of non-banking services was also based on it.

The first version of fintech API was launched in 2016. It was created with an eye on our other APIs of our bank, according to the classic API recipes of large financial organizations. Here are the basic ingredients:
')

We made such a decision and started pilot integrations with several non-classical banking services: the Evotor online store, the Seeneco Business Analytics financial management system, My Delo cloud accounting and others.

The results of the integration were far from desired. From the API of modern non-financial services, the partners waited for something completely different from what is customary in the development of classic banking products. We wanted to get something similar to the API of modern Internet giants: Facebook, Google, Yandex.

But in the end, we faced the classic API of the bank - hard, incomprehensible, requiring high and specific qualifications, understanding the subtleties of workflows, the implementation of redundant security requirements ... in general, many things that lead to a violation of all possible integration deadlines.

We analyzed this experience and decided to make a new version of the fintech API from scratch. To get the maximum win-win with third-party non-financial services, the most important requirements outlined in advance:


With this list we went to the implementation and chose solutions for the second version of the fintech API:


What has changed in fact


To assess the difference between the two versions of the API, let's compare the implementation of its three key components: authorization, the implementation of a ruble payment order and electronic signature.

In the first version of the API, the authorization of the partner required a login and password, a certificate, and AccessToken, obtained as a result of the OAUTH authentication of the requesting client:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:upg="http://upg.sbns.zzzzz.com/">   <soapenv:Header/>   <soapenv:Body>      <upg:preLogin>         <!--Optional:-->         <upg:userLogin>U1</upg:userLogin>         <!--Optional:-->         <upg:changePassword>!d63NvJ+Sa</upg:changePassword>      </upg:preLogin>   </soapenv:Body> </soapenv:Envelope> 

In API 2.0, authorization has become much more compact. To access the services, you only need the AccessToken obtained during OAUTH client authentication:

 { "access_token": "fdba5482-460c-4535-b829-9fd836fd01f0-1", "token_type": "Bearer", "expires_in": 3600, "refresh_token": "7f545a14-ab7b-45ff-823a-0421e9f3b42e-1", } 

In API 1.0, work with a ruble payment order was also based on SOAP:

 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:upg="http://upg.sbns.zzzzz.com/">  <soapenv:Header/>  <soapenv:Body>     <upg:sendRequestsSRP>        <!--Zero or more repetitions:-->        <upg:requests><![CDATA[       <Request xmlns='http://zzzzz.com/upg/request' orgId='84b70f22-703f-bf04-db60-bd110572f40d' requestId='a81ddc6d-fb92-416d-83f9-6785a59a4b17' version='1.0' sender='PARTNER' clientOrgIdHash='ee0fb56b01a9d9b9648a2c60549b77702eb2a6de8f2189c4349447e43b250da5' clientAccessToken='ee0fb56b01a9d9b9648a2c60549b77702eb2a6de8f2189c4349447e43b250da5-1'> <PayDocRuInvoice docExtId='a81decfd-fb92-416d-83f9-6785a59abb65' orderNum='62' deadLine='2017-04-10T17:16:03'> <PersonalAcc>40802810000000000000</PersonalAcc> <AccDoc docDate='2017-02-15' docSum='777' transKind='01' paytKind='01' priority='1'> <Purpose>!!!!! 18%</Purpose> </AccDoc> </PayDocRuInvoice> </Request>        ]]></upg:requests>        <!--Optional:-->        <upg:sessionId>5a869c00-e979-4280-b11a-6dbbb8a90214</upg:sessionId>     </upg:sendRequestsSRP>  </soapenv:Body> </soapenv:Envelope> 

In API 2.0, in the same way, everything has become much simpler and clearer:

 {  "amount": 12.01,   "date": "2018-06-22",   "deliveryKind": "",   "expirationDate": "2018-06-23",   "externalId": "1516ec0c-761c-11e8-adc0-fa7ae01bbebc",  "operationCode": "01",  "orderNumber": "1237",   "payeeAccount": "40706810000000000000",   "paymentNumber": "1",  "priority": "5",   "purpose": "  №1237.   .",  "urgencyCode": "NORMAL",   "vat": {    "amount": 100.01,     "rate": "7",     "type": "NO_VAT" } 

Electronic signature, we also facilitated. This is how everything was in API 1.0.


It looked like a request


Here is a list of attributes


And here is the finished signature

In the version of API 2.0 through JSON implemented everything easier:


Request itself


Signature as a result

Results


The fintech API 2.0 pilot launches showed that things went much better. The time of integration with partners' products - from the start of work to the date of release into commercial operation - has decreased by more than 3 times. The number of questions from our support service has decreased by an order of magnitude, and most importantly, the complexity of these questions has decreased. Finally, the number of complaints about the complexity and unpredictability of the API work has decreased by as much as two orders. In general, we did it. If you have any questions - welcome to the comments, we are happy to tell you the details.

The material was prepared by Andrey Khokhlov, Project Manager of the Digital Corporate Bank Division of Sberbank

Source: https://habr.com/ru/post/421693/


All Articles