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
 /**
  * Builds a transaction reporting request the transaction will be query by id
  *
  * @param parameters The parameters to be sent to the server
  * @param string $lang language of request see SupportedLanguages class
  * @return The complete reporting request to be sent to the server
  */
 public static function buildTransactionResponse($parameters, $lang = null)
 {
     if (!isset($lang)) {
         $lang = PayU::$language;
     }
     $request = CommonRequestUtil::buildCommonRequest($lang, PayUCommands::TRANSACTION_RESPONSE_DETAIL);
     $transactionId = CommonRequestUtil::getParameter($parameters, PayUParameters::TRANSACTION_ID);
     $request->details = CommonRequestUtil::addMapEntry(null, PayUKeyMapName::TRANSACTION_ID, $transactionId);
     return $request;
 }
Ejemplo n.º 3
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.º 4
0
 /**
  * Builds a credit card token to be added to request
  * @param array $parameters
  * @return the credit card token built
  */
 private static function buildCreditCardToken($parameters)
 {
     $creditCardToken = new \stdClass();
     $creditCardToken->name = CommonRequestUtil::getParameter($parameters, PayUParameters::PAYER_NAME);
     $creditCardToken->payerId = CommonRequestUtil::getParameter($parameters, PayUParameters::PAYER_ID);
     $creditCardToken->identificationNumber = CommonRequestUtil::getParameter($parameters, PayUParameters::PAYER_DNI);
     $creditCardToken->paymentMethod = CommonRequestUtil::getParameter($parameters, PayUParameters::PAYMENT_METHOD);
     $creditCardToken->expirationDate = CommonRequestUtil::getParameter($parameters, PayUParameters::CREDIT_CARD_EXPIRATION_DATE);
     $creditCardToken->number = CommonRequestUtil::getParameter($parameters, PayUParameters::CREDIT_CARD_NUMBER);
     $creditCardToken->document = CommonRequestUtil::getParameter($parameters, PayUParameters::CREDIT_CARD_DOCUMENT);
     return $creditCardToken;
 }
Ejemplo n.º 5
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.º 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);
 }
Ejemplo n.º 7
0
 /**
  * Indicates whether any of the parameters for Bank Account is within the parameters list
  * @param parameters The parametrs to evaluate
  * @return <boolean> returns true if the parameter is in the set
  */
 public static function existParametersBankAccount($parameters)
 {
     $keyNamesSet = self::getParameterNames();
     return CommonRequestUtil::isParameterInSet($parameters, $keyNamesSet);
 }
Ejemplo n.º 8
0
 /**
  * Build a basic credit card object to be added to payment request
  * @param object $parameters with the credit card info
  * @return the credit card built
  */
 protected static function buildCreditCard($parameters)
 {
     $creditCard = new stdClass();
     $creditCard->name = CommonRequestUtil::getParameter($parameters, PayUParameters::PAYER_NAME);
     $creditCard->number = CommonRequestUtil::getParameter($parameters, PayUParameters::CREDIT_CARD_NUMBER);
     $creditCard->expirationDate = CommonRequestUtil::getParameter($parameters, PayUParameters::CREDIT_CARD_EXPIRATION_DATE);
     $creditCard->securityCode = CommonRequestUtil::getParameter($parameters, PayUParameters::CREDIT_CARD_SECURITY_CODE);
     $creditCard->processWithoutCvv2 = (bool) CommonRequestUtil::getParameter($parameters, PayUParameters::PROCESS_WITHOUT_CVV2);
     $creditCard->document = CommonRequestUtil::getParameter($parameters, PayUParameters::CREDIT_CARD_DOCUMENT);
     return $creditCard;
 }
Ejemplo n.º 9
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);
 }
 /**
  * Validate a Bank Account
  * @param array $parameters
  * @throws InvalidParameterException
  */
 public static function validateBankAccount($parameters)
 {
     $bankAccountId = CommonRequestUtil::getParameter($parameters, PayUParameters::BANK_ACCOUNT_ID);
     if (isset($bankAccountId)) {
         $required = array(PayUParameters::BANK_ACCOUNT_ID);
         $invalid = array(PayUParameters::BANK_ACCOUNT_DOCUMENT_NUMBER, PayUParameters::BANK_ACCOUNT_DOCUMENT_NUMBER_TYPE, PayUParameters::BANK_ACCOUNT_CUSTOMER_NAME, PayUParameters::BANK_ACCOUNT_AGENCY_NUMBER, PayUParameters::BANK_ACCOUNT_AGENCY_DIGIT, PayUParameters::BANK_ACCOUNT_ACCOUNT_DIGIT, PayUParameters::BANK_ACCOUNT_NUMBER, PayUParameters::BANK_ACCOUNT_BANK_NAME, PayUParameters::BANK_ACCOUNT_TYPE, PayUParameters::BANK_ACCOUNT_STATE);
         CommonRequestUtil::validateParameters($parameters, $required, $invalid);
     } else {
         $required = array(PayUParameters::BANK_ACCOUNT_CUSTOMER_NAME, PayUParameters::BANK_ACCOUNT_DOCUMENT_NUMBER, PayUParameters::BANK_ACCOUNT_DOCUMENT_NUMBER_TYPE, PayUParameters::BANK_ACCOUNT_BANK_NAME, PayUParameters::BANK_ACCOUNT_TYPE, PayUParameters::BANK_ACCOUNT_NUMBER, PayUParameters::COUNTRY);
         CommonRequestUtil::validateParameters($parameters, $required);
     }
 }
Ejemplo n.º 11
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");
             }
         }
     }
 }
Ejemplo n.º 12
0
 /**
  * Builds a bank account list request
  *
  * @param parameters The parameters to be sent to the server
  * @return stdClass with the bank account list request built
  */
 public static function buildBankAccountListRequest($parameters)
 {
     $bankAccountListRequest = new \stdClass();
     $bankAccountListRequest->customerId = CommonRequestUtil::getParameter($parameters, PayUParameters::CUSTOMER_ID);
     return $bankAccountListRequest;
 }
Ejemplo n.º 13
0
 /**
  * Get the value for parameter processWithoutCvv2 if the parameter doesn't exist
  * in the parameters array or the parameter value isn't valid boolean representation return false
  * the otherwise return the parameter value
  * @param array $parameters
  * @return boolean whith the value for processWithoutCvv2 parameter, if the parameter doesn't exist in the array or 
  * it has a invalid boolean value returs false;
  */
 private static function isProcessWithoutCvv2Param($parameters)
 {
     $processWithoutCvv2 = CommonRequestUtil::getParameter($parameters, PayUParameters::PROCESS_WITHOUT_CVV2);
     if (is_bool($processWithoutCvv2)) {
         return $processWithoutCvv2;
     } else {
         return false;
     }
 }