2015-10-28 20:22:07 +01:00
|
|
|
/<?php
|
2015-09-01 20:40:30 +02:00
|
|
|
|
|
|
|
use Codeception\Util\Fixtures;
|
|
|
|
use Faker\Factory;
|
|
|
|
|
|
|
|
class OnlinePaymentCest
|
|
|
|
{
|
|
|
|
private $faker;
|
|
|
|
|
|
|
|
public function _before(AcceptanceTester $I)
|
|
|
|
{
|
|
|
|
$I->checkIfLogin($I);
|
|
|
|
|
|
|
|
$this->faker = Factory::create();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function onlinePayment(AcceptanceTester $I)
|
|
|
|
{
|
|
|
|
$I->wantTo('test an online payment');
|
|
|
|
|
|
|
|
$clientEmail = $this->faker->safeEmail;
|
|
|
|
$productKey = $this->faker->text(10);
|
|
|
|
|
2017-03-19 14:31:25 +01:00
|
|
|
$I->createGateway($I);
|
|
|
|
$I->createClient($I, $clientEmail);
|
2015-09-01 20:40:30 +02:00
|
|
|
|
|
|
|
// create product
|
|
|
|
$I->amOnPage('/products/create');
|
|
|
|
$I->fillField(['name' => 'product_key'], $productKey);
|
|
|
|
$I->fillField(['name' => 'notes'], $this->faker->text(80));
|
|
|
|
$I->fillField(['name' => 'cost'], $this->faker->numberBetween(1, 20));
|
|
|
|
$I->click('Save');
|
2015-10-28 20:22:07 +01:00
|
|
|
$I->wait(1);
|
2016-10-02 11:52:23 +02:00
|
|
|
//$I->see($productKey);
|
2015-09-01 20:40:30 +02:00
|
|
|
|
|
|
|
// create invoice
|
|
|
|
$I->amOnPage('/invoices/create');
|
2017-03-19 16:44:35 +01:00
|
|
|
$invoiceNumber = $I->grabAttributeFrom('#invoice_number', 'value');
|
2015-09-01 20:40:30 +02:00
|
|
|
$I->selectDropdown($I, $clientEmail, '.client_select .dropdown-toggle');
|
|
|
|
$I->fillField('table.invoice-table tbody tr:nth-child(1) #product_key', $productKey);
|
2016-02-29 19:08:09 +01:00
|
|
|
$I->click('table.invoice-table tbody tr:nth-child(1) .tt-selectable');
|
2016-12-05 11:30:41 +01:00
|
|
|
$I->click('Mark Sent');
|
2015-09-01 20:40:30 +02:00
|
|
|
$I->see($clientEmail);
|
|
|
|
|
|
|
|
// enter payment
|
|
|
|
$clientId = $I->grabFromDatabase('contacts', 'client_id', ['email' => $clientEmail]);
|
2017-03-19 16:44:35 +01:00
|
|
|
$invoiceId = $I->grabFromDatabase('invoices', 'id', ['client_id' => $clientId, 'invoice_number' => $invoiceNumber]);
|
|
|
|
$invitationKey = $I->grabFromDatabase('invitations', 'invitation_key', ['invoice_id' => $invoiceId]);
|
|
|
|
|
2017-03-19 14:31:25 +01:00
|
|
|
$I->createOnlinePayment($I, $invoiceNumber);
|
|
|
|
|
|
|
|
/*
|
2015-09-01 20:40:30 +02:00
|
|
|
$invoiceId = $I->grabFromDatabase('invoices', 'id', ['client_id' => $clientId]);
|
|
|
|
$invitationKey = $I->grabFromDatabase('invitations', 'invitation_key', ['invoice_id' => $invoiceId]);
|
|
|
|
|
|
|
|
$clientSession = $I->haveFriend('client');
|
|
|
|
$clientSession->does(function(AcceptanceTester $I) use ($invitationKey) {
|
|
|
|
$I->amOnPage('/view/' . $invitationKey);
|
|
|
|
$I->click('Pay Now');
|
2016-06-21 11:31:38 +02:00
|
|
|
$I->click('Credit Card');
|
2016-02-11 16:12:27 +01:00
|
|
|
$I->fillField('#card_number', '4242424242424242');
|
2016-12-15 12:54:09 +01:00
|
|
|
$I->fillField('#cvv', '100');
|
2015-09-01 20:40:30 +02:00
|
|
|
$I->selectOption('#expiration_month', 12);
|
|
|
|
$I->selectOption('#expiration_year', date('Y'));
|
|
|
|
$I->click('.btn-success');
|
2016-02-11 16:12:27 +01:00
|
|
|
$I->wait(3);
|
2015-09-01 20:40:30 +02:00
|
|
|
$I->see('Successfully applied payment');
|
|
|
|
});
|
2015-11-27 13:55:28 +01:00
|
|
|
$I->wait(1);
|
2017-03-19 14:31:25 +01:00
|
|
|
*/
|
2015-11-27 13:55:28 +01:00
|
|
|
|
2015-09-10 19:50:09 +02:00
|
|
|
// create recurring invoice and auto-bill
|
|
|
|
$I->amOnPage('/recurring_invoices/create');
|
2016-07-13 19:16:45 +02:00
|
|
|
$I->selectDropdown($I, 'Test Test', '.client_select .dropdown-toggle');
|
2015-09-10 19:50:09 +02:00
|
|
|
$I->fillField('table.invoice-table tbody tr:nth-child(1) #product_key', $productKey);
|
2016-03-02 18:23:20 +01:00
|
|
|
$I->click('table.invoice-table tbody tr:nth-child(1) .tt-selectable');
|
2016-05-13 09:38:42 +02:00
|
|
|
$I->selectOption('#auto_bill', 3);
|
2017-02-27 11:57:45 +01:00
|
|
|
$I->executeJS('onConfirmEmailClick()');
|
2017-01-15 20:52:31 +01:00
|
|
|
$I->wait(4);
|
2015-09-10 19:50:09 +02:00
|
|
|
$I->see("$0.00");
|
|
|
|
}
|
2016-05-13 09:38:42 +02:00
|
|
|
}
|