Ver código fonte

Système de paiement

Mise en place d'un système de paiement via Paypal.
prodstable
keun 8 anos atrás
pai
commit
4b5c210d81
2 arquivos alterados com 5 adições e 17 exclusões
  1. +2
    -15
      backend/controllers/PaiementController.php
  2. +3
    -2
      common/models/User.php

+ 2
- 15
backend/controllers/PaiementController.php Ver arquivo

@@ -9,6 +9,7 @@ use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use common\models\User;
use common\models\Etablissement;
use c006\paypal_ipn\PayPal_Ipn;

/**
@@ -92,14 +93,6 @@ class PaiementController extends Controller
$custom = $ipn->getKeyValue('custom');
$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)
{
$user = User::findOne($custom) ;
@@ -108,13 +101,7 @@ class PaiementController extends Controller
$etablissement = Etablissement::findOne($user->id_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() ;
}
}

+ 3
- 2
common/models/User.php Ver arquivo

@@ -256,10 +256,11 @@ class User extends ActiveRecord implements IdentityInterface
{
$date_limite = strtotime($etablissement->date_creation) + 30*24*60*60 ;
$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 {
if($date < $date_limite)

Carregando…
Cancelar
Salvar