Moneris 通过 php 中的令牌付款

Posted

技术标签:

【中文标题】Moneris 通过 php 中的令牌付款【英文标题】:Moneris payments by token in php 【发布时间】:2016-07-23 15:17:07 【问题描述】:

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

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

我知道定期付款是解决此问题的一种方法。但在我的情况下,计费间隔和计费金额不是固定的。这就是我不使用定期付款的原因。

以下是代码示例:

/********* 代码开头*********/

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

提前致谢!!!

【问题讨论】:

【参考方案1】:

您可以使用 Moneris 的保险库功能。使用保管库,您可以通过 API 调用来存储卡片。 API 会返回 Token,以便您可以随意提交付款。

【讨论】:

以上是关于Moneris 通过 php 中的令牌付款的主要内容,如果未能解决你的问题,请参考以下文章

php : 贝宝定期付款令牌无效

php 将Moneris信用卡类型添加到woocommerce订单电子邮件中

php 将Moneris信用卡类型添加到woocommerce订单电子邮件中

paypal rest sdk - 取消付款只提供令牌

通过贝宝成功的自适应付款付款请求

在 react redux saga 中处理同步