Giter Club home page Giter Club logo

Comments (5)

thiivalente avatar thiivalente commented on June 21, 2024 1

máximas de parcelas e quantos

Como você implementou?

Basicamente segui a forma de construção do XML no código, porém eu fiz de forma não genérica, pois fiz atendendo as necessidades do projeto por isso não abri PR para essa feature.

from laravel-pagseguro.

thiivalente avatar thiivalente commented on June 21, 2024

Descobri o que é necessário adicionar ao XML para conseguir fazer com que set a quantidade máximas de parcelas e quantos irei arcar com os juros

<paymentMethodConfigs>
    <paymentMethodConfig>
        <paymentMethod>
            <group>CREDIT_CARD</group>
        </paymentMethod>
        <configs>
            <config>
                <key>MAX_INSTALLMENTS_NO_INTEREST</key>
                <value>%s</value>
            </config>
            <config>
                <key>MAX_INSTALLMENTS_LIMIT</key>
                <value>%s</value>
            </config>
        </configs>
    </paymentMethodConfig>
</paymentMethodConfigs>

from laravel-pagseguro.

Fuhrmann avatar Fuhrmann commented on June 21, 2024

máximas de parcelas e quantos

Como você implementou?

from laravel-pagseguro.

douglastehling avatar douglastehling commented on June 21, 2024

@thiivalente onde voce colocou esse xml?

from laravel-pagseguro.

thiivalente avatar thiivalente commented on June 21, 2024

@douglastehling você configura isso no PaymentMethod, OBS: não esqueça do da interface.

    /**
     * Max Installments No Interest (Quantidade máxima de parcelas que não importam)
     * @var float
     */
    protected $maxInstallmentsNoInterest;

    /**
     * Get Max Installments Limit (Quantidade máxima de parcelas)
     * @var float
     */
    protected $maxInstallmentsLimit;

E também não esqueça de fazer os get e sets pro hydrate

/**
     * Get Max Installments No Interest (Quantidade máxima de parcelas que não importam)
     * @return float
     */
    public function getMaxInstallmentsNoInterest()
    {
        return $this->maxInstallmentsNoInterest;
    }

    /**
     * Get Max Installments Limit (Quantidade máxima de parcelas)
     * @return float
     */
    public function getMaxInstallmentsLimit()
    {
        return $this->maxInstallmentsLimit;
    }
// ...
**
     * Set Max Installments No Interest (Quantidade máxima de parcelas que não importam)
     * @param  float|null $method
     * @return float
     */
    public function setMaxInstallmentsNoInterest($maxInstallmentsNoInterest)
    {
        if(is_null($maxInstallmentsNoInterest)) { 
            return; 
        }
        $this->maxInstallmentsNoInterest = $maxInstallmentsNoInterest;
        return $this;
    }

/**
     * Set Max Installments No Interest (Quantidade máxima de parcelas que não importam)
     * @param  float|null $method
     * @return float
     */
    public function setMaxInstallmentsLimit($maxInstallmentsLimit)
    {
        if(is_null($maxInstallmentsLimit)) { 
            return; 
        }
        $this->maxInstallmentsLimit = $maxInstallmentsLimit;
        return $this;
    }

No ValidationRules coloque a validaçåo:

        'maxInstallmentsNoInterest' => 'numeric|between:2,16|',
        'maxInstallmentsLimit' => 'numeric|between:2,16|',

E por último, configurar dentro do XmlPaymentMethod no método:

    private function getPaymentMethodsXmlString(PaymentMethodInterface $paymentMethod)
    {
        // ...
        $configs = [];
        $hasConfigs = false;
        if(!is_null($paymentMethod->getMaxInstallmentsNoInterest()) && $paymentMethod->getMaxInstallmentsNoInterest() > 1) {
            $configs[] = $this->getInstallmentsNoInterestXmlString($paymentMethod->getMaxInstallmentsNoInterest());
            $hasConfigs = true;
        }
        if(!is_null($paymentMethod->getMaxInstallmentsLimit())) {
            $configs[] = $this->getMaxInstallmentsLimitXmlString($paymentMethod->getMaxInstallmentsNoInterest());
            $hasConfigs = true;
        }
        // ..
  }

  **
     * @param  float $maxInstallmentsNoInterest
     * @return string XML
     */
    private function getInstallmentsNoInterestXmlString(float $maxInstallmentsNoInterest)
    {
        $str = <<<XML
            <config>
                <key>MAX_INSTALLMENTS_NO_INTEREST</key>
                <value>%s</value>
            </config>
XML;
        return sprintf($str, $maxInstallmentsNoInterest);
    }

    /**
     * @return string XML
     */
    private function getMaxInstallmentsLimitXmlString(float $maxInstallmentsLimit)
    {
        $str = <<<XML
        <config>
            <key>MAX_INSTALLMENTS_LIMIT</key>
            <value>%s</value>
        </config>
XML;
    return sprintf($str, $maxInstallmentsLimit);
    }

from laravel-pagseguro.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.