Browse Source

Système de paiement

Mise en place d'un système de paiement via Paypal.
prodstable
keun 8 years ago
parent
commit
4b5c210d81
2 changed files with 5 additions and 17 deletions
  1. +2
    -15
      backend/controllers/PaiementController.php
  2. +3
    -2
      common/models/User.php

+ 2
- 15
backend/controllers/PaiementController.php View File

use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use common\models\User; use common\models\User;
use common\models\Etablissement;
use c006\paypal_ipn\PayPal_Ipn; use c006\paypal_ipn\PayPal_Ipn;


/** /**
$custom = $ipn->getKeyValue('custom'); $custom = $ipn->getKeyValue('custom');
$txn_type = $ipn->getKeyValue('txn_type'); $txn_type = $ipn->getKeyValue('txn_type');
/*$message = '' ;

foreach($_POST as $key => $val) {
$message .= $key.' : '.$val."\n" ;
}

mail('guillaume.bourgeois13@laposte.net','Données IPN', $message) ;*/
if($txn_type == 'subscr_payment' && $custom) if($txn_type == 'subscr_payment' && $custom)
{ {
$user = User::findOne($custom) ; $user = User::findOne($custom) ;
$etablissement = Etablissement::findOne($user->id_etablissement) ; $etablissement = Etablissement::findOne($user->id_etablissement) ;
if($etablissement) if($etablissement)
{ {
$date = $etablissement->date_paiement ;
if(!$date) $date = time() ;
else $date = strtotime($date) ;
$date += 30*24*60*60 ;
$etablissement->date_paiement = date('Y-m-d H:i:s',$date) ;
$etablissement->date_paiement = date('Y-m-d H:i:s',time()) ;
$etablissement->save() ; $etablissement->save() ;
} }
} }

+ 3
- 2
common/models/User.php View File

{ {
$date_limite = strtotime($etablissement->date_creation) + 30*24*60*60 ; $date_limite = strtotime($etablissement->date_creation) + 30*24*60*60 ;
$date = time() ; $date = time() ;
$date_paiement = strtotime($etablissement->date_paiement) ;
if($etablissement->gratuit)
if($date < $date_paiement + 30*24*60*60 || $etablissement->gratuit)
{ {
return 'gratuit' ;
return 'ok' ;
} }
else { else {
if($date < $date_limite) if($date < $date_limite)

Loading…
Cancel
Save