doudou3213 2015-06-19 16:25
浏览 58

在标准购物车结帐时,是否没有合理的方法从PayPal返回商品选项字段?

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?

  • 写回答

2条回答 默认 最新

  • drqn5418 2015-06-19 16:34
    关注

    Here's what I do.

    1) Create an order identifier and store all the items that the user is buying into a table. In an ideal system you would have a SKU (stock keeping unit) for every possible combination of item you sell, e.g:

    • Green tee with Alien print
    • Green tee with Fish print
    • Red tee with Alien print

    So against the order ID you would store these SKU IDs, the quantity, any additional info, i.e. if there's a discount applied maybe.

    2) Pass the invoice ID to PayPal and then you can recall it on the IPN.

    3) For user's who don't go all the way through the payment process you can create a cron job to clear out unwanted data. Run it every so often against the time the order was initialised, if that order is older than a set amount of time (because PayPal can get delayed), then remove it from the table.

    评论

报告相同问题?

悬赏问题

  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)