这是我将实现的伪代码:
include("../../application/config/db_config.php");
if ($payment_status == 'Completed')
{
if customer/order details exist in table
{
change payment_status to completed, create PDF and Email to customer_email.
}
elseif customer/order details not exist in table
{
insert details into table, create PDF and Email to customer_email.
}
}
else if($payment_status == 'Denied' || $payment_status == 'Failed' || $payment_status == 'Voided')
{
Do Nothing.
}
else if($payment_status == 'In-Progress' || $payment_status == 'Pending' || $payment_status == 'Processed')
{
insert into table, customer details/order details.
}
这不包括验证。我只是想知道我是否正在考虑这个问题。
我还需要在付款之前将客户输入检索为变量,最好在用户付款之前保存到数据库吗?或者是否可以通过paypal发送此变量并让它返回ipn中的变量?
谢谢大家
答案 0 :(得分:1)
一般而言,在收到成功的支付IPN后触发充实是一种可靠的方法(只要实现不是即时/内联,因此客户坐在他们的屏幕上等待IPN处理)。所以在高层次上,是的,你正确地接近这个。
那就是说,关于你所写的内容的一些指示:
1)在IPN时间拥有这么多分支似乎很不寻常。为什么有时你会收到有关订单信息的付款,而不是其他时间? IPN是否用于完成延迟付款的前一种情况?如果是,请参阅#2
2)我建议始终在付款步骤之前的某个地方存储订单,从而使相应的IPN响应始终是状态更新,而不是有时写入,有时是状态更新。将未付款订单写入您的数据库几乎没有任何成本,以及一些潜在的好处(例如分析人们未完成的内容/原因的能力;甚至可能跟进不完整的订单)。它还简化了您的生活,以避免尝试通过您的支付处理器传递大量数据。只需通过订单#/发票#/无论如何,其余的都在您身边。这可以降低您的集成成本,并为您提供更大的灵活性(例如,如果您添加/更改了处理器)。
3)我不认为您处理PayPal付款状态是完全正确的,但我认为这是您在实施时可以获得的详细信息。
4)您没有提及您是否打算使用付款或授权,但延迟履行的行业最佳做法是授权,填写,然后捕获。特别是如果你的履行可能包括额外的用户互动(我不理解你的最后一个paragrpah"我仍然需要...")这可能有助于清理流程。
答案 1 :(得分:1)
我认为这种做法是错误的,没有检查验证的响应和/或接收者的详细信息。
// is response VERIFIED?
// is the receiver email correct?
// is the payment type correct?
// is the transaction id new or existing?
// transaction id is new, insert
// transaction id is old, update status/pending reason/paypal fee/total
请结帐https://github.com/paypal/ipn-code-samples/blob/master/paypal_ipn.php以获取样本。