1

I am trying to build a simple payment processor using PayPal to sell pay-per-view tickets for an boxing company I work with. When I ran the PHP code below in a browser, I saw the HTTP Error 505 - This page isn't working.

I removed segments of the coded piece by piece and ran it again until I found that one line in particular was causing the issue.

The line that says $itemList->setItems([$item]); is causing the issue and I have no idea why. Any help would be amazing.

<?php  

use PayPal\Api\Payer;
use PayPal\Api\Item;
use PayPal\Api\ItemList;
use PayPal\Api\Details;
use PayPal\Api\Amount;
use PayPal\Api\Transaction;
use PayPal\Api\RedirectUrls;
use PayPal\Api\Payment;

require $_SERVER['DOCUMENT_ROOT'] . '/process/ppv_start.php';

$product = 'FILL_WITH_BKB';
$price   = 5;

$payer = new Payer();
$payer->setPaymentMethod('paypal');

$item = new Item();
$item->setName($product)
     ->setCurrency('GBP')
     ->setQuantity(1)
     ->setPrice($price);

$itemList = new ItemList();
$itemList->setItems([$item]);


$amount = new Amount();
$amount->setCurrency('GBP')
       ->setTotal($price);

$transaction = new Transaction();
$transaction->setAmount($amount)
            ->setItemList($itemList)
            ->setDescription('PPV Purchase')
            ->setInvoiceNumber(uniqid());

$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl(SITE_URL . 'process/ppv_pay.php?success=true')
             ->setCancelUrl(SITE_URL . 'process/ppv_pay.php?success=false');


$payment = new Payment();
$payment->setIntent('sale')
        ->setPayer($payer)
        ->redirectUrls($redirectUrls)
        ->setTransactions([$transaction]);

?>
miken32
  • 42,008
  • 16
  • 111
  • 154
  • Chances are if you [enable some error reporting](https://stackoverflow.com/q/845021/1255289) you'll get some more useful info to add to the question. – miken32 Oct 06 '18 at 03:11
  • Is this an official library ? A 505 Status is serverside so is strange, given the description in the [documentation](https://developer.paypal.com/docs/classic/ipn/integration-guide/HTMLStatusCodes/) – msg Oct 06 '18 at 03:57

0 Answers0