Php 需要关于使用paypal IPN创建自定义订单的建议/示例吗
我需要使用paypal的IPN在客户网站上创建订单。他为他的客户制作kydex枪套,所以我需要在订单上有多个选项。此外,交易完成后,我需要向客户以及我的客户发送一封包含发票的电子邮件。我对paypal IPN几乎没有任何经验,所以我希望这里的任何人都能为我提供任何建议、指导或示例。我在谷歌搜索时运气不太好 有两个非常好的选择,其中不包括手动操作。为什么要重新发明轮子?这方面已经有很多很好的免费例子了Php 需要关于使用paypal IPN创建自定义订单的建议/示例吗,php,paypal,paypal-ipn,Php,Paypal,Paypal Ipn,我需要使用paypal的IPN在客户网站上创建订单。他为他的客户制作kydex枪套,所以我需要在订单上有多个选项。此外,交易完成后,我需要向客户以及我的客户发送一封包含发票的电子邮件。我对paypal IPN几乎没有任何经验,所以我希望这里的任何人都能为我提供任何建议、指导或示例。我在谷歌搜索时运气不太好 有两个非常好的选择,其中不包括手动操作。为什么要重新发明轮子?这方面已经有很多很好的免费例子了 将CMS与电子商务平台(drupal+ubercart或其他,wordpress+woocomm
除非你能很快地完成帖子,否则你将在几周的时间里努力完成一些已经掌握并多次反馈给社区的东西。如果我是你,我会从developer.paypal.com开始,从那里你可以设置你的ipn内容并查看集成方法。简单介绍一下它的工作原理:
现在,如果一切顺利,你可以开始赊账,从他们那里你可以向管理层和买家发送电子邮件,即使paypal也这样做以下是你可以遵循的步骤 步骤1创建IPN表单。确保将IPN URL(通知URL)传递给paypal 对于表单变量,您可以参考
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="seller@designerfotos.com">
<input type="hidden" name="item_name" value="hat">
<input type="hidden" name="item_number" value="123">
<input type="hidden" name="amount" value="15.00">
<input type="hidden" name="first_name" value="John">
<input type="hidden" name="last_name" value="Doe">
<input type="hidden" name="address1" value="9 Elm Street">
<input type="hidden" name="address2" value="Apt 5">
<input type="hidden" name="city" value="Berwyn">
<input type="hidden" name="state" value="PA">
<input type="hidden" name="zip" value="19312">
<input type="hidden" name="night_phone_a" value="610">
<input type="hidden" name="night_phone_b" value="555">
<input type="hidden" name="night_phone_c" value="1234">
<input type="hidden" name="email" value="jdoe@zyzzyu.com">
<input type="hidden" name="return" value="https//www.mysite.com/order/return">
<input type="hidden" name="cancel_return" value="https//www.mysite.com/order/cancel" id="cancel_return">
<input type="hidden" name="notify_url" value="https//www.mysite.com/ipn">
</form>
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) { $_POST[$key] = mysql_real_escape_string($value); }
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
$header = '';
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen('www.sandbox.paypal.com', 80, $errno, $errstr, 30);
// assign posted variables to local variables
$content['payment_status'] = $_POST['payment_status'];
$content['payment_amount'] = $_POST['mc_gross'];
$content['payment_currency'] = $_POST['mc_currency'];
$content['txn_id'] = $_POST['txn_id'];
$content['receiver_email'] = $_POST['receiver_email'];
$content['payer_email'] = $_POST['payer_email'];
$content['txn_type'] = $_POST['txn_type'];
$content['paydate'] = date('Y-m-d H:i:s');
if (!$fp)
{
// HTTP ERROR
}
else
{
fputs ($fp, $header . $req);
if (!feof($fp))
{
$res = fgets ($fp, 1024);
if(strcasecmp($content['txn_type'], "subscr_payment") == 0)
{
//Action
}
else if(strcasecmp($content['payment_status'], "Completed") == 0)
{
//Action
}
else if(strcasecmp($content['txn_type'], "subscr_cancel") == 0)
{
//Action
}
}
fclose ($fp);
}