当前位置:网站首页>Complete payment system architecture!

Complete payment system architecture!

2020-12-08 09:53:28 Java technology stack

2017-12-04 08:57:44

Organized on the Internet

From product classification 、 Module functions and business processes , Understand the design of payment products and services .

The payment product module provides payment services for business parties according to payment scenarios . This module is usually located behind the payment gateway , Before the payment channel . It encapsulates different payment channels into a unified interface according to the payment ability , Through the payment gateway to provide services . therefore , From the perspective of microservices , The payment product itself is also a micro service of agent mode , It responds to business side requests through a payment gateway , After some unified treatment , Distribute to different payment channels to execute , Finally, after processing the execution result , It is sent back to the business side through the payment gateway . The position of payment products in the payment system architecture diagram , As shown in the figure below :

Product classification

In different companies, due to different access channels and Applications , The classification of payment products is slightly different . Integrated payment scenarios and processes , Payment products can be divided into the following categories :

Payment product is the payment ability provided by the payment system to the business party by encapsulating the payment channel . On the whole , The following payment products are available :

1. Quick payment

After the user has finished binding the card , At the time of payment , There's no need to enter a card or ID again , Just enter the payment password to complete the payment . For small payments , You can even open a small amount of password free , Direct payment . This payment method does not interrupt the user's experience , Is the main online payment method at present . Generally, fast payment products are implemented by encapsulating the quick payment interface or agent payment interface provided by the bank or the third-party payment platform .

2. E-currency payment

When users pay , Need to jump to the bank online banking page to complete the payment . On the online banking page , You need to enter the user's card number and identity information . This payment method will interrupt the user's current experience , Generally only used for PC Web Payment on . Online banking payment is to encapsulate the online banking payment provided by banks .

3. Payment by agreement

Agreement payment is also called collection or withholding , Collection means that the channel authorized merchant can deduct money from the user's bank account , It is generally used for regular deduction , Not for daily consumption . Such as water, electricity and gas 、 Cable TV fee . Agreement payment is made by encapsulating the bank 、 Third party payment provides a withholding or quick interface to implement .

4. Platform payment

Use wechat 、 Alipay and other three party payment platform to complete the payment . When using , Generally, users need to install payment platform system in advance ( On the cell phone ), Sign up and log in to a third-party payment platform , And has completed the binding card and other operations on the platform . Due to wechat 、 Alipay has been widely used. , Users also generate trust in these platforms , Platform payment is often the main payment method of e-commerce companies .

5. Foreign card payment

For overseas payments , Also need to provide foreign card payment support . Many domestic payment channels can support foreign card payment , Such as Alipay global purchase, etc. . Direct docking Paypal, It is also the most used foreign card payment channel at present .

6. Call payment

For small payments with monthly payments , Mobile phone charges are also a good choice . At present, there are also some platforms that can support payment , Soft as a rainbow 、 Linkage advantages, etc .

7. Virtual currency payment

Many companies will have their own virtual currency , Like Jingdou 、Q Money, etc . These virtual currencies can also be used as a way of payment .

8. Account payment

Also known as balance payment 、 Change payment, etc . It refers to the establishment of local accounts for users , Support recharge , You can then use this account to complete the payment .

9. Credit payment

Such as Jingdong's white note , Ant flower, etc , To use a credit account for overdraft , Similar to credit card payment .

10. Payment on behalf of

Contrary to withholding , Payment on behalf is that the platform sends money to users .

Module function

Payment products depend on their ability to pay , It provides different functions to the outside world . On the whole , General payment products need to provide the following interface :

1. Signing and termination

In express payment 、 Withholding and other products , Before using , We need to complete the contract first . The contract can be signed on the channel side , Generally, third party payment is made in this way , When e-commerce needs access , Let the third party give the authorization . The signing of a contract between the bank and UnionPay is generally conducted on the e-commerce side , The e-commerce side is responsible for collecting user information , Call the interface between bank and UnionPay to sign a contract . After signing , The subsequent payment will be made with the signing number , No need to enter personal information . Corresponding to signing a contract , To terminate a contract is to cancel a contract .

2. payment

Payment is an indispensable operation . Payment behavior is different in different products . Fast payment is initiated on e-commerce servers , Request channels to pay ; Online banking payment is to jump to the bank payment gateway ; And the account pays 、 Virtual currency payment , It's done locally .

3. Cancellation and refund

Some channels distinguish between revocation and refund , Such as UnionPay 、 ABC, etc , Cancellation refers to the cancellation of unsettled transactions on the channel side on the same day ; The refund is only for transactions that have been settled . Some channels are not distinguished .

4. Query contract status

For transactions that need to be signed , You can query the contract status through this interface .

5. Query order status

Through this interface, you can query the status of the payment list and the order status of the refund .

6. Pre licensing

Pre authorization transaction is used by the acceptor to confirm the transaction permission to the cardholder's issuer . The receiver takes the estimated consumption amount as the pre authorization amount , Issuer to cardholder .

7. Revocation of pre authorization

For successful pre authorization transactions , Use pre authorization to reverse transactions before settlement , Notify issuer to cancel payment commitment . Pre authorization revocation transaction must be the full cancellation of the final acceptance amount of the original pre authorization transaction or additional pre authorization transaction .

8. Pre authorization completion transaction

For approved pre authorization transactions , Use pre authorization to complete payment settlement .

9. Pre authorization complete revocation

Pre authorization completion revocation transaction must be the full revocation of the original pre authorization completion transaction . Pre authorization is still valid after revocation of pre authorization .

10. Reconciliation

adopt FTP perhaps HTTP Method to provide reconciliation documents for merchant side reconciliation .

11. Balance inquiry

Check the balance of the merchant's trading account , Avoid trading failure due to insufficient balance . Be careful , It's not the customer's balance . Of course , Not all banks or third-party payments provide this interface .

The business process

The above operation , Except for the reconciliation 、 Check the list , Main process implemented by each operation , It usually includes “ Parameter checking , Payment route , Generate order , risk assessment , Call channel service , Update orders and send messages ” this 7 Step , For some more complex services , It also involves the steps of asynchronous notification processing .

1. Perform parameter verification

All payment operations , All need to perform parameter verification on the input , Avoid attacks on interfaces . Verify the validity of the fields in the input parameters , Such as user ID、 Merchant ID、 Price 、 Return address and other parameters . Verify account status , The subject of the transaction 、 The status of accounts such as counterparties is in a tradable state . Verify order , If advance orders are involved , Also need to verify the validity of the order number , The order status is unpaid . In order to prevent users from caching a URL Address , We also need to check whether the order time and payment time exceed the predetermined interval . Verify the signature , The signature is also to prevent the payment interface from being forged . The general signature is distributed to the merchant key To do this for the string that the input parameters are spliced into MD5 Hash perhaps RSA encryption , It is then submitted to the server as a parameter along with other parameters , Signature verification can also be done uniformly in the gateway .

2. Find the right payment service according to the payment route

Determine the appropriate payment channel to complete the operation according to the payment method selected by the user . The payment method specified by the user is not necessarily the final channel for payment . For example, users choose to pay through ICBC credit card , But we did not realize the docking with ICBC , It can be paid through a third party , Like alipay 、 Wechat payment 、 Yi Po payment , Or UnionPay . How to choose the right payment channel , Through the payment path to achieve . The payment route will consider the charges comprehensively 、 Channel availability and other factors to choose the best solution .

3. Assessing transaction risk

Check if there is any risk in this transaction . The risk control interface returns three results : Blocking transactions 、 Transaction validation and release enhancement . Blocking transactions , It shows that the transaction is high risk , Need to end , Do not execute the 5 A step ; Enhanced verification , It shows that there is a certain risk in the transaction , Need to confirm whether the user is operating in person . This can be verified by sending SMS verification code or other ways to verify the user's identity , After the verification is passed , The transaction can continue . Release transaction , That is, the transaction is safe , You can keep going .

4. Generate transaction order

Persist the order information to the database . When access pressure is high , Database writing can be a bottleneck .

5. Invoking services provided by payment channels

All payment services require a third-party channel to perform . General bank channel call is relatively simple , You can return the result directly . And some third parties pay , Alipay , Wechat payment, etc , The payment result will be informed through the asynchronous interface .

6. Update order

For results returned synchronously , The status of the order needs to be updated in the main thread , Mark whether the payment was successful or failed . For asynchronous return channels , It needs to be handled in an asynchronous program .

7. Send a message

Inform the relevant system of the order change by message . Risk control , credit BI etc. , We need to rely on this data for quasi real-time calculation .

8. Asynchronous notification

Such as the above process , It involves calling the remote interface , The delay is uncontrollable . If the caller keeps blocking and waiting , It's easy to time out . Introducing asynchronous notification mechanism , You can have the caller return as soon as possible in the main thread , Get payment results through asynchronous threads . For the channel interface to get payment results asynchronously , You also need to return the result to the caller in an asynchronous notification . Asynchronous notification requires the caller to provide a callback address , General with http perhaps https The way . There is a technical risk , If the call fails , You need to try again . And try again not too often , You need to gradually increase the interval between each try again . In an asynchronous handler , After the order changes its status according to the result of processing , Also send a message to inform the relevant system .

Overall design of payment system architecture

Each company depends on its business and the different stages of its development , The payment system will be different . Let's take a look at some typical payment system architectures of Internet companies .

1. Alipay

There is no difference in the overall architecture . In terms of module division , This graph shows the top-level partition , No more details could be given . But there are two points in Alipay architecture document that must be carefully considered in designing payment platforms . One is Accounting treatment , In terms of bookkeeping , Two subsystems are involved , The external subsystem is a unilateral account , Meet online performance requirements ; Double entry bookkeeping of internal subsystem , Meet financial needs , Such as bookkeeping 、 Reconciliation and reconciliation .

The other is Flexible transaction processing , Using message mechanism to realize cross system transaction processing , Avoid performance issues caused by database locks .

2. Jingdong Finance

Jingdong finance is developed on the basis of online banking . There are many technical personnel in the original class of online banking from Yibao company , After Jingdong's acquisition , And introduced Alipay talents. , Therefore, they are greatly influenced by the two companies in terms of structure .

3. Where are you going?

All of these architecture documents come from the Internet , Whether the architecture truly reflects the actual system situation , It's up to you to judge . We are only based on these documents , Analyze the software architecture of payment system .

Reference Architecture

Generally speaking , The typical architecture of payment system will include the following modules :

The payment system is architecturally , Divided into three layers ;

  • Supporting layer : The basic software packages and infrastructure used to support the core system , Including operation and maintenance monitoring system 、 Log analysis system, etc .

  • Core layer : The core module of payment system , The interior is divided into two parts : Payment core module and payment service module .

  • Product layer : Services provided through the core layer are combined , For end users 、 Merchant 、 System provided by operation management personnel .

1. Support system

The support system is the infrastructure that a company provides to the operation of the payment system . It mainly includes subsystems :

  • Operation and maintenance monitoring : Payment system will inevitably be affected by various internal and external interference in the process of operation , The fiber is cut off 、 The hacker attacks 、 The database was deleted by mistake 、 There are bug wait , The operation and maintenance personnel must respond to these accidents as soon as possible , Not one day 24 Hours staring . This requires an operation and maintenance monitoring system to help complete .

  • Log analysis : Log is the statistical analysis of payment system 、 Important basis for operation and maintenance monitoring . The company needs to provide infrastructure to support the unified collection and analysis of logs .

  • SMS platform : SMS plays an important role in the payment system , Like authentication 、 Secure login 、 Retrieve password 、 And alarm monitoring , All need SMS support .

  • Security mechanism : Security is the lifeline of payment . SSL、 Certificate system 、 Anti brush interface, etc , Are necessary facilities for payment .

  • Statistical report : Visualization of payment data , It is the basis for the company to make decisions .

Remote connection management 、 Distributed computing 、 Message mechanism 、 Full text search 、 File transfer 、 data storage 、 Machine learning, etc , They are the basic software necessary for building large-scale systems , I will not introduce them in detail here .

2. Payment core system

Payment core system refers to the core process of payment by users , Include :

  • The user starts the payment process from the payment application ;

  • The payment application calls the corresponding payment product according to the payment tool selected by the application and the user to execute the payment ;

  • The payment route is based on the payment tool 、 Channel rate 、 Interface stability and other factors to choose the appropriate payment channel to land payment ;

  • Payment channel calls bank 、 Third party payment and other channels provide the interface to perform payment operations , Final landing fund transfer .

3. Payment service system

Support the functions provided by the payment core system , Service system is divided into basic service system 、 The funding system 、 Risk control and credit system .

Basic service system Provide the basic business functions to support the operation of online payment system :

  • Customer information management : Including for users 、 Merchant's real name identity 、 essential information 、 Management of agreements ;

  • Card and voucher management : On coupons 、 vouchers 、 Production of discount coupon 、 issue 、 Management of usage process ;

  • Payment channel management : Channel interface 、 Configuration parameters 、 cost 、 Limits and QOS Management of ;

  • Accounts and accounting systems : Manage account information and transaction flow 、 Bookkeeping voucher, etc . The accounting here generally refers to the accounting of the system on the wiring , The bookkeeping method of unilateral account is adopted , Internal accounts are recorded in the accounting system .

  • Order system : General order system can be realized independently of business system , Orders here , Mainly refers to the payment order .

The funding system Refers to the verification of back office funds generated around financial accounting 、 Scheduling and management system , Include :

  • Accounting : Provide accounting subjects 、 Internal accounting 、 Trial balance 、 Sun cut 、 Flow registration 、 Functions of accounting and filing .

  • fund management : Managing the company's position in various payment channels , Make payment when the balance is insufficient . To third party payment companies , Provisions also need to be managed .

  • Liquidation and distribution : For the business with profit sharing demand , There is also a need to provide clearing 、 Reconciliation processing and billing sharing function .

Wind control system It is the basic function of payment system , All payments must be risk assessed and appropriate measures taken ; Credit system It is an advanced function developed on the basis of risk control , Jingdong's white note , Ant flower, etc , All successful cases .

4. Payment application

Support system 、 Core system and service system , The architecture of every Internet company is very similar , Are essential modules . The payment application is built by each company according to its own business , Each are not identical .

On the whole , It can be divided into end-user applications according to the object of use 、 Application for merchants 、 Operation management for operators 、BI And risk control backstage .

Recent hot article recommends :

1.Java 15 Official release , 14 A new feature , Refresh your mind !!

2. Finally, I got it through open source projects IntelliJ IDEA Activation code , It's delicious !

3. I use Java 8 Wrote a piece of logic , I can't understand it , You try ..

4. To hang up Tomcat ,Undertow It's very powerful !!

5.《Java Development Manual ( Song Mountain version )》 The latest release , Download it quickly !

I think it's good , Don't forget to like it + Forward !

版权声明
本文为[Java technology stack]所创,转载请带上原文链接,感谢
https://chowdera.com/2020/12/20201208095304352f.html