Luffy Xuecheng project - to pay - Alipay third-party payment

############### pay me through this Alipay What can be learned? ################

# Alipay 
# from which I can learn anything? 
# 1, the logical Alipay 
# 2, how to pay for access Polaris project, can be achieved Alipay payment 
# 3, look Alipay interface specification, write interfaces for their own reference,

 

############### Alipay apply ################

# To apply Alipay 
# This is Alipay open platform: HTTPS: //open.alipay.com/platform/home.htm 
# formal environment: 
# In the Developer Center, click on the Network & mobile applications, payments access, access when you need to create an application, and then give you a appid, which is a unique identifier, and now we do not have the qualification, is the need for the company's business license, 
# sandbox environment: 
# into the sandbox environment, there is a Developer Center R & D services, there is a sandbox, which is the analog Alipay real environment, which is a development simulation environment, so you can develop a program, and 
# important sandbox environment contents: 
# 1, AppID: this is a unique identifier, 
# 2, payment gateway: https: //openapi.alipaydev.com/gateway.do, through this address is the transfer of, dev is a sandbox environment, is removed after the formal, 
# 3, Peru key set: 
# 4, sandbox account: including merchants and buyers,

 

############### Alipay payment process ################

 

# Docking Alipay process: 
# need to look Alipay developer documentation, https: //docs.open.alipay.com/270, this is the computer's site to pay, there is a document used by the process, # 1, the user clicks to go payment 
# after the click, access django backend, then there is background processing function calls will go to pay treasure payment interface (alipay.trade.page.pay) 
# transfer interfaces need to pass any parameters: the order id, the total amount of orders the title, these three must pass, 
# and two will not pass, return_url, notify_url, which is the address of two django site, # 2, and then adjust the payment interface, Alipay what return? 
# Returns a payment interface, the payment page is a two-dimensional code, we need to guide users to the payment page, then that is the interaction between the user and the process to log Alipay payment, and 
# but then after a successful we do not know how do? # 3, after the completion of the payment, Alipay what return? 
# We need to adjust payment interface if there return_url, after Alipay payment is completed, immediately visit return_url this address, and pass parameters, the results tell site to pay, 
# we call this synchronous access, 
#



notify_url, this access is asynchronous, that is, after the payment is complete, access will not immediately have a certain amount of time, the goal is to tell the result of payment, just a synchronous an asynchronous, # or asynchronously prevail, because synchronization may not be allowed, # but now we even provide the address, because our address is not public, so Alipay can not access this address, how to get paid for the results? # Our site can access interface (alipay.trade.query) Alipay, which is the interface a transaction query, you can check the results of the transaction, will return results paid by users,

 

 

############### use sdk and configuration keys ################

# Use sdk and configuration keys 
# native interface requires our own tone, his own pass parameters to generate prepaid orders require the use of a signature, signature generation is too much trouble prone to error, it provides a sdk, simplifying the development process, 
# how to use this sdk ? 
# Now we have sdk official language of the python 
# ################################ 
# Set keys 
# a need to pass parameters, this process requires a transfer request before encryption, which is related to the public and private keys, 
# private key for encryption, public key to decrypt, 
# Django website issued when Alipay platform, it is necessary through their own private key to encrypt data, then Alipay public key to decrypt, so need to get your public key to tell Alipay, 
# Alipay to django message back when the need to use private key encryption Alipay, distributed sites, and sites need Alipay the public key is decrypted, 

# Alipay provides tools to generate public and private keys, you can download it, and then generate, 
# after generating their own public and private keys, put their own public key to Alipay, then it will generate a public key Alipay, 
# then you want to save public Alipay in the project, and private app

 

############### paid logic ################

# Click the button to pay the logic 
# backend: 
# 1, get to the front end pass over the price of goods purchased, 
# 2, generate orders, 
# 3, using the argument that we need to build sdk, 
#    3.1, the instantiation of a alipay object, passing the required parameters, 
#    3.2, build our parameter 
# 4, stitching url, redirect to Alipay, Alipay request payment interface, 
# 5, directly to the rear end of the url redirection, can give to the front and then the front to deal with,

after # front end jump to the payment page
# landing Alipay,
# after successful payment, Alipay will automatically call notify_url, tell whether or not we succeed, # we have to deal with the post request, # backend: # 1 verification data # 2, if the payment is successful, modify the order status,
# 3, return to the front end result of payment,
# 4, and then the tip will be returned to the customer, failure to return a page failure, the success of the successful return of the page,

 

 

############### end line ################

Guess you like

Origin www.cnblogs.com/andy0816/p/12094803.html