Skip to content

Commit

Permalink
Ajusta fluxo de assinaturas com cobrança no término do período (#121)
Browse files Browse the repository at this point in the history
* Insere suporte a cobranças no término do período da assinatura

* Insere testes para compras com assinatura

* Versão 1.8.7
  • Loading branch information
laerte-guimaraes authored Aug 26, 2019
1 parent f28c2bb commit bacd749
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 13 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Notas das versões

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

### Ajustado
- Insere compatibilidade com assinaturas com cobrança no término do período


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

### Ajustado
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,14 +369,17 @@ public function validatePayment($payment, $order, $orderAttempt)
$type = 'bills';
if($payment && $payment['id']) {
$vindiId = $payment['id'];
$billing_type = 'beginning_of_period';
if (! $this->isSingleOrder($order)) {
$billing_type = $payment['billing_trigger_type'];
$payment = $payment['bill'];
$type = 'subscriptions';
}

$paymentMethod = reset($payment['charges'])['payment_method']['type'];
if ($paymentMethod === 'PaymentMethod::BankSlip'
|| $paymentMethod === 'PaymentMethod::DebitCard'
|| $billing_type !== 'beginning_of_period'
|| $payment['status'] === 'paid'
|| $payment['status'] === 'review'
|| reset($payment['charges'])['status'] === 'fraud_review')
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.6</version>
<version>1.8.7</version>
</Vindi_Subscription>
</modules>
<global>
Expand Down
6 changes: 6 additions & 0 deletions tests/_support/Shop.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ public function addProductToCart($I)
$I->click('Add to Cart');
}

public function addSubscriptionToCart($I)
{
$I->amOnPage('/vindi-subscription.html');
$I->click('Add to Cart');
}

public function addDiscountCode($I)
{
$I->fillField('#coupon_code', 'desconto');
Expand Down
21 changes: 19 additions & 2 deletions tests/acceptance/vindiCheckoutWithBankSlipCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public function _before(AcceptanceTester $I)
$I->setConnectionConfig($I);
}

public function buyAnProduct(AcceptanceTester $I)
public function buyProduct(AcceptanceTester $I)
{
$I->setDefaultBankSlip($I);
$I->loginAsUser($I);
Expand All @@ -26,7 +26,7 @@ public function buyAnProduct(AcceptanceTester $I)
$I->see('Your order has been received.');
}

public function buyAnProductWithDiscount(AcceptanceTester $I)
public function buyProductWithDiscount(AcceptanceTester $I)
{
$I->setDefaultBankSlip($I);
$I->loginAsUser($I);
Expand All @@ -46,4 +46,21 @@ public function buyAnProductWithDiscount(AcceptanceTester $I)
if ($bill['amount'] != '14.8')
throw new \RuntimeException;
}

public function buySubscription(AcceptanceTester $I)
{
$I->setDefaultBankSlip($I);
$I->loginAsUser($I);
$I->addSubscriptionToCart($I);
$I->click('Proceed to Checkout');
$I->skipCheckoutForm($I);
$I->waitForElement('#dt_method_vindi_bankslip', 30);
$I->selectOption('dl#checkout-payment-method-load', 'Boleto Bancário');
$I->click('Continue', '#payment-buttons-container');
$I->waitForElement('#review-buttons-container', 30);
$I->click('Place Order');
$I->waitForElement('.main-container.col1-layout', 30);
$I->seeInCurrentUrl('/checkout/onepage/success');
$I->see('Your order has been received.');
}
}
48 changes: 38 additions & 10 deletions tests/acceptance/vindiCheckoutWithCreditCardCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public function _before(AcceptanceTester $I)
$I->setConnectionConfig($I);
}

public function buyAProductInInstallment(AcceptanceTester $I)
public function buyProductInInstallment(AcceptanceTester $I)
{
$I->setDefaultCreditCard($I, true);
$I->loginAsUser($I);
Expand All @@ -33,7 +33,7 @@ public function buyAProductInInstallment(AcceptanceTester $I)
$I->see('Your order has been received.');
}

public function buyAProductWithoutInstallment(AcceptanceTester $I)
public function buyProductWithoutInstallment(AcceptanceTester $I)
{
$I->setDefaultCreditCard($I, false);
$I->loginAsUser($I);
Expand All @@ -56,6 +56,7 @@ public function buyAProductWithoutInstallment(AcceptanceTester $I)
$I->seeInCurrentUrl('/checkout/onepage/success');
$I->see('Your order has been received.');
}

public function buyAProductWithInstallmentsOne(AcceptanceTester $I)
{
$I->setDefaultCreditCard($I, false, 1);
Expand All @@ -66,12 +67,6 @@ public function buyAProductWithInstallmentsOne(AcceptanceTester $I)
$I->waitForElement('#dt_method_vindi_creditcard', 30);
$I->selectOption('dl#checkout-payment-method-load', 'Cartão de Crédito');
$I->dontSeeElement('select.required-entry');

try
{
$I->fillCreditCardInfo($I);
} catch(Exception $e) { }

$I->click('Continue', '#payment-buttons-container');
$I->waitForElement('#review-buttons-container', 30);
$I->click('Place Order');
Expand All @@ -80,8 +75,7 @@ public function buyAProductWithInstallmentsOne(AcceptanceTester $I)
$I->see('Your order has been received.');
}


public function buyAProductWithDiscount(AcceptanceTester $I)
public function buyProductWithDiscount(AcceptanceTester $I)
{
$I->setDefaultCreditCard($I, false);
$I->loginAsUser($I);
Expand All @@ -107,4 +101,38 @@ public function buyAProductWithDiscount(AcceptanceTester $I)
if ($bill['amount'] != '14.8')
throw new \RuntimeException;
}

public function buyMonthlySubscriptionWithInstallments(AcceptanceTester $I)
{
$I->setDefaultCreditCard($I, true);
$I->loginAsUser($I);
$I->addSubscriptionToCart($I);
$I->click('Proceed to Checkout');
$I->skipCheckoutForm($I);
$I->waitForElement('#dt_method_vindi_creditcard', 30);
$I->selectOption('dl#checkout-payment-method-load', 'Cartão de Crédito');
$I->click('Continue', '#payment-buttons-container');
$I->waitForElement('#review-buttons-container', 30);
$I->click('Place Order');
$I->waitForElement('.main-container.col1-layout', 30);
$I->seeInCurrentUrl('/checkout/onepage/success');
$I->see('Your order has been received.');
}

public function buySubscriptionWithoutInstallment(AcceptanceTester $I)
{
$I->setDefaultCreditCard($I, false);
$I->loginAsUser($I);
$I->addSubscriptionToCart($I);
$I->click('Proceed to Checkout');
$I->skipCheckoutForm($I);
$I->waitForElement('#dt_method_vindi_creditcard', 30);
$I->selectOption('dl#checkout-payment-method-load', 'Cartão de Crédito');
$I->click('Continue', '#payment-buttons-container');
$I->waitForElement('#review-buttons-container', 30);
$I->click('Place Order');
$I->waitForElement('.main-container.col1-layout', 30);
$I->seeInCurrentUrl('/checkout/onepage/success');
$I->see('Your order has been received.');
}
}

0 comments on commit bacd749

Please sign in to comment.