/**
  * 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);
 }
예제 #4
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);
 }
예제 #5
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);
 }
 /**
  * Validate a customer in subscription request
  * @param array $parameters
  * @throws InvalidParameterException 
  */
 public static function validateCustomerToSubscription($parameters, $edit = FALSE)
 {
     $customerId = CommonRequestUtil::getParameter($parameters, PayUParameters::CUSTOMER_ID);
     if (isset($customerId) || $edit == TRUE) {
         $invalid = array(PayUParameters::CUSTOMER_EMAIL, PayUParameters::CUSTOMER_NAME);
         CommonRequestUtil::validateParameters($parameters, NULL, $invalid);
     } else {
         PayUSubscriptionsRequestUtil::validateCustomer($parameters, FALSE);
     }
 }
예제 #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
 /**
  * validate the Payment Method parameters. Only one payment methos is permitted
  * @param $parameters
  * @param $existParamBankAccount
  * @param $existParamCreditCard
  * @throws PayUException
  */
 public static function validatePaymentMethod($parameters, $existParamBankAccount, $existParamCreditCard, $edit = FALSE)
 {
     if ($existParamBankAccount == TRUE && $existParamCreditCard == TRUE) {
         throw new PayUException(PayUErrorCodes::INVALID_PARAMETERS, "The subscription must have only one payment method");
     } else {
         if ($existParamBankAccount == TRUE) {
             PayUSubscriptionsRequestUtil::validateBankAccount($parameters);
             if ($edit == FALSE) {
                 //The TERMS_AND_CONDITIONS_ACEPTED Parameter is required for Bank Account
                 $required = array(PayUParameters::TERMS_AND_CONDITIONS_ACEPTED);
                 CommonRequestUtil::validateParameters($parameters, $required);
             }
         } else {
             if ($existParamCreditCard == TRUE) {
                 PayUSubscriptionsRequestUtil::validateCreditCard($parameters);
             } else {
                 throw new PayUException(PayUErrorCodes::INVALID_PARAMETERS, "The subscription must have one payment method");
             }
         }
     }
 }