title: 0 - Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment
body: <p>I'm using the paypal rest API, but I am getting an error. Here is my code:</p>
  
  <pre><code>function makePaymentUsingPayPal($total, $currency, $paymentDesc, $returnUrl, $cancelUrl) {
  
      // set billing address
      $addr = new Address();
      $addr-&gt;setLine1('fh52 N Main ST');
      $addr-&gt;setCity('Johnstownfhf');
      $addr-&gt;setCountry_code('UK');
      $addr-&gt;setPostal_code('35345');
      $addr-&gt;setState('DF');
  
      // set credit card information
      $card = new CreditCard();
      $card-&gt;setNumber('4111111111111111');
      $card-&gt;setType('visa');
      $card-&gt;setExpire_month('12');
      $card-&gt;setExpire_year('2015');
      $card-&gt;setCvv2('123');
      $card-&gt;setFirst_name('dgdg');
      $card-&gt;setLast_name('dgdgdShopper');
      $card-&gt;setBilling_address($addr);
  
      $fi = new FundingInstrument();
      $fi-&gt;setCredit_card($card);
  
      $payer = new Payer();
      $payer-&gt;setPaymentMethod("paypal");
  
      //$payer = new Payer();
      //$payer-&gt;setPayment_method('credit_card');
      //$payer-&gt;setFunding_instruments(array($fi));
  
      // Specify the payment amount.        
      $amountDetails = new Details();
      $amountDetails-&gt;setSubtotal('57.41');
      $amountDetails-&gt;setTax('0.06');
      $amountDetails-&gt;setShipping('0.06');
  
      $amount = new Amount();
      $amount-&gt;setCurrency('USD');
      $amount-&gt;setTotal('5.47');
      $amount-&gt;setDetails($amountDetails);
  
      // ###Transaction
      // A transaction defines the contract of a
      // payment - what is the payment for and who
      // is fulfilling it. Transaction is created with
      // a `Payee` and `Amount` types
      $transaction = new Transaction();
      $transaction-&gt;setAmount($amount);
      $transaction-&gt;setDescription('sdgdfg This is the payment transaction description.');
  
      $redirectUrls = new RedirectUrls();
      $redirectUrls-&gt;setReturnUrl($returnUrl);
      $redirectUrls-&gt;setCancelUrl($cancelUrl);
  
      $payment = new Payment();
      $payment-&gt;setRedirectUrls($redirectUrls);
      $payment-&gt;setIntent("buy");
      $payment-&gt;setPayer($payer);
      $payment-&gt;setTransactions(array($transaction));
  
      //print_r($payment);exit; 
      $payment-&gt;create($apiContext);
  
      // return $payment;
  }
  </code></pre>
  
  <p>Everything works fine until I call <code>$payment-&gt;create($apiContext);</code></p>
  
  <p>Then it shows this error:</p>
  
  <blockquote>
    <p>0 - 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>.</p>
  </blockquote>