PayPalApiPlan

Class Plan.

Defined (1)

The class is defined in the following location(s).

/classes/lib/PayPal/Api/Plan.php  
  1. class Plan extends PayPalResourceModel 
  2. /** 
  3. * Identifier of the billing plan. 128 characters max. 
  4. * @param string $id 
  5. *  
  6. * @return $this 
  7. */ 
  8. public function setId($id) 
  9. $this->id = $id; 
  10. return $this; 
  11.  
  12. /** 
  13. * Identifier of the billing plan. 128 characters max. 
  14. * @return string 
  15. */ 
  16. public function getId() 
  17. return $this->id; 
  18.  
  19. /** 
  20. * Name of the billing plan. 128 characters max. 
  21. * @param string $name 
  22. *  
  23. * @return $this 
  24. */ 
  25. public function setName($name) 
  26. $this->name = $name; 
  27. return $this; 
  28.  
  29. /** 
  30. * Name of the billing plan. 128 characters max. 
  31. * @return string 
  32. */ 
  33. public function getName() 
  34. return $this->name; 
  35.  
  36. /** 
  37. * Description of the billing plan. 128 characters max. 
  38. * @param string $description 
  39. *  
  40. * @return $this 
  41. */ 
  42. public function setDescription($description) 
  43. $this->description = $description; 
  44. return $this; 
  45.  
  46. /** 
  47. * Description of the billing plan. 128 characters max. 
  48. * @return string 
  49. */ 
  50. public function getDescription() 
  51. return $this->description; 
  52.  
  53. /** 
  54. * Type of the billing plan. Allowed values: `FIXED`, `INFINITE`. 
  55. * @param string $type 
  56. *  
  57. * @return $this 
  58. */ 
  59. public function setType($type) 
  60. $this->type = $type; 
  61. return $this; 
  62.  
  63. /** 
  64. * Type of the billing plan. Allowed values: `FIXED`, `INFINITE`. 
  65. * @return string 
  66. */ 
  67. public function getType() 
  68. return $this->type; 
  69.  
  70. /** 
  71. * Status of the billing plan. Allowed values: `CREATED`, `ACTIVE`, `INACTIVE`, and `DELETED`. 
  72. * @param string $state 
  73. *  
  74. * @return $this 
  75. */ 
  76. public function setState($state) 
  77. $this->state = $state; 
  78. return $this; 
  79.  
  80. /** 
  81. * Status of the billing plan. Allowed values: `CREATED`, `ACTIVE`, `INACTIVE`, and `DELETED`. 
  82. * @return string 
  83. */ 
  84. public function getState() 
  85. return $this->state; 
  86.  
  87. /** 
  88. * Time when the billing plan was created. Format YYYY-MM-DDTimeTimezone, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). 
  89. * @param string $create_time 
  90. *  
  91. * @return $this 
  92. */ 
  93. public function setCreateTime($create_time) 
  94. $this->create_time = $create_time; 
  95. return $this; 
  96.  
  97. /** 
  98. * Time when the billing plan was created. Format YYYY-MM-DDTimeTimezone, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). 
  99. * @return string 
  100. */ 
  101. public function getCreateTime() 
  102. return $this->create_time; 
  103.  
  104. /** 
  105. * Time when this billing plan was updated. Format YYYY-MM-DDTimeTimezone, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). 
  106. * @param string $update_time 
  107. *  
  108. * @return $this 
  109. */ 
  110. public function setUpdateTime($update_time) 
  111. $this->update_time = $update_time; 
  112. return $this; 
  113.  
  114. /** 
  115. * Time when this billing plan was updated. Format YYYY-MM-DDTimeTimezone, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). 
  116. * @return string 
  117. */ 
  118. public function getUpdateTime() 
  119. return $this->update_time; 
  120.  
  121. /** 
  122. * Array of payment definitions for this billing plan. 
  123. * @param \PayPal\Api\PaymentDefinition[] $payment_definitions 
  124. *  
  125. * @return $this 
  126. */ 
  127. public function setPaymentDefinitions($payment_definitions) 
  128. $this->payment_definitions = $payment_definitions; 
  129. return $this; 
  130.  
  131. /** 
  132. * Array of payment definitions for this billing plan. 
  133. * @return \PayPal\Api\PaymentDefinition[] 
  134. */ 
  135. public function getPaymentDefinitions() 
  136. return $this->payment_definitions; 
  137.  
  138. /** 
  139. * Append PaymentDefinitions to the list. 
  140. * @param \PayPal\Api\PaymentDefinition $paymentDefinition 
  141. * @return $this 
  142. */ 
  143. public function addPaymentDefinition($paymentDefinition) 
  144. if (!$this->getPaymentDefinitions()) { 
  145. return $this->setPaymentDefinitions(array($paymentDefinition)); 
  146. } else { 
  147. return $this->setPaymentDefinitions( 
  148. array_merge($this->getPaymentDefinitions(), array($paymentDefinition)) 
  149. ); 
  150.  
  151. /** 
  152. * Remove PaymentDefinitions from the list. 
  153. * @param \PayPal\Api\PaymentDefinition $paymentDefinition 
  154. * @return $this 
  155. */ 
  156. public function removePaymentDefinition($paymentDefinition) 
  157. return $this->setPaymentDefinitions( 
  158. array_diff($this->getPaymentDefinitions(), array($paymentDefinition)) 
  159. ); 
  160.  
  161. /** 
  162. * Array of terms for this billing plan. 
  163. * @param \PayPal\Api\Terms[] $terms 
  164. *  
  165. * @return $this 
  166. */ 
  167. public function setTerms($terms) 
  168. $this->terms = $terms; 
  169. return $this; 
  170.  
  171. /** 
  172. * Array of terms for this billing plan. 
  173. * @return \PayPal\Api\Terms[] 
  174. */ 
  175. public function getTerms() 
  176. return $this->terms; 
  177.  
  178. /** 
  179. * Append Terms to the list. 
  180. * @param \PayPal\Api\Terms $terms 
  181. * @return $this 
  182. */ 
  183. public function addTerm($terms) 
  184. if (!$this->getTerms()) { 
  185. return $this->setTerms(array($terms)); 
  186. } else { 
  187. return $this->setTerms( 
  188. array_merge($this->getTerms(), array($terms)) 
  189. ); 
  190.  
  191. /** 
  192. * Remove Terms from the list. 
  193. * @param \PayPal\Api\Terms $terms 
  194. * @return $this 
  195. */ 
  196. public function removeTerm($terms) 
  197. return $this->setTerms( 
  198. array_diff($this->getTerms(), array($terms)) 
  199. ); 
  200.  
  201. /** 
  202. * Specific preferences such as: set up fee, max fail attempts, autobill amount, and others that are configured for this billing plan. 
  203. * @param \PayPal\Api\MerchantPreferences $merchant_preferences 
  204. *  
  205. * @return $this 
  206. */ 
  207. public function setMerchantPreferences($merchant_preferences) 
  208. $this->merchant_preferences = $merchant_preferences; 
  209. return $this; 
  210.  
  211. /** 
  212. * Specific preferences such as: set up fee, max fail attempts, autobill amount, and others that are configured for this billing plan. 
  213. * @return \PayPal\Api\MerchantPreferences 
  214. */ 
  215. public function getMerchantPreferences() 
  216. return $this->merchant_preferences; 
  217.  
  218. /** 
  219. * Retrieve the details for a particular billing plan by passing the billing plan ID to the request URI. 
  220. * @param string $planId 
  221. * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. 
  222. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls 
  223. * @return Plan 
  224. */ 
  225. public static function get($planId, $apiContext = null, $restCall = null) 
  226. ArgumentValidator::validate($planId, 'planId'); 
  227. $payLoad = ""; 
  228. $json = self::executeCall( 
  229. "/v1/payments/billing-plans/$planId",  
  230. "GET",  
  231. $payLoad,  
  232. null,  
  233. $apiContext,  
  234. $restCall 
  235. ); 
  236. $ret = new Plan(); 
  237. $ret->fromJson($json); 
  238. return $ret; 
  239.  
  240. /** 
  241. * Create a new billing plan by passing the details for the plan, including the plan name, description, and type, to the request URI. 
  242. * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. 
  243. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls 
  244. * @return Plan 
  245. */ 
  246. public function create($apiContext = null, $restCall = null) 
  247. $payLoad = $this->toJSON(); 
  248. $json = self::executeCall( 
  249. "/v1/payments/billing-plans/",  
  250. "POST",  
  251. $payLoad,  
  252. null,  
  253. $apiContext,  
  254. $restCall 
  255. ); 
  256. $this->fromJson($json); 
  257. return $this; 
  258.  
  259. /** 
  260. * 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. 
  261. * @param PatchRequest $patchRequest 
  262. * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. 
  263. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls 
  264. * @return bool 
  265. */ 
  266. public function update($patchRequest, $apiContext = null, $restCall = null) 
  267. ArgumentValidator::validate($this->getId(), "Id"); 
  268. ArgumentValidator::validate($patchRequest, 'patchRequest'); 
  269. $payLoad = $patchRequest->toJSON(); 
  270. self::executeCall( 
  271. "/v1/payments/billing-plans/{$this->getId()}",  
  272. "PATCH",  
  273. $payLoad,  
  274. null,  
  275. $apiContext,  
  276. $restCall 
  277. ); 
  278. return true; 
  279.  
  280. /** 
  281. * Delete a billing plan by passing the ID of the billing plan to the request URI. 
  282. * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. 
  283. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls 
  284. * @return bool 
  285. */ 
  286. public function delete($apiContext = null, $restCall = null) 
  287. ArgumentValidator::validate($this->getId(), "Id"); 
  288. $patchRequest = new PatchRequest(); 
  289. $patch = new Patch(); 
  290. $value = new PayPalModel('{ 
  291. "state":"DELETED" 
  292. }'); 
  293. $patch->setOp('replace') 
  294. ->setPath('/') 
  295. ->setValue($value); 
  296. $patchRequest->addPatch($patch); 
  297. return $this->update($patchRequest, $apiContext, $restCall); 
  298.  
  299. /** 
  300. * List billing plans according to optional query string parameters specified. 
  301. * @param array $params 
  302. * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. 
  303. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls 
  304. * @return PlanList 
  305. */ 
  306. public static function all($params, $apiContext = null, $restCall = null) 
  307. ArgumentValidator::validate($params, 'params'); 
  308. $payLoad = ""; 
  309. $allowedParams = array( 
  310. 'page_size' => 1,  
  311. 'status' => 1,  
  312. 'page' => 1,  
  313. 'total_required' => 1 
  314. ); 
  315. $json = self::executeCall( 
  316. "/v1/payments/billing-plans/" . "?" . http_build_query(array_intersect_key($params, $allowedParams)),  
  317. "GET",  
  318. $payLoad,  
  319. null,  
  320. $apiContext,  
  321. $restCall 
  322. ); 
  323. $ret = new PlanList(); 
  324. $ret->fromJson($json); 
  325. return $ret; 
  326.