/**
  * Update the Order ID with the response from PayZippy Charging API
  *
  * @param \WC_Order $order Order to update
  * @param \ChargingResponse $pz_response PayZippy Charging Response
  */
 private function update_order_info(WC_Order $order, ChargingResponse $pz_response)
 {
     $pz_order_note = "PayZippy Response Summary : {";
     $pz_order_note .= " 'PayZippy Transaction ID' : '" . $pz_response->get_payzippy_transaction_id() . "', ";
     switch ($pz_response->get_payment_method()) {
         case PZ_Constants::PAYMENT_MODE_NET:
             $payment_method = PZ_Constants::BANK_NAMES($pz_response->get_bank_name()) . ' ' . PZ_Constants::PAYMENT_METHODS($pz_response->get_payment_method());
             break;
         case PZ_Constants::PAYMENT_MODE_EMI:
             $payment_method = PZ_Constants::BANK_NAMES($pz_response->get_bank_name()) . ' ' . $pz_response->get_emi_months() . ' ' . PZ_Constants::PAYMENT_METHODS($pz_response->get_payment_method());
             break;
         default:
             $payment_method = $pz_response->get_payment_method();
     }
     $pz_order_note .= " 'Payment Method' : '" . $payment_method . "', ";
     update_post_meta($order->id, 'Payment Method', mysql_real_escape_string($payment_method));
     $pz_order_note .= " 'Transaction Status' : '" . $pz_response->get_transaction_status() . "', ";
     update_post_meta($order->id, 'Transaction Status', mysql_real_escape_string($pz_response->get_transaction_status()));
     $pz_order_note .= " 'Transaction Response Code' : '" . $pz_response->get_transaction_response_code() . "', ";
     update_post_meta($order->id, 'Transaction Response Code', mysql_real_escape_string($pz_response->get_transaction_response_code()));
     $pz_order_note .= " 'Transaction Response Message' : '" . $pz_response->get_transaction_response_message() . "', ";
     update_post_meta($order->id, 'Transaction Response Message', mysql_real_escape_string($pz_response->get_transaction_response_message()));
     $pz_order_note .= " 'Is International' : '" . $pz_response->get_is_international() . "', ";
     update_post_meta($order->id, 'Is International', mysql_real_escape_string($pz_response->get_is_international()));
     $pz_order_note .= " 'Fraud Action' : '" . $pz_response->get_fraud_action() . "' }";
     update_post_meta($order->id, 'Fraud Action', mysql_real_escape_string($pz_response->get_fraud_action()));
     $order->add_order_note(mysql_real_escape_string($pz_order_note));
 }
Beispiel #2
0
<?php

include dirname(__FILE__) . "/../common/header.php";
require dirname(__FILE__) . "/../../payzippy-sdk/ChargingResponse.php";
// This file corresponds to your Charging Response Callback URL.
// Create an instance of the ChargingResponse using the GET parameters
// returned to the callback URL.
$pz_charging_response = new ChargingResponse(array_merge($_POST, $_GET));
$transaction_success = $pz_charging_response->is_transaction_successful();
$transaction_status = $pz_charging_response->get_transaction_status();
$transaction_response_message = $pz_charging_response->get_transaction_response_message();
$transaction_response_code = $pz_charging_response->get_transaction_response_code();
if ($transaction_success) {
    echo "<p class='text-success'><b>";
} else {
    echo "<p class='text-error'><b>";
}
echo "Transaction Status : {$transaction_status}<br/>";
echo "Transaction Response Code : {$transaction_response_code}<br/>";
echo "Transaction Response Message : {$transaction_response_message}<br/>";
echo "</b></p>";
// To check the validity of the response, call the validate function on
// the ChargingResponse object. It verifies the hash returned in the response.
$hash_match = $pz_charging_response->validate();
if ($hash_match) {
    echo "<p class='text-success'><b>Hash matches. The response is valid.</b></p>";
} else {
    echo "<p class='text-error'><b>Hash mismatch. Response is invalid</b></p>";
}
echo "<h4>Charging Response</h4>";
echo "Merchant ID: {$pz_charging_response->get_merchant_id()}<br/>";