JSAPI payment for WeChat payment development

Source: Internet
Author: User
JSAPI can only be used in a built-in browser, but cannot be called by other browsers. The getBrandWCPayRequest interface is provided for the front-end webpage of the merchant to call. the merchant's payment permission will be verified before the call. if the merchant has the permission to initiate the payment, the payment process will begin. This section describes the interface calling rules before payment. for details about the message notification mechanism of payment status, refer to the following section. Note: all input parameters are of the string type! 1. js api Payment Interface (getBrandWCPayRequest)

JS APIs can only be used in built-in browsers, but cannot be called by other browsers. The getBrandWCPayRequest interface is provided for the front-end webpage of the merchant to call. the merchant's payment permission will be verified before the call. if the merchant has the permission to initiate the payment, the payment process will begin. This section describes the interface calling rules before payment. for details about the message notification mechanism of payment status, refer to the following section. Note: all input parameters are of the string type!

The getBrandWCPayRequest parameter is shown in Table 6-5.


Parameters

Name

Required

Format

Description

AppId

Public id

Yes

String type

After a merchant registers a public account with the payment permission, the account can be obtained;

TimeStamp

Timestamp

Yes

String type, less than 32 bytes

The number of seconds generated by the merchant from 00:00:00 to the present on January 1, January 1, 1970, that is, the current time, and must be converted to the string form;

NonceStr

Random string

Yes

String type, less than 32 bytes

Random string generated by the merchant;

Package

Order details extension string

Yes

String type, less than 4096 bytes

The merchant makes up the order information into this string. for details about the composition scheme, refer to the package group package in the interface instructions. the merchant concatenates the information according to the specifications and then transmits the information;

SignType

Signature method

Yes

String type. the parameter value is "SHA1"

Enter as shown in the document. Currently, only SHA1 is supported;

PaySign

Signature

Yes

String type

The merchant signs the parameters in the interface list according to the specified method, and uses the signature method marked in signType in the signature method. for details about the signature scheme, refer to the signature in the interface instructions to help the poor; after being signed by the merchant according to the specifications, it is passed in;


Table 6-5 getBrandWCPayRequest parameters

The returned value of getBrandWCPayRequest is shown in Table 6-6.


Return value

Description

Err_msg

Get_brand_wcpay_request: OK, payment successful
Get_brand_wcpay_request: The user cancels the cancel payment process.
Get_brand_wcpay_request: fail payment failed


Table 6-6 getBrandWCPayRequest return values

Js api return result get_brand_wcpay_request: OK is returned only when the user successfully completes the payment. Due to the complexity of front-end interaction, get_brand_wcpay_request: cancel or get_brand_wcpay_request: fail can be handled in a unified manner for users to encounter errors or voluntarily give up without further division.

II. js api payment implementation

The following code is the official js api payment demo.

 SetParameter ("bank_type", "WX"); $ wxPayHelper-> setParameter ("body", "test"); $ wxPayHelper-> setParameter ("partner ", "1900000109"); $ wxPayHelper-> setParameter ("out_trade_no", $ commonUtil-> create_noncestr (); $ wxPayHelper-> setParameter ("total_timeout", "1 "); $ wxPayHelper-> setParameter ("fee_type", "1"); $ wxPayHelper-> setParameter ("policy_url", "htttp: // www.baidu.com "); $ wxPayHelper-> setParameter ("spbill_create_ip "," 127.0.0.1 "); $ wxPayHelper-> setParameter (" input_charset "," GBK ");?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.