Hi Greg

Fantastic work on this module, it seems to be exactly what we need to integrate into the MyGate Enterprise service.

I've put in all the Merchant ID's and so forth that Mygate has given me, and set it up on their website console correctly, but when i submit my trasnaction from the ubercart shopping cart's checkout window, it throws up a page of RAW XML - there is an error as you will see, but still - am i doing something wrong that this comes up instead of it being redirected back to the site correctly with either a success or fail message?

the result page i get looks like this:

Data:Array
(
    [txn_type] => auth_capture
)
Order:stdClass Object
(
    [order_id] => 21
    [uid] => 672
    [order_status] => in_checkout
    [order_total] => 250
    [product_count] => 1
    [primary_email] => ash@ops.tc
    [delivery_first_name] => 
    [delivery_last_name] => 
    [delivery_phone] => 
    [delivery_company] => 
    [delivery_street1] => 
    [delivery_street2] => 
    [delivery_city] => 
    [delivery_zone] => 0
    [delivery_postal_code] => 
    [delivery_country] => 710
    [billing_first_name] => Ash
    [billing_last_name] => Glover
    [billing_phone] => 
    [billing_company] => 
    [billing_street1] => Box
    [billing_street2] => 
    [billing_city] => 
    [billing_zone] => 81
    [billing_postal_code] => 1715
    [billing_country] => 710
    [payment_method] => credit
    [data] => Array
        (
            [cc_data] => 6d%6&Wde>PKmIr=%$VxZ_#aW/U:^ KwTXhg6=HSHhOF^$;pm9)uKdKYIUSi`Yi(`U]#zCCafWt
        )

    [created] => 1323163496
    [modified] => 1323163496
    [host] => 196.210.183.201
    [currency] => ZAR
    [products] => Array
        (
            [0] => stdClass Object
                (
                    [order_product_id] => 30
                    [order_id] => 21
                    [nid] => 2394
                    [title] => Conference 2012 Tickets
                    [manufacturer] => 
                    [model] => BFAconf-2012
                    [qty] => 1
                    [cost] => 0.00000
                    [price] => 250.00000
                    [weight] => 0
                    [data] => Array
                        (
                            [attributes] => Array
                                (
                                )

                            [uc_event_registration] => Array
                                (
                                    [sid] => 29
                                )

                            [module] => uc_product
                        )

                    [order_uid] => 672
                )

        )

    [payment_details] => Array
        (
            [cc_type] => Visa
            [cc_owner] => joe soap
            [cc_number] => 4111111111111111
            [cc_start_month] => 
            [cc_start_year] => 
            [cc_exp_month] => 5
            [cc_exp_year] => 2012
            [cc_issue] => 
            [cc_cvv] => 123
            [cc_bank] => 
        )

    [line_items] => Array
        (
            [0] => Array
                (
                    [line_item_id] => subtotal
                    [type] => subtotal
                    [title] => Subtotal
                    [amount] => 250
                    [weight] => 0
                    [data] => Array
                        (
                        )

                )

        )

)
Results:Array
(
    [0] => Result||-1
    [1] => TransactionIndex||14cc02b1-34dd-40d6-ab9c-615c79a6382f
    [2] => Error||1019||Service.ThreeDValidate||TransactionIndex required||This transaction requires a TransactionIndex.  Please specify a correct transaction index.  If this problem persists, please contact MyGate at support@mygate.co.za
    [3] => AcquirerDateTime||2011/12/06 11:29:13 AM
)

Comments

Gemma Morton’s picture

Your error relates to the transaction index.

I dont know if you know code, but you should do the following:
- Find the function (it is around line: 89):
function uc_mygate_charge($order_id, $amount, $data) {

Where the following code exists, just do the following above $parameters:
$transid = isset($_SESSION['3dsecure']['MyGate_TransactionId']) ? $_SESSION['3dsecure']['MyGate_TransactionId'] : '';

Then, into the Parameters array, underneath the Application ID, add the variable:

 $parameters = array(
      variable_get('uc_mygate_gatewayid','21'),          //Gateway
      variable_get('uc_mygate_merchantid', 'XXXXX-XXXXXXX-XXXXXXX-XXXXXX-XXXXXX'),          //MerchantID
      variable_get('uc_mygate_applicationid', ''XXXXX-XXXXXXX-XXXXXXX-XXXXXX-XXXXXX'),          //ApplicationID
      $transid,          //TransactionIndex
      'Website',          //Terminal

Let me know if this solves your problem.

onepartscissors’s picture

OK, i have tried that, but it doesn't seem to be working... the function is named slightly differently in the module from the site here, this is how the function reads now with these additions you requested:

I'm mystified - it somehow feels like the transaction index isn't being generated properly, but the weird thing for me is that the result array from my original error message actually had a transaction index listed there - not sure if that relates to the result posted back, or if this is the transaction index they're wanting?

the module with your new lines for transaction index looks like this:

function uc_mygate_gateway_charge($order_id, $amount, $data) {
  $transid = isset($_SESSION['3dsecure']['MyGate_TransactionId']) ? $_SESSION['3dsecure']['MyGate_TransactionId'] : '';
  global $user;
  $order = uc_order_load($order_id);
  $cctype = $order->payment_details['cc_type'];
  switch($cctype) {
    case 'Visa':
      $cardtype = '4';
      break;

    case 'MasterCard':
      $cardtype = '3';
      break;
    
    case 'American Express':
      $cardtype = '1';
      break;
    
    default:
      $cardtype= 'none';
  }
  $userip = $_SERVER['REMOTE_ADDR'];
  $name = explode(' ', $order->payment_details['cc_owner']);
  $merchant_ref = $order_id . $name[1];
  $client = new SoapClient("https://www.mygate.co.za/enterprise/4x0x0/ePayWebService.cfc?wsdl");
  
  
  
  $arrResults = $client->fProcessAndSettle(
      variable_get('uc_mygate_virtual_gatewayid','21'),          //Gateway
      variable_get('uc_mygate_virtual_merchantid', '79958a8d-0c7b-4038-8e2e-8948e1d678e1'),          //MerchantID
      variable_get('uc_mygate_virtual_applicationid', '4b775479-a264-444c-b774-22d5521852d8'),          //ApplicationID
      
	  $transid,          //TransactionIndex
      'Website',          //Terminal
	  
	  variable_get('uc_mygate_virtual_mode','0'),          //Mode
      $merchant_ref,          //MerchantReference
      $amount,          //Amount
      'ZAR',          //Currency
      '',          //CashBackAmount - Leave Blank                    
      $cardtype,          //CardType
      '',          //AccountType
      $order->payment_details['cc_number'],     //CardNumber
      $order->payment_details['cc_owner'],      //CardHolder
      $order->payment_details['cc_cvv'],        //CVVNumber
      $order->payment_details['cc_exp_month'],  //ExpiryMonth
      $order->payment_details['cc_exp_year'],   //ExpiryYear
      '',    //Budget
      '',     //BudgetPeriod
      '',     //AuthorizationNumber
      '',     //PIN
      '',     //DebugMode
      '00',   //eCommerceIndicator              
      '',     //verifiedByVisaXID
      '',     //verifiedByVisaCAFF
      '',      //secureCodeUCAF
      '',      //UCI
      $userip, //IP Address
      '',     //ShippingCountryCode
      ''      //PurchaseItemsID
      );
  $debug = variable_get('uc_mygate_virtual_payment_post_debug', '0');
  if ($debug == '1') {
    print "<pre>";
    print "Data:";
    print_r($data);
    print "Order:";
    print_r($order);
    print "Results:";
    print_r($arrResults);
    print "</pre>";
    exit;
  }
  // -1 = Unsuccessful; 0/1 = Successful Transaction. 
  $result = explode('||', $arrResults[0]);
  if ($result[1] == '-1') {
    $success = FALSE;
  }
  else {
    $success = TRUE;
  }

  // The information for the payment is in the $order->payment_details array.
  // drupal_set_message('<pre>'. print_r($order->payment_details, TRUE) .'</pre>');
  if ($success) {
    $message = t('Credit card charged: !amount', array('!amount' => uc_currency_format($amount)));
    uc_order_comment_save($order_id, $user->uid, $message, 'admin');
  }
  else {
    $message = t('Credit card charge failed.');
    uc_order_comment_save($order_id, $user->uid, $message, 'admin');
  }

  $result = array(
      'success' => $success,
      'comment' => t('Card charged, resolution code: 0022548315'),
      'message' => $success ? t('Credit card payment processed successfully.') : t('Credit card charge failed.'),
      'uid' => $user->uid,
      // 'data' => $data,
      );

  return $result;
}
Gemma Morton’s picture

StatusFileSize
new22.85 KB
new59.72 KB
new166.34 KB
new113.18 KB
new192.21 KB
new160.29 KB

Hi OnePartScissors ;)

Ok. The change I suggested above is not necessary. I thought the API had changed, and that this was needed, but I have just created a clean install, without anything other than ubercart and uc_mygate (downloaded from drupal.org with no modifications) module senabled.

Please see the following screenshots to understand my setup. Let's see what the differences are. I also advise that you go back to the Dev version from drupal.org (essentially, abandon the changes made above).

This is my Debug:

Data:Array
(
    [txn_type] => auth_capture
)
Order:stdClass Object
(
    [order_id] => 1
    [uid] => 1
    [order_status] => in_checkout
    [order_total] => 10
    [product_count] => 1
    [primary_email] => support@telamenta.com
    [delivery_first_name] => 
    [delivery_last_name] => 
    [delivery_phone] => 
    [delivery_company] => 
    [delivery_street1] => 
    [delivery_street2] => 
    [delivery_city] => 
    [delivery_zone] => 0
    [delivery_postal_code] => 
    [delivery_country] => 840
    [billing_first_name] => 
    [billing_last_name] => 
    [billing_phone] => 
    [billing_company] => 
    [billing_street1] => 
    [billing_street2] => 
    [billing_city] => 
    [billing_zone] => 0
    [billing_postal_code] => 
    [billing_country] => 840
    [payment_method] => credit
    [data] => Array
        (
            [cc_data] => 6"J_NNM<{S?"K2ewrWH*(gP=/ &E77H6XdkY2,kgb_ [;^p8YX[/GB,k-W]Y5[b`(iiT8% ]CB5J(xQ8sL"]?Njp$vU}WzRj7$TL(>@d1c)H:$f(GvU!
        )

    [created] => 1323253003
    [modified] => 1323253817
    [host] => 196.209.235.133
    [currency] => USD
    [products] => Array
        (
            [0] => stdClass Object
                (
                    [order_product_id] => 6
                    [order_id] => 1
                    [nid] => 1
                    [title] => Greg Test Product
                    [manufacturer] => 
                    [model] => greg-test
                    [qty] => 1
                    [cost] => 0.00000
                    [price] => 10.00000
                    [weight] => 0
                    [data] => Array
                        (
                            [shippable] => 1
                            [module] => uc_product
                        )

                    [order_uid] => 1
                )

        )

    [payment_details] => Array
        (
            [cc_type] => Visa
            [cc_owner] => Joe Soap
            [cc_number] => 4111111111111111
            [cc_start_month] => 
            [cc_start_year] => 
            [cc_exp_month] => 1
            [cc_exp_year] => 2013
            [cc_issue] => 
            [cc_cvv] => 123
            [cc_bank] => 
        )

    [line_items] => Array
        (
            [0] => Array
                (
                    [line_item_id] => subtotal
                    [type] => subtotal
                    [title] => Subtotal
                    [amount] => 10
                    [weight] => 0
                    [data] => Array
                        (
                        )

                )

        )

)
Results:Array
(
    [0] => Result||0
    [1] => TransactionIndex||6f9b355e-488c-4700-b0b9-b4a5de89a347
    [2] => AcquirerDateTime||2011/12/07 12:34:45 PM
    [3] => AuthorisationID||189877
    [4] => AuthorisationID||896319
)
onepartscissors’s picture

Thanks for all your investigations on this!

I looked at their standard php example they sent me, and these are the only clues i could find - differences between their example and the drupal module. I tried making these changes but they had no success, though - maybe you can see something in these differences? (i'll post this into the issue queue too)

1. SoapClient:
their example: $client = new SoapClient("https://www.mygate.co.za/enterprise/4x0x0/ePayService.cfc?wsdl");
our module: $client = new SoapClient("https://www.mygate.co.za/enterprise/4x0x0/ePayWebService.cfc?wsdl");

2. Action variable:
theirs has an action variable in it, see here:

'21', 	//Gateway
'79958a8d-0c7b-4038-8e2e-8948e1d678e1',  	//MerchantID
'4b775479-a264-444c-b774-22d5521852d8', 	//ApplicationID
'1',		//Action
'',			//TransactionIndex
'Website',	//Terminal
'0',		//Mode

and the module does't:

variable_get('uc_mygate_virtual_merchantid', '79958a8d-0c7b-4038-8e2e-8948e1d678e1'),          //MerchantID
variable_get('uc_mygate_virtual_applicationid', '4b775479-a264-444c-b774-22d5521852d8'),          //ApplicationID
'',          //TransactionIndex
'Website',          //Terminal
variable_get('uc_mygate_virtual_mode','0'),          //Mode

Whether there is anything in those differences, i can't tell - when i make the module look like this it doesn't work.

will try and follow up with mygate some more - their support guys aren't big on answering emails it seems!

onepartscissors’s picture

Status: Active » Closed (works as designed)

OK, so to close this issue up , i think, we can say that this particular module works fine as intended, but it doesn't support 3D Secure, so perhaps we need to just post a note about that on the front page?

If you need 3D Secure, and sometimes MyGate refuses to let you bypass it, then you need a different module altogether.

Thanks for all your help on this Greg - truly!

life. saver.