Divided into two steps: 1. Generate an order 2. Pay for the order
It seems easy to understand the logic after breaking it down:
Generate an order and associate it to generate two payment paths (points + WeChat)
The order has a payment validity period (for example, automatic cancellation if payment is not made within 2 hours), and there is also an entry for manual cancellation by the user.
Enter the payment logic after the order is generated. In these two logics, the points payment is carried out immediately, and the WeChat payment calls the interface. When the payment is successfully called back, the payment status of the two payment methods is checked. If both have been paid successfully, the order is paid successfully. If the points payment has not been completed, wait for the points payment. .
If there is a timeout cancellation or the user cancels by himself, the payment from each path will be returned to the original route: the points will be returned to the points account, and WeChat will call the refund interface
After initiating payment, freeze the points to be deducted. If the payment is successful, the points will be deducted. If the payment fails or is canceled, the points will be unfrozen.
Set how many RMB a point will cost at the beginning, or launch a separate point + cash activity, otherwise it will be difficult to add it later. I think you can add a new module and define the value of points yourself. Users can choose the number of points to use when making purchases, and they can be combined into cash for calculation during settlement.
Points will be deducted first. 1. If the payment is unsuccessful, points will be returned according to the payment callback function and the order will be voided. 2. If the payment is successful, just modify the order status to completed.
Divided into two steps:
1. Generate an order
2. Pay for the order
It seems easy to understand the logic after breaking it down:
Generate an order and associate it to generate two payment paths (points + WeChat)
The order has a payment validity period (for example, automatic cancellation if payment is not made within 2 hours), and there is also an entry for manual cancellation by the user.
Enter the payment logic after the order is generated. In these two logics, the points payment is carried out immediately, and the WeChat payment calls the interface. When the payment is successfully called back, the payment status of the two payment methods is checked. If both have been paid successfully, the order is paid successfully. If the points payment has not been completed, wait for the points payment. .
If there is a timeout cancellation or the user cancels by himself, the payment from each path will be returned to the original route: the points will be returned to the points account, and WeChat will call the refund interface
Judge the points before initiating payment and then deduct them after the payment is successful? Isn’t this okay?
After initiating payment, freeze the points to be deducted. If the payment is successful, the points will be deducted. If the payment fails or is canceled, the points will be unfrozen.
Set how many RMB a point will cost at the beginning, or launch a separate point + cash activity, otherwise it will be difficult to add it later.
I think you can add a new module and define the value of points yourself. Users can choose the number of points to use when making purchases, and they can be combined into cash for calculation during settlement.
Points will be deducted first.
1. If the payment is unsuccessful, points will be returned according to the payment callback function and the order will be voided.
2. If the payment is successful, just modify the order status to completed.