/**
  * return a instance of this class
  * @return PayUSubscriptionsUrlResolver
  */
 public static function getInstance()
 {
     if (!self::$instancia instanceof self) {
         self::$instancia = new self();
     }
     return self::$instancia;
 }
 /**
  * Cancels 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 cancel($parameters, $lang = null)
 {
     $required = array(PayUParameters::SUBSCRIPTION_ID);
     CommonRequestUtil::validateParameters($parameters, $required);
     $request = PayUSubscriptionsRequestUtil::buildSubscription($parameters);
     $urlSegment = PayUSubscriptionsUrlResolver::getInstance()->getUrlSegment(PayUSubscriptionsUrlResolver::SUBSCRIPTIONS_ENTITY, PayUSubscriptionsUrlResolver::DELETE_OPERATION, array($parameters[PayUParameters::SUBSCRIPTION_ID]));
     $payUHttpRequestInfo = PayUSubscriptionsRequestUtil::buildHttpRequestInfo($urlSegment, $lang, RequestMethod::DELETE);
     return PayUApiServiceUtil::sendRequest($request, $payUHttpRequestInfo);
 }
 /**
  * Deletes a credit card
  * @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 delete($parameters, $lang = null)
 {
     $required = array(PayUParameters::TOKEN_ID, PayUParameters::CUSTOMER_ID);
     CommonRequestUtil::validateParameters($parameters, $required);
     $creditCard = PayUSubscriptionsRequestUtil::buildCreditCard($parameters);
     $urlSegment = PayUSubscriptionsUrlResolver::getInstance()->getUrlSegment(PayUSubscriptionsUrlResolver::CREDIT_CARD_ENTITY, PayUSubscriptionsUrlResolver::DELETE_OPERATION, array($creditCard->customerId, $creditCard->token));
     $payUHttpRequestInfo = PayUSubscriptionsRequestUtil::buildHttpRequestInfo($urlSegment, $lang, RequestMethod::DELETE);
     return PayUApiServiceUtil::sendRequest($creditCard, $payUHttpRequestInfo);
 }
 /**
  * Deletes a subscription plan
  * @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 delete($parameters, $lang = null)
 {
     $required = array(PayUParameters::PLAN_CODE);
     CommonRequestUtil::validateParameters($parameters, $required);
     $plan = PayUSubscriptionsRequestUtil::buildSubscriptionPlan($parameters);
     $urlSegment = PayUSubscriptionsUrlResolver::getInstance()->getUrlSegment(PayUSubscriptionsUrlResolver::PLAN_ENTITY, PayUSubscriptionsUrlResolver::DELETE_OPERATION, array($plan->planCode));
     $payUHttpRequestInfo = PayUSubscriptionsRequestUtil::buildHttpRequestInfo($urlSegment, $lang, RequestMethod::DELETE);
     return PayUApiServiceUtil::sendRequest($plan, $payUHttpRequestInfo);
 }
예제 #5
0
 /**
  * Finds all bill filtered by 
  * - customer id
  * - date begin
  * - date final
  * - payment method
  * - subscription Id
  * 
  * @param parameters The parameters to be sent to the server
  * @param string $lang language of request see SupportedLanguages class
  * @return the subscription plan list
  * @throws PayUException
  * @throws InvalidArgumentException
  */
 public static function listRecurringBills($parameters, $lang = null)
 {
     $request = new stdClass();
     $request->customerId = CommonRequestUtil::getParameter($parameters, PayUParameters::CUSTOMER_ID);
     $request->dateBegin = CommonRequestUtil::getParameter($parameters, PayUParameters::RECURRING_BILL_DATE_BEGIN);
     $request->dateFinal = CommonRequestUtil::getParameter($parameters, PayUParameters::RECURRING_BILL_DATE_FINAL);
     $request->paymentMethod = CommonRequestUtil::getParameter($parameters, PayUParameters::RECURRING_BILL_PAYMENT_METHOD_TYPE);
     $request->state = CommonRequestUtil::getParameter($parameters, PayUParameters::RECURRING_BILL_STATE);
     $request->subscriptionId = CommonRequestUtil::getParameter($parameters, PayUParameters::SUBSCRIPTION_ID);
     $request->limit = CommonRequestUtil::getParameter($parameters, PayUParameters::LIMIT);
     $request->offset = CommonRequestUtil::getParameter($parameters, PayUParameters::OFFSET);
     $urlSegment = PayUSubscriptionsUrlResolver::getInstance()->getUrlSegment(PayUSubscriptionsUrlResolver::RECURRING_BILL_ENTITY, PayUSubscriptionsUrlResolver::QUERY_OPERATION);
     $urlSegment = CommonRequestUtil::addQueryParamsToUrl($urlSegment, $request);
     $payUHttpRequestInfo = PayUSubscriptionsRequestUtil::buildHttpRequestInfo($urlSegment, $lang, RequestMethod::GET);
     return PayUApiServiceUtil::sendRequest(null, $payUHttpRequestInfo);
 }
예제 #6
0
 /**
  * Finds all subscription plans filtered by merchant or account
  * by default the function filter by merchant if you need filter by account
  * you can send in the parameters the account id
  * @param parameters The parameters to be sent to the server
  * @param string $lang language of request see SupportedLanguages class 
  * @return the subscription plan list
  * @throws PayUException
  * @throws InvalidParametersException
  * @throws InvalidArgumentException
  */
 public static function listPlans($parameters, $lang = null)
 {
     $request = new stdClass();
     $request->accountId = CommonRequestUtil::getParameter($parameters, PayUParameters::ACCOUNT_ID);
     $request->limit = CommonRequestUtil::getParameter($parameters, PayUParameters::LIMIT);
     $request->offset = CommonRequestUtil::getParameter($parameters, PayUParameters::OFFSET);
     $urlSegment = PayUSubscriptionsUrlResolver::getInstance()->getUrlSegment(PayUSubscriptionsUrlResolver::PLAN_ENTITY, PayUSubscriptionsUrlResolver::QUERY_OPERATION);
     $urlSegment = CommonRequestUtil::addQueryParamsToUrl($urlSegment, $request);
     $payUHttpRequestInfo = PayUSubscriptionsRequestUtil::buildHttpRequestInfo($urlSegment, $lang, RequestMethod::GET);
     return PayUApiServiceUtil::sendRequest(null, $payUHttpRequestInfo);
 }
예제 #7
0
 /**
  * Finds the customers associated to a plan by plan id or by plan code
  * 
  * @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 findCustomerListByPlanIdOrPlanCode($parameters, $lang = null)
 {
     $request = new stdClass();
     $request->planId = CommonRequestUtil::getParameter($parameters, PayUParameters::PLAN_ID);
     $request->planCode = CommonRequestUtil::getParameter($parameters, PayUParameters::PLAN_CODE);
     $request->limit = CommonRequestUtil::getParameter($parameters, PayUParameters::LIMIT);
     $request->offset = CommonRequestUtil::getParameter($parameters, PayUParameters::OFFSET);
     $urlSegment = PayUSubscriptionsUrlResolver::getInstance()->getUrlSegment(PayUSubscriptionsUrlResolver::CUSTOMER_ENTITY, PayUSubscriptionsUrlResolver::CUSTOMERS_PARAM_SEARCH, null);
     $urlSegment = CommonRequestUtil::addQueryParamsToUrl($urlSegment, $request);
     $payUHttpRequestInfo = PayUSubscriptionsRequestUtil::buildHttpRequestInfo($urlSegment, $lang, RequestMethod::GET);
     return PayUApiServiceUtil::sendRequest(null, $payUHttpRequestInfo);
 }
예제 #8
0
 /**
  * Deletes a recurring bill item
  * @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 delete($parameters, $lang = null)
 {
     $required = array(PayUParameters::RECURRING_BILL_ITEM_ID);
     CommonRequestUtil::validateParameters($parameters, $required);
     $recurrinbBillItem = PayUSubscriptionsRequestUtil::buildRecurringBillItem($parameters);
     $urlSegment = PayUSubscriptionsUrlResolver::getInstance()->getUrlSegment(PayUSubscriptionsUrlResolver::RECURRING_BILL_ITEM_ENTITY, PayUSubscriptionsUrlResolver::DELETE_OPERATION, array($recurrinbBillItem->id));
     $payUHttpRequestInfo = PayUSubscriptionsRequestUtil::buildHttpRequestInfo($urlSegment, $lang, RequestMethod::DELETE);
     return PayUApiServiceUtil::sendRequest(NULL, $payUHttpRequestInfo);
 }
예제 #9
0
 /**
  * Finds the bank accounts associated to a customer by customer id
  * 
  * @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 findListByCustomer($parameters, $lang = null)
 {
     $request = new stdClass();
     $request->customerId = CommonRequestUtil::getParameter($parameters, PayUParameters::CUSTOMER_ID);
     $urlSegment = PayUSubscriptionsUrlResolver::getInstance()->getUrlSegment(PayUSubscriptionsUrlResolver::BANK_ACCOUNT_ENTITY, PayUSubscriptionsUrlResolver::GET_LIST_OPERATION, array($request->customerId));
     $payUHttpRequestInfo = PayUSubscriptionsRequestUtil::buildHttpRequestInfo($urlSegment, $lang, RequestMethod::GET);
     return PayUApiServiceUtil::sendRequest($request, $payUHttpRequestInfo);
 }
예제 #10
0
 /**
  * Finds the subscriptions associated to a customer by either
  * payer id, plan id, plan code, accoun id and account status
  * using an offset and a limit 
  *
  * @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 findSubscriptionsByPlanOrCustomerOrAccount($parameters, $lang = null)
 {
     $request = new stdClass();
     $request->planId = CommonRequestUtil::getParameter($parameters, PayUParameters::PLAN_ID);
     $request->planCode = CommonRequestUtil::getParameter($parameters, PayUParameters::PLAN_CODE);
     $request->state = CommonRequestUtil::getParameter($parameters, PayUParameters::ACCOUNT_STATE);
     $request->customerId = CommonRequestUtil::getParameter($parameters, PayUParameters::CUSTOMER_ID);
     $request->accountId = CommonRequestUtil::getParameter($parameters, PayUParameters::ACCOUNT_ID);
     $request->limit = CommonRequestUtil::getParameter($parameters, PayUParameters::LIMIT);
     $request->offset = CommonRequestUtil::getParameter($parameters, PayUParameters::OFFSET);
     $urlSegment = PayUSubscriptionsUrlResolver::getInstance()->getUrlSegment(PayUSubscriptionsUrlResolver::SUBSCRIPTIONS_ENTITY, UrlResolver::GET_LIST_OPERATION, null);
     $urlSegment = CommonRequestUtil::addQueryParamsToUrl($urlSegment, $request);
     $payUHttpRequestInfo = PayUSubscriptionsRequestUtil::buildHttpRequestInfo($urlSegment, $lang, RequestMethod::GET);
     return PayUApiServiceUtil::sendRequest(null, $payUHttpRequestInfo);
 }