Overview
  • Namespace
  • Class

Namespaces

  • PayPal
    • Api
    • Auth
    • Cache
    • Common
    • Converter
    • Core
    • Exception
    • Handler
    • Log
    • Rest
    • Security
    • Transport
    • Validation

Classes

  • PayPal\Api\Address
  • PayPal\Api\Agreement
  • PayPal\Api\AgreementDetails
  • PayPal\Api\AgreementStateDescriptor
  • PayPal\Api\AgreementTransaction
  • PayPal\Api\AgreementTransactions
  • PayPal\Api\AlternatePayment
  • PayPal\Api\Amount
  • PayPal\Api\Authorization
  • PayPal\Api\BankAccount
  • PayPal\Api\BankAccountsList
  • PayPal\Api\BankToken
  • PayPal\Api\BaseAddress
  • PayPal\Api\Billing
  • PayPal\Api\BillingAgreementToken
  • PayPal\Api\BillingInfo
  • PayPal\Api\CancelNotification
  • PayPal\Api\Capture
  • PayPal\Api\CarrierAccount
  • PayPal\Api\CarrierAccountToken
  • PayPal\Api\CartBase
  • PayPal\Api\ChargeModel
  • PayPal\Api\Cost
  • PayPal\Api\CountryCode
  • PayPal\Api\CreateProfileResponse
  • PayPal\Api\Credit
  • PayPal\Api\CreditCard
  • PayPal\Api\CreditCardHistory
  • PayPal\Api\CreditCardList
  • PayPal\Api\CreditCardToken
  • PayPal\Api\CreditFinancingOffered
  • PayPal\Api\Currency
  • PayPal\Api\CurrencyConversion
  • PayPal\Api\CustomAmount
  • PayPal\Api\DetailedRefund
  • PayPal\Api\Details
  • PayPal\Api\Error
  • PayPal\Api\ErrorDetails
  • PayPal\Api\ExtendedBankAccount
  • PayPal\Api\ExternalFunding
  • PayPal\Api\FileAttachment
  • PayPal\Api\FlowConfig
  • PayPal\Api\FmfDetails
  • PayPal\Api\FundingDetail
  • PayPal\Api\FundingInstrument
  • PayPal\Api\FundingOption
  • PayPal\Api\FundingSource
  • PayPal\Api\FuturePayment
  • PayPal\Api\HyperSchema
  • PayPal\Api\Image
  • PayPal\Api\Incentive
  • PayPal\Api\InputFields
  • PayPal\Api\InstallmentInfo
  • PayPal\Api\InstallmentOption
  • PayPal\Api\Invoice
  • PayPal\Api\InvoiceAddress
  • PayPal\Api\InvoiceItem
  • PayPal\Api\InvoiceNumber
  • PayPal\Api\InvoiceSearchResponse
  • PayPal\Api\Item
  • PayPal\Api\ItemList
  • PayPal\Api\Links
  • PayPal\Api\Measurement
  • PayPal\Api\MerchantInfo
  • PayPal\Api\MerchantPreferences
  • PayPal\Api\Metadata
  • PayPal\Api\NameValuePair
  • PayPal\Api\Notification
  • PayPal\Api\OpenIdAddress
  • PayPal\Api\OpenIdError
  • PayPal\Api\OpenIdSession
  • PayPal\Api\OpenIdTokeninfo
  • PayPal\Api\OpenIdUserinfo
  • PayPal\Api\Order
  • PayPal\Api\OverrideChargeModel
  • PayPal\Api\Participant
  • PayPal\Api\Patch
  • PayPal\Api\PatchRequest
  • PayPal\Api\Payee
  • PayPal\Api\Payer
  • PayPal\Api\PayerInfo
  • PayPal\Api\Payment
  • PayPal\Api\PaymentCard
  • PayPal\Api\PaymentCardToken
  • PayPal\Api\PaymentDefinition
  • PayPal\Api\PaymentDetail
  • PayPal\Api\PaymentExecution
  • PayPal\Api\PaymentHistory
  • PayPal\Api\PaymentInstruction
  • PayPal\Api\PaymentOptions
  • PayPal\Api\PaymentSummary
  • PayPal\Api\PaymentTerm
  • PayPal\Api\Payout
  • PayPal\Api\PayoutBatch
  • PayPal\Api\PayoutBatchHeader
  • PayPal\Api\PayoutItem
  • PayPal\Api\PayoutItemDetails
  • PayPal\Api\PayoutSenderBatchHeader
  • PayPal\Api\Phone
  • PayPal\Api\Plan
  • PayPal\Api\PlanList
  • PayPal\Api\PotentialPayerInfo
  • PayPal\Api\Presentation
  • PayPal\Api\PrivateLabelCard
  • PayPal\Api\ProcessorResponse
  • PayPal\Api\RecipientBankingInstruction
  • PayPal\Api\RedirectUrls
  • PayPal\Api\Refund
  • PayPal\Api\RefundDetail
  • PayPal\Api\RefundRequest
  • PayPal\Api\RelatedResources
  • PayPal\Api\Sale
  • PayPal\Api\Search
  • PayPal\Api\ShippingAddress
  • PayPal\Api\ShippingCost
  • PayPal\Api\ShippingInfo
  • PayPal\Api\Tax
  • PayPal\Api\Template
  • PayPal\Api\TemplateData
  • PayPal\Api\Templates
  • PayPal\Api\TemplateSettings
  • PayPal\Api\TemplateSettingsMetadata
  • PayPal\Api\Terms
  • PayPal\Api\Transaction
  • PayPal\Api\TransactionBase
  • PayPal\Api\Transactions
  • PayPal\Api\VerifyWebhookSignature
  • PayPal\Api\VerifyWebhookSignatureResponse
  • PayPal\Api\Webhook
  • PayPal\Api\WebhookEvent
  • PayPal\Api\WebhookEventList
  • PayPal\Api\WebhookEventType
  • PayPal\Api\WebhookEventTypeList
  • PayPal\Api\WebhookList
  • PayPal\Api\WebProfile
  • PayPal\Auth\OAuthTokenCredential
  • PayPal\Cache\AuthorizationCache
  • PayPal\Common\ArrayUtil
  • PayPal\Common\PayPalModel
  • PayPal\Common\PayPalResourceModel
  • PayPal\Common\PayPalUserAgent
  • PayPal\Common\ReflectionUtil
  • PayPal\Converter\FormatConverter
  • PayPal\Core\PayPalConfigManager
  • PayPal\Core\PayPalConstants
  • PayPal\Core\PayPalCredentialManager
  • PayPal\Core\PayPalHttpConfig
  • PayPal\Core\PayPalHttpConnection
  • PayPal\Core\PayPalLoggingManager
  • PayPal\Handler\OauthHandler
  • PayPal\Handler\RestHandler
  • PayPal\Log\PayPalDefaultLogFactory
  • PayPal\Log\PayPalLogger
  • PayPal\Rest\ApiContext
  • PayPal\Security\Cipher
  • PayPal\Transport\PayPalRestCall
  • PayPal\Validation\ArgumentValidator
  • PayPal\Validation\JsonValidator
  • PayPal\Validation\NumericValidator
  • PayPal\Validation\UrlValidator

