Skip to content

Commit

Permalink
Mettre le buyer à null lors d'une transaction CB
Browse files Browse the repository at this point in the history
Si l'utilisateur essaie de payer par compte payutc, que ça échoue, puis paie par CB, on veut effacer le buyerId pour pouvoir distinguer le type de transaction.
  • Loading branch information
apuyou committed Nov 3, 2013
1 parent 2e4e2e6 commit 1e1160d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Payutc/Bom/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,12 @@ public function setEmail($email){
}

public function setBuyer($buyer){
$this->buyerId = $buyer->getId();
if($buyer == null){
$this->buyerId = null;
}
else {
$this->buyerId = $buyer->getId();
}

Dbal::conn()->update('t_transaction_tra',
array('usr_id_buyer' => $this->buyerId),
Expand Down
1 change: 1 addition & 0 deletions src/Payutc/Service/WEBSALECONFIRM.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public function doTransaction($tra_id, $token, $montant_reload) {
}
} else {
$pl = new Payline($this->application()->getId(), $this->service_name);
$transaction->setBuyer(null);
return $pl->doWebPayment(
null,
$transaction,
Expand Down
18 changes: 18 additions & 0 deletions tests/TransactionRwdbTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,23 @@ public function testCreateEmail(){
$transaction2 = Transaction::getById($transaction->getId());
$this->assertEquals("[email protected]", $transaction2->getEmail());
}

/**
* @requires PHP 5.4
*/
public function testSetToNull(){
$items = array(
array(4, 1),
array(4, 3)
);
$matthieu = new User("mguffroy");
$transaction = Transaction::create($matthieu, $matthieu, 51, 1, $items, null, null);

$this->assertEquals(600, $transaction->getMontantTotal());

$transaction->setBuyer(null);

$this->assertEquals(null, $transaction->getBuyerId());
}
}

0 comments on commit 1e1160d

Please sign in to comment.