user1835434 user1835434 - 3 months ago 13
reST (reStructuredText) Question

paypal: how to access the next billing date for an agreement with REST api

I need to access the next billing date for an agreement using the PayPal REST api via the php sdk.

I see inside

PayPal\Api\AgreementDetails;


We have

getNextBillingDate()


How do I access this?

I have:

...other code
use PayPal\Api\AgreementDetails;
$agreement_check = \PayPal\Api\Agreement::get($agreementID, $apiContext);
$renew_date = $agreement_check->getNextBillingDate();


I get the following error:

Fatal error: Call to undefined method PayPal\Api\Agreement::getNextBillingDate()


What is the correct way to access this?

Answer

You're not using a method to return AgreementDetails in $agreement_check. The right method is named getAgreementDetails and it's part of Agreement Class, so you must do something like this:

use PayPal\Api\AgreementDetails;
$agreement_check = \PayPal\Api\Agreement::get($agreementID, $apiContext);
$agreement_details = $agreement_check->getAgreementDetails();
$renew_date = $agreement_details->getNextBillingDate();

Just take a good look at official PayPal PHP SDK documentation: Class PayPal Agreement - PHP PayPal SDK

Comments