Can I send a variable to paypal, and have it post it back to me when payment completes?

前端 未结 7 1368

Ive been using express checkout API to convert people\'s accounts on my site to premium accounts after paying. The only problem with it is that it doesn\'t send the user bac

相关标签:
7条回答
  • 2020-12-04 18:11

    Yes, if you send item_number, the IPN notification will include that when it posts back to you. I record a unique ID in the database when the user starts the payment process, and include that when sending them to PayPal. When the IPN comes in, that unique ID matches up with the record in the database, giving me all the info I need.

    Edit Re your comment:

    I expect there's a code example somewhere on the site linked above, but basically in my case I'm using a form that I POST to https://www.paypal.com/cgi-bin/webscr. Within that form are various hidden fields documented in the IPN stuff (cmd for what command to perform, business to specify your business ID, item_name for a nice description in the PayPal UI, item_number for the item number I mentioned above, etc., etc.). When IPN posts back to your IPN address, it includes various fields (such as payment_status — kind of important! &mdash and the item_number you fed in when posting to them).

    0 讨论(0)
  • 2020-12-04 18:17
    <input type="hidden" name="on0" value="Ajay Gadhavana">
    <input type="hidden" name="on1" value="my_phone_number">
    <input type="hidden" name="on2" value="my_third_extra_field">
    

    Response from paypal would be

    [option_name1] => Ajay Gadhavana [option_name1] => my_phone_number [option_name1] => my_third_extra_field

    0 讨论(0)
  • 2020-12-04 18:18

    Iten_number hidden variable don't work in my application. But i found that custom hidden field works fine. Just add this field to the form, generated by paypal: <input type="hidden" name="custom" value="YOUR VALUE FROM DB"/>. After, you can read this value to identify, for example, what product have been purchased. (Java code): String custom = request.getParameter("custom");

    0 讨论(0)
  • 2020-12-04 18:20

    I hope this URL solves your issue. As it solved mine as well. Add a custom variable to your form and then retrieve it on your success payment page. Example : <input type='hidden' name='custom' value='<?php echo $email; ?>'/>

    and then retrieve it as :

     $_POST['custom']
    
    0 讨论(0)
  • 2020-12-04 18:21

    Just to add to this old question...

    There are option parameters that are commonly used for custom data sending through paypal.

    These option tags are on0, on1, or on2 for the custom field names and os0, os1, and os2 for the custom field values.

    I would send on0 with a value of "UserID" and os0 the actual ID.

    These values will be represented in the IPN as follows:

    os0 is represented as option_selection1

    os1 is represented as option_selection2

    os2 is represented as option_selection3

    on0 is represented as option_name1

    on1 is represented as option_name2

    on2 is represented as option_name3

    Here's the info on PayPal's HTML parameters

    0 讨论(0)
  • 2020-12-04 18:31

    According to HTML Variables for PayPal Payments Standard you can send all the "Pass-through" variables:

    item_number Pass-through variable for you to track product or service purchased or the contribution made. The value you specify is passed back to you upon payment completion. This variable is required if you want PayPal to track inventory or track profit and loss for the item the button sells.

    custom Pass-through variable for your own tracking purposes, which buyers do not see. Default – No variable is passed back to you.

    and

    invoice Pass-through variable you can use to identify your invoice number for this purchase. Default – No variable is passed back to you.

    All these pass-through variables are sent back by the IPN in the payment response info.

    You just have to render your HTML template server-side and write the fields back in the HTML code like

    <input type="hidden" name="item_number" value="{{ productID }}">
    <input type="hidden" name="invoice_id" value="{{ invoiceID }}">
    <input type="hidden" name="custom" value="{{ jsonInfo }}">
    

    Technically the field "custom" can be a JSON encoded string if you want to handle more data like

    myItemObject = {
       "customerEmail" : "john@doe.com
       "customerID: "AAFF324"
    }
    jsonInfo = json.dumps( myItemObject )
    return render_template(tmpl_name, jsonInfo=jsonInfo, productID=productID, invoiceID=invoiceID)
    
    0 讨论(0)
提交回复
热议问题