在php中通过代币进行Moneris支付


Moneris payments by token in php

我为我的客户使用Moneris PHP API,并使用这个API每月支付大量款项。每次我必须向客户收费时,我都必须将他们的信用卡信息传递给这个API请求。

现在的问题是,我永远不想把信用卡信息存储在我的数据库中。所以我正在nmoneris中寻找一些机制,通过它我只能传递第一次付款的卡信息。在那之后,moneris应该返回一个代币用于未来的支付。所以使用这个代币,我只在下次向客户收费时传递一些基本信息。(基本上我不想一次又一次地发送卡片信息)。

我知道经常性付款是解决这个问题的方法之一。但在我的情况下,计费间隔和计费amont是不固定的。这就是为什么我不使用定期付款。

以下是代码示例:

/*********代码起始*********/

<?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 *********/
?>

提前感谢!!!

您可以使用Moneris的保险库功能。使用vault,您可以通过API调用存储卡。API退还代币,以便您可以随意提交付款。