News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Payment Extra Info are not executed

Started by jocke4u, April 14, 2006, 14:35:48 PM

Previous topic - Next topic

jocke4u

Hi,

I have used payment extra info back and forth in my development to try out the best solution in a new payment module.

In the main payment class everythings seems fine and the process_payment(...) looks like this:
function process_payment($order_number, $order_total, &$d) {
global $mosConfig_secret, $vendor_name, $VM_LANG, $vmFileLogger;
$auth = $_SESSION['auth'];

require_once(CLASSPATH ."payment/ps_samport_api.cfg.php");
require_once(CLASSPATH ."payment/ps_samport_api.class.php");

$DebugLogging = (SAMPORT_API_LOG_DEBUG == 'YES' ? true : false);
$InfoLogging = (SAMPORT_API_LOG_INFO == 'YES' ? true : false);
   
// We need the $order_total in cents!
$order_total = $order_total * 100;

// We need to show the year with two digits only
$year = substr( $_SESSION['ccdata']['order_payment_expire_year'], 2, 2 );

$validation_string = md5( session_id() . $mosConfig_secret . ENCODE_KEY);

// Redirect to URL
$redirectURL = SECUREURL."index.php?page=checkout.samport_api_result&option=com_virtuemart&O=".$order_number."&VS=".urlencode($validation_string)."&S=";

$samport = new Samport(true, true );
$samport->setSamportID( SAMPORT_API_ID );
$samport->setCardData( $_SESSION['ccdata']['order_payment_number']."=".$year.$_SESSION['ccdata']['order_payment_expire_month']  );
$samport->setAmount( $order_total );
$samport->setCurrencyCode( SAMPORT_API_CURRENCY_CODE );
$samport->setCardCVV2( $_SESSION['ccdata']['credit_card_code'] );
$samport->setOrderNo($order_number);
$samport->setReturnURL ( $redirectURL);

$resInit3D = $samport->Init3D();
if ($resInit3D->SecureID != "") {
    // Seems to have went fine
    if ($resInit3D->URL == "NO") {
        // If we not have an URL we can directly authorize the card
    $vmFileLogger->info("It was not a 3-D card sp we can authorize the card");
//    $_SESSION['samport_api']['redirect_url'] = $redirectURL.$resInit3D->SecureID;
    $_SESSION['samport_api']['3D'] = false;
    } else {
        // Else we have to redirect the user to the card issuer
    $vmFileLogger->info("We have to redirect the customer before we can authorize the card because it is a 3-D card");
  //  $_SESSION['samport_api']['redirect_url'] = $resInit3D->URL.$resInit3D->SecureID;
    $_SESSION['samport_api']['3D'] = true;
    }
// In authorization process we need the CVV2 code
    //$_SESSION['samport_api']['cvv2'] = $_SESSION['ccdata']['credit_card_code'];
  //  $_SESSION['samport_api']['cvv2'] = 333;
} else {
    // We have got some problems
    $vmFileLogger->info("Something went wrong");
return false;
}
return true;
    }   

The logging prints out the strings correctly.

And the code in Payment Extra Info looks:
<?php

global $vmFileLogger;
$vmFileLogger->debug("___________________Payment Extra Info___________________");

$is3Dcard $_SESSION['samport_api']['3D'];
$redirectURL $_SESSION['samport_api']['redirect_url'];

if ( ! 
$is3Dcard ) {
    
$vmFileLogger->info("It was not a 3-D card sp we can authorize the card");
    
mosRedirect($redirectURL);
} else {
    
$vmFileLogger->info("Redirecting to: ".$redirectURL);
    echo 
"<iframe src =\"".$redirectURL."\" width=\"100%\" height=\"500\"></iframe>";
    
//mosRedirect($resInit3D->URL.$resInit3D->SecureID);
}

?>

But it seems not to be executed (nor logged)

Why does this happen or not happen??
BR
Joacim
[Sweden]

deneb

not sure what you mean....

the Payment Extra Info is executed after final confirmation in checkout.

it is also executed when viewing an existing order (both in VM admin and customer's Account Maintence>View order)

jocke4u

#2
Quote from: deneb on April 15, 2006, 00:04:55 AM
not sure what you mean....

I have a payment class "ps_samport_api" and for example setting some session variables. On that payment method I have now added (for test purpose) a plain text string "This is a test in PEI".
When running this payment method I can in VM debug mode see the session variables just fine but never the testing text that are in Payment Extra Info (PEI).

I have changed PEI several times and also have had it executed. But now it seems to have lost track in some way..
I can also see in jos_vm_order_payment table that the payment_method_id are set to the correct value according to jos_vm_payment_method -> payment_method_id. Also verified that the test string is in jos_vm_payment_method -> payment_extrainfo

Quote
the Payment Extra Info is executed after final confirmation in checkout.

it is also executed when viewing an existing order (both in VM admin and customer's Account Maintence>View order)

Not in this case  ??? I have also checked the HTML output and seached for the string, nothing found. With your posting you added some good clarification about how it's working but the issue still remains.
BR
Joacim
[Sweden]

jocke4u

I have now found some solution or at least got a better understanding in the payment process.

The configuration parameters are parsed out, using the $payment_code in the payment class.  In my configuration I have set:

SAMPORT_API_VERIFIED_STATUS = B (paid)
SAMPORT_API_PENDING_STATUS = P (pending)
SAMPORT_API_INVALID_STATUS = X (Cancelled)

The orders are set to B and therefore the Payment Extra Info are never executed since the status check is hardcoded in VM (e.g. in html/account.order_details.php line 95):
if ( $db->f("order_status") == "P" ) { for the PEI to be executed.
The same code is in checkout.thankyou.php.

I think this logic is fine in account.order_details but in checkout.thankyou it should always be executed, or what is your opinion?

In my case I need to perform some additional processing and using the PEI to redirect to a customized checkout.result where the additional processing can take place. Need to think about this, changing the names a bit  should override the automatic status change and let me control it.
BR
Joacim
[Sweden]