anouarabdsslm / laravel-paypalpayment

Laravel paypal payment package , help you process credit card payment using paypal api
Apache License 2.0
337 stars 198 forks source link

Payment detail if transaction failed #129

Open wassimhattab opened 6 years ago

wassimhattab commented 6 years ago

Hello, i'm using paypal payment api and setIntent as sale as the example shown,

when i get the payment detail in the array if i go to related_resources and check the state it's completed and the main state is approved even if the amount requested was higher than the amount i have in my account..

How can i check if a payment was made successfully or no?

This is how i'm creating the payment:

            $payer = Paypal::Payer();
            $payer->setPaymentMethod('paypal');
            $item1 = Paypal:: Item();

            $item1->setName('Deposit Money')
            ->setDescription('Deposit Money')
            ->setCurrency($currency)
            ->setQuantity(1)
            ->setPrice($total_amount);

            $itemList = Paypal:: ItemList();
            $itemList->addItem($item1);

            //Payment Amount
            $amount = Paypal:: Amount();
            $amount->setCurrency($currency)
            ->setTotal($total_amount);

            $transaction = Paypal:: Transaction();
            $transaction->setAmount($amount)
            ->setItemList($itemList)
            ->setInvoiceNumber($account_id.$token_key)
            ->setDescription('Deposit Money');

            $redirectUrls = Paypal:: RedirectUrls();
            $redirectUrls->setReturnUrl(url('/payments/callback_paypal'));
            $redirectUrls->setCancelUrl(url('/payments'));

            $payment = Paypal::Payment();
            $payment->setIntent('sale');
            $payment->setPayer($payer);
            $payment->setRedirectUrls($redirectUrls);
            $payment->setTransactions(array($transaction));

            $response = $payment->create($this->_apiContext);
            $redirectUrl = $response->links[1]->href;

Regards

anouarabdsslm commented 6 years ago

@wassimhattab If I understand you correctly you mean that you have processed order successfully with paypal account that does not have enough funds to order this item. If that the case maybe this is an issue with the sandbox platforme not the package.