In the paypal developer dashboard I see the API call for this action, but in orange...
I don't understand where is the error !
Thanks in advance for your help.
The Community Forum is not available for new posts or responses; previous posts remain available to review. For comprehensive support options, please visit PayPal.com/HelpCenter
Merchant Technical Support: For technical support and related questions, please visit our Technical Support Help Center or Developer Central
If you want to report illegal content under the EU Digital Services Act, please do so here
Hello
I'm using a Sandbox and I created a paypal plan with Paypal PHP SDK and activated it.
// Paypal plan definition
$plan = new Plan();
$plan->setName('A plan title');
$plan->setDescription('The plan description');
$plan->setType('fixed');
// paypal trial
$paymentDefinitionTrial = new PaymentDefinition();
$paymentDefinitionTrial->setName('7 free days');
$paymentDefinitionTrial->setType('TRIAL');
$paymentDefinitionTrial->setFrequency('Day');
$paymentDefinitionTrial->setFrequencyInterval(7);
$paymentDefinitionTrial->setCycles('1');
$paymentDefinitionTrial->setAmount(new Currency(array('value' => 0, 'currency' => 'EUR')));
// Paypal standard payment definition
$paymentDefinition = new PaymentDefinition();
$paymentDefinition->setName('Subscription');
$paymentDefinition->setType('REGULAR');
$paymentDefinition->setFrequency('Month');
$paymentDefinition->setFrequencyInterval('1');
$paymentDefinition->setCycles('12');
$paymentDefinition->setAmount(new Currency(array('value' => 30, 'currency' => 'EUR')));
// Array of the two payment definitions
$paymentDefinitions = array($paymentDefinitionTrial, $paymentDefinition);
// Paypal Merchant Preferences
$merchantPreferences = new MerchantPreferences();
$merchantPreferences->setReturnUrl(setUrlSchemeIfNotExist('<a href="https://mydomain.com/ExecuteAgreement.php?success=true" target="_blank">https://mydomain.com/ExecuteAgreement.php?success=true</a>'));
$merchantPreferences->setCancelUrl(setUrlSchemeIfNotExist('<a href="https://mydomain.com/ExecuteAgreement.php?success=false" target="_blank">https://mydomain.com/ExecuteAgreement.php?success=false</a>'));
$merchantPreferences->setAutoBillAmount('yes');
$merchantPreferences->setInitialFailAmountAction('CONTINUE');
$merchantPreferences->setMaxFailAttempts('0');
// Paypal Plan conf definition
$plan->setPaymentDefinitions($paymentDefinitions);
$plan->setMerchantPreferences($merchantPreferences);
// Plan creation
$request = clone $plan;
try {
$output = $plan->create($paypalApiContext);
} catch (Exception $ex) {
throw new WireException('Error from Paypal to create the Plan');
}
When I try to check if this Pla is OK, I used :
try {
$plan = Plan::get('P-8N611293...11KKMN5MZI', $paypalApiContext);
} catch (Exception $ex) {
exit(1);
}
And it's OK. The Plan is created and active :
But, when I'm following the Paypal dev doc (https://developer.paypal.com/docs/checkout/integrate/#3-render-the-smart-payment-buttons) to create a subscription with Smart Button method, and I am cliquing on the yellow smart button I have a Javascript Error in the console :
Error: Create Subscription Api response error:
{
"name": "RESOURCE_NOT_FOUND",
"message": "The specified resource does not exist.",
"debug_id": "23912dc1195d",
"details": [
{
"issue": "INVALID_RESOURCE_ID",
"description": "Requested resource ID was not found."
}
],
"links": [
{
"href": "<a href="https://developer.paypal.com/webapps/developer/docs/api/#INVALID_RESOURCE_ID" target="_blank">https://developer.paypal.com/webapps/developer/docs/api/#INVALID_RESOURCE_ID</a>",
"rel": "information_link",
"method": "GET"
}
]
}
Here is the Javascript code used :
// paypal.Buttons().render('#paypal-button-container');
paypal.Buttons({
createSubscription: function(data, actions) {
return actions.subscription.create({
'plan_id': 'P-8N611293...11KKMN5MZI'
});
},
onApprove: function(data, actions) {
alert('You have successfully created subscription ' + data.subscriptionID);
}
}).render('#paypal-button-container');
In the paypal developer dashboard I see the API call for this action, but in orange...
I don't understand where is the error !
Thanks in advance for your help.
I had the same problem. Probably you are loading the button script with "client-id=sb" or no client id specified. In order to work with plans you created via API you need to explicitly set "client-id=<client-id-of-your-REST-API-app>" when loading the script. Then the buttons will find your created plan. It took me a while to get that and this is nowhere documented.
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.