Home  >  Q&A  >  body text

html5 - 自己的H5页面如何集成支付宝支付

大家讲道理大家讲道理2742 days ago1010

reply all(3)I'll reply

  • 迷茫

    迷茫2017-04-17 14:58:47

    Thank you for the invitation.

    Unfortunately, I have not integrated Alipay... but I have integrated Paypal with some foreign credit card payments.
    For details on how to integrate, just take a look at the documentation and demo.

    Front-end page or server-side integration?

    This depends on the complexity of your payment business. If it is just a simple scan code payment or something, just integrate it directly on the page. For specifics, you still have to refer to the suggestions in Alipay’s official documentation. When your payment business is quite complex (such as recurring payments, I don’t know if Alipay has it) or you feel that the page is unsafe, you can put it on the server.

    Note the following:

    1. Message callback after payment (paypal is called IPN), you must read the document carefully and understand every status mentioned in the official document, success, failure, processing, etc. (maybe in Alipay None of these...I don't know). The handling of each status must be considered comprehensively.

    2. Pay attention to the delay of message callback. The user may have paid, but the payment server may have a processing delay. This situation must be considered.

    3. The verification of parameters is extremely strict. It is best to calculate the price on the server side and then pass it to Alipay. Do not trust the data given by the client.

    4. The payment interface guidance must be friendly. For example, after the user makes a successful payment, but the server has an error and no corresponding processing is done, you must give the user an entrance to contact you to avoid confusion...

    The above are my feelings after doing some payment integration...
    Don’t deceive users. . .
    You must treat the money code with all your strength, you really can’t be careless...

    reply
    0
  • PHPz

    PHPz2017-04-17 14:58:47

    I have done Alipay front-end payment before, and the back-end needs to return a string of codes. The front end can pay as long as it triggers this code. As for what parameters are required for the back end, it depends on your business. See Alipay documentation for details

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-17 14:58:47

    I don’t know how to configure the backend. Alipay’s official documentation should mention that the front-end still needs to write some code:
    It’s mainly a callback function

                   res => {     const p = document.createElement('p');
                        p.innerHTML = res.html;
                        document.body.appendChild(p);
                        document.forms.alipaysubmit.submit(); }

    reply
    0
  • Cancelreply