Process Standalone Credits using BACS without payment token.

@param \Paysafe\DirectDebit\StandaloneCredits $standalonecredits
@return \Paysafe\DirectDebit\StandaloneCredits
@throws PaysafeException
183799
private function standalonecreditsBACS( DirectDebit\StandaloneCredits $standalonecredits )
    {
        $fields = array(
            'merchantRefNum',
            'amount',
            'bacs'
        );
        if (!isset($standalonecredits->bacs->paymentToken))
        {
            $fields[] = 'profile';
            $fields[] = 'billingDetails';
			$fields2 = array("firstName","lastName");
            $standalonecredits->profile->setRequiredFields($fields2);
            $standalonecredits->profile->checkRequiredFields($fields2);
        }

        $standalonecredits->setRequiredFields($fields);
        $standalonecredits->checkRequiredFields();
        $standalonecredits->setOptionalFields(array(
            'customerIp',
            'dupCheck'
        ));
        $request = new Request(array(
            'method' => Request::POST,
            'uri' => $this->prepareURI($this->standalonePath),
            'body' => $standalonecredits
        ));
        $response = $this->client->processRequest($request);
        return new DirectDebit\StandaloneCredits($response);
    }
255887
public static function listAllCreditCardPaymentsAsync(array $parameters = [])
    {
        return self::listAllCreditCardPaymentsAsyncWithHttpInfo($page, $size, $sort)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }
1219159
public function setCreditsType($creditsType)
    {
        $allowedValues = $this->getCreditsTypeAllowableValues();
        if (!in_array($creditsType, $allowedValues)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'creditsType', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['creditsType'] = $creditsType;

        return $this;
    }
113052
public function setCreditcardType($creditcardType)
    {
        if (!in_array($creditcardType, $this->creditcardTypes)) {
            throw new InvalidArgumentException('Invalid credit card type. Allowed types: ' . implode(', ', $this->creditcardTypes));
        }

        return $this->setData(self::CREDITCARD_TYPE, $creditcardType);
    }
1053552
public function createSecretCredentialsToken(CredentialsInterface $credentials, array $scopes = array())
    {
        /** @var Command $createSession */
        $createSession = $this->createCommand()
            ->setRequest($this->client->post('encrypted/session'))
            ->setBodyEntity($credentials->toPublicArray(), 'urlencoded')
            ->setResponseClass('Maba\OAuthCommerceClient\Entity\SignedCredentials\Session')
        ;

        $registry = $this->registry;

        $httpClient = $this->client;
        return $this->createCommand()
            ->setBeforeExecute(function(Command $command) use ($createSession, $credentials, $scopes, $httpClient, $registry) {
                /** @var Session $session */
                $session = $createSession->getResult();

                $keyExchange = $registry->getKeyExchange($session->getKeyExchange()->getType());
                $encrypting = $registry->getEncrypting($session->getCipher()->getType());
                $hasher = $registry->getHasher($session->getCertificate()->getHashType());

                $serverCertificate = $httpClient->get($session->getCertificate()->getUrl())
                    ->send()
                    ->getBody(true)
                ;

                $hash = $hasher->hash($serverCertificate);
                if ($session->getCertificate()->getHash() !== $hash) {
                    throw new InvalidHashException(sprintf(
                        'Provided hash (%s) does is not as calculated from downloaded certificate (%s)',
                        $session->getCertificate()->getHash(),
                        $hash
                    ));
                }

                $additionalParameters = new Collection();
                $commonKey = $keyExchange->generateCommonKey(
                    $session->getKeyExchange()->getParameters(),
                    $serverCertificate,
                    $additionalParameters,
                    $encrypting->getKeyLength()
                );
                $encoded = http_build_query($credentials->toPrivateArray(), null, '&');
                $encrypted = $encrypting->encrypt($encoded, base64_decode($session->getCipher()->getIv()), $commonKey);

                $command->setBodyEntity(array(
                    'grant_type' => 'urn:marius-balcytis:oauth:grant-type:encrypted-credentials',
                    'scope' => implode(' ', $scopes),
                    'session_id' => $session->getSessionId(),
                    'encrypted_credentials' => $encrypted,
                ) + $additionalParameters->getAll(), 'urlencoded');
            })
            ->setRequest($this->client->post('encrypted/token'))
            ->setResponseClass('Maba\OAuthCommerceClient\Entity\AccessToken')
        ;
    }
138729
public static function get(
        int $paymentServiceProviderCredentialId,
        array $customHeaders = []
    ): BunqResponsePaymentServiceProviderCredential {
        $apiClient = new ApiClient(static::getApiContext());
        $responseRaw = $apiClient->get(
            vsprintf(
                self::ENDPOINT_URL_READ,
                [$paymentServiceProviderCredentialId]
            ),
            [],
            $customHeaders
        );

        return BunqResponsePaymentServiceProviderCredential::castFromBunqResponse(
            static::fromJson($responseRaw, self::OBJECT_TYPE_GET)
        );
    }
96772
public function getRefundableProducts($bIncludeUnconfirmedTransactions = true)
    {
        $aProductList = array();
        $oOrderItemList = $this->order->GetFieldShopOrderItemList();
        $oOrderItemList->GoToStart();
        while ($oOrderItem = $oOrderItemList->Next()) {
            $iBilled = $this->getProductAmountWithTransactionType(
                $oOrderItem->id,
                self::TRANSACTION_TYPE_PAYMENT,
                false
            );
            $iRefunded = $this->getProductAmountWithTransactionType(
                $oOrderItem->id,
                self::TRANSACTION_TYPE_CREDIT,
                $bIncludeUnconfirmedTransactions
            );
            $iRefunded += $this->getProductAmountWithTransactionType(
                $oOrderItem->id,
                self::TRANSACTION_TYPE_PAYMENT_REVERSAL,
                $bIncludeUnconfirmedTransactions
            );
            $iRefundable = round($iBilled + $iRefunded);
            if ($iRefundable > 0) {
                $aProductList[$oOrderItem->id] = $iRefundable;
            }
        }
        $oOrderItemList->GoToStart();

        return $aProductList;
    }
959540
public function createCreditCardData($params)
    {
        Util::verifyKeys(
                self::$_createCreditCardSignature,
                $params
                );
        $params["kind"] = TransparentRedirect::CREATE_PAYMENT_METHOD;
        return $this->_data($params);
    }
1205491
public static function batchConfirm($params = null, $options = null)
    {
        $url = static::appBaseUrl().'/batch_withdrawals';
        return static::_directRequest('post', $url, $params, $options);
    }
447329
public function authentications( ThreeDSecure\Authentications $authentications )
    {
        $authentications->setRequiredFields(array(
            'merchantRefNum',
            'paRes'
        ));
        $authentications->checkRequiredFields();
        $request = new Request(array(
            'method' => Request::POST,
            'uri' => $this->prepareURI("/enrollmentchecks/" . $authentications->id . "/authentications"),
            'body' => $authentications
        ));

        $response = $this->client->processRequest($request);
        return new ThreeDSecure\Authentications($response);
    }
1337314
public function execute()
    {
        parent::execute();

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

        $hpsBlock1->appendChild($xml->createElement('hps:Amt', $this->amount));
        $hpsBlock1->appendChild($xml->createElement('hps:AllowDup', ($this->allowDuplicates ? 'Y' : 'N')));

        $cardData = $xml->createElement('hps:CardData');
        if ($this->card != null) {
            $cardData->appendChild($this->service->_hydrateManualEntry($this->card, $xml));
        } else if ($this->trackData != null) {
            $cardData->appendChild($this->service->_hydrateTrackData($this->trackData, $xml));
        } else if ($this->token != null) {
            $cardData->appendChild($this->service->_hydrateTokenData($this->token, $xml));
        }

        $hpsBlock1->appendChild($cardData);
        $hpsCreditAuth->appendChild($hpsBlock1);
        $hpsTransaction->appendChild($hpsCreditAuth);

        return $this->service->_submitTransaction($hpsTransaction, 'PrePaidAddValue');
    }
535163
public function get($applicationCreditId, array $fields = array())
    {
        $params = array();
        if (!empty($fields)) {
            $params['fields'] = implode(',', $fields);
        }
        $endpoint = '/admin/application_credits/'.$applicationCreditId.'.json';
        $data = $this->request($endpoint, 'GET', $params);
        return $this->createObject(ApplicationCredit::class, $data['application_credit']);
    }
449900
public function createCreditCardCheckCall(array $defaults)
    {
        return new CreditCardCheck(
            $this->createStandardParameter($defaults),
            $this->createHashGenerator(),
            $this->createModeDetector(),
            $this->createUtilEncodingService()
        );
    }
94770
public function onlyOnePaymentMethod($actionCounts)
    {
        return (isset($actionCounts['card']) && $actionCounts['card'] == 1
                && (!isset($actionCounts['token'])
                    || isset($actionCounts['token']) && $actionCounts['token'] == 0)
                && (!isset($actionCounts['transactionId'])
                    || isset($actionCounts['transactionId']) == 0))
            || (isset($actionCounts['token']) && $actionCounts['token'] == 1
                && (!isset($actionCounts['card'])
                    || isset($actionCounts['card']) && $actionCounts['card'] == 0)
                && (!isset($actionCounts['transactionId'])
                    || isset($actionCounts['transactionId']) == 0))
            || (isset($actionCounts['transactionId']) && $actionCounts['transactionId'] == 1
                && (!isset($actionCounts['card'])
                    || isset($actionCounts['card']) && $actionCounts['card'] == 0)
                && (!isset($actionCounts['token'])
                    || isset($actionCounts['token']) == 0));
    }
148485
public function invoices($includePending = false, $parameters = []): Collection
    {
        $invoices = [];

        $customer = $this->asBraintreeCustomer();

        $parameters = array_merge([
            'id' => TransactionSearch::customerId()->is($customer->id),
            'range' => TransactionSearch::createdAt()->between(
                Carbon::today()->subYears(2)->format('m/d/Y H:i'),
                Carbon::tomorrow()->format('m/d/Y H:i')
            ),
        ], $parameters);

        $transactions = BraintreeTransaction::search($parameters);

        // Here we will loop through the Braintree invoices and create our own custom Invoice
        // instance that gets more helper methods and is generally more convenient to work
        // work than the plain Braintree objects are. Then, we'll return the full array.
        if (! is_null($transactions)) {
            foreach ($transactions as $transaction) {
                if ($transaction->status == BraintreeTransaction::SETTLED || $includePending) {
                    $invoices[] = new Invoice($this, $transaction);
                }
            }
        }

        return new Collection($invoices);
    }
178502
public function transactionXa($callback, array $dbs = [])
    {
        $xid = uniqid('xa');

        if (empty($dbs)) {
            $dbs[] = $this->getConnection();
        }

        foreach ($dbs as $key => $db) {
            if ($db instanceof Query) {
                $db = $db->getConnection();

                $dbs[$key] = $db;
            }

            $db->startTransXa($xid);
        }

        try {
            $result = null;
            if (is_callable($callback)) {
                $result = call_user_func_array($callback, [$this]);
            }

            foreach ($dbs as $db) {
                $db->prepareXa($xid);
            }

            foreach ($dbs as $db) {
                $db->commitXa($xid);
            }

            return $result;
        } catch (\Exception $e) {
            foreach ($dbs as $db) {
                $db->rollbackXa($xid);
            }
            throw $e;
        } catch (\Throwable $e) {
            foreach ($dbs as $db) {
                $db->rollbackXa($xid);
            }
            throw $e;
        }
    }
512353
private function setProviderCreditDetails($parameters, $providerCreditInfo)
    {
        $providerIndex = 0;
        $providerString = 'ProviderCreditList.member.';

        $fieldMappings = array(
            'provider_id'   => 'ProviderId',
            'credit_amount' => 'CreditAmount.Amount',
            'currency_code' => 'CreditAmount.CurrencyCode'
        );

        foreach ($providerCreditInfo as $key => $value) {
            $value = array_change_key_case($value, CASE_LOWER);
            $providerIndex = $providerIndex + 1;

            foreach ($value as $param => $val) {
                if (array_key_exists($param, $fieldMappings) && trim($val)!='') {
                    $parameters[$providerString.$providerIndex. '.' .$fieldMappings[$param]] = $val;
                 }
            }

            // If currency code is not entered take it from the config array
            if (empty($parameters[$providerString.$providerIndex. '.' .$fieldMappings['currency_code']])) {
                $parameters[$providerString.$providerIndex. '.' .$fieldMappings['currency_code']] = strtoupper($this->config['currency_code']);
            }
        }

        return $parameters;
    }