dongtaihui5131 2010-09-03 02:23
浏览 27
已采纳

使用PayPal API和PHP设置简单的撤退注册

So I'm running out of time on this project and I posted here in hopes that someone can help me.

Backstory There's a church retreat coming up and I'm in charge of making the website.

The Meaty Info On the site there's a simple registration form on the page that has some basic information (I have to add fields for Location, Phone Number, and Address. Ignoring that...) Screenshot of the page here. Ignore the error at the top and the PayPal button, I was trying to get it to work but I'm doing something wrong.

Now the retreat site does checks in PHP when you submit the form to see that you put real information for all the fields. Hitting the submit button will call the register.php page and do the checks, returning whether or not there were any errors.

The Problem I've never used an API but I have a good knowledge of PHP. As of now, what I wanted to happen was:

  1. The user inputs their information on the church retreat site. The retreat site would then check if the information was correct, and if it was it would redirect them to a PayPal page very similair to this.
  2. There, they'd enter billing information, then, after completing and processing the order all on PayPal's site, PayPal would redirect to my church registration page.
  3. My site would (somehow) receive from PayPal that the transaction was successful, and then add the user to a database of paid attendees.

The problems are setting up PayPal on my site how I outlined. Then, how would my site know whether or not a transfer was successful? Where would I find the files necessary to do the API commands?

I have no idea how to do that. It's boggling my mind and after reading documentation, I've just become more confused. I need someone's help on this so if anyone cares to help me: Thank You. I could really use a human answer as to the steps I need to take to get this done.

  • 写回答

1条回答 默认 最新

  • doukaizha5417 2010-09-03 02:46
    关注

    To do what you're talking about, first you need to post a form to paypal. This pseudocode should help.

    <form action='https://www.paypal.com/cgi-bin/webscr' method='post'>
    <input type='hidden' name='cmd' value='_cart' />
    <input type='hidden' name='upload' value='1' />
    <input type='hidden' name='business' value='{$paypal_email}' />
    <input type='hidden' name='shopping_url' value='{$return_path}' />
    <input type='hidden' name='currency_code' value='USD' />
    
    (for each item in the cart, repeat...)
    
      <input type='hidden' name='item_number_{$one_based_counter}' value='{$item_number}'>
      <input type='hidden' name='item_name_{$one_based_counter}' value='{$item_name}'>
      <input type='hidden' name='amount_{$one_based_counter}' value='{$amount}'>
      <input type='hidden' name='quantity_{$one_based_counter}' value='{$quantity}'>
    
      (for each custom field for this item (e.g. size, style))
    
        <input type='hidden' name='on{$zero_based_counter}_{$one_based_counter}' 
                            value='{$custom_field_name[$zero_based_counter]}'>
        <input type='hidden' name='os{$zero_based_counter}_{$one_based_counter}' 
                            value='{$custom_field_value[$zero_based_counter]}'>
    
      (end for each)
    
    (end for each)
    
    <input type='submit' value='Pay Me' /></form>
    

    After that, you need to write another script to handle payment notifications from PayPal. Look into PayPal's Instant Payment Notification (IPN). Log in to PayPal and have IPN post to your notification handler script. There are some pretty good IPN tutorials on PayPal's site and elsewhere.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用ns3仿真出5G核心网网元
  • ¥15 matlab答疑 关于海上风电的爬坡事件检测
  • ¥88 python部署量化回测异常问题
  • ¥30 酬劳2w元求合作写文章
  • ¥15 在现有系统基础上增加功能
  • ¥15 远程桌面文档内容复制粘贴,格式会变化
  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”