Skip to content

Commit

Permalink
Merge pull request #23 from pagarme/capture-with-metadata
Browse files Browse the repository at this point in the history
Allow send metadata on capture transaction.
  • Loading branch information
jgabrielfaria committed Nov 13, 2015
2 parents 9b668bc + 1883192 commit 21e9ebf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Binary file added composer.phar
Binary file not shown.
12 changes: 9 additions & 3 deletions lib/Pagarme/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@ public function charge()
$this->create();
}

public function capture($amount = false)
public function capture($data = false)
{
$request = new PagarMe_Request(self::getUrl().'/'.$this->id . '/capture', 'POST');
if($amount) {
$request->setParameters(array('amount' => $amount));

if(gettype($data) == 'array') {
$request->setParameters($data);
} else {
if($data) {
$request->setParameters(array('amount' => $data));
}
}

$response = $request->run();
$this->refresh($response);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/PagarMe/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public function testPostbackUrl() {
public function testCalculateInstallmentsAmount() {
$request = PagarMe_Transaction::calculateInstallmentsAmount('10000', '1.5', '12');
$installments = $request['installments'];
$this->assertEqual($installments["5"]["amount"], '10471');
$this->assertEqual($installments["5"]["amount"], 10750);
$this->assertEqual($installments["5"]["installment"], '5');
$this->assertEqual($installments["5"]["installment_amount"], '2094');
$this->assertEqual($installments["5"]["installment_amount"], 2150);
}

public function testPostbackWithBoleto() {
Expand Down

0 comments on commit 21e9ebf

Please sign in to comment.