Has anyone been able to get quantity updating on quantity-based subscriptions working with PHP? I've spent months trying to get it working. I've tried the raw CURL code, as per the developer docs and returned "PAYMENT_IN_PROGRESS" error. When using the PHP libraries, I get a 204 (no content) response and the subscription is not changed. CURL code: curl -v -X POST https://api-m.paypal.com/v1/billing/subscriptions/I-4PAEKHKDNA81/revise -H "Content-Type: application/json" -H "Authorization: Basic base64_encode($paypal_client_id.':'.$paypal_secret)" -d '{"quantity":"5"}' (the base64 stuff is just showing how I used PHP to create a base64 version of client_id:client_secret for inserting into the CURL command) PHP code: <?php namespace PayPal\Api; require '/opt/bitnami/php/bin/vendor/autoload.php'; use PayPalCheckoutSdk\Orders\OrdersPatchRequest; use PayPalCheckoutSdk\Orders\OrdersGetRequest; use PayPalCheckoutSdk\Orders\OrdersCreateRequest; use PayPalCheckoutSdk\Core\PayPalHttpClient; use PayPalCheckoutSdk\Core\ProductionEnvironment; include('globals.php'); // defines Paypal client_id, client_secret, etc. $subscrID ='I-YT07M8NCEMRN'; // hard coded for test ini_set('error_reporting', E_ALL); // or error_reporting(E_ALL); ini_set('display_errors', '1'); ini_set('display_startup_errors', '1'); $environment=new ProductionEnvironment($paypal_client_id, $paypal_secret); $client = new PayPalHttpClient($environment); $request = new OrdersCreateRequest(); $request->prefer("return=representation"); $request->body =[ "intent" => "CAPTURE", "purchase_units" => [[ "reference_id" => $subscrID, "amount" => [ "value" => "1.77", "currency_code" => "USD" ] ]], "redirect_urls" => [ "cancel_url" => "https://calltaker.co/cancel", "return_url" => "https://calltaker.co/return" ] ]; $createdOrder = $client->execute($request); $request2 = new OrdersPatchRequest($createdOrder->result->id); $request2->body = [ 0=>[ "op" => "add", "path" => "/purchase_units/@reference_id=='$subscrID'/description", "value" => "3 user license" ], 1=>[ "op" => "replace", "path" => "/purchase_units/@reference_id=='$subscrID'/amount", "resource"=>[ "quantity"=>"3" ], "value" => [ "currency_code" => "USD", "value" => "1.56", "quantity" => "3" ] ] ]; try { // Call API with your client and get a response for your call $response2 = $client->execute($request2); // If call returns body in response, you can get the deserialized version from the result attribute of the response print_r($response2); }catch (HttpException $ex) { echo $ex->statusCode; print_r($ex->getMessage()); } $space4=' '; foreach($response2 as $key=>$value) { print "$key = "; if (is_array($value)) { print "(array):<BR>"; foreach($value as $key2=>$value2) { print $space4.$key2."="; if (is_array($value2)) { print "(array):<BR>"; foreach($value2 as $key3=>$value3) print $space4.$space4."$key3=$value3<BR>"; } else print "$value2<BR>"; } } else print "$value<BR>"; } ?>
... View more