Skip to content

Commit

Permalink
Adiciona suporte para boletos Webservice (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
st3llaris authored Oct 16, 2019
1 parent 1d2a420 commit f90333d
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 29 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Notas das versões

## [1.8.8 - 08/10/2019](https://github.com/vindi/vindi-magento/releases/tag/1.8.8)

### Adicionado
- Adiciona suporte para boletos Webservice

### Corrigido
- Correção erro de php "Undefined variable: lastProduct" (por @brunotda: #126)

### Ajustado
- Ajusta tratativa para número de parcelas em cartões de crédito salvos


## [1.8.7 - 26/08/2019](https://github.com/vindi/vindi-magento/releases/tag/1.8.7)

### Ajustado
Expand Down
6 changes: 3 additions & 3 deletions app/code/community/Vindi/Subscription/Helper/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ public function findOrCreateCustomer($body)
*/
public function createCustomerPaymentProfile($body)
{
$this->log(json_encode($dataToLog), 'vindi_creditcard.log');
$customerId = $body['customer_id'];
$this->cache()->remove("vindi_payment_profile_{$customerId}");

Expand Down Expand Up @@ -194,12 +193,13 @@ public function getPaymentMethods()
$paymentMethods['credit_card'],
$method['payment_companies']
);
}elseif('PaymentMethod::DebitCard' === $method['type']) {
} elseif('PaymentMethod::DebitCard' === $method['type']) {
$paymentMethods['debit_card'] = array_merge(
$paymentMethods['debit_card'],
$method['payment_companies']
);
} elseif ('PaymentMethod::BankSlip' === $method['type']) {
} elseif ('PaymentMethod::BankSlip' === $method['type']
|| 'PaymentMethod::OnlineBankSlip' === $method['type']) {
$paymentMethods['bank_slip'] = true;
}
}
Expand Down
3 changes: 2 additions & 1 deletion app/code/community/Vindi/Subscription/Helper/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ public function renewalOrder($order, $vindiData)
if (Mage::getStoreConfig('vindi_subscription/general/bankslip_link_in_order_comment')) {
$charges = $vindiData['bill']['charges'];
foreach ($charges as $charge) {
if ($charge['payment_method']['type'] === 'PaymentMethod::BankSlip') {
if ($charge['payment_method']['type'] === 'PaymentMethod::BankSlip'
|| $charge['payment_method']['type'] === 'PaymentMethod::OnlineBankSlip') {
$order->addStatusHistoryComment(sprintf(
'<a target="_blank" href="%s">Clique aqui</a> para visualizar o boleto.',
$charge['print_url']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ public function validatePayment($payment, $order, $orderAttempt)

$paymentMethod = reset($payment['charges'])['payment_method']['type'];
if ($paymentMethod === 'PaymentMethod::BankSlip'
|| $paymentMethod === 'PaymentMethod::OnlineBankSlip'
|| $paymentMethod === 'PaymentMethod::DebitCard'
|| $billing_type !== 'beginning_of_period'
|| $payment['status'] === 'paid'
Expand Down
2 changes: 1 addition & 1 deletion app/code/community/Vindi/Subscription/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<config>
<modules>
<Vindi_Subscription>
<version>1.8.7</version>
<version>1.8.8</version>
</Vindi_Subscription>
</modules>
<global>
Expand Down
59 changes: 35 additions & 24 deletions tests/_support/Responses.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,32 @@ class Responses
const ACTIVE_BANK_SLIP = array(
'payment_methods' => array(
array(
'name' => 'Boleto bancário',
'type' => 'PaymentMethod::BankSlip',
'status' => 'active',
'code' => 'bank_slip'
'name' => 'Boleto bancário',
'type' => 'PaymentMethod::BankSlip',
'status' => 'active',
'code' => 'bank_slip'
)
)
);

const ACTIVE_ONLINE_BANK_SLIP = array(
'payment_methods' => array(
array(
'name' => 'Boleto bancário Online',
'type' => 'PaymentMethod::OnlineBankSlip',
'status' => 'active',
'code' => 'bank_slip'
)
)
);

const ACTIVE_CREDIT_CARD = array(
'payment_methods' => array(
array(
'name' => 'Cartão de Crédito',
'type' => 'PaymentMethod::CreditCard',
'status' => 'active',
'code' => 'credit_card',
'name' => 'Cartão de Crédito',
'type' => 'PaymentMethod::CreditCard',
'status' => 'active',
'code' => 'credit_card',
'payment_companies' => array(
array(
'name' => 'Mastercard',
Expand All @@ -42,10 +53,10 @@ class Responses
const ACTIVE_DEBIT_CARD = array(
'payment_methods' => array(
array(
'name' => 'Cartão de Débito',
'type' => 'PaymentMethod::DebitCard',
'status' => 'active',
'code' => 'debit_card',
'name' => 'Cartão de Débito',
'type' => 'PaymentMethod::DebitCard',
'status' => 'active',
'code' => 'debit_card',
'payment_companies' => array(
array(
'name' => 'Maestro',
Expand All @@ -68,16 +79,16 @@ class Responses
const GENERAL_PAYMENT_METHODS = array(
'payment_methods' => array(
array(
'name' => 'Boleto bancário',
'type' => 'PaymentMethod::BankSlip',
'status' => 'active',
'code' => 'bank_slip'
'name' => 'Boleto bancário',
'type' => 'PaymentMethod::BankSlip',
'status' => 'active',
'code' => 'bank_slip'
),
array(
'name' => 'Cartão de Crédito',
'type' => 'PaymentMethod::CreditCard',
'status' => 'active',
'code' => 'credit_card',
'name' => 'Cartão de Crédito',
'type' => 'PaymentMethod::CreditCard',
'status' => 'active',
'code' => 'credit_card',
'payment_companies' => array(
array(
'name' => 'Mastercard',
Expand All @@ -95,10 +106,10 @@ class Responses
)
),
array(
'name' => 'Cartão de Débito',
'type' => 'PaymentMethod::DebitCard',
'status' => 'active',
'code' => 'debit_card',
'name' => 'Cartão de Débito',
'type' => 'PaymentMethod::DebitCard',
'status' => 'active',
'code' => 'debit_card',
'payment_companies' => array(
array(
'name' => 'Maestro',
Expand Down
17 changes: 17 additions & 0 deletions tests/unit/Helper/ApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ public function testGetPaymentMethodBankSlip()
$this->assertEquals($dummy_class->getPaymentMethods(), $success);
}

public function testGetPaymentMethodOnlineBankSlip()
{
$dummy_class = $this->make(
'Vindi_Subscription_Helper_API',
[
'get' => $this->response::ACTIVE_ONLINE_BANK_SLIP
]
);
$success = array(
'credit_card' => [],
'debit_card' => [],
'bank_slip' => true
);

$this->assertEquals($dummy_class->getPaymentMethods(), $success);
}

public function testGetPaymentMethodCreditCard()
{
$dummy_class = $this->make(
Expand Down

0 comments on commit f90333d

Please sign in to comment.