Difference between revisions of "Page Templates:Creating a Payment Template"
From Whirlwind eCommerce Wiki
(New page: The payment template is a form for the user to enter their payment information After creating the template, setup a page for it. Place the pageId of this new page in Settings > eCommerce ...) |
|
(No difference)
|
Revision as of 12:33, 21 October 2008
The payment template is a form for the user to enter their payment information
After creating the template, setup a page for it. Place the pageId of this new page in Settings > eCommerce tab: "Payment Page Id"
Sample content is below:
// get order data, including payment info $orderCompleteArray = eV::orderGetCompleteArray(); // shortcut order info $orderArr = $orderCompleteArray['order']; // short cut payment info // system made to support multiple payments // but at this time we can only process one payment per order $payArr = $orderCompleteArray['payments'][0]; // lets get the pay types for the select field $arrPayTypes = eV::orderGetPayTypes(); $payTypeOptionString = eV::orderGetPayTypesOptionsString($payArr['payType']); // lets get the expiration dates for the select field $expDateOptionString = eV::orderGetExpDateString($payArr['expDate']); /* static function orderGetExpDateString($expDate){ $optionString = ""; if($expDate < date("Y-m-d")) $year = date('Y'); for($i=$year;$i<(intval($year)+20);$i++){ for($ii=1;$ii<13;$ii++){ $thisDate = mktime ( 23,23,59,($ii+1),0,$i ); $thisDateVal = date("Y-m-d",$thisDate); if(strToTime(date("Y-m-d")) <= $thisDate){ $thisDateText = date("m/Y",$thisDate); $optionString .= "<option value=\"$thisDateVal\""; if($thisDateVal == $expDate) $optionString .= " selected "; $optionString .= ">$thisDateText</option>"; }; }; }; */ // output message if passed // this is typically used to inform the visitor of invalid payment information submitted or declined credit card if(!empty($message)) echo "<font color=\"red\">$message</font>"; // start form // note use of securedsiteurl to ensure SSL connection submitted echo "<form action=\"" . $iProducts['securedSiteUrl']. "/index.php\" method=\"post\" name=\"checkoutPaymentForm\">"; echo "<br>Select Card Type: "; // output pay types // use the string generated at the begging of the script when calling the orderGetPayTypeOptionString request echo "<select name=\"payType\">$payTypeOptionString</select>"; echo "<br>First Name: "; echo "<input name=\"firstName\" value=\"" . $payArr['firstName'] . "\" type=\"text\" />"; echo "<br>Last Name: "; echo "<input name=\"lastName\" value=\"" . $payArr['lastName'] . "\" type=\"text\" />"; echo "<br>Card Number: ": // note the value here is empty - we dont want to pass the card number back to the browser echo "<input name=\"accountNumber\" size=18 maxlength=16 value=\"\" class=\"form-field\" type=\"text\" />"; echo "<br>Expiration Date: "; // output expiration date options // use the string generated at the begginging of the script when calling the orderGetExpDateString request echo "<select name=\"expDate\">$expDateOptionString</select>"; echo "<br>Card Security Code: "; // like the card number, we dont want t pass this back to the browser echo "<input name=\"cvv\" type=\"text\" value=\"\" size=\"5\" />"; // required hidden fields tell the system where to go and what to do when submitted // redirect failure and success tell the system where to go after the payment info is submitted // paymentId is passed to tell the system which payment to post this submission to // the payment supports the payType, accountNumber, cvv and expDate fields // sale_addressId is passed to tell the system which address to post this submission to // the address supports the firstName, lastName fields in addition to street1, street2, city, state, zipCode, country, phone1, phone2, fax echo "<input type=\"hidden\" name=\"fa\" value=\"ORDER.paymentPost\"> <input type=\"hidden\" name=\"redirectSuccess\" value=\"index.php?fa=ORDER.checkoutConfirmation\"> <input type=\"hidden\" name=\"redirectFailure\" value=\"index.php?fa=ORDER.checkoutPayment\"> <input type=\"hidden\" name=\"paymentId\" value=\"" . $payArr['paymentId']. "\"> <input type=\"hidden\" name=\"sale_addressId\" value=\"" . $payArr['sale_addressId']. "\">": // form post button echo "<input type=\"submit\" value=\"Post Payment\">"; // close out the form echo "</form>";