Accepting a Paypal payment through a custom-built website

后端 未结 2 1103
予麋鹿
予麋鹿 2020-12-18 16:20

I have been making a hotel booking software that calculates, for given dates and specifications, a price for staying at a hotel. I\'m looking to use Paypal for accepting th

相关标签:
2条回答
  • 2020-12-18 17:00

    Paypal's Direct Integration can handle pricing like this. I'd imagine some of their less involved solutions will too, but I know that DI does.

    Edit:

    ExpressCheckout appears to also:

    https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_SetExpressCheckout

    0 讨论(0)
  • 2020-12-18 17:11

    I just completed this process in my current website: bpremium.com, basically I built a webservice api for the payment process where it can send commands over javascript until it gets to the last stage, which is where you build the form you send to paypal.

    in order to record the payment, you setup another webservice for the notify url and this will catch all the $_POST data and process it into your database.

    <form id="form-payment-paypal" action="https://www.paypal.com/cgi-bin/webscr">
    <input type="hidden" name="cmd" value="_xclick" />
    <input type="hidden" name="bn" value="PP-BuyNowBF" />
    <input type="hidden" name="charset" value="utf-8" />
    <input type="hidden" name="business" value="YOUR_ACCOUNT_EMAIL_ADDRESS" />
    <input type="hidden" name="item_name" value="THE PRODUCT NAME" />
    <input type="hidden" name="item_number" value="YOUR_RECOGNISABLE_SALE_ID?>" />
    <input type="hidden" name="currency_code" value="EUR" />
    <input type="hidden" name="lc" value="THE LANGUAGE CODE: es_ES, en_GB, etc" />
    <input type="hidden" name="amount" value="<?=$amount+($amount*0.04)?>" />
    <input type="hidden" name="return" value="/payment/complete/" />
    <input type="hidden" name="notify_url" value="/webservice/payment/notify/paypal/" />
    
    <p class="ac span300">
        <input  type="submit" class="form-style-bt" value="PAY" />
    </p>
    </form>
    

    that is basically what we use, you can see we put the $amount + $amount*0.04 because you needed to add a 4% surcharge in spain, where I am. perhaps thats different in your code.

    I think the rest of it is pretty self explanatory.

    on the /webservice/ url, you need to record everything into your database, it sends you the information whether it succeeded or failed, but it's not a call to your website, you won't see this page, it's a "back channel" call to your website, so it's not your landing page, it's simple the url paypal sends all the raw data to, you're supposed to record it, process it and perhaps send out emails, etc.

    then if the user returns to your website, you land on the /payment/complete page, so this page could show the result, whether everything is ok, or something failed.

    hope it helps.

    0 讨论(0)
提交回复
热议问题