<?php

// INITIALIZE
include "../../include.php";
$array = array();
$payline = new paylineSDK();
// CONTRACT NUMBER
$array['contractNumber'] = $_POST['contractNumber'];
$array['paymentRecordId'] = $_POST['paymentRecordId'];
// EXECUTE
$response = $payline->get_payment_record($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';
Exemple #2
0
    public function getPaymentRecord($iPaymentRecordId)
    {
        /*
         * Récupère les données lié à un paymentRecordId
         * et les met à jours dans la table si besoin
         */
        // Récupére les infos sur le payment
        $oPayline = new paylineSDK();
        $aParam['contractNumber'] = CONTRACT_NUMBER;
        $aParam['paymentRecordId'] = $iPaymentRecordId;
        $aPaymentRecordId = $oPayline->get_payment_record($aParam);
        // Vérifie si le dossier existe dans notre base
        $aCoolizPaymentFolder = $this->oPDO->query('SELECT COUNT(*) FROM bo_payline_folder WHERE paymentRecordId=' . $iPaymentRecordId)->fetch();
        if ($aPaymentRecordId['result']['code'] == '02500' || $aPaymentRecordId['result']['code'] == '02501') {
            /*
             * Le dossier de payment existe chez Payline, on l'enregistre dans notre base
             */
            // Le dossier n'existe pas dans notre base, on le créer
            if ($aCoolizPaymentFolder[0] == 0) {
                $this->oPDO->query('INSERT INTO bo_payline_folder SET paymentRecordId="' . $iPaymentRecordId . '"');
            }
            // Met à jour le dossier dans notre base
            $oPaymentFolder = $this->oPDO->prepare('UPDATE bo_payline_folder SET result_code=:result_code
			, result_longMessage=:result_longMessage
			, result_shortMessage=:result_shortMessage
			, recurring_firstAmount=:recurring_firstAmount
			, recurring_amount=:recurring_amount
			, recurring_billingCycle=:recurring_billingCycle
			, recurring_billingLeft=:recurring_billingLeft
			, recurring_billingDay=:recurring_billingDay
			, recurring_startDate=:recurring_startDate
			, isDisabled=:isDisabled
			, reforder=:reforder
			, totalAmount=:totalAmount WHERE paymentRecordId="' . $iPaymentRecordId . '"');
            $oPaymentFolder->bindValue(':result_code', $aPaymentRecordId['result']['code']);
            $oPaymentFolder->bindValue(':result_longMessage', $aPaymentRecordId['result']['longMessage']);
            $oPaymentFolder->bindValue(':result_shortMessage', $aPaymentRecordId['result']['shortMessage']);
            $oPaymentFolder->bindValue(':recurring_firstAmount', $aPaymentRecordId['recurring']['firstAmount']);
            $oPaymentFolder->bindValue(':recurring_amount', $aPaymentRecordId['recurring']['amount']);
            $oPaymentFolder->bindValue(':recurring_billingCycle', $aPaymentRecordId['recurring']['billingCycle']);
            $oPaymentFolder->bindValue(':recurring_billingLeft', $aPaymentRecordId['recurring']['billingLeft']);
            $oPaymentFolder->bindValue(':recurring_billingDay', $aPaymentRecordId['recurring']['billingDay']);
            $oPaymentFolder->bindValue(':recurring_startDate', $aPaymentRecordId['recurring']['startDate']);
            $oPaymentFolder->bindValue(':isDisabled', $aPaymentRecordId['isDisabled']);
            if (!isset($aPaymentRecordId['order']['ref'])) {
                $aPaymentRecordId['order']['ref'] = '';
            }
            if (!isset($aPaymentRecordId['order']['amount'])) {
                $aPaymentRecordId['order']['amount'] = '';
            }
            $oPaymentFolder->bindValue(':reforder', $aPaymentRecordId['order']['ref']);
            $oPaymentFolder->bindValue(':totalAmount', $aPaymentRecordId['order']['amount']);
            $oPaymentFolder->execute();
        } else {
            /*
             * Si le folder n'existe pas chez payline mais dans nos table,
             * on met tout de même nos table à jour
             */
            if ($aCoolizPaymentFolder[0] == 1) {
                $oPaymentFolder = $this->oPDO->query('UPDATE bo_payline_folder SET result_code=:result_code, result_longMessage=:result_longMessage, result_shortMessage=:result_shortMessage WHERE paymentRecordId="' . $iPaymentRecordId . '"');
                $oPaymentFolder->bindValue(':result_code', $aPaymentRecordId['result']['code']);
                $oPaymentFolder->bindValue(':result_longMessage', $aPaymentRecordId['result']['longMessage']);
                $oPaymentFolder->bindValue(':result_shortMessage', $aPaymentRecordId['result']['shortMessage']);
                $oPaymentFolder->execute();
            }
        }
        return $aPaymentRecordId;
    }