This article provides a detailed analysis of the Code for using php to implement the fast payment function. For more information, see
This article provides a detailed analysis of the Code for using php to implement the fast payment function. For more information, see
This project is implemented using the zend framework
Modules/default/controllers/IndexController. php
IndexController. php
The Code is as follows:
Class IndexController extends Zend_Controller_Action
{
Public function init ()
{
/* Initialize action controller here */
}
Public function indexAction ()
{
/* Simulate an order
* $ MockOrder refers to the information obtained from the database, which contains information about the Request for a certain amount of money. Here I am writing dead.
* OrderId: the order number, which is the primary key (unique) of the database table ). // Required fields
* Usr_idtype: Specifies the credential type.
* Usr_idcode ID, as required.
* Whether the etx_status is favorable depends on your needs.
* Time_create is used to verify whether the discount time is met.
* The ets_license package code is similar to the product category and can be customized as needed.
* Contact_type: contact type. The value is invariably set to 1 or 2. 1 email, 2 mobile phone number, according to your needs, the block money can be blank.
* Contact_text contact information, which can be filled in according to contact_type. For us space, the block price can be Blank Based on your needs.
* The etsPrice package price and product price are based on your needs.
* The actual price of orderPrice depends on your needs.
* The actual payment amount of the orderAmount order, which requires a handling fee. // Required fields
* OrderTime order time. // Required fields
* Whether the payment for the paySuccess order is successful. // Required fields
* Whether the buySuccess account is successfully created depends on your needs.
* PayTime: the time when the order is successfully paid. // Required fields
* In short, all fields related to orders are required.
* OrderId, orderAmount, and orderTime are required fields for Request.
* PaySuccess and payTime are the fields required for Response.
*/
$ MockOrder = array ();
$ MockOrder ['orderid'] = '000000'; // the order number. -- Required
$ MockOrder ['usr _ idtype'] = '1'; // credential type, ID card
$ MockOrder ['usr _ idcode'] = '000000'; // ID card number
$ MockOrder ['etx _ status'] = '0'; // whether the offer is made, no
$ MockOrder ['time _ create'] = '000000'; // verify whether the discount is made
$ MockOrder ['ets _ license '] = '1'; // package code and product category
$ MockOrder ['Contact _ type'] = '1'; // contact method type 1, email
$ MockOrder ['Contact _ text'] = 'x @ 163.com '; // contact information, email
$ MockOrder ['etspric'] = '000000'; // package price and product price
$ MockOrder ['orderprice'] = '000000'; // actual price
$ MockOrder ['orderamount '] = '000000'; // the actual payment price of the Order, plus the handling fee. -- Required
$ MockOrder ['ordertime'] = '000000'; // The Order generation time. -- Required
$ MockOrder ['paysuccess'] = '0'; // whether the order is successfully paid. -- Required
$ MockOrder ['buckets'] = '0'; // whether the account is successfully generated
$ MockOrder ['paytime'] = '0'; // The order payment time. -- Required
// BillRequest is the parameter required by quickmoney.
$ This-> view-> BillRequest = new Application_Model_BillRequest ($ MockOrder );
Zend_Debug: dump ($ this-> view-> BillRequest); exit;
}
// BgUrl address points to here
Public function receiveAction ()
{
// Receive Database Design
/* Use the $ MockReceive array to simulate
* $ MockReceive = array ();
* $ MockReceive ['id'] primary key;
* $ MockReceive ['orderid'] Merchant Order number;
* $ MockReceive ['receivetime'] receiving time;
* $ MockReceive ['querystring'] http_build_encode ($ _ REQUEST );
* $ MockReceive ['dealid'] fast money transaction number;
* $ MockReceive ['bankdealid'] bank transaction number;
* $ MockReceive ['payresult'] processing result 10: Payment successful; 11: Payment failed;
* $ MockReceive ['dealtime'] fast money transaction time;
* $ MockReceive ['payamount'] actual payment amount of the order;
* $ MockReceive ['signature'] fee;
* $ MockReceive ['errorcode'] error code;
*/
/* $ _ REQUEST is the data returned by quickmoney.
* The merchantAcctId account is the same as the block money account used to submit the order.
* Version: The Gateway version with a fixed value: v2.0, which is consistent with the gateway version number when the order is submitted.
* The language web page displays the language type, which is displayed in Chinese and consistent with the language type displayed on the web page when the order is submitted.
* SignType: signType, 4 PKI signature. It must be consistent with the signature type when the order is submitted.
* PayType payment method, 00 all, consistent with the payment method when submitting the order
* BankId Banking Code
* OrderId: the merchant's order number. It is a Hong Kong server. It must be consistent with the merchant's order number when the order is submitted.
* OrderTime: the time when the merchant's order was submitted, consistent with the time when the merchant's order was submitted
* OrderAmount refers to the Merchant Order amount, which is consistent with the Merchant Order amount when the order is submitted.
* DealId: fast money transaction number
* BankDealId: bank transaction No.
* DealTime: fast money transaction time
* Actual payment amount of the payAmount order
* Renewal fee
* Ext1 extension field 1, which is consistent with the extension field 1 when the order is submitted
* Ext2 extension field 2, which is consistent with the extension field 2 when the order is submitted
* PayResult processing result 10: Payment successful; 11: Payment failed
* ErrCode error code, which can be empty
* SignMsg signature string
*/
$ BillResponse = new Application_Model_BillResponse ($ _ REQUEST );
// $ BillResponse-> checkSignMsg verifies that the signature string is correct and prevents bugs.
If ($ BillResponse-> checkSignMsg ){
// Determine whether the order payment is successful
If ($ BillResponse-> isSuccess ){
// Return to quickmoney. The quickmoney will jump to the new page according to the redirecturl address. This is the success page.
Return" 1 "; Exit;
} Else {
// Return to quickmoney. The quickmoney will jump to the new page according to the redirecturl address. This is a failure page.
Return" 1 "; Exit;
}
}
// Return to quickmoney. The quickmoney will jump to the new page according to the redirecturl address. This is a failure page.
Return" 1 "; Exit;
}
// Redirecturl
// Succeeded
Public function success ()
{
}
// Failed
Public function fail ()
{
}
}
Modules/default/views/scripts/index. phtml
Https://www.99bill.com/gateway/recvMerchantInfoAction.htm
The Code is as follows: