$privateData1 = array(); $privateData1['key'] = $_POST['privateDataKey1']; $privateData1['value'] = $_POST['privateDataValue1']; $payline->setPrivate($privateData1); $privateData2 = array(); $privateData2['key'] = $_POST['privateDataKey2']; $privateData2['value'] = $_POST['privateDataValue2']; $payline->setPrivate($privateData2); $privateData3 = array(); $privateData3['key'] = $_POST['privateDataKey3']; $privateData3['value'] = $_POST['privateDataValue3']; $payline->setPrivate($privateData3); // WALLET ID $array['walletId'] = $_POST['walletId']; // scheduled $array['scheduled'] = $_POST['ScheduledDate']; // RECCURENT $array['recurring']['firstAmount'] = $_POST['recurringFirstAmount']; $array['recurring']['amount'] = $_POST['recurringAmount']; $array['recurring']['billingCycle'] = $_POST['recurringBillingCycle']; $array['recurring']['billingLeft'] = $_POST['recurringBillingLeft']; $array['recurring']['billingDay'] = $_POST['recurringBillingDay']; $array['recurring']['startDate'] = $_POST['recurringStartDate']; // EXECUTE $response = $payline->do_recurrent_wallet_payment($array); require '../demos/result/header.html'; echo '<H3>REQUEST</H3>'; print_a($array); echo '<H3>RESPONSE</H3>'; print_a($response, 0, true); require '../demos/result/footer.html';
public function createNewAbonnementFromToken() { /* * Récupère les données de la table bo_payline_token et intéroge payline pour savoir ce qu'il en est */ $oPayline = new paylineSDK(); $aToken = $this->oPDO->query('SELECT * FROM bo_payline_token ORDER BY PTID ASC LIMIT 0,1')->fetch(PDO::FETCH_ASSOC); if (!$aToken) { return false; } /* * Intérogge Payline sur le token, si ok on créer le dossier de payment * Si token en attente on ne fais rien * Si echec du portefeuille on supprime toutes donné associé */ // Cet appelle ne vise QUE à stoper la notification de Payline $aPaylineWallet = $oPayline->get_WebWallet($aToken['token']); /* * Si le code indique que le token est en attente, on retourne true * il faudra vérifier à nouveau dans 1 minutes, * sinon on continue */ // Si code = 02306, l'utilisateur na pas terminé de taper ses donnée de CB if ($aPaylineWallet['result']['code'] == '02306') { return true; } // Récupère les information sur le portefeuille $aPaylineWallet = $this->getPaylineWallet($aToken['UID']); /* * Le portefeuil éxiste, on créer le dossier de paiement */ if ($aPaylineWallet['result']['code'] == '02500' || $aPaylineWallet['result']['code'] == '02501') { /* * Récupére les données nécéssaire */ $aPaymentFolder = $this->oPDO->query('SELECT * FROM bo_payline_folder WHERE paymentRecordId="' . $aToken['token'] . '"')->fetch(PDO::FETCH_ASSOC); /* * Calcule le montant de l'abonnement et la durée */ $aAbonnement = $this->calcAbonnement($aToken['token']); // PAYMENT $aParam['payment']['amount'] = $aAbonnement['iTotalPrice']; // Montant total $aParam['payment']['currency'] = PAYMENT_CURRENCY; $aParam['payment']['action'] = PAYMENT_ACTION; $aParam['payment']['mode'] = PAYMENT_MODE; $aParam['payment']['contractNumber'] = CONTRACT_NUMBER; $aParam['payment']['differedActionDate'] = CONTRACT_NUMBER_LIST; // ORDER $aParam['orderRef'] = $aPaymentFolder['reforder']; $aParam['orderDate'] = date('d/m/Y H:m'); //ORDER $aParam['order']['ref'] = $aPaymentFolder['reforder']; $aParam['order']['origin'] = ''; $aParam['order']['country'] = 'FR'; $aParam['order']['taxes'] = round($aAbonnement['iTotalPrice'] * 0.196); $aParam['order']['amount'] = $aAbonnement['iTotalPrice']; $aParam['order']['date'] = date('d/m/Y H:m'); $aParam['order']['currency'] = ORDER_CURRENCY; // WALLET ID $aParam['walletId'] = $aToken['UID']; // scheduled $aParam['scheduled'] = ''; // RECCURENT $aParam['recurring']['firstAmount'] = $aAbonnement['iPriceFirst']; $aParam['recurring']['amount'] = $aAbonnement['iRecurrentPrice']; $aParam['recurring']['billingCycle'] = 40; $aParam['recurring']['billingLeft'] = $aAbonnement['iRecurrentDuree']; $aParam['recurring']['billingDay'] = 5; $aParam['recurring']['startDate'] = ''; // EXECUTE $aRecurrentPayment = $oPayline->do_recurrent_wallet_payment($aParam); // Si ce n'est pas bon on donne l'ordre de tout supprimer if ($aRecurrentPayment['result']['code'] != '02500' || $aRecurrentPayment['result']['code'] != '02501') { $bNeedDelete = true; } else { /* * Le dossier de payment est créer, * on modifie tout les paymentRecordId pour remplacer le numéro de token par le * véritable paymentRecordId */ $this->oPDO->query('UPDATE bo_payline_folder SET paymentRecordId="' . $aRecurrentPayment['paymentRecordId'] . '" WHERE paymentRecordId="' . $aToken['token'] . '"'); $this->getPaymentRecord($aRecurrentPayment['paymentRecordId']); $this->oPDO->query('UPDATE bo_payline_folder_product SET paymentRecordId="' . $aRecurrentPayment['paymentRecordId'] . '" WHERE paymentRecordId="' . $aToken['token'] . '"'); $this->oPDO->query('UPDATE bo_payline_token WHERE token="' . $aToken['token'] . '"'); $this->oPDO->query('DELETE FROM bo_payline_token WHERE token="' . $aToken['token'] . '"'); $bNeedDelete = false; } } else { $bNeedDelete = true; } if ($bNeedDelete) { /* * Le portefeuille n'existe pas, on supprime toutes les donné lié */ $this->oPDO->query('DELETE FROM bo_user_rib WHERE UID="' . $aToken['UID'] . '"'); $this->oPDO->query('DELETE FROM bo_user_adresse WHERE UID="' . $aToken['UID'] . '"'); $this->oPDO->query('DELETE FROM bo_user_info WHERE UID="' . $aToken['UID'] . '"'); $this->oPDO->query('DELETE FROM bo_user WHERE UID="' . $aToken['UID'] . '"'); $this->oPDO->query('DELETE FROM bo_payline_wallet WHERE UID="' . $aToken['UID'] . '"'); $this->oPDO->query('DELETE FROM bo_payline_folder WHERE paymentRecordId="' . $aToken['token'] . '"'); $this->oPDO->query('DELETE FROM bo_payline_folder_product WHERE paymentRecordId="' . $aToken['token'] . '"'); $this->oPDO->query('DELETE FROM bo_payline_token WHERE paymentRecordId="' . $aToken['token'] . '"'); } return true; }