Authorizing Credit Cards via MacAuthorize

Example

Authorizing shopping basket orders paid by credit card via MacAuthorize.

MGI Tags

  • mgiCreditCard
  • mgiConditional
  • mgiConfirmOrder
  • mgiFieldContent
  • mgiGet
  • mgiSendOrder
  • mgiSet

Steps

  1. Open the confirm order page in a text editor.
  2. Insert the mgiCreditCard tag validate function.
  3. Save the confirm order page.
  4. Open the order processing page in a text editor.
  5. Insert the mgiCreditCard tag authorize function.
  6. Save the order processing page.
  7. FTP the confirm order page and order processing page to the web server running MGI.
  8. Order a product and complete the shopping basket process with MacAuthorize in demo mode.


Step 1: Open the confirm order page in a text editor.

Open the confirm order page in a text editing program that allows you to view and modify HTML.

Step 2: Insert the mgiCreditCard tag validate function.

Determine the customer's payment method with a conditional comparison. If the customer is paying by credit card, validate the credit card number. The validate function of mgiCreditCard validates the credit card number and returns a value of "Yes" or "No". Yes indicates that the credit card is valid. No indicates that the credit card is not valid. Set the value of the credit card validation in a variable, then perform a conditional comparison with the value of the variable to determine the action on the confirm order page.
 
To determine the customer's payment method, enter a beginning mgiConditional tag, id parameter, lhs parameter, relationship parameter, rhs parameter, mgiElse tag and id parameter, and ending mgiConditional tag. In the ID parameter, enter "1". In the lhs parameter, embed the value of the payment method form field. If you use the mgiPaymentInfo tag on the check out page, the name of the payment method form field is "shoppingBasketPaymentMethod". In the relationship parameter, enter "equals". In the rhs parameter, enter "creditCard".
 
If the customer's payment method is a credit card, validate the credit card number. Otherwise continue to display order confirmation. To validate the credit card, enter the beginning mgiSet tag, name parameter, and ending mgiSet tag. In the name parameter, enter the name of the page variable (e.g., "CCValidation"). In the body of the mgiSet tag, enter the mgiCreditCard tag, function parameter, and accountNumber parameter. In the function parameter, enter "Validate". In the accountNumber parameter, embed the customer's credit card number from the payment information on the check out page. If you use the mgiPaymentInfo tag on the check out page, the name of the credit card number form field is "shoppingBasketCreditCardNumber".
 
If the credit card is valid, display the order confirmation. If the credit card is not valid, display an error message. Enter a beginning mgiConditional tag, id parameter, lhs parameter, relationship parameter, rhs parameter, mgiElse tag and id parameter, and ending mgiConditional tag. In the ID parameter, enter "2". In the lhs parameter, embed the value of the "CCValidation" variable. In the relationship parameter, enter "equals". In the rhs parameter, enter "Yes". In the "true" body of the mgiConditional tag, enter the mgiConfirmOrder tag. In the "false" body of the mgiConditional tag, enter the error message.
<mgiConditional id="1" lhs={mgiFieldContent name="shoppingBasketPaymentMethod"}
relationship="equals" rhs="creditCard">
<mgiSet name="CCValidation">
<mgiCreditCard function="Validate"
accountNumber={mgiFieldContent name="shoppingBasketCreditCardNumber"}>
</mgiSet>

<mgiConditional id="2" lhs={mgiGet name="CCValidation"} 
relationship="equals" rhs="Yes">

<FORM ACTION="orderprocessing.html" METHOD="Post">
<mgiConfirmOrder taxRate=".06" state="North Carolina">
Garden Supply Co.
1007 Main Ave
Raleigh NC 27606
</mgiConfirmOrder>
<mgiButton name="Send Order">
</FORM>

<mgiElse id="2">

The credit card number you entered is not valid.  
Please click the "Back" button on your browser and 
re-enter the card number.

</mgiConditional>
<mgiElse id="1">

<FORM ACTION="orderprocessing.html" METHOD="Post">
<mgiConfirmOrder taxRate=".06" state="North Carolina">
Garden Supply Co.
1007 Main Ave
Raleigh NC 27606
</mgiConfirmOrder>
<mgiButton name="Send Order">
</FORM>

</mgiConditional>

Step 3: Save the confirm order page.

Save the changes you have made to the confirm order page.

Step 4: Open the order processing page in a text editor.

Open the order processing page in a text editing program that allows you to view and modify HTML.

Step 5: Insert the mgiCreditCard tag authorize function.

On the order processing page, determine the customer's payment method with a conditional comparison. If the customer is paying by credit card, authorize the credit card number. The authorize function of mgiCreditCard authorizes the credit card for the total order amount. Set the value of the credit card authorization in a variable, then perform a conditional comparison with the value of the variable to determine the action on the send order page.
 
To determine the customer's payment method, enter a beginning mgiConditional tag, id parameter, lhs parameter, relationship parameter, rhs parameter, mgiElse tag and id parameter, and ending mgiConditional tag. In the ID parameter, enter "1". In the lhs parameter, embed the value of the payment method form field. If you use the mgiPaymentInfo tag on the check out page, the name of the payment method form field is "shoppingBasketPaymentMethod". In the relationship parameter, enter "equals". In the rhs parameter, enter "creditCard".
 
If the customer's payment method is a credit card, combine the expiration month and year in a variable, authorize the credit card for the total order amount and send the order based on the authorization.
 
On the check out page, the expiration month and year are entered in separate fields. For the credit card authorization, the expiration month and year must be combined into a four-digit number. Use a page variable to create the expiration date. Enter the beginning mgiSet tag, name parameter, and ending mgiSet tag. In the name parameter, enter the name of the page variable (e.g., "CCExpiration"). In the body of the mgiSet tag, enter an mgiFieldContent tag for the expiration month and an mgiFieldContent tag for the expiration year. The form field names for the expiration month and year are "shoppingBasketCreditCardMonth" and "shoppingBasketCreditCardYear", respectively.
 
To authorize the credit card, enter the beginning mgiSet tag, name parameter, and ending mgiSet tag. In the name parameter, enter the name of the page variable (e.g., "CCAuthorization"). In the body of the mgiSet tag, enter the mgiCreditCard tag, function parameter, merchantHandle parameter, accountNumber parameter, expirationDate parameter, chargeAmount parameter, and chargeDescription parameter. In the function parameter, enter "Authorize". In the merchantHandle parameter, enter your merchant handle as it is configured in MacAuthorize. In the accountNumber parameter, embed the customer's credit card number from the hidden field on the confirm order page. If you use the mgiPaymentInfo tag on the check out page, the name of the credit card number form field is "shoppingBasketCreditCardNumber". In the expirationDate parameter, embed the value of the expiration date variable that was previously entered ("CCExpiration"). In the chargeAmount parameter, enter the total order amount from the hidden field on the confirm order page. The name of the total charge amount form field is "shoppingBasketTotal". In the chargeDescription parameter, enter a brief description of the charge (e.g., "Garden Supplies").
 
If the credit card is authorized, send the order to the email address "orders@gardensupplydomain.com" with the subject "Product Order" and display a message to the customer. If the credit card is not authorized, send the order to the email address "errors@gardensupplydomain.com" with the subject "Order Authorization Error" and display an error message. Enter a beginning mgiConditional tag, id parameter, lhs parameter, relationship parameter, rhs parameter, mgiElse tag and id parameter, and ending mgiConditional tag. In the ID parameter, enter "2". In the lhs parameter, embed the value of the "CCAuthorization" variable. In the relationship parameter, enter "equals". In the rhs parameter, enter "Authorized". In the "true" body of the mgiConditional tag, enter the mgiSendOrder tag with the to address as "orders@gardensupplydomain.com" and the subject as "Product Order". In the "false" body of the mgiConditional tag, enter the mgiSendOrder tag with the to address as "errors@gardensupplydomain.com" and the subject as "Order Authorization Error".
<mgiConditional id="1" lhs={mgiFieldContent name="shoppingBasketPaymentMethod"}
relationship="equals" rhs="creditCard">
<mgiSet name="CCExpiration">
<mgiFieldContent name="shoppingBasketCreditCardMonth">
<mgiFieldContent name="shoppingBasketCreditCardYear">
</mgiSet>

<mgiSet name="CCAuthorization">
<mgiCreditCard function="Authorize" merchantHandle="GardenCoHandle"
accountNumber={mgiFieldContent name="shoppingBasketCreditCardNumber"} 
expirationDate={mgiGet name="CCExpiration"} 
chargeAmount={mgiFieldContent name="shoppingBasketTotal"}
chargeDescription="Garden Supplies">
</mgiSet>

<mgiConditional id="2" lhs={mgiGet name="CCAuthorization"} 
relationship="equals" rhs="Authorized">

<mgiSendOrder to="orders@gardensupplydomain.com" 
from="webmaster@gardensupplydomain.com" 
mailServer="mail.gardensupplydomain.com"
subject="Product Order" taxRate=".06" state="North Carolina">

Your order has been processed. You should receive the order 
within 5 business days.

<mgiElse id="2">

<mgiSendOrder to="errors@gardensupplydomain.com" 
from="webmaster@gardensupplydomain.com" 
mailServer="mail.gardensupplydomain.com"
subject="Order Authorization Error" taxRate=".06" state="North Carolina">

We have experienced an error while processing your order. Your 
order has been sent and a representative will contact you to 
resolve this issue as soon as possible.

</mgiConditional>
<mgiElse id="1">

<mgiSendOrder to="orders@gardensupplydomain.com" 
from="webmaster@gardensupplydomain.com" 
mailServer="mail.gardensupplydomain.com"
subject="Product Order" taxRate=".06" state="North Carolina">

</mgiConditional>

Step 6: Save the order processing page.

Save the changes you have made to the order processing page.

Step 7: FTP the confirm order page and order processing page to the web server running MGI.

Upload the confirm order page and the order processing page to the web server using an FTP program.

Step 8: Order a product and complete the shopping basket process with MacAuthorize in demo mode.

Use the demo mode of MacAuthorize and order a product using the shopping basket process. If the credit card is authorized for the amount, then an email is sent to "orders@gardensupplydomain.com" with the subject "Product Order". If the credit card is not authorized, then an order email is sent to "errors@gardensupplydomain.com" with the subject "Order Authorization Error".


[Return to the Shopping Online Menu]


[User Guide Main Menu] [Understanding MGI Menu] [Using MGI Menu] [Referencing MGI Menu]