简体   繁体   English

PayPal PHP SDK-付款创建不适用于生产-空响应

[英]PayPal PHP SDK - payment creation doesn't work on production - empty response

I'm just facing that problem for hours. 我只是面对这个问题几个小时。 This complete app works locally (OSX/MAMP/modphp/PHP 5.5.18) but for some reason on the production server the payment creation fails: White/Empty response. 这个完整的应用程序可以在本地运行(OSX / MAMP / modphp / PHP 5.5.18),但是由于某种原因,在生产服务器上,付款创建失败:白色/空响应。 No Exception, no max_execution time limit reached also HTTP 200. PHP and Apache logs are just fine and also there are no errors on the screen. 也不例外,HTTP 200也没有达到max_execution时间限制。PHP和Apache日志很好,并且屏幕上也没有错误。

Everything before $payment->create($this->apiContext); $payment->create($this->apiContext); gets executed - after that line the result is blank page. 被执行-在该行之后,结果为空白页。

The production server runs Ubuntu 14.04 / Apache 2.4.7 / modphp / PHP 5.5.9 生产服务器运行Ubuntu 14.04 / Apache 2.4.7 / modphp / PHP 5.5.9

Here is the code: 这是代码:

public function create($data)
{
    $payer = new Payer();
    $payer->setPaymentMethod("paypal");

    $total    = 0.0;
    $shipping = 0.0;
    foreach ($data as $key => $value) {
        $item = new Item();
        $item->setName($value->name)
            ->setDescription($value->type)
            ->setCurrency(Option::get('general-settings', 'currency'))
            ->setQuantity($value->amount)
            ->setPrice($value->price);

        $items[] = $item;
        $total += $value->price * $value->amount;
    }

    if ($total < 100) {
        $shipping += 10;
    }

    $itemList = new ItemList();
    $itemList->setItems($items);

    $details = new Details();
    $details->setShipping($shipping)
    ->setSubtotal($total);

    $amount = new Amount();
    $amount->setCurrency(Option::get('general-settings', 'currency'))
        ->setTotal($total+$shipping)
        ->setDetails($details);

    $transaction = new Transaction();
    $transaction->setAmount($amount)
        ->setItemList($itemList)
        ->setDescription("JustinRein Auftag")
        ->setInvoiceNumber(uniqid());

    $baseUrl = "http://example.ch";
    $redirectUrls = new RedirectUrls();
    $redirectUrls->setReturnUrl("$baseUrl/payment?success=true")
        ->setCancelUrl("$baseUrl/payment?success=false");

    $payment = new Payment();
    $payment->setIntent("sale")
        ->setPayer($payer)
        ->setRedirectUrls($redirectUrls)
        ->setTransactions(array($transaction));

    try {
        $payment->create($this->apiContext);

    } catch (Exception $ex) {
        td($ex);
        exit(1);
    }

    return $payment;
}

This runs also on paypal sandbox mode. 这也可以在贝宝沙箱模式下运行。 The paypal logfile is also empty. 贝宝日志文件也为空。

Posting here to close out the question. 在此处发布以结束问题。 Question author investigated and found a third party library that he was using which was suppressing the error that he needed to see with a '@' operator. 问题作者调查并找到了他正在使用的第三方库,该库正在抑制他需要使用'@'运算符查看的错误。 After removing the '@' operator (temporarily?) he was able to correct the problem with the PayPal SDK that he was using. 删除“ @”运算符(暂时吗?)后,他能够纠正所使用的PayPal SDK的问题。

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

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