PayPal产品的工作方式不同于沙盒 [英] PayPal production working differently than sandbox

查看:70
本文介绍了PayPal产品的工作方式不同于沙盒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经构建了一个应用程序,该应用程序将带有登录用户的GUID的通知URL发送到PayPal,完成购买后,将调用该URL,并在验证后,用户数据库条目将更新列purchased从0到1.

I have built an application, that sends a notification url with the GUID of the logged in user to PayPal, and upon completion of purchase, the url is called, and after verification, the user database entry updates the column purchased from 0 to 1.

然后,用户单击返回应用程序按钮,并根据purchased列显示高级功能.

The user then clicks the return to app button, and the premium functionality displays based on the purchased column.

过去几个月来,我一直在沙盒中对此进行测试.在100%的测试时间(包括此问题之后)中,购买完成后会显示高级"标签.

I have been testing this over the last few months in the sandbox. 100% of the times tested (including after this issue), the premium tab displays after purchase completion.

客户很兴奋,并继续前进到生产.我已使用完全相同的网址设置了IPN,除了从www.sandbox.paypal.com切换到www.paypal.com并将列出的帐户从沙盒业务更改为个人业务.

Client is thrilled, and gives the go ahead to move to production. I have set up IPN with the exact same URL, I have changed literally nothing except switching from www.sandbox.paypal.com to www.paypal.com and changing the account listed from the sandbox business to the personal business.

问题是,该按钮现在不显示, 直到 ,您刷新了屏幕.单击以前按预期运行的返回到应用程序"按钮,现在不显示高级选项卡.单击刷新后,它就会显示出来.如果我将所有内容都切换回沙箱设置,则请重新启动-再次正常.

Ths issue is, the button now doesn't show up, until, you refresh the screen. Clicking the "return to app" button, which previously was working as expected, now doesn't display the premium tab. Once I click refresh - it then shows up. If I switch everything back to the sandbox settings, boom - it works just fine again.

以下是带有生产帐户的BuyNow按钮代码:

Here is the BuyNow button code with production account:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="buynowForm" target="_top">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="ACCOUNT EMAIL">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="item_name" value="Product">
<input type="hidden" name="amount" value="10.00">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="no_shipping" value="1">
<input type='hidden' name='notify_url' value='http://app.com/purchase/<?php echo $data[0]['uid'] ?>'>
<input type='hidden' name='return' value='http://app.com/'>
<input type="hidden" name="rm" value="1">
<input type="hidden" name="cbt" value="Return to Product Plus">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted">
<input type="submit" class="hidden-print visible-print" border="0" name="buysubmit" value="Click For Product Plus" alt="Click for Product Plus">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">

这是上面调用的处理路径:

And here is the processing route called above:

$app->post('/purchase/:uid', function ($uid) use ($app) {

 $request = Slim::getInstance()->request();
 $inputs = json_decode($request->getBody());
 $db_conn = conn();

 $req = 'cmd=_notify-validate'; 
    foreach ($_POST as $key => $value) 
    { 
        if (get_magic_quotes_gpc()) 
        { 
            $_POST[$key] = stripslashes($value); 
            $value = stripslashes($value); 
        } 
        $value = urlencode($value); 
        $req .= "&$key=$value"; 
    } 

    $url = "https://www.paypal.com/cgi-bin/webscr";
    $ch = curl_init();    
    curl_setopt($ch, CURLOPT_URL,$url); 
    curl_setopt($ch, CURLOPT_FAILONERROR, 1); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); 
    curl_setopt($ch, CURLOPT_TIMEOUT, 3); 
    curl_setopt($ch, CURLOPT_POST, 1); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $req); 
    $result = curl_exec($ch); 
    curl_close($ch); 

    if (strcmp ($result, "VERIFIED") == 0)
    { 
        $sql_st = 'UPDATE  `user_data` SET `purchased` = 1 WHERE uid=:uid';

          $sql = $db_conn->prepare($sql_st);
          if ($sql->execute(array('uid'=>$uid))) {
            $data = array('status' => "Ok");
          } else {
            $data = array('status' => print_r(mysql_error()));
          }
    } 
    else  
    { 
        // Did Not Process IPN Properly
    } 

});

REALLY 希望这只是我的愚蠢之举.任何帮助/指导表示赞赏.

REALLY hoping this is just something incredibly dumb on my part. Any help/guidance is appreciated.

推荐答案

基本上,这里的解决方案是两个选项之一-

Essentially the solution here is one of two options -

  1. 构建辅助完成方法-换句话说,IPN并不是购买软件升级的第一道防线.我这边的一切都正常,但是IPN(notify_url)调用的时间太慢,无法立即升级.将它们返回到执行升级的页面,然后重定向.

  1. Build a secondary method of completion - in other words, the IPN is not the first line of defense for a purchased upgrade to software. Everything on my end is working, however the timing of the IPN (notify_url) call is too slow to make instant upgrades not exactly instant. Return them to a page that performs the upgrade then redirects.

将升级的功能存储在不同的路径下-这是PayPal的建议.从本质上讲,请升级app.com/basic和app.com/.这不是很理想,我也不建议将其作为永久解决方案.

Store the upgraded features behind a different route - this was PayPal's suggestion. Essentially, have app.com/basic and app.com/upgraded. This isn't really ideal, nor would I suggest it as a permanent solution.

总结-这是PayPal的已知问题.沙箱和生产工作流程本质上是不同的-不是按功能或API而是按使用-生产级别帐户受到的打击更多,并且处理通知所花费的时间要慢得多.

Summed up - this is a known issue with PayPal. The sandbox and production workflows are basically different - not by function or API, but in usage - the production level account is getting hit more, and the time it takes to process the notifications are much slower.

希望这对某人有帮助.

这篇关于PayPal产品的工作方式不同于沙盒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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