{"action":"created","issue":{"url":"https://api.github.com/repos/paypal/PayPal-PHP-SDK/issues/319","labels_url":"https://api.github.com/repos/paypal/PayPal-PHP-SDK/issues/319/labels{/name}","comments_url":"https://api.github.com/repos/paypal/PayPal-PHP-SDK/issues/319/comments","events_url":"https://api.github.com/repos/paypal/PayPal-PHP-SDK/issues/319/events","html_url":"https://github.com/paypal/PayPal-PHP-SDK/issues/319","id":84209512,"number":319,"title":"Partial Refunds : response code 400","user":{"login":"guillermog","id":6329986,"avatar_url":"https://avatars.githubusercontent.com/u/6329986?v=3","gravatar_id":"","url":"https://api.github.com/users/guillermog","html_url":"https://github.com/guillermog","followers_url":"https://api.github.com/users/guillermog/followers","following_url":"https://api.github.com/users/guillermog/following{/other_user}","gists_url":"https://api.github.com/users/guillermog/gists{/gist_id}","starred_url":"https://api.github.com/users/guillermog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guillermog/subscriptions","organizations_url":"https://api.github.com/users/guillermog/orgs","repos_url":"https://api.github.com/users/guillermog/repos","events_url":"https://api.github.com/users/guillermog/events{/privacy}","received_events_url":"https://api.github.com/users/guillermog/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/paypal/PayPal-PHP-SDK/labels/api-payments","name":"api-payments","color":"207de5"},{"url":"https://api.github.com/repos/paypal/PayPal-PHP-SDK/labels/question","name":"question","color":"fbca04"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-06-02T20:59:18Z","updated_at":"2015-06-04T16:24:05Z","closed_at":"2015-06-04T15:49:40Z","body":"Hi, is anyone else having problems with partial refunds? I keep getting: \r\n\r\n<pre>PayPalConnectionException in PayPalHttpConnection.php line 177: Got Http response code 400 when accessing https://api.paypal.com/v1/payments/sale/[tx-id]/refund.</pre>\r\n\r\nWhen I do full refunds (using full amount) it goes through fine, only when the amount is less than the total transaction amount it gives me this error. I believe it was working fine a couple of days ago, it is only recently that I started experiencing this issue.\r\n\r\nThis is the code Im using to refund:\r\n\r\n<pre>$reference = $order->fetchOrderMeta('payment_transaction_id', true);\r\n\t\t\t$reason = $request->input('refund_reason');\r\n\t\t\t$amount = new Amount();\r\n\t\t\t$amount->setCurrency(\"GBP\");\r\n\t\t\t$amount->setTotal($request->input('refund_amount'));\r\n\t\t\t\r\n\t\t\t$refund = new Refund();\r\n\t\t\t$refund->setAmount($amount);\r\n\t\t\t$refund->setReason($reason);\r\n\t\t\t\r\n\t\t\t$capture = Capture::get($reference, $apiContext);\r\n\t\t\t\t\r\n\t\t\ttry {\r\n\t\t\t\t//dd($reason);\r\n\t\t        $capture->refund($refund, $apiContext);\r\n\t\t        \r\n\t\t        //dd($captureRefund);\r\n\t\t    } catch (\\PayPal\\Exception\\PPConnectionException $ex) {\r\n\t\t        if (\\Config::get('app.debug')) {\r\n\t\t            echo \"Exception: \" . $ex->getMessage() . PHP_EOL;\r\n\t\t            $err_data = json_decode($ex->getData(), true);\r\n\t\t            exit;\r\n\t\t        } else {\r\n\t\t            die('Some error occur, sorry for inconvenient');\r\n\t\t        }\r\n\t\t    }</pre>\r\n\r\nAny help would be greatly appreciated. Bellow is some more debuging info I get from laravel:\r\n\r\n<pre>in PayPalHttpConnection.php line 177\r\nat PayPalHttpConnection->execute('{\"amount\":{\"currency\":\"GBP\",\"total\":\"0.14\"}}') in PayPalRestCall.php line 74\r\nat PayPalRestCall->execute(array('PayPal\\Handler\\RestHandler'), '/v1/payments/sale/0UB26548H26568121/refund', 'POST', '{\"amount\":{\"currency\":\"GBP\",\"total\":\"0.14\"}}', null) in PayPalResourceModel.php line 103\r\nat PayPalResourceModel::executeCall('/v1/payments/sale/0UB26548H26568121/refund', 'POST', '{\"amount\":{\"currency\":\"GBP\",\"total\":\"0.14\"}}', null, object(ApiContext), null) in Sale.php line 553\r\nat Sale->refund(object(Refund), object(ApiContext)) in PaymentController.php line 358\r\nat PaymentController->refundPayment(object(Request), object(Order))\r\nat call_user_func_array(array(object(PaymentController), 'refundPayment'), array(object(Request), 'order' => object(Order))) in Controller.php line 246\r\nat Controller->callAction('refundPayment', array(object(Request), 'order' => object(Order))) in ControllerDispatcher.php line 162\r\nat ControllerDispatcher->call(object(PaymentController), object(Route), 'refundPayment') in ControllerDispatcher.php line 107\r\nat ControllerDispatcher->Illuminate\\Routing\\{closure}(object(Request))\r\nat call_user_func(object(Closure), object(Request)) in Pipeline.php line 141\r\nat Pipeline->Illuminate\\Pipeline\\{closure}(object(Request))\r\nat call_user_func(object(Closure), object(Request)) in Pipeline.php line 101\r\nat Pipeline->then(object(Closure)) in ControllerDispatcher.php line 108\r\nat ControllerDispatcher->callWithinStack(object(PaymentController), object(Route), object(Request), 'refundPayment') in ControllerDispatcher.php line 67\r\nat ControllerDispatcher->dispatch(object(Route), object(Request), 'App\\Http\\Controllers\\PaymentController', 'refundPayment') in Route.php line 204</pre>"},"comment":{"url":"https://api.github.com/repos/paypal/PayPal-PHP-SDK/issues/comments/108956593","html_url":"https://github.com/paypal/PayPal-PHP-SDK/issues/319#issuecomment-108956593","issue_url":"https://api.github.com/repos/paypal/PayPal-PHP-SDK/issues/319","id":108956593,"user":{"login":"ppmtscory","id":6306449,"avatar_url":"https://avatars.githubusercontent.com/u/6306449?v=3","gravatar_id":"","url":"https://api.github.com/users/ppmtscory","html_url":"https://github.com/ppmtscory","followers_url":"https://api.github.com/users/ppmtscory/followers","following_url":"https://api.github.com/users/ppmtscory/following{/other_user}","gists_url":"https://api.github.com/users/ppmtscory/gists{/gist_id}","starred_url":"https://api.github.com/users/ppmtscory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ppmtscory/subscriptions","organizations_url":"https://api.github.com/users/ppmtscory/orgs","repos_url":"https://api.github.com/users/ppmtscory/repos","events_url":"https://api.github.com/users/ppmtscory/events{/privacy}","received_events_url":"https://api.github.com/users/ppmtscory/received_events","type":"User","site_admin":false},"created_at":"2015-06-04T16:24:05Z","updated_at":"2015-06-04T16:24:05Z","body":"It was resolved on PayPal's end.  You don't need to do anything on your side."}}