Skip to content
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

Capture transactions via platform #305

Merged
merged 23 commits into from Jun 26, 2018

Conversation

leonampd
Copy link
Contributor

Description

It allow ecommerce administrators to capture transactions via platform. To do that, they should create a new invoice to capture the related transaction on Pagar.me.

Tests

Created acceptance and unit tests to validate the behavior

@leonampd leonampd requested a review from lflimeira June 18, 2018 22:17
@leonampd leonampd changed the title Capture transactions via platform [wip] Capture transactions via platform Jun 18, 2018
@leonampd leonampd force-pushed the feature/capture-through-platform branch from bd5036f to 26d6b4f Compare June 20, 2018 01:55
@leonampd leonampd changed the base branch from v2 to feature/capture June 20, 2018 12:45
@leonampd leonampd changed the title [wip] Capture transactions via platform Capture transactions via platform Jun 20, 2018
'4242424242424242',
'Livia Nascimento',
'0224',
'123'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you put those data hard coded in this class?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method should return a PagarMe\Sdk\Card\Card object and works well but, during the tests this will break because we can't pass a valid card hash, so, if the card hash informed is invalid AND there's an environment variable PAGARME_DEVELOPMENT=enabled an object test will be returned.

I don't like this but, thats the way I figured out to automate the test. I'll extract this behavior in another method.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good =)

* @return void
* @throws PagarMe_CreditCard_Model_Exception_CantCaptureTransaction
* @throws \Exception
*/
public function capture(Varien_Object $payment, $amount)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you using this method only in the button's click, is it correctly?

Leonam Pereira Dias and others added 18 commits June 22, 2018 14:28
Define a workflow to validate that capture from platform will work
properly
This trait, it's usefull not only for postbacks context. This trait was
used to create orders paid by credit card and boleto, so we should use
this in another places. So, it will deprecate this trait and create a
new class agnostic from contexts that do the job.
Create a new order by credit card using checkout transparent. To do
that, it defines a new environment variable `PAGARME_DEVELOPMENT=enabled` wich will be used to generate a valid `PagarMe\Sdk\Card` on `PagarMe_CreditCard_Model_Creditcard::generateCard` during the e2e tests.

The method `generateCard` is responsible to return an `PagarMe\Sdk\Card`
and, if the new environment variable is setted to `enabled` it means
that we're running magento in development environment, so, it'll return
a Card for tests.
Add spin method to `SessionWait` trait
Implement a new method responsible to retrieve the page details url from
an order id.
Declares the `session` property, also, remove an unused line
Create a new test to validate that the method responsible to get and
instantiate a new Abstract transaction works well
Implement a new method that can retrieve transaction informations
through Pagar.me's API. It uses the sdk and instantiate an
`AbstractTransaction` object
Implement the capture behavior that will permit to invoice orders online
(capture online).
Removes useless steps and change async to capture
During the creation of an order programmatically, we should inform the
customer. This changes the assign to set that avoid some treatments and
just attribute the object to the correctly property
Fix and implement the capture false steps to validate the feature
The quote data was retrieved from the session. This change to get that
value from order to allow an order creation programmatically
The step was expecting that the page should have an element related to
"success" to get the message. This change that to a generic one,
independent that the operation was executed successfully or not
@leonampd leonampd force-pushed the feature/capture-through-platform branch from 897afb7 to 1b6c839 Compare June 22, 2018 18:55
Check if there's an api key setted on magento and, if yes, avoid to
create another one
Leonam Pereira Dias added 3 commits June 22, 2018 16:17
Remove unused pieces of code and set default magento store
Some tests was breaking after the new implementation

To-do: refactor capture method to isolate the service model dependency
Since there's no way to inform a valid cardhash in the backend. This
will return a card object for e2e tests only if the `PAGARME_DEVELOPMENT` environment variable has the value `enabled`. Otherwise throw an exception
@leonampd leonampd force-pushed the feature/capture-through-platform branch from 1b6c839 to e75bdb6 Compare June 22, 2018 19:17
There's a problem on this scenario and, to deliver a alpha version we'll
skip this test for now since manual tests guarantee that this feature
works well
@leonampd leonampd merged commit 20d7094 into feature/capture Jun 26, 2018
@lflimeira lflimeira deleted the feature/capture-through-platform branch June 26, 2018 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants