title: Paypal PHP SDK implementation
body: <p>My paypal sdk version is ^1.13</p>
  
  <p>I'm having errors in my paypal implementation. I followed this tutorial 
  <a href="https://www.youtube.com/watch?v=BD1dOWIABe0" rel="nofollow noreferrer">https://www.youtube.com/watch?v=BD1dOWIABe0</a></p>
  
  <pre><code>&lt;?php
  require 'vendor/autoload.php';
  use PayPal\Api\Payer;
  use PayPal\Api\Item;
  use PayPal\Api\ItemList;
  use PayPal\Api\Amount;
  use PayPal\Api\Transaction;
  use PayPal\Api\RedirectUrls;
  use PayPal\Api\Payment;
  use PayPal\Api\Details;
  use PayPal\Rest\ApiContext;
  Use PayPal\Auth\OAuthTokenCredential;
  
  
  
  if(!isset($_POST['product'], $_POST['price'])){
  die();
  }
  
  $clientId = 'client-id';
  $clientSecret = 'client-secret';
  
  $apiContext = new ApiContext(
  new OAuthTokenCredential(
  $clientId,
  $clientSecret
  )
  );
  
  $product = $_POST['product'];
  $price = $_POST['price'];
  $tax = 2.00;
  
  $total = $price + $tax;
  
  $payer = new Payer();
  $payer-&gt;setPaymentMethod('paypal');
  
  $item = new Item();
  $item-&gt;setName($product)
  -&gt;setCurrency('USD')
  -&gt;setQuantity(1)
  -&gt;setPrice($price);
  
  $itemList = new ItemList();
  $itemList-&gt;setItems([$item]);
  
  $details = new Details();
  $details-&gt;setShipping($tax)
  -&gt;setSubtotal($price)
  -&gt;setTax(2.00);
  
  $amount = new Amount();
  $amount-&gt;setCurrency('USD')
  -&gt;setTotal($total)
  -&gt;setDetails($product);
  
  $transaction = new Transaction();
  $transaction-&gt;setAmount($amount)
      -&gt;setItemList($itemList)
      -&gt;setDescription('dsds')
      -&gt;setInvoiceNumber(uniqid());
  
  $baseUrl = "http://www.localhost/xc";
  $redirectUrls = new RedirectUrls();
  $redirectUrls-&gt;setReturnUrl("$baseUrl/pay.php?success=true")
  -&gt;setCancelUrl("$baseUrl/pay.php?success=false");
  
  $payment = new Payment();
  $payment-&gt;setIntent('sale')
  -&gt;setPayer($payer)
  -&gt;setRedirectUrls($redirectUrls)
  -&gt;setTransactions([$transaction]);
  
  
  try{
  
  $payment-&gt;create($apiContext);
  
  }
  catch(PayPal\Exception\PayPalConnectionException $ex){
  echo $ex;
  die($ex);
  }
  
  echo $approvalUral = $payment-&gt;getApprovalLink(); 
  </code></pre>
  
  <p>I've tried to search about the error but I can't seem to find an answer so I need some help. What have I done wrong ? Do I need to downgrade ? because the video in tutorial made 2 years ago so I think I need to downgrade but is it possible ? </p>
  
  <blockquote>
    <p>exception 'PayPal\Exception\PayPalConnectionException' with message 'Got Http response code 400 when accessing  <a href="https://api.sandbox.paypal.com/v1/payments/payment" rel="nofollow noreferrer">https://api.sandbox.paypal.com/v1/payments/payment</a>.' in C:\xampp\htdocs\ladea\vendor\paypal\rest-api-sdk-php\lib\PayPal\Core\PayPalHttpConnection.php:202<br>
    Stack trace:<br>
    #0 C:\xampp\htdocs\ladea\vendor\paypal\rest-api-sdk-php\lib\PayPal\Transport\PayPalRestCall.php(78): PayPal\Core\PayPalHttpConnection->execute('{"intent":"sale...')<br>
    #1 C:\xampp\htdocs\ladea\vendor\paypal\rest-api-sdk-php\lib\PayPal\Common\PayPalResourceModel.php(104): PayPal\Transport\PayPalRestCall->execute(Array, '/v1/payments/pa...', 'POST', '{"intent":"sale...', NULL)<br>
    #2 C:\xampp\htdocs\ladea\vendor\paypal\rest-api-sdk-php\lib\PayPal\Api\Payment.php(577): PayPal\Common\PayPalResourceModel::executeCall('/v1/payments/pa...', 'POST', '{"intent":"sale...', NULL, Object(PayPal\Rest\ApiContext), NULL)<br>
    #3 C:\xampp\htdocs\ladea\checkout.php(78): PayPal\Api\Payment->create(Object(PayPal\Rest\ApiContext))<br>
    #4 {main}exception 'PayPal\Exception\PayPalConnectionException' with message 'Got Http response code 400 when accessing <a href="https://api.sandbox.paypal.com/v1/payments/payment" rel="nofollow noreferrer">https://api.sandbox.paypal.com/v1/payments/payment</a>.' in C:\xampp\htdocs\ladea\vendor\paypal\rest-api-sdk-php\lib\PayPal\Core\PayPalHttpConnection.php:202 Stack trace: #0 C:\xampp\htdocs\ladea\vendor\paypal\rest-api-sdk-php\lib\PayPal\Transport\PayPalRestCall.php(78): PayPal\Core\PayPalHttpConnection->execute('{"intent":"sale...') #1 C:\xampp\htdocs\ladea\vendor\paypal\rest-api-sdk-php\lib\PayPal\Common\PayPalResourceModel.php(104): PayPal\Transport\PayPalRestCall->execute(Array, '/v1/payments/pa...', 'POST', '{"intent":"sale...', NULL) #2 C:\xampp\htdocs\ladea\vendor\paypal\rest-api-sdk-php\lib\PayPal\Api\Payment.php(577): PayPal\Common\PayPalResourceModel::executeCall('/v1/payments/pa...', 'POST', '{"intent":"sale...', NULL, Object(PayPal\Rest\ApiContext), NULL) #3 C:\xampp\htdocs\ladea\checkout.php(78): PayPal\Api\Payment->create(Object(PayPal\Rest\ApiContext)) #4 {main}</p>
  </blockquote>
  
  <p>Thank you and Regards.</p>