简体   繁体   English

PayPal:IPN和PDT协同工作-单项付款系统-无需购物车

[英]PayPal: IPN and PDT working together - Single Item Payment System - NO SHOPPING CART

I use a custom online booking system I made in PHP with a MySQL database . 我使用在PHP中使用MySQL数据库创建的自定义在线预订系统。 Currently, payments are taken when the client attends their booking face to face in cash and I am now implementing Paypal's IPN and PDT payments setups into the system together for use as a single item payment/"PAY NOW" option system (so no shopping cart) . 目前,付款是在客户面对面以现金面对面预订时进行的,我现在正在将Paypal的IPN和PDT付款设置实施到系统中,以用作单项付款/“立即付款”选项系统(因此没有购物车) ) The price, dates and user information vary only. 价格,日期和用户信息仅有所不同。

After months of research into different debates and security isses, I have come to the conclusion that the best way to use the IPN and PDT systems together is to do it on a first-come-first-serve basis with a script for each. 经过数月的研究,人们对各种辩论和安全问题进行了研究,得出的结论是,将IPN和PDT系统一起使用的最佳方法是,在先到先得的基础上 ,为每个脚本编写脚本。 Whether the PDT or the IPN script processes, whichever one is first sends the confirmation email and adds the relevant information to the database. 无论是PDT还是IPN脚本都在处理,无论哪个先发送确认电子邮件并将相关信息添加到数据库。 If either the PDT or the IPN processes and finds that the other has already processed, it only updates the database information that is missing as an email will already have been sent by the other script. 如果PDT或IPN进行了处理,并且发现另一个已经处理过,则它更新缺少的数据库信息,因为另一个脚本已经发送了电子邮件。

The booking system made from scratch has been in use for 2 years without problems but now requires online payments instead. 从头开始制作的预订系统已经使用了两年,没有问题,但是现在需要在线付款。

When a booking is made online, the client enters their details, selects start date, end date, times for their booking and then the information is POSTED (form method POST) to a PHP script. 在线预订时,客户输入他们的详细信息,选择预订的开始日期,结束日期,时间,然后将该信息发布到PHP脚本中(表单方法POST)。 The script verifies, processes and outputs to a confirmation page that the booking was successful as well as emails the client and the admin email address. 该脚本会验证,处理并输出到预订成功的确认页面,并通过电子邮件向客户和管理员电子邮件地址发送电子邮件。

THE MYSQL DATABASE IS NOT CURRENTLY USED FOR SAVING BOOKING DETAILS. MYSQL数据库当前未用于保存预订详细信息。

I now want to do the payments online with the same structure. 我现在想使用相同的结构在线进行付款。

The MySQL database has now been amended and has a new table with all the fields possible back from a call back from either an IPN or PDT reply from Paypal, successful or failed, as well as basic information about a booking. MySQL数据库现已进行了修改,并具有一个新表,其中包含从Paypal的IPN或PDT回复成功或失败返回的所有字段,以及有关预订的基本信息。

The problems I have are these: 我遇到的问题是:

  • The PDT can be faked. 可以伪造PDT。 How can this be avoided, as if the email from the PDT script is sent, they will have already received confirmation which will cause problems? 如何避免这种情况发生,就好像发送了来自PDT脚本的电子邮件一样,他们已经收到确认,这会引起问题? I could avoid this by only sending emails with the IPN script and telling PDT process to only show the booking information back to the client but state a confirmation email will be sent but sometimes the IPN can take a while and the client needs to be reassured immediately that the booking has been confirmed as the booking could be for a booking within the next 30 minutes. 我可以通过只发送带有IPN脚本的电子邮件并告诉PDT流程仅向客户显示预订信息来避免这种情况,但声明将发送确认电子邮件,但有时IPN可能需要一段时间,因此需要立即向客户保证该预订已被确认,因为该预订可能是在接下来的30分钟内进行的预订。

  • I have attempted to create several PDT and IPN scripts based on the examples on the web with Xcommerce Paypal developers website, Paypal, and many others for almost a month and none seem to work correctly. 我已经尝试使用Xcommerce Paypal开发人员网站,Paypal和许多其他网站,基于网络上的示例创建了几个PDT和IPN脚本,将近一个月,但似乎都无法正常工作。 Can anyone please provide a PDT script and a IPN script which both process all variables possible and verify key basic information for the orders such as name, address, zip/post code and price? 谁能提供一个PDT脚本和IPN脚本,它们都可以处理所有可能的变量并验证订单的关键基本信息,例如名称,地址,邮政编码/邮编和价格? This would be useful for anyone trying to create a payment process with IPN and PDT for anyone as all anyone would need to do is remove what isn't needed for each script. 这对于尝试使用IPN和PDT为任何人创建付款流程的任何人都是有用的,因为任何人都需要做的就是删除每个脚本不需要的内容。

Just as a note, each script checks if the other has run by checking a the IPN or the PDT field in an MySQL table has a "1" in it. 只是要注意,每个脚本通过检查MySQL表中的IPN或PDT字段中是否包含“ 1”来检查另一个脚本是否已运行。 "0" is the default. 默认值为“ 0”。

I look forward to peoples replys as I am sure this will help everyone having problems with either systems, no matter how the scripts are used. 我期待人们的答复,因为我确信这将帮助每个使用这两个系统的人,无论如何使用脚本。

Thank you to all in advance. 谢谢大家。

Please provide a tested MySQL table also, if different from below, for any answers provided to help others reading the answers. 如果与以下内容有所不同,还请提供经过测试的MySQL表,以提供所提供的任何答案,以帮助其他人阅读答案。

I have created and am using the following table: 我已经创建并正在使用下表:

CREATE TABLE `bookings` (
`id` int( 11 ) NOT NULL AUTO_INCREMENT ,
`date1` char( 2 ) NOT NULL default '',
`month1` char( 2 ) NOT NULL default '',
`year1` char( 2 ) NOT NULL default '',
`date2` char( 2 ) NOT NULL default '',
`month2` char( 2 ) NOT NULL default '',
`year2` char( 2 ) NOT NULL default '',
`name` text NOT NULL ,
`address` text NOT NULL ,
`zippostcode` text NOT NULL ,
`email` text NOT NULL ,
`price` char( 2 ) NOT NULL default '',
`pdt` varchar( 12 ) NOT NULL default '0',
`ipn` varchar( 12 ) NOT NULL default '0',
`paypalstatus` varchar( 12 ) NOT NULL default '',
`datebooked` varchar( 50 ) NOT NULL default '',
`receiver_email` varchar( 127 ) NOT NULL ,
`payment_status` varchar( 25 ) NOT NULL ,
`pending_reason` varchar( 25 ) NOT NULL ,
`payment_date` varchar( 100 ) NOT NULL ,
`mc_gross` double NOT NULL ,
`mc_fee` double NOT NULL ,
`tax` double NOT NULL ,
`mc_currency` varchar( 10 ) NOT NULL ,
`txn_id` varchar( 25 ) NOT NULL ,
`txn_type` varchar( 25 ) NOT NULL ,
`first_name` varchar( 75 ) NOT NULL ,
`last_name` varchar( 75 ) NOT NULL ,
`address_street` varchar( 200 ) NOT NULL ,
`address_city` varchar( 50 ) NOT NULL ,
`address_state` varchar( 40 ) NOT NULL ,
`address_zip` varchar( 20 ) NOT NULL ,
`address_country` varchar( 64 ) NOT NULL ,
`address_status` varchar( 25 ) NOT NULL ,
`payer_email` varchar( 127 ) NOT NULL ,
`payer_status` varchar( 25 ) NOT NULL ,
`payment_type` varchar( 25 ) NOT NULL ,
`notify_version` varchar( 50 ) NOT NULL ,
`verify_sign` varchar( 255 ) NOT NULL ,
`address_name` varchar( 130 ) NOT NULL ,
`protection_eligibility` varchar( 50 ) NOT NULL ,
`ipn_status` varchar( 25 ) NOT NULL ,
`subscr_id` varchar( 25 ) NOT NULL ,
`reason_code` varchar( 25 ) NOT NULL ,
`contact_phone` varchar( 25 ) NOT NULL ,
`invoice` varchar( 127 ) NOT NULL ,
`for_auction` tinyint( 10 ) NOT NULL ,
`auction_buyer_id` varchar( 75 ) NOT NULL ,
`auction_closing_date` varchar( 100 ) NOT NULL ,
`auction_multi_item` double NOT NULL ,
`address_country_code` varchar( 2 ) NOT NULL ,
`order_id` tinyint( 10 ) NOT NULL ,
`item_name` varchar( 130 ) NOT NULL ,
`item_number` varchar( 130 ) NOT NULL ,
`os0` varchar( 200 ) NOT NULL ,
`on0` varchar( 75 ) NOT NULL ,
`os1` varchar( 200 ) NOT NULL ,
`on1` varchar( 75 ) NOT NULL ,
`quantity` double NOT NULL ,
`custom` varchar( 255 ) NOT NULL ,
`mc_handling` double NOT NULL ,
`mc_shipping` double NOT NULL ,
`creation_timestamp` timestamp NOT NULL ,
PRIMARY KEY ( `id` )
) TYPE = MYISAM AUTO_INCREMENT =1

I found a site. 我找到一个站点。 Check out this guy's script: 查看此人的脚本:

http://ksquared.de/blog/2011/10/paypal-generic-php-payment-pdtipn-script/ http://ksquared.de/blog/2011/10/paypal-generic-php-payment-pdtipn-script/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM