Ejemplo n.º 1
0
 /**
  * Removes a credit card token
  * @param parameters The parameters to be sent to the server
  * @param string $lang language of request see SupportedLanguages class
  * @return The transaction response to the request sent
  * @throws PayUException
  * @throws InvalidArgumentException
  */
 public static function remove($parameters, $lang = null)
 {
     $required = array(PayUParameters::TOKEN_ID, PayUParameters::PAYER_ID);
     CommonRequestUtil::validateParameters($parameters, $required);
     $request = PayUTokensRequestUtil::buildRemoveTokenRequest($parameters, $lang);
     $payUHttpRequestInfo = new PayUHttpRequestInfo(Environment::PAYMENTS_API, RequestMethod::POST);
     return PayUApiServiceUtil::sendRequest($request, $payUHttpRequestInfo);
 }
Ejemplo n.º 2
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);
 }
Ejemplo n.º 3
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);
 }
Ejemplo n.º 4
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);
 }
Ejemplo n.º 5
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);
 }
Ejemplo n.º 6
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);
 }
Ejemplo n.º 7
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);
 }
Ejemplo n.º 8
0
 /**
  * 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);
 }
Ejemplo n.º 9
0
 /**
  * Process a transaction already authorizated
  *
  * @param parameters The parameters to be sent to the server
  * @param transactionType
  *            The type of the payment transaction
  * @param string $lang language of request see SupportedLanguages class            
  * @return The transaction response to the request sent
  * @throws PayUException
  * @throws InvalidArgumentException
  */
 private static function processTransactionAlreadyAuthorizated($parameters, $transactionType, $lang)
 {
     $required = array(PayUParameters::TRANSACTION_ID, PayUParameters::ORDER_ID);
     CommonRequestUtil::validateParameters($parameters, $required);
     $request = RequestPaymentsUtil::buildPaymentRequest($parameters, $transactionType, $lang);
     $payUHttpRequestInfo = new PayUHttpRequestInfo(Environment::PAYMENTS_API, RequestMethod::POST);
     return PayUApiServiceUtil::sendRequest($request, $payUHttpRequestInfo);
 }