Learn what's new with PayPal Subscriptions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The new PayPal Subscriptions includes:
- A self-service dashboard
- Customized pricing and billing details for new and existing subscriptions
- Two new pricing models
- 2 Trial periods to let subscribers try your product at a free or discounted price before the regular billing cycle starts.
Read all about these new features in our blog, PayPal Presents the New Subscriptions Experience today.
Want to learn more? Check out our:
- Labels:
-
Payments REST APIs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am looking for a plug and play solution to enable subscriptions on my website. Can you guys please guide me through it? thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi. What sort of functionality do you need? The answer will depend on the level of flexibility you need. Creating subscriptions in Paypal is quite simple, but if you need your system to programmatically alter them, that's a major challenge. On our website, https://calltaker.co, we have implemented 4 different subscription plans, where the customer chooses the plan they want, and then the customer's subscription gets created by the system automatically, with the actual monthly fee dependent on the number of registered users they have (i.e., "per seat" billing). The only action the customer needs to do is to log into Paypal and authorise the subscription.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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>";
}
?>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It appears that quanitity updates do not work for subscriptions API
I followed the documentation and it just does not work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
"reference_id" => $subscrID,
"amount" => [ "value" => "1.77",
"currency_code" => "USD" ] ]],
"redirect_urls" => [ "cancel_url" => "https://calltaker.co/return",
"return_url" => "https://calltaker.co/return"
here you need to make changes according to your example and everything will work out. Try it. If not, contact the experts from [removed], they will help you.
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- Subscription Status Immediately Updates to New Plan Despite Payment Scheduled for Next Billing Cycle in NVP/SOAP APIs
- I'm having error contingency : "DECLINED_INSTRUMENT" when user is subscribing to the service in REST APIs
- How to deal with PayPal error codes on the modal? Only 1 subscription plan works out of 3 in PayPal Payments Standard
- Subscription API doesn't support updates? in REST APIs
- Assistance Needed with Handling Future Subscription Payments Without User Interaction in REST APIs