Skip to content

Commit

Permalink
Verification du token
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgu74 committed Oct 29, 2013
1 parent 9621698 commit 7d00a53
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/Payutc/Service/WEBSALE.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,20 @@ public function CreateTransaction($items, $funId, $returnUrl, $callbackUrl=null)
* @param int $tr_id (id de la transaction a checker)
* @return array
*/
public function GetTransactionInfo($fun_id, $tr_id) {
public function GetTransactionInfo($fun_id, $tra_id) {
// On a une appli qui a les droits ?
$this->checkRight(false, true, true, $fun_id);

// Get info on this transaction
$transaction = \Payutc\Bom\Transaction::getById($tr_id);
$transaction = \Payutc\Bom\Transaction::getById($tra_id);

// Check fun_id is correct
if($fun_id != $transaction->getFunId()) {
throw new \Payutc\Exception\TransactionNotFound("La transaction $idTrans n'existe pas");
throw new \Payutc\Exception\TransactionNotFound("La transaction $tra_id n'existe pas");
}

return array(
"id" => $tr_id,
"id" => $tra_id,
"status" => $transaction->getStatus(),
"purchases" => $transaction->getPurchases(),
"created" => $transaction->getDate()
Expand Down
17 changes: 13 additions & 4 deletions src/Payutc/Service/WEBSALECONFIRM.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Payutc\Service;

use \Payutc\Config;
use \Payutc\Exception\PayutcException;

/**
* WEBSALECONFIRM.php
Expand All @@ -20,12 +21,16 @@ class WEBSALECONFIRM extends \ServiceBase {
* @param int $tr_id (id de la transaction a checker)
* @return array
*/
public function getTransactionInfo($tr_id) {
public function getTransactionInfo($tra_id, $token) {
// On a une appli qui a les droits ?
$this->checkRight(false, true, true, null);

// Get info on this transaction
$transaction = \Payutc\Bom\Transaction::getById($tr_id);
$transaction = \Payutc\Bom\Transaction::getById($tra_id);

if($transaction->getToken() != $token) {
throw new PayutcException("Token non valide");
}

// TODO : Récupérer le nom de la fundation pour qu'on puisse afficher à qui l'utilisateur va payer.

Expand All @@ -51,11 +56,15 @@ public function getTransactionInfo($tr_id) {
* $mail n'est utilisé que s'il n'y a pas d'utilisateur connecté.
* $mail est obligatoire dans ce cas la et doit être un email valide !
*/
public function doTransaction($tr_id, $montant_reload, $mail=null) {
public function doTransaction($tra_id, $token, $montant_reload, $mail=null) {
// On a une appli qui a les droits ?
$this->checkRight(false, true, true, null);

$transaction = \Payutc\Bom\Transaction::getById($tr_id);
$transaction = \Payutc\Bom\Transaction::getById($tra_id);

if($transaction->getToken() != $token) {
throw new PayutcException("Token non valide");
}

if($this->user()) {
if($montant_reload == 0) {
Expand Down

0 comments on commit 7d00a53

Please sign in to comment.