-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Como configurar as parcelas [ installments ]? #149
Comments
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> |
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. |
@thiivalente onde voce colocou esse xml? |
@douglastehling você configura isso no /**
* 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 'maxInstallmentsNoInterest' => 'numeric|between:2,16|',
'maxInstallmentsLimit' => 'numeric|between:2,16|', E por último, configurar dentro do 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);
} |
Bem, gostaria de poder configurar as parcelas, podendo colocar o máximo de parcelas e até quantas parcelas o cliente poderia pagar sem juros.
Segundo documentação para colocar esses limites há 2 propriedades.
maxInstallmentNoInterest
noInterestInstallmentQuantity
Porém, tentei soltar diretamente no array que cria o checkout e não funcionou, alguém poderia me dizer como proceder?
The text was updated successfully, but these errors were encountered: