737371; #--------------------------------------------------------------- # # Generated by WUPayCashOCCConfigCtrl # #--------------------------------------------------------------- # my $bCompleteOnTechnicalFailures = $::FALSE; my $bCompleteOnFinancialFailures = $::FALSE; my $bAuthorize = $::FALSE; my $bTestMode = $::FALSE; my $sProcessScriptURL = 'https://www.paypal.com/cgi-bin/webscr'; my $sMerchantName = ''; my $sMerchantID = 'craig@hmdp.com'; # #--------------------------------------------------------------- # # OCCPayPalTemplate.pl - code part of OCC script # # *** Do not change this code unless you know what you are doing *** # # Adapted from OCCAuthorizeNetScriptTemplate.pl by Bill Birthisel # # 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 - customer invoice contact information # %::OCCShipData - customer invoice shipping 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 # $::sCartID - the cart id # # 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 # $::sRedirectURL - (optional) data for logging or # for redirect if implemented someday # # $Revision: 21530 $ # #--------------------------------------------------------------- use strict; # # This block of code isolates the plug-in scripts from version specific code that they have historically used # BEGIN my $sCartID; if (defined $::EC_MAJOR_VERSION) # EC version 6 or greater { $sCartID = $::sCartID; # Use the value setup by OrderScript.pl } else # Pre-version 6 { $sCartID = $::g_sCartId; # copy the global value } # END # This block of code isolates the plug-in scripts from version specific code that they have historically used # # # 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. # $::eStatus = $::PENDING; # # constants # my $ALWAYS = 1; my $OPTION = 0; my $NOENCODE = 0; my $ENCODE = 1; # encode both bounce and redirect my $REDIRECT = 2; # encode redirect only my %VarTable; # substitution hash for template # # insert the OCC web site URL into the HTML template # $VarTable{$::VARPREFIX . 'OCC_URL'} = $sProcessScriptURL; # # build up a string of all of the values that must be passed to OCC # my $sHiddenValues; my $sRedirectData = $sProcessScriptURL; # # sprintf template for data form sent to the OCC # my $OCC_template = ''."\n"; my $POST_template = '%s%s=%s'; # # Required PayPal fields - these values are hard coded based on the options that work best with Actinic # AddPostValues ('?', 'cmd', '_xclick', $ALWAYS, $NOENCODE); # required "command" value AddPostValues ('&', 'undefined_quantity', 0, $ALWAYS, $NOENCODE); # make the quantity editable - I'm just going to leave it hard coded to one AddPostValues ('&', 'no_shipping', 1, $ALWAYS, $NOENCODE); # don't use paypal's shipping calculator AddPostValues ('&', 'no_note', 1, $ALWAYS, $NOENCODE); # don't allow entry of a payment note AddPostValues ('&', 'bn', 'ActinicCat_Cart_ST', $ALWAYS, $NOENCODE); # hard code the provider # # Merchant ID # AddPostValues ('&', 'business', $sMerchantID, $ALWAYS, $REDIRECT); # the merchant email address or business PayPal ID # # Pack some additional values on the authorization URL # my $sCompleteCallBackURLAuth = $::sCallBackURLAuth; $sCompleteCallBackURLAuth .= "ON=" . $::sOrderNumber; $sCompleteCallBackURLAuth .= "&TM=0"; $sCompleteCallBackURLAuth .= "&AM=" . $::nOrderTotal; $sCompleteCallBackURLAuth .= "&ACT_POSTPROCESS=1&"; # # 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 # AddPostValues ('&', 'notify_url', $sCompleteCallBackURLAuth, $ALWAYS, $REDIRECT); AddPostValues ('&', 'cancel_return', $::sCallBackURLBack, $ALWAYS, $REDIRECT); AddPostValues ('&', 'return', $::sCallBackURLUser, $ALWAYS, $REDIRECT); # # order details # AddPostValues ('&', 'invoice', $::sOrderNumber, $ALWAYS, $NOENCODE); AddPostValues ('&', 'item_name', $::sOrderNumber, $ALWAYS, $NOENCODE); AddPostValues ('&', 'item_number', $::sOrderNumber, $ALWAYS, $NOENCODE); # # Calculate the conversion factor for the currency # my $nFactor = 100; my $nNumDigits = $::PriceFormatBlob{"ICURRDIGITS"}; # read the currency format values if(defined $nNumDigits) { $nFactor = (10 ** $nNumDigits); } my $sCurrencyFormat = sprintf('%%d.%%0%dd', $nNumDigits); my $sAmount .= sprintf($sCurrencyFormat, $::nOrderTotal / $nFactor, $::nOrderTotal % $nFactor); AddPostValues ('&', 'amount', $sAmount, $ALWAYS, $NOENCODE); # # Currency # AddPostValues ('&', 'currency_code', $::PriceFormatBlob{SINTLSYMBOLS}, $ALWAYS, $NOENCODE); # # supply the cardholder's address details # my ($sFirstName, $sLastName); $sLastName = $::InvoiceContact{NAME}; # default to a blank first name and complete last name if ($sLastName =~ /^(.+)\s+(\S+)/) # if the name field looks to contain at least two name parts { $sFirstName = $1; # break the name up $sLastName = $2; } my $sCountry = $::g_LocationInfo{INVOICE_COUNTRY_CODE}; $sCountry =~ s/^GB$/UK/; my $sState = ($::g_LocationInfo{INVOICE_REGION_CODE} ne $ActinicOrder::UNDEFINED_REGION) ? ActinicLocations::GetISOInvoiceRegionCode() : $::InvoiceContact{ADDRESS4}; AddPostValues ('&', 'first_name', $sFirstName, $OPTION, $REDIRECT); AddPostValues ('&', 'last_name', $sLastName, $ALWAYS, $REDIRECT); AddPostValues ('&', 'email', $::InvoiceContact{EMAIL}, $OPTION, $NOENCODE); AddPostValues ('&', 'address1', $::InvoiceContact{ADDRESS1}, $ALWAYS, $REDIRECT); AddPostValues ('&', 'address2', $::InvoiceContact{ADDRESS2}, $OPTION, $REDIRECT); AddPostValues ('&', 'city', $::InvoiceContact{ADDRESS3}, $OPTION, $REDIRECT); AddPostValues ('&', 'state', $sState, $OPTION, $REDIRECT); AddPostValues ('&', 'zip', $::InvoiceContact{POSTALCODE}, $OPTION, $REDIRECT); AddPostValues ('&', 'country', $sCountry, $OPTION, $REDIRECT); my ($nAreaCode, $nPart1, $nPart2); if ($::InvoiceContact{PHONE} =~ /(\d*)\D*(\d*)\D*(\d*)/) { $nAreaCode = $1; $nPart1 = $2; $nPart2 = $3; } if (length $nPart1 == 0) # if only digits were entered { $nPart1 = $nAreaCode; $nPart2 = $nAreaCode = ''; } if ($::InvoiceContact{PHONE} =~ /\+(\d{2})(.*)/) { $nAreaCode = $1; $nPart1 = $2; $nPart2 = ''; } AddPostValues ('&', 'night_phone_a', $nAreaCode, $OPTION, $NOENCODE); AddPostValues ('&', 'night_phone_b', $nPart1, $OPTION, $NOENCODE); AddPostValues ('&', 'night_phone_c', $nPart2, $OPTION, $REDIRECT); # # end of the invoice address details # # # add the OCC values to the template # $VarTable{$::VARPREFIX . 'OCC_VALUES'} = $sHiddenValues; my $sLinkHTML = 'occlink.html'; if(defined $::g_pPaymentList) { $sLinkHTML = $$::g_pPaymentList{ActinicOrder::PaymentStringToEnum($::g_PaymentInfo{'METHOD'})}{BOUNCE_HTML}; } my @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 $::sRedirectURL = $sRedirectData; # data for log or redirect # # 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 .) } # # AddPostValues ($sPostSeparator, $sPostName, $sPostValue, $bAlways, $bEncode) # # adds a name/value pair to $sHiddenValues and $sRedirectData # sub AddPostValues { my ($sDelim, $sName, $sValue, $bAlways, $eEncode) = @_; if ($sValue || $bAlways) { my $sEncValue = $sValue; if ($eEncode) { $sEncValue = ACTINIC::EncodeText2 ($sValue, $::FALSE); } if ($eEncode == $REDIRECT) { $sHiddenValues .= sprintf ($OCC_template, $sName, $sValue); } else { $sHiddenValues .= sprintf ($OCC_template, $sName, $sEncValue); } $sRedirectData .= sprintf ($POST_template, $sDelim, $sName, $sEncValue); } } return ($::SUCCESS); # # End of OCCPayPalTemplate.pl # # # End of File