Interfaces

  • PayPal\Handler\IPayPalHandler
  • PayPal\Log\PayPalLogFactory
  • PayPal\Rest\IResource

Exceptions

  • PayPal\Exception\PayPalConfigurationException
  • PayPal\Exception\PayPalConnectionException
  • PayPal\Exception\PayPalInvalidCredentialException
  • PayPal\Exception\PayPalMissingCredentialException
  1 <?php
  2 
  3 namespace PayPal\Api;
  4 
  5 use PayPal\Common\PayPalModel;
  6 use PayPal\Common\PayPalResourceModel;
  7 use PayPal\Rest\ApiContext;
  8 use PayPal\Transport\PayPalRestCall;
  9 use PayPal\Validation\ArgumentValidator;
 10 
 11 /**
 12  * Class Plan
 13  *
 14  * Billing plan resource that will be used to create a billing agreement.
 15  *
 16  * @package PayPal\Api
 17  *
 18  * @property string id
 19  * @property string name
 20  * @property string description
 21  * @property string type
 22  * @property string state
 23  * @property string create_time
 24  * @property string update_time
 25  * @property \PayPal\Api\PaymentDefinition[] payment_definitions
 26  * @property \PayPal\Api\Terms[] terms
 27  * @property \PayPal\Api\MerchantPreferences merchant_preferences
 28  */
 29 class Plan extends PayPalResourceModel
 30 {
 31     /**
 32      * Identifier of the billing plan. 128 characters max.
 33      *
 34      * @param string $id
 35      * 
 36      * @return $this
 37      */
 38     public function setId($id)
 39     {
 40         $this->id = $id;
 41         return $this;
 42     }
 43 
 44     /**
 45      * Identifier of the billing plan. 128 characters max.
 46      *
 47      * @return string
 48      */
 49     public function getId()
 50     {
 51         return $this->id;
 52     }
 53 
 54     /**
 55      * Name of the billing plan. 128 characters max.
 56      *
 57      * @param string $name
 58      * 
 59      * @return $this
 60      */
 61     public function setName($name)
 62     {
 63         $this->name = $name;
 64         return $this;
 65     }
 66 
 67     /**
 68      * Name of the billing plan. 128 characters max.
 69      *
 70      * @return string
 71      */
 72     public function getName()
 73     {
 74         return $this->name;
 75     }
 76 
 77     /**
 78      * Description of the billing plan. 128 characters max.
 79      *
 80      * @param string $description
 81      * 
 82      * @return $this
 83      */
 84     public function setDescription($description)
 85     {
 86         $this->description = $description;
 87         return $this;
 88     }
 89 
 90     /**
 91      * Description of the billing plan. 128 characters max.
 92      *
 93      * @return string
 94      */
 95     public function getDescription()
 96     {
 97         return $this->description;
 98     }
 99 
100     /**
101      * Type of the billing plan. Allowed values: `FIXED`, `INFINITE`.
102      *
103      * @param string $type
104      * 
105      * @return $this
106      */
107     public function setType($type)
108     {
109         $this->type = $type;
110         return $this;
111     }
112 
113     /**
114      * Type of the billing plan. Allowed values: `FIXED`, `INFINITE`.
115      *
116      * @return string
117      */
118     public function getType()
119     {
120         return $this->type;
121     }
122 
123     /**
124      * Status of the billing plan. Allowed values: `CREATED`, `ACTIVE`, `INACTIVE`, and `DELETED`.
125      *
126      * @param string $state
127      * 
128      * @return $this
129      */
130     public function setState($state)
131     {
132         $this->state = $state;
133         return $this;
134     }
135 
136     /**
137      * Status of the billing plan. Allowed values: `CREATED`, `ACTIVE`, `INACTIVE`, and `DELETED`.
138      *
139      * @return string
140      */
141     public function getState()
142     {
143         return $this->state;
144     }
145 
146     /**
147      * Time when the billing plan was created. Format YYYY-MM-DDTimeTimezone, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
148      *
149      * @param string $create_time
150      * 
151      * @return $this
152      */
153     public function setCreateTime($create_time)
154     {
155         $this->create_time = $create_time;
156         return $this;
157     }
158 
159     /**
160      * Time when the billing plan was created. Format YYYY-MM-DDTimeTimezone, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
161      *
162      * @return string
163      */
164     public function getCreateTime()
165     {
166         return $this->create_time;
167     }
168 
169     /**
170      * Time when this billing plan was updated. Format YYYY-MM-DDTimeTimezone, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
171      *
172      * @param string $update_time
173      * 
174      * @return $this
175      */
176     public function setUpdateTime($update_time)
177     {
178         $this->update_time = $update_time;
179         return $this;
180     }
181 
182     /**
183      * Time when this billing plan was updated. Format YYYY-MM-DDTimeTimezone, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
184      *
185      * @return string
186      */
187     public function getUpdateTime()
188     {
189         return $this->update_time;
190     }
191 
192     /**
193      * Array of payment definitions for this billing plan.
194      *
195      * @param \PayPal\Api\PaymentDefinition[] $payment_definitions
196      * 
197      * @return $this
198      */
199     public function setPaymentDefinitions($payment_definitions)
200     {
201         $this->payment_definitions = $payment_definitions;
202         return $this;
203     }
204 
205     /**
206      * Array of payment definitions for this billing plan.
207      *
208      * @return \PayPal\Api\PaymentDefinition[]
209      */
210     public function getPaymentDefinitions()
211     {
212         return $this->payment_definitions;
213     }
214 
215     /**
216      * Append PaymentDefinitions to the list.
217      *
218      * @param \PayPal\Api\PaymentDefinition $paymentDefinition
219      * @return $this
220      */
221     public function addPaymentDefinition($paymentDefinition)
222     {
223         if (!$this->getPaymentDefinitions()) {
224             return $this->setPaymentDefinitions(array($paymentDefinition));
225         } else {
226             return $this->setPaymentDefinitions(
227                 array_merge($this->getPaymentDefinitions(), array($paymentDefinition))
228             );
229         }
230     }
231 
232     /**
233      * Remove PaymentDefinitions from the list.
234      *
235      * @param \PayPal\Api\PaymentDefinition $paymentDefinition
236      * @return $this
237      */
238     public function removePaymentDefinition($paymentDefinition)
239     {
240         return $this->setPaymentDefinitions(
241             array_diff($this->getPaymentDefinitions(), array($paymentDefinition))
242         );
243     }
244 
245     /**
246      * Array of terms for this billing plan.
247      *
248      * @param \PayPal\Api\Terms[] $terms
249      * 
250      * @return $this
251      */
252     public function setTerms($terms)
253     {
254         $this->terms = $terms;
255         return $this;
256     }
257 
258     /**
259      * Array of terms for this billing plan.
260      *
261      * @return \PayPal\Api\Terms[]
262      */
263     public function getTerms()
264     {
265         return $this->terms;
266     }
267 
268     /**
269      * Append Terms to the list.
270      *
271      * @param \PayPal\Api\Terms $terms
272      * @return $this
273      */
274     public function addTerm($terms)
275     {
276         if (!$this->getTerms()) {
277             return $this->setTerms(array($terms));
278         } else {
279             return $this->setTerms(
280                 array_merge($this->getTerms(), array($terms))
281             );
282         }
283     }
284 
285     /**
286      * Remove Terms from the list.
287      *
288      * @param \PayPal\Api\Terms $terms
289      * @return $this
290      */
291     public function removeTerm($terms)
292     {
293         return $this->setTerms(
294             array_diff($this->getTerms(), array($terms))
295         );
296     }
297 
298     /**
299      * Specific preferences such as: set up fee, max fail attempts, autobill amount, and others that are configured for this billing plan.
300      *
301      * @param \PayPal\Api\MerchantPreferences $merchant_preferences
302      * 
303      * @return $this
304      */
305     public function setMerchantPreferences($merchant_preferences)
306     {
307         $this->merchant_preferences = $merchant_preferences;
308         return $this;
309     }
310 
311     /**
312      * Specific preferences such as: set up fee, max fail attempts, autobill amount, and others that are configured for this billing plan.
313      *
314      * @return \PayPal\Api\MerchantPreferences
315      */
316     public function getMerchantPreferences()
317     {
318         return $this->merchant_preferences;
319     }
320 
321     /**
322      * Retrieve the details for a particular billing plan by passing the billing plan ID to the request URI.
323      *
324      * @param string $planId
325      * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
326      * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
327      * @return Plan
328      */
329     public static function get($planId, $apiContext = null, $restCall = null)
330     {
331         ArgumentValidator::validate($planId, 'planId');
332         $payLoad = "";
333         $json = self::executeCall(
334             "/v1/payments/billing-plans/$planId",
335             "GET",
336             $payLoad,
337             null,
338             $apiContext,
339             $restCall
340         );
341         $ret = new Plan();
342         $ret->fromJson($json);
343         return $ret;
344     }
345 
346     /**
347      * Create a new billing plan by passing the details for the plan, including the plan name, description, and type, to the request URI.
348      *
349      * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
350      * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
351      * @return Plan
352      */
353     public function create($apiContext = null, $restCall = null)
354     {
355         $payLoad = $this->toJSON();
356         $json = self::executeCall(
357             "/v1/payments/billing-plans/",
358             "POST",
359             $payLoad,
360             null,
361             $apiContext,
362             $restCall
363         );
364         $this->fromJson($json);
365         return $this;
366     }
367 
368     /**
369      * Replace specific fields within a billing plan by passing the ID of the billing plan to the request URI. In addition, pass a patch object in the request JSON that specifies the operation to perform, field to update, and new value for each update.
370      *
371      * @param PatchRequest $patchRequest
372      * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
373      * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
374      * @return bool
375      */
376     public function update($patchRequest, $apiContext = null, $restCall = null)
377     {
378         ArgumentValidator::validate($this->getId(), "Id");
379         ArgumentValidator::validate($patchRequest, 'patchRequest');
380         $payLoad = $patchRequest->toJSON();
381         self::executeCall(
382             "/v1/payments/billing-plans/{$this->getId()}",
383             "PATCH",
384             $payLoad,
385             null,
386             $apiContext,
387             $restCall
388         );
389         return true;
390     }
391 
392     /**
393      * Delete a billing plan by passing the ID of the billing plan to the request URI.
394      *
395      * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
396      * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
397      * @return bool
398      */
399     public function delete($apiContext = null, $restCall = null)
400     {
401         ArgumentValidator::validate($this->getId(), "Id");
402         $patchRequest = new PatchRequest();
403         $patch = new Patch();
404         $value = new PayPalModel('{
405             "state":"DELETED"
406         }');
407         $patch->setOp('replace')
408             ->setPath('/')
409             ->setValue($value);
410         $patchRequest->addPatch($patch);
411         return $this->update($patchRequest, $apiContext, $restCall);
412     }
413 
414     /**
415      * List billing plans according to optional query string parameters specified.
416      *
417      * @param array $params
418      * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
419      * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
420      * @return PlanList
421      */
422     public static function all($params, $apiContext = null, $restCall = null)
423     {
424         ArgumentValidator::validate($params, 'params');
425         $payLoad = "";
426         $allowedParams = array(
427             'page_size' => 1,
428             'status' => 1,
429             'page' => 1,
430             'total_required' => 1
431         );
432         $json = self::executeCall(
433             "/v1/payments/billing-plans/" . "?" . http_build_query(array_intersect_key($params, $allowedParams)),
434             "GET",
435             $payLoad,
436             null,
437             $apiContext,
438             $restCall
439         );
440         $ret = new PlanList();
441         $ret->fromJson($json);
442         return $ret;
443     }
444 
445 }
446 
API documentation generated by ApiGen