贝宝IPN自定义字段 [英] Paypal IPN Custom field

查看:70
本文介绍了贝宝IPN自定义字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以使用带有$ _POST ['custom']的IPN发送自定义字段 但是我可以使用上传的文件吗?更具体地说,是上传的图片?

I know I can send a custom field using IPN with $_POST['custom'] But can I do that with an uploaded file? More specifically an uploaded image?

如果我有两个自定义字段怎么办?我以前用过这样的东西:

And what if I have two custom fields? I previously used something like this:

<input type="hidden" name="custom" value="<?php echo $a.'|'.$b ?>"/>

但这只是文本!现在我要上传文件,并且我还具有自定义文本,然后我想获取它.

But that was just text! Now I want to upload a file and I also have custom text, then I want to get it.

这有可能吗?看起来如何?

Is this possible and how would that look like?

谢谢!

推荐答案

我认为无法按照您描述的方式进行操作,但这是我过去使用的替代方法.

I don't think it's possible to do it the way you're describing, but here's an alternative that I have used in the past.

  1. 与其使用包含将文件上传发布到PayPal的表单,不如将其发布到您的网站,然后将该上传的文件和任何其他自定义数据存储在数据库中(或您选择存储的任何其他方式)它).为该数据分配一个ID.

  1. Instead of having the form that contains the file upload post to PayPal, have it post to your site, and then store that uploaded file and any other custom data in a database (or any other way you choose to store it). Assign that data an id.

现在将用户重定向到包含基本相同表单的页面,不同之处在于应隐藏输入字段,并且表单将发布到PayPal.以编程方式使用上一篇文章中的数据填写该表格,并使用您分配给该自定义数据的ID填充自定义"字段.此页面还将包含这样的JavaScript语句(在表单的底部,以确保它不会在加载表单之前执行)...

Now redirect the user to a page that contains basically the same form, except that the input fields should be hidden, and the form will post to PayPal. Fill in that form programmatically with the data from the previous post, and fill the 'custom' field with the id that you assigned to the custom data. This page would also contain a JavaScript statement like this (at the bottom after the form, to ensure that it doesn't execute until the form is loaded)...

<script type="text/javascript">
    document.forms["paypalform"].submit();
</script>

...以在页面加载时自动提交表单.最好保留一个提交按钮(如果需要,可以将其设置为链接的样式),以防用户禁用JavaScript.可能会显示类似如果您在10秒内未重定向到PayPal,请单击此处".您还可以在页面上添加另一条消息,例如重定向到PayPal."

...to automatically submit the form when the page is loaded. It's still a good idea to leave a submit button (you could style it as a link, if you want) in case the user has JavaScript disabled. It could say something like "Click here if you are not redirected to PayPal within 10 seconds." You could also add another message on the page such as "Redirecting to PayPal."

现在,当您从贝宝(PayPal)获得有关该交易的PDT或IPN信息时,自定义"字段将包含您之前分配给数据的ID.只需从存储位置取回数据即可.

Now when you get your PDT or IPN information back from PayPal for that transaction, the 'custom' field will contain the id you assigned to the data earlier. It's just a matter of retrieving the data from wherever you stored it.

之前我已经在ASP.NET中做到了这一点,并且我认为它在PHP(服务器端部分)中也能正常工作,但我不能肯定地说.

I've done this in ASP.NET before, and I assume it would work just as well in PHP (the server-side parts), but I can't say for sure.

注意:自定义"字段最多只能包含256个字符.

Note: The 'custom' field can only contain up to 256 characters.

这篇关于贝宝IPN自定义字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