Get from webservice installments for direct payment.
@param PagSeguroCredentials $credentials
@param $amount
@param $cardBrand
@param $maxInstallmentNoInterest
@return bool|PagSeguroInstallment
@throws Exception
@throws PagSeguroServiceException
191771
public static function getInstallments(
        PagSeguroCredentials $credentials,
        $amount,
        $cardBrand = null,
        $maxInstallmentNoInterest = null
    ) {
        $amount = PagSeguroHelper::decimalFormat($amount);
        LogPagSeguro::info(
            "PagSeguroInstallmentService.getInstallments(".$amount.") - begin"
        );
        self::$connectionData = new PagSeguroConnectionData($credentials, self::SERVICE_NAME);

        try {
            $connection = new PagSeguroHttpConnection();
            $connection->get(
                self::buildInstallmentURL(self::$connectionData, $amount, $cardBrand, $maxInstallmentNoInterest),
                self::$connectionData->getServiceTimeout(),
                self::$connectionData->getCharset()
            );

            $httpStatus = new PagSeguroHttpStatus($connection->getStatus());

            switch ($httpStatus->getType()) {
                case 'OK':
                    $installments = PagSeguroInstallmentParser::readInstallments($connection->getResponse());
                    LogPagSeguro::info(
                        "PagSeguroInstallmentService.getInstallments() - end "
                    );
                    break;
                case 'BAD_REQUEST':
                    $errors = PagSeguroInstallmentParser::readErrors($connection->getResponse());
                    $e = new PagSeguroServiceException($httpStatus, $errors);
                    LogPagSeguro::error(
                        "PagSeguroInstallmentService.getInstallments() - error " .
                        $e->getOneLineMessage()
                    );
                    throw $e;
                    break;
                default:
                    $e = new PagSeguroServiceException($httpStatus);
                    LogPagSeguro::error(
                        "PagSeguroInstallmentService.getInstallments() - error " .
                        $e->getOneLineMessage()
                    );
                    throw $e;
                    break;

            }
            return (isset($installments) ? $installments : false);

        } catch (PagSeguroServiceException $e) {
            throw $e;
        } catch (Exception $e) {
            LogPagSeguro::error("Exception: " . $e->getMessage());
            throw $e;
        }
    }
244855
public function mapPaymentToPreAuthorization(SpyPaymentPayone $paymentEntity): AbstractAuthorizationContainer
    {
        $preAuthorizationContainer = new PreAuthorizationContainer();
        $preAuthorizationContainer = $this->mapPaymentToAbstractAuthorization($paymentEntity, $preAuthorizationContainer);

        return $preAuthorizationContainer;
    }
660870
public function getToken(HpsCreditCard $cardData)
    {
        $data = array();
        $data['api_key'] = $this->_config->publicApiKey;
        $data['object'] = 'token';
        $data['token_type'] = 'supt';
        $data['_method'] = 'post';
        $data['card[number]'] = $cardData->number;
        $data['card[cvc]'] = $cardData->cvv;
        $data['card[exp_month]'] = $cardData->expMonth;
        $data['card[exp_year]'] = $cardData->expYear;

        $url = $this->_url ."?". http_build_query($data);
        $header = array('Content-type: application/json');

        return $this->submitRequest($url, $header, null, 'GET', HpsServicesConfig::KEY_TYPE_PUBLIC);
    }
757519
public function downloadAccount($nextPageToken = null, $maxResults = 10) {
    $data = array();
    if ($nextPageToken) {
      $data['nextPageToken'] = $nextPageToken;
    }
    $data['maxResults'] = $maxResults;
    return $this->invokeGitkitApiWithServiceAccount('downloadAccount', $data);
  }
1253610
private function newCard($securityCode, $brand)
    {
        $card = new CreditCard();
        $card->setSecurityCode($securityCode);
        $card->setBrand($brand);

        return $card;
    }
1332543
public function authorize($money, CreditCard $creditcard, $options = array())
    {
        $this->required_options('address,order_id', $options);

        $this->post = array();

        $this->addInvoice($options);
        $this->addCreditcard($creditcard);
        $this->addAddress($options);
        $this->addCustomerData($options);
        $this->addOptionalData();

        $this->post['TotalAmount'] = $this->amount($money);

        return $this->commit('xmlauth', $money, $options);
    }
207906
public function getInterestAmount($amount, $installmentQuantity)
    {
        $minimumAmountNoInterest = $this->getMinimumAmountNoInterest($installmentQuantity);

        if (
            ($minimumAmountNoInterest === null) ||
            ($minimumAmountNoInterest !== null) && ($amount < $minimumAmountNoInterest)
        ) {
            $interestRateForInstallment = $this->getInterestRateForInstallment($installmentQuantity);
        } else {

            $interestRateForInstallment = 1;
        }

        $totalInstallmentAmount = $interestRateForInstallment * $amount;
        return ($totalInstallmentAmount - $amount);
    }
1262037
public static function create($alias = null)
    {
        $card = new static();

        $response = (new AuthorizationBuilder(TransactionType::ALIAS, $card))
            ->withAlias(AliasAction::CREATE, $alias)
            ->execute();

        if ($response->responseCode === '00') {
            return $response->giftCard;
        }

        throw new ApiException($response->responseMessage);
    }
178110
public function execute()
    {

        //$cardInternational = $this->getRequest()->getParam('card_international');

        try {
            $creditCard = new CreditCardMethod(
                $this->_objectManager->create('Magento\Directory\Api\CountryInformationAcquirerInterface'),
                $this->_objectManager->create('Magento\Framework\App\Config\ScopeConfigInterface'),
                $this->_objectManager->create('Magento\Framework\Module\ModuleList'),
                $this->loadOrder(),
                $this->_objectManager->create('UOL\PagSeguro\Helper\Library'),
                $data = [
                    'sender_document' => $this->helperData()->formatDocument($this->getRequest()->getParam('sender_document')),
                    'sender_hash' => $this->getRequest()->getParam('sender_hash'),
                    'order_id' => $this->lastRealOrderId(),
                    'installment' => [
                        'quantity' => $this->getRequest()->getParam('installment_quantity'),
                        'amount'   => $this->getRequest()->getParam('installment_amount')
                    ],
                    'token' => $this->getRequest()->getParam('card_token'),
                    'holder' => [
                        'name'       => $this->getRequest()->getParam('holder_name'),
                        'birth_date' => $this->getRequest()->getParam('holder_birthdate'),

                    ]
                ]
            );
            return $this->placeOrder($creditCard);

        } catch (\Exception $exception) {
            $this->changeOrderHistory('pagseguro_cancelada');
            $this->clearSession();
            return $this->whenError($exception->getMessage());
        }
    }
964951
public function getCard($cardID)
    {
        $tokenContext = new TokenContext("", 'get');
        $token = $this->accessTokenProvider->getToken($tokenContext);

        $responseModel = $this->cardClient->getCard($cardID, (string)$token);
        if ($responseModel instanceof ErrorResponseModel) {
            throw new CardClientException(
                "error response from card service", $responseModel->getCode(), $responseModel->getMessage()
            );
        }

        $card = $this->parseRawCard($responseModel->getRawSignedModel(), $responseModel->isOutdated());

        if (!$this->cardVerifier->verifyCard($card)) {
            throw new CardVerificationException('Validation errors have been detected');
        }

        return $card;
    }
634311
public function session($clientCustomerId = null, $credentials = null)
    {
        $credentials = (is_null($credentials)) ? $this->oauth2Credentials($clientCustomerId) : $credentials;

        return ((new AdWordsSessionBuilder())
            ->from($this->configuration($clientCustomerId))
            ->withOAuth2Credential($credentials)
            ->build());
    }
1221723
public function getCardByAlias($alias)
    {
        if (!array_key_exists($alias, $this->aliases)) {
            throw new Exception\NoSuchAliasException(sprintf('Alias "%s" has not been assigned to any cards.', $alias));
        }

        return $this->getCard($this->aliases[$alias]);
    }
1097176
public function createCustomer($paymentType, $customerId, $payment, $additional = [])
    {
        $this->integrityCheck();
        $createCustomerRes = $this->mpay24Sdk->createCustomer($paymentType, $customerId, $payment, $additional);
        $this->recordedLastMessageExchange('CreateCustomer');

        return $createCustomerRes;
    }
610803
public function getPayprice($card_id, $quantity)
    {
        $url = "POST https://api.weixin.qq.com/card/pay/getpayprice?access_token=ACCESS_TOKEN";
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->httpPostForJson($url, ['card_id' => $card_id, 'quantity' => $quantity]);
    }
93632
public function refund($amount, $currency, $cardData, $cardHolder = null, $details = null)
    {
        HpsInputValidation::checkCurrency($currency);
        $this->_currency = $currency;
        $this->_amount = HpsInputValidation::checkAmount($amount);

        $xml = new DOMDocument();
        $hpsTransaction = $xml->createElement('hps:Transaction');
        $hpsCreditReturn = $xml->createElement('hps:CreditReturn');
        $hpsBlock1 = $xml->createElement('hps:Block1');

        $hpsBlock1->appendChild($xml->createElement('hps:AllowDup', 'Y'));
        $hpsBlock1->appendChild($xml->createElement('hps:Amt', $amount));
        if ($cardData instanceof HpsCreditCard) {
            $cardDataElement = $xml->createElement('hps:CardData');
            $cardDataElement->appendChild($this->_hydrateManualEntry($cardData, $xml));
            $hpsBlock1->appendChild($cardDataElement);
        } else if ($cardData instanceof HpsTokenData) {
            $cardDataElement = $xml->createElement('hps:CardData');
            $cardDataElement->appendChild($this->_hydrateTokenData($cardData, $xml));
            $hpsBlock1->appendChild($cardDataElement);
        } else {
            $hpsBlock1->appendChild($xml->createElement('hps:GatewayTxnId', $cardData));
        }
        if ($cardHolder != null) {
            $hpsBlock1->appendChild($this->_hydrateCardHolderData($cardHolder, $xml));
        }
        if ($details != null) {
            $hpsBlock1->appendChild($this->_hydrateAdditionalTxnFields($details, $xml));
        }

        $hpsCreditReturn->appendChild($hpsBlock1);
        $hpsTransaction->appendChild($hpsCreditReturn);

        return $this->_submitTransaction($hpsTransaction, 'CreditReturn', (isset($details->clientTransactionId) ? $details->clientTransationId : null));
    }
602178
public function getCredentials(array $parameters = array(), $multipart = false, $appOnlyAuth = false)
    {
        return $this->getAccountVerifyCredentials($parameters, $multipart, $appOnlyAuth);
    }
1210359
protected function verifyAndSettlePayment()
    {

        $username = $this->config->get('gateway.asanpardakht.username');
        $password = $this->config->get('gateway.asanpardakht.password');

        $encryptedCredintials = $this->encrypt("{$username},{$password}");
        $params = array(
            'merchantConfigurationID' => $this->config->get('gateway.asanpardakht.merchantConfigId'),
            'encryptedCredentials' => $encryptedCredintials,
            'payGateTranID' => $this->trackingCode
        );


        try {
            $soap = new SoapClient($this->serverUrl);
            $response = $soap->RequestVerification($params);
            $response = $response->RequestVerificationResult;

        } catch (\SoapFault $e) {
            $this->transactionFailed();
            $this->newLog('SoapFault', $e->getMessage());
            throw $e;
        }

        if ($response != '500') {
            $this->transactionFailed();
            $this->newLog($response, AsanpardakhtException::getMessageByCode($response));
            throw new AsanpardakhtException($response);
        }


        try {

            $response = $soap->RequestReconciliation($params);
            $response = $response->RequestReconciliationResult;

            if ($response != '600')
                $this->newLog($response, AsanpardakhtException::getMessageByCode($response));

        } catch (\SoapFault $e) {
            //If fail, shaparak automatically do it in next 12 houres.
        }


        $this->transactionSucceed();

        return true;
    }