Exemplo n.º 1
0
 /**
  * Creates a subscription plans
  * @param parameters The parameters to be sent to the server
  * @param string $lang language of request see SupportedLanguages class
  * @return The response to the request sent
  * @throws PayUException
  * @throws InvalidArgumentException
  */
 public static function create($parameters, $lang = null)
 {
     PayUSubscriptionsRequestUtil::validateSubscriptionPlan($parameters);
     $request = PayUSubscriptionsRequestUtil::buildSubscriptionPlan($parameters);
     $urlSegment = PayUSubscriptionsUrlResolver::getInstance()->getUrlSegment(PayUSubscriptionsUrlResolver::PLAN_ENTITY, PayUSubscriptionsUrlResolver::ADD_OPERATION);
     $payUHttpRequestInfo = PayUSubscriptionsRequestUtil::buildHttpRequestInfo($urlSegment, $lang, RequestMethod::POST);
     return PayUApiServiceUtil::sendRequest($request, $payUHttpRequestInfo);
 }
Exemplo n.º 2
0
 /**
  * Creates a subscription
  * @param parameters The parameters to be sent to the server
  * @param string $lang language of request see SupportedLanguages class
  * @return The response to the request sent
  * @throws PayUException
  * @throws InvalidArgumentException
  */
 public static function createSubscription($parameters, $lang = null)
 {
     $planCode = CommonRequestUtil::getParameter($parameters, PayUParameters::PLAN_CODE);
     $tokenId = CommonRequestUtil::getParameter($parameters, PayUParameters::TOKEN_ID);
     if (!isset($planCode)) {
         PayUSubscriptionsRequestUtil::validateSubscriptionPlan($parameters);
     }
     PayUSubscriptionsRequestUtil::validateCustomerToSubscription($parameters);
     $existParamBankAccount = PayUBankAccounts::existParametersBankAccount($parameters);
     $existParamCreditCard = PayUCreditCards::existParametersCreditCard($parameters);
     self::validatePaymentMethod($parameters, $existParamBankAccount, $existParamCreditCard);
     $request = PayUSubscriptionsRequestUtil::buildSubscription($parameters, $existParamBankAccount, $existParamCreditCard);
     $urlSegment = PayUSubscriptionsUrlResolver::getInstance()->getUrlSegment(PayUSubscriptionsUrlResolver::SUBSCRIPTIONS_ENTITY, PayUSubscriptionsUrlResolver::ADD_OPERATION);
     $payUHttpRequestInfo = PayUSubscriptionsRequestUtil::buildHttpRequestInfo($urlSegment, $lang, RequestMethod::POST);
     return PayUApiServiceUtil::sendRequest($request, $payUHttpRequestInfo);
 }