Announcement

Collapse
No announcement yet.

Google Checkout Implementation

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Google Checkout Implementation

    After seeing what brightlight wrote in this post, I thought I would have a go.
    http://community.actinic.com/showpos...3&postcount=73

    I modified the Net4You files in the CommonOCC folder and go it to work with Google Checkout, it is very rough at the moment though but it is working in a test environment.

    The only issue I seem to have is regarding the VAT calculations.

    At the moment the script passes a variable called $::nOrderTotal which is the total value of the order including VAT, now Google checkout wants to calculate the VAT for me and show this in the checkout. I have told Google checkout not to calculate the tax and it processes against the whole order but it shows up in the checkout as VAT @ £0.00, which is a bit misleading.
    What I need to do is pass the order total to Google without VAT, any ideas ?

    Peter
    Printerbase - Colour & Mono Laser Printers

    #2
    Peter

    Could you not create a new variable to pass to Google which is excluding VAT ?

    $OrderTotalExVAT = $::OrderTotal / 1.175;

    I'd be very interested to see your modified scripts !!
    Dom Watts
    sales@sexy2wear.co.uk
    Sexy 2 Wear Lingerie - WARNING contains adult images

    Comment


      #3
      That would probably work but how would I round it down to 2 decimal places ?
      Printerbase - Colour & Mono Laser Printers

      Comment


        #4
        Peter

        This should do the trick but I am no perl programmer !

        $OrderTotalExVATDirty = $::OrderTotal / 1.175;
        $OrderTotalExVATClean = sprintf("%.2f", $OrderTotalExVATDirty );
        Dom Watts
        sales@sexy2wear.co.uk
        Sexy 2 Wear Lingerie - WARNING contains adult images

        Comment


          #5
          Ok, that appears to have done the trick after some slight modification.

          Please find below the modified scrips.

          They are very rough and haven’t been tested at all, they have only ever been run against the Google test server and you use them at your own risk, I take no responsibility.
          Further work needs to be done on the scripts to make it full functional.

          To implement them you need to set up net4you as a payment provider and in the scripts change this line and replace xxxxxxxxxx with your merchant number:
          https://sandbox.google.com/checkout/...x/checkoutForm

          OCCNet4YouScriptTemplate.pl
          Code:
          #---------------------------------------------------------------
          #
          # OCCScriptTemplate.pl	- code part of OCC script
          #
          # Copyright (c) Actinic Software Ltd 2001 All rights reserved
          #
          # *** Do not change this code unless you know what you are doing ***
          #
          # Written by George Menyhert
          #
          # This script is called by an eval() function and it will already
          # have the following variables set up:
          #
          #	Expects:		$::sOrderNumber		- the alphanumeric order number for this order
          #				$::nOrderTotal			- the total for this order (stored in based currency format e.g. 1000 = $10.00)
          #				%::PriceFormatBlob   - the price format data
          #				%::InvoiceContact		- the customer invoice contact information
          #				$::sCallBackURLAuth	- the URL of the authorization callback script
          #				$::sCallBackURLBack	- the URL of the backup script
          #				$::sCallBackURLUser	- the URL of the receipt script
          #				$::sPath					- the path to the Catalog directory
          #				$::sWebSiteUrl			- the Catalog web site URL
          #				$::sContentUrl			- the content URL
          #
          #	Affects:		$::eStatus     		- the status of the transaction:
          #						$::FAILURE 	- Failure
          #						$::ACCEPTED - Accepted
          #						$::REJECTED - Rejected
          #						$::PENDING  - Pending
          #					$::sErrorMessage		- error message if any
          #					$::sHTML					- the HTML to display
          #
          #  $Revision: 1 $
          #
          #---------------------------------------------------------------
          
          use strict;
          
          $::eStatus = $::PENDING;								# The OCC plug-in runs in pending mode.  This script does not
          																# perform the transaction.  Rather, it forwards the customer to
          															# the OCC site for completion.
          my (%VarTable);
          
          ## Shared Script, different HTML templates;
          
          $VarTable{$::VARPREFIX . 'https://sandbox.google.com/checkout/cws/v2/Merchant/xxxxxxxxxxx/checkoutForm'} =				# insert the OCC web site URL into the HTML template
          	$sProcessScriptURL;
          #
          # build up a string of all of the values that must be passed to OCC
          #
          my $sHiddenValues;
          $sHiddenValues .= "<INPUT TYPE=HIDDEN NAME=\"ORDERNUMBER\" VALUE=\"" . $::sOrderNumber . "\">\n";
          $sHiddenValues .= "<INPUT TYPE=HIDDEN NAME=\"item_name_1\" VALUE=\"Goods Purchased\">\n";
          $sHiddenValues .= "<INPUT TYPE=HIDDEN NAME=\"item_description_1\" VALUE=\"Products Purchased from Printerbase\">\n";
          $sHiddenValues .= "<INPUT TYPE=HIDDEN NAME=\"item_currency_1\" VALUE=\"" . $::PriceFormatBlob{SINTLSYMBOLS} . "\">\n";
          $sHiddenValues .= "<INPUT TYPE=HIDDEN NAME=\"item_price_1\" VALUE=\"" . sprintf("%.2f",($::nOrderTotal/117.5)) . "\">\n";
          #$sHiddenValues .= "<INPUT TYPE=HIDDEN NAME=\"price_1\" VALUE=\"" . $OrderTotalExVATClean . "\">\n";
          $sHiddenValues .= "<INPUT TYPE=HIDDEN NAME=\"item_quantity_1\" VALUE=\"1\">\n";
          #$sHiddenValues .= "<INPUT TYPE=HIDDEN NAME=\"tax_rate\" VALUE=\"1.175\">\n";
          $sHiddenValues .= "<INPUT TYPE=HIDDEN NAME=\"_charset_\">\n";
          
          
          #if (!$bAuthorize)											# if in pre-authorize mode, set the flag
          #	{
          #	$sHiddenValues .= "<INPUT TYPE=HIDDEN NAME=\"PREAUTH\" VALUE=\"1\">\n";
          #	}
          #
          #if ($bTestMode)											# only include the test mode flag if it is on
          #	{
          #	$sHiddenValues .= "<INPUT TYPE=HIDDEN NAME=\"TESTMODE\" VALUE=\"1\">\n";
          #	}
          #
          # URLs:
          #
          #		AUTH - the URL to create the authorization blob
          #		BACK - the URL to return to the Catalog checkout process
          #		USER - the URL to the receipt script
          #
          my @Response = ACTINIC::EncodeText($::sCallBackURLAuth);
          #$sHiddenValues .= "<INPUT TYPE=HIDDEN NAME=\"CALLBACKURLAUTH\" VALUE=\"" . $Response[1] . "\">\n";
          @Response = ACTINIC::EncodeText($::sCallBackURLBack);
          #$sHiddenValues .= "<INPUT TYPE=HIDDEN NAME=\"CALLBACKURLBACK\" VALUE=\"" . $Response[1] . "\">\n";
          @Response = ACTINIC::EncodeText($::sCallBackURLUser);
          #$sHiddenValues .= "<INPUT TYPE=HIDDEN NAME=\"CALLBACKURLUSER\" VALUE=\"" . $Response[1] . "\">\n";
          
          $VarTable{$::VARPREFIX . 'OCC_VALUES'} =			# add the OCC values to the template
          	$sHiddenValues;
          
          my $sLinkHTML = 'occlink.html';
          if(defined $::g_pPaymentList)
          	{
          	$sLinkHTML = $$::g_pPaymentList{ActinicOrder::PaymentStringToEnum($::g_PaymentInfo{'METHOD'})}{BOUNCE_HTML};
          	}
          @Response = ACTINIC::TemplateFile($::sPath . $sLinkHTML, \%VarTable); # build the file
          
          if ($Response[0] != $::SUCCESS)
          	{
          	$::eStatus = $::FAILURE;							# return a plug-in error
          	$::sErrorMessage = $Response[1];
          	return ($::SUCCESS);									# always return success if the script runs
          	}
          
          @Response = ACTINIC::MakeLinksAbsolute($Response[2], $::sWebSiteUrl, $::sContentUrl);
          if ($Response[0] != $::SUCCESS)
          	{
          	$::eStatus = $::FAILURE;							# return a plug-in error
          	$::sErrorMessage = $Response[1];
          	return ($::SUCCESS);									# always return success if the script runs
          	}
          
          $::sHTML = $Response[2];								# grab the resulting HTML
          #
          # process the test mode warning
          #
          my ($sDelimiter) = $::DELPREFIX . 'TESTMODE';
          if ($bTestMode)											# only include the test mode block if we are in test mode
          	{
          	$::sHTML =~ s/$sDelimiter//g;						# remove the delimiter text
          	}
          else															# not in test mode - remove the block
          	{
          	$::sHTML =~ s/$sDelimiter(.*?)$sDelimiter//gs;	# remove the test mode warning blob (/s removes the \n limitation of .)
          	}
          
          return ($::SUCCESS);
          
          #
          # End of OCCScriptTemplate.pl
          #

          Act_OCCNet4YouTemplate.html
          Code:
          <!-- saved from url=(0022)http://internet.e-mail -->
          <!-- Template for IPEurope OCC HTML template -->
          
          <!-- Terminate the parent template form -->
          
          </form>
          
          Click <B>Næste</B> for at gå til Net4You's Secure Server med fuld sikkerhed indbygget og betal trygt med kreditkort.
          
          
          
          
          
          <P>
          
          <BIG>Dette katalog arbejder p.t. i test mode. Der vil ikke blive hævet på dit kreditkort.</BIG>
          
          
          
          
          
          <FORM NAME="formOCC" METHOD="POST" ACTION="https://sandbox.google.com/checkout/cws/v2/Merchant/xxxxxxxxxxx/checkoutForm" accept-charset="utf-8">
          
          NETQUOTEVAR:OCC_VALUES
          
          <input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.tax-tables.default-tax-table.tax-rules.default-tax-rule-1.rate" value="0.175"/> 
          <input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.tax-tables.default-tax-table.tax-rules.default-tax-rule-1.tax-area.postal-area.country-code" value="GB"/> 
          
          
          </FORM>
          <P>
          
          <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
          
          <TR><TD ALIGN=RIGHT>
          
          <!--<INPUT TYPE=SUBMIT NAME="SUBMIT" VALUE="Next&gt;"> -->
          
          </TD></TR>
          
          </TABLE>
          
          
          
          <FORM METHOD=POST ACTION="NETQUOTEVAR:OCC_URL"><!-- Create a bogus form to keep the parent template happy -->
          
          <!-- End of template for DATASCAN.NET OCC
          </form> -->
          If anybody want to add to these scripts please feel free to do so.

          And again I stress these scripts are just something I modified last night very quickly and I've posted them here to give an idea of what could be done, they are not designed to be a full working version.

          Peter
          Printerbase - Colour & Mono Laser Printers

          Comment


            #6
            Google Checkout Actinic Code

            Peter

            Your code works fine - good work !

            I found the Google checkout interface to be really disappointing , looks very amateur, but feel that there is short term gain to see the Google checkout logo against Adwords listings.

            I'm also disappointed that you cannot pass the Actinic order number using the HTML API. Upon reading the developers guide this can only be sent using the XML API. There is also the question of callback.

            I guess we have to wait for Actinic to write the proper XML integration. I know there is a wish list for this feature, but I would be willing to pay.
            Dom Watts
            sales@sexy2wear.co.uk
            Sexy 2 Wear Lingerie - WARNING contains adult images

            Comment


              #7
              Originally posted by sexy2wear
              Peter

              This should do the trick but I am no perl programmer !

              $OrderTotalExVATDirty = $::OrderTotal / 1.175;
              $OrderTotalExVATClean = sprintf("%.2f", $OrderTotalExVATDirty );
              Like you, I'm no perl programmer - but I don't think this will round up the number - is that right?

              Comment

              Working...
              X