Exemplo n.º 1
0
 /**
  * Save the payment data returned by the payment server
  *
  * @param integer $order_id
  */
 function save_payment_return_data($order_id)
 {
     $data = wpshop_tools::getMethode();
     $current_payment_return = get_post_meta($order_id, '_wpshop_payment_return_data', true);
     $current_payment_return[] = $data;
     update_post_meta($order_id, '_wpshop_payment_return_data', $current_payment_return);
 }
Exemplo n.º 2
0
 function display_response()
 {
     // Begin Main : Retrieve Variables posted by CMCIC Payment Server
     $CMCIC_bruteVars = wpshop_tools::getMethode();
     // TPE init variables
     $oTpe = new CMCIC_Tpe();
     $oHmac = new CMCIC_Hmac($oTpe);
     // Message Authentication
     $cgi2_fields = sprintf(CMCIC_CGI2_FIELDS, $oTpe->sNumero, $CMCIC_bruteVars["date"], $CMCIC_bruteVars['montant'], $CMCIC_bruteVars['reference'], $CMCIC_bruteVars['texte-libre'], $oTpe->sVersion, $CMCIC_bruteVars['code-retour'], $CMCIC_bruteVars['cvx'], $CMCIC_bruteVars['vld'], $CMCIC_bruteVars['brand'], $CMCIC_bruteVars['status3ds'], $CMCIC_bruteVars['numauto'], $CMCIC_bruteVars['motifrefus'], $CMCIC_bruteVars['originecb'], $CMCIC_bruteVars['bincb'], $CMCIC_bruteVars['hpancb'], $CMCIC_bruteVars['ipclient'], $CMCIC_bruteVars['originetr'], $CMCIC_bruteVars['veres'], $CMCIC_bruteVars['pares']);
     if ($oHmac->computeHmac($cgi2_fields) == strtolower($CMCIC_bruteVars['MAC'])) {
         wpshop_payment::save_payment_return_data($CMCIC_bruteVars['reference']);
         $payment_status = 'denied';
         switch ($CMCIC_bruteVars['code-retour']) {
             case "Annulation":
                 // Attention : an autorization may still be delivered for this payment
                 //wpshop_payment::setOrderPaymentStatus($CMCIC_bruteVars['reference'], 'denied');
                 $payment_status = 'denied';
                 break;
             case "payetest":
                 // test
                 //wpshop_payment::setOrderPaymentStatus($CMCIC_bruteVars['reference'], 'completed');
                 $payment_status = 'completed';
                 break;
             case "paiement":
                 // prod
                 // Save cic txn_id
                 // 					update_post_meta($CMCIC_bruteVars['reference'], '_order_cic_txn_id', $CMCIC_bruteVars['numauto']);
                 //wpshop_payment::set_payment_transaction_number($CMCIC_bruteVars['reference'], $CMCIC_bruteVars['numauto']);
                 //wpshop_payment::setOrderPaymentStatus($CMCIC_bruteVars['reference'], 'completed');
                 $payment_status = 'completed';
                 break;
                 /*** ONLY FOR MULTIPART PAYMENT ***/
             /*** ONLY FOR MULTIPART PAYMENT ***/
             case "paiement_pf2":
             case "paiement_pf3":
             case "paiement_pf4":
                 // Payment has been accepted on the productive server for the part #N
                 // return code is like paiement_pf[#N]
                 // put your code here (email sending / Database update)
                 // You have the amount of the payment part in $CMCIC_bruteVars['montantech']
                 break;
             case "Annulation_pf2":
             case "Annulation_pf3":
             case "Annulation_pf4":
                 // Payment has been refused on the productive server for the part #N
                 // return code is like Annulation_pf[#N]
                 // put your code here (email sending / Database update)
                 // You have the amount of the payment part in $CMCIC_bruteVars['montantech']
                 break;
         }
         $order_meta = get_post_meta($CMCIC_bruteVars['reference'], '_order_postmeta', true);
         $params_array = array('method' => 'cic', 'waited_amount' => number_format((double) $order_meta['order_amount_to_pay_now'], 2, '.', ''), 'status' => $payment_status == 'completed' ? number_format((double) $order_meta['order_amount_to_pay_now'], 2, '.', '') == number_format((double) substr($CMCIC_bruteVars['montant'], 0, -3), 2, '.', '') ? 'payment_received' : 'incorrect_amount' : $payment_status, 'author' => $order_meta['customer_id'], 'payment_reference' => $CMCIC_bruteVars['numauto'], 'date' => current_time('mysql', 0), 'received_amount' => number_format((double) substr($CMCIC_bruteVars['montant'], 0, -3), 2, '.', ''));
         wpshop_payment::check_order_payment_total_amount($CMCIC_bruteVars['reference'], $params_array, $payment_status);
         $receipt = CMCIC_CGI2_MACOK;
     } else {
         // your code if the HMAC doesn't match
         $receipt = CMCIC_CGI2_MACNOTOK . $cgi2_fields;
     }
     // Send receipt to CMCIC server
     printf(CMCIC_CGI2_RECEIPT, $receipt);
 }