In addition to our regular processing, we have integrated the option for customers of our site to check out with their shopping cart through PayPal, using a combination of PayPal IPN & PDT to record the transaction. We've had the code completed for almost a year, and it works reliably and as expected. However, we have been extremely hesitant to implement it until recently for this reason: We cannot determine any reasonable way to return or retrieve item option values post-checkout from PayPal.
We have to have these item options. For example, we have a slightly complicated system that when a user adds an item, let's say a t-shirt, there are two item option IDs indicating the color and size of the t-shirt. These are stripped out from PayPal before being returned to us, meaning we only get the general item, and not specifically what the customer ordered.
Here is our dilemma:
1) While the documentation clearly states that you can send PayPal on0_ and os0_ variables with the item option information, we cannot determine any way to have it return these back to you. Below is a stripped down sample of the item return values.
This is sent to PayPal:
<input type="hidden" name="item_number_1" value="10272">
<input type="hidden" name="amount_1" value="19.95">
<input type="hidden" name="shipping_1" value="3.55">
<input type="hidden" name="quantity_1" value="1">
<input type="hidden" name="on0_1" value="15001">
<input type="hidden" name="on1_1" value="14000">
This is returned from PayPal (stripped to only have relevant item info):
Post Vars: Array
(
[item_number1] => 10272
[num_cart_items] => 1
[mc_handling1] => 3.55
[mc_shipping1] => 3.55
[item_name1] => [Complete Item Description...]
[mc_gross_1] => 25.00
[transaction_subject] => Shopping Cart[complete item description]
[payment_gross] => 25.00
[ipn_track_id] => 4f3054cc843ba
)
2) From what I understand, there IS a custom field. A single custom field. However, our customers can have 10 or more items in their shopping carts, and most items would have one to three item options. So we'd have to create a parseable pseudo-array of item IDs, options and numbers as a string of text to place in the custom field to simply have our item's options returned to us. This hacky workaround appears to be the "Best chance" option we've got, however it is also not feasible because there is a 256 character limit, so we could not rely on the information returned.
3) So, if I'm correct, we cannot receive or retrieve returns of Item Option variables. But, if PayPal simply returned customers to our website after checking out, then we could still retrieve the session variables, which DO contain full shopping cart information. So when PayPal redirects users, we CAN get information. Except when users check out, they are NOT automatically redirected to PayPal, and instead the choice to redirect is optional and in a small, easy to miss link post-checkout -- meaning not technically reliable by any means.
Ultimately, we went ahead and began accepting PayPal, having to manually go retrieve item options for every customer on PayPal.com, and simply had code in the redirect page to correctly populate orders from users that DID choose to redirect, populating which orders we reasonably could. We had about a hundred orders, and few of them actually redirected back to our site.
4) We tried passing custom variables in hidden input fields, however, in line with PayPal's documentation, these seem to be stripped out before being returned.
5) It is not a realistic or feasible for us to create a custom database record for every user that clicks "PayPal" to store the information for retrieval if or when the IPN comes back. This is not a solution.
UPDATE: 6) As per a user suggestion, we tried a call to PayPal's GetTransactionDetails() through the rather unhelpful use of some documentation here. This did not return item options, instead it returns an array similar to what's returned in the PDT in this format:
[40] => L_NUMBER0=10100
We may have to shut the PayPal option off again if we cannot find an acceptable fix to this problem. We simply cannot determine any actual way to return item option values, yet using PayPal's cart system, we absolutely have to let the user leave our site to finish checking out, and complete cart data is not returned to us, so it appears we cannot record complete customer transactions unless we want to store transaction data of every single person who clicks the "PayPal" button. Is this correct?
Is there any way to accomplish this that we're missing? If PayPal's cart solution is the best way to check out, why does PayPal not return the cart's data?