PaypalConnectionException - Got Http response code 400 on Paypal integration Laravel

Posted in CategoryLaravel
  • S
    Sharif Uddin Ahamed 1 year ago

    I had checked your example of paypal integration in laravel and it works fine but When I have more then 1 item in database. I got "PaypalConnectionException" and Got Http response code 400 on Paypal Send box response. I am use this link: https://itsolutionstuff.com/post/how-to-integrate-paypal-payment-gateway-with-laravel54example.html and I use following Code :

    $order_discount = $order->invoice->discount;
    $order_subtotal = $order->invoice->sub_total;
    $order_grandtotal = $order->invoice->grand_total;
    
    $i = 1;
    $order_items = array();
    foreach ($order->invoice->products as $product) {
    
    $order_items[$i] = new Item();
    $order_items[$i]->setName($product->name)
    ->setCurrency('USD')
    ->setQuantity($product->qty)
    ->setPrice($product->price);
    
    $i++;
    }

    Can you look at that and let me know what is Issue ?

     

  • H
    Hardik Savani 1 year ago

    I think you need to add the equal price on setPrice() and setTotal().

    Can you try and let me know?

     

  • S
    Sharif Uddin Ahamed 1 year ago

    I did not find any solution yet. here my controller code : https://pastebin.com/yR5L5i3G can you check please?

  • H
    Hardik Savani 1 year ago

    According to what I read, that problem is caused because the sum of the items must be equal to the total, sum all your items and verify if it is equal to what you put in total. (setPrice() and setTotal())

    Try a simple test.

    Put only one item, price 10 USD and total put 10 USD.
    With that, you should open paypal and should not appear error 400.

  • S
    Sharif Uddin Ahamed 1 year ago

    Good day, could you tell me how you solved this problem?

Please login or register to leave a response.

* You May Also Like Bellow Issue to check *