I have been working extensively with payment gateways and have discovered a few common denominators that I’d like to share with the group. The first part is that most payment providers share a common set of fields for processing.
CustomerFirstName
CustomerLastName
CustomerAddress
CustomerCity
CustomerState
CustomerZip
GatewayURL
GatewayUserLogin
GatewayUserPassword
CardNumber
CardExpiry Month
CardExpiryYear
TransactionType
TransactionAmount
Different gateways may require additional fields so we’ll add a collection of custom field names and values…
CustomFields
AddField(“Test”,True)
Ok, now we should be ready to process the transaction.
Gateway.ProcessPayment
When we receive the results we should check the codes to make sure everything was ok.
Record TransactionResults
If TransactionApproved and ResultCode=Approved ‘Gateway Specific
Approve Store.OrderPayment
Display TransactionApproved(“Thank you for your order.”)
Else
Display TranactionDeclined(“Sorry your transaction was declined.”)
That’s it! (Well, there is a little more behind the scenes, but that is it in a nutshell.)
After watching the way the Store module works, it should be quite easy to develop a payment provider model to handle many gateways and other processing scenarios.
The only issue that I have noticed with the implementation in the store is that the customer should be able to choose a payment processing method which in turn will provide the proper payment provider. Having one setting in the Admin module is usable but very limited. To get around this I suggest that a new module called Store.Payment or Store.Checkout is created that holds the Gateway settings per module added to the page.
One other advantage is that a Portal Administrator (or Store.Owner) can navigate to an order pending for payment, and process the checkout on behalf of the user. This will solve a frequent problem when there is a delay between the customer order and the receipt of the customer payment.
That way I could use a checkout page listing multiple payment provider choices something like this…
Cash
Cheque
CreditCard
Invoice
Here is what I have come up with so far.
Store.PayMethods
PayMethods Accepted by your Store
Store.Gateway.PayMethods
PayMethods accepted by the Gateway
Store.Gateway.TransactionTypes
TransactionTypes accepted by the Gateway
Store.Gateway
Common gateway requirements (configurable and extensible)
Override Authorized method for gateway specific rules
Override Transaction Approved for Actual Results
Store.PayMethods
The following possible PayMethods could either be enumerated or preloaded in a database. I prefer the former (an enum) to keep things more predictable, but by using a database you can add your own and include an Accepted field to control what PayMethods your Store accepts.
Unknown(0) Unknown payment method
Cash(1) Typical cash transaction
Cheque(2) May incorporate check verification service
Credit Cards
Visa(3) May incorporate Verified by Visa
MasterCard(4) May incorporate MasterCard SecureCode
AMEX(5)
Discover(6)
Diners(7)
JCB(8)
CCUnknown(9)
Account Transfer
DirectDeposit(10)
EmailTransfer(11) Available from banks, delay for funds
MobileTransfer(12)
WireTransfer(13)
Debit Card (reserved for future use)
Bank Card(14)
Smart Card (reserved for future use)
Smart Card(15)
Store.Gateway.PayMethods
This is just a mechanism to store the payment methods available for a specific Gateway. The Portal Admin (or Store.Owner) should view a list of available payment methods that they are able to accept, and this list is presented to the customer during the checkout process.
Store.Gateway.TransactionTypes
These are fairly common between Gateways, although some may only support a Sale transaction type.
Gateway.TransactionTypes
Sale PreAuth and Capture
PreAuth Authorization Only
Void Voids an exiting PreAuth
Capture Closes an existing PreAuth
Credit Refunds part or all of previous Captured transaction
Force A voice authorization procedure with an approval code
AVSCheck Address Verification Service only, not transaction approval.
Store.Gateway
One of things that I noticed from the forums is that many people do not require immediate payment to process an order. In fact, some payment methods need only return a fake authorized message and the customer can go on his/her merry way. I thought if we could develop a standard Gateway model, we would be able to add all sorts of payment gateways to the Store.
Taking the process further, I realized that some Stores may operate differently then others. One example is shipping charges. Consider the following scenarios…
Pre-Processing - when a merchant requires payment before processing the order.
Pre-Ship Verification - when a merchant or distribution centre fills an order, payment may be required before shipping, or different then the original order.
Post-Shipping (Prepaid and Charge) - when the shipping costs need to be determined before the total amount can be processed for payment.
Prepaid Shipping - when the cost of shipping is included in the price of the product.
Delayed Payment – The check is in the mail. After the check has cleared, the payment is applied to the order.
Invoice – Simply allow the checkout to continue.
Back Orders - when an item was not in stock at the time the order was shipped.
Store.Gateway Providers
Builtin with Store (may be converted to Store.Gateway Provider)
AuthorizeNetSIM authorize.net server (SSL not required)
PayPal your website -> paypal site -> your website
Secure Providers (integrated own secure server with SSL)
AuthorizeNetAIM Merchant initiated server to server
PayPalPro Website Payments Pro
Accounting Providers
BalanceForward Customer account # required
OpenItem Customer account # and invoice # required
Non Payment Providers (simply allow checkout)
Invoice Invoice generated by separate system
InvoiceTerms Invoice issued with terms for payment
Quote Submit order for price quotation
COD Cash on Delivery
Trade Trade/Barter goods/services
Simple Providers
Donation Issue tax receipt from template
TrustFund Add personal note, issue receipt from template
DirectDeposit Transaction reference required
Two Stage Providers
Allow instant checkout, and delay for receipt of funds. Customer or StoreManager may complete transaction when payment information is received (transaction id, etc.)
Check PayMethodCheck
CertfiedCheck PayMethodCash
BankDraft PayMethodCash
MoneyOrder PayMethodCash
PayPalEmail PayMethodEmail (send invoice with PayPal button)
PayPalMobile PayMethodMobile
Advanced Providers
MutlipleInvoices Select multiple invoices and make single payment
If you are still reading this, I am impressed. Now you will have to forgive me because the remaining part is unfinished – it requires some serious help from the community.
Gateway
Properties
GatewayID
GatewayURL
MerchantLogin
MerchantPassword
TestMode
ExtraFields
Methods
SendAuthorization(TransactionRequest)
SendTestAuthorization(TransactionRequest)
CheckAVS
Check
GatewayTransactionRequest
Properties
PortalID
UserID
GatewayID
PayMethodID
TransactionTypeID
CustomerFirstName
CustomerLastName
CustomerAddress
CustomerCity
CustomerState
CustomerZip
CreditCardNumber
CreditCardExpiryDate
CreditCardExpiryYear
TransactionAmount
Methods
GatewayTransactionResponse
Inherits Gateway.TransactionRequest
Properties
TransactionID
ApprovalCode
DisplayText
InvoiceNumber
ResponseAVS
ResponseCode
ResponseData
ResponseCVV2
ResponseText
TransactionApproved
Store.Transactions
Inherits GatewayTransactionResponse
Properties
PortalID
UserID
Methods
SaveTransactionInfo
Someone had to start somewhere. Any comments?