I am using Moneris PHP API for my client and doing a lot of monthly payments using this API. Each time when I have to charge from customers I have to pass their Credit Card info to this API request.
Now problem is that I never want to store credit card info in my database. SO I am looking for some mechanism in nmoneris by which I can only pass card info for first time payment. After that moneris should return a token for future payments. So using this token, I only pass some basic info when charging customer next time. (Basically I never want to send card info again and again).
I know recurring payment is one of solution for this. But in my case billing interval and billing amont is not fixed. That is why I am not using recurring payment.
Below is sample of code:
/********* Start of Code *********/
<?php
/*Purchase (basic)
In the purchase example we require several variables (store_id, api_token, order_id, amount, pan, expdate, and
crypt_type). Please refer to Appendix A. Definition of Request Fields for variable definitions.*/
// ------ Requires the actual API file.
// ------ the proper path
This can be placed anywhere as long as you indicate
require "../mpgClasses.php";
// ------ Define all the required variables.
These can be passed by whatever means you wish
$store_id = ‘store1’;
$customerid = ‘student_number’;
$api_token = ‘yesguy’;
$orderid = ‘need_unique_orderid’;
$pan = ‘5454545454545454’;
$amount = ’12.00’;
$expirydate = ‘0612’;
$crypttype = ‘7’;
// ------ step 1) create transaction hash
$txnArray=array(‘type’=>'purchase',
‘order_id’=>$orderid,
‘cust_id’=>$customerid,
‘amount’=>$amount,
‘pan’=>$pan,
‘expdate’=>$expirydate,
‘crypt_type’=>$crypttype
);
// ------ step 2) create a transaction object passing the hash created in step 1.
$mpgTxn = new mpgTransaction($txnArray);
// ------ step 3) create a mpgRequest object passing the transaction object created in step 2
$mpgRequest = new mpgRequest($mpgTxn);
// ------ step 4) create mpgHttpsPost object which does an https post
$mpgHttpPost =new mpgHttpsPost($store_id,$api_token,$mpgRequest);
// ------ step 5) get an mpgResponse object
$mpgResponse=$mpgHttpPost->getMpgResponse();
// ------ step 6) retrieve data using get methods. Using these methods you can retrieve the
// ------ appropriate variables (getResponseCode) to check if the transactions is approved
// ------ (=>0 or <50) or declined (>49) or incomplete (NULL)
print ("\nCardType = " . $mpgResponse->getCardType());
print("\nTransAmount = " . $mpgResponse->getTransAmount());
print("\nTxnNumber = " . $mpgResponse->getTxnNumber());
print("\nReceiptId = " . $mpgResponse->getReceiptId());
print("\nTransType = " . $mpgResponse->getTransType());
print("\nReferenceNum = " . $mpgResponse->getReferenceNum());
print("\nResponseCode = " . $mpgResponse->getResponseCode());
print("\nISO = " . $mpgResponse->getISO());
print("\nMessage = " . $mpgResponse->getMessage());
print("\nAuthCode = " . $mpgResponse->getAuthCode());
print("\nComplete = " . $mpgResponse->getComplete());
print("\nTransDate = " . $mpgResponse->getTransDate());
print("\nTransTime = " . $mpgResponse->getTransTime());
print("\nTicket = " . $mpgResponse->getTicket());
print("\nTimedOut = " . $mpgResponse->getTimedOut());
/********* End of Code *********/
?>
Thanks in Advance !!!
You can use vault feature of Moneris. With vault you can store the card with an API call. API return the Token so you can submit payment at will.