sagepay表单集成-错误3045 [英] sagepay form integration - error 3045

查看:98
本文介绍了sagepay表单集成-错误3045的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设置一个简单的PHP表单,以使用表单集成将事务发送到sagepay,密钥设置如下:

I'm setting up a simple PHP form to send transactions to sagepay using form integration, the cryptkey is setup as follows:

$PAYMENT_CRYPT = 
"VendorTxCode=website
&Amount=$total
&Currency=GBP
&Description=Ticket
&SuccessURL=EDITED-OUT/registered-thanks
&FailureURL=EDITED-OUT/registered-fail
&BillingSurname=$surname
&BillingFirstnames=$firstname
&BillingAddress1=$address1
&BillingCity=$city
&BillingPostCode=$postcode
&BillingCountry=UK
&DeliverySurname=$surname
&DeliveryFirstnames=$firstname
&DeliverAddress1=$address1
&DeliveryCity=$city
&DeliveryPostCode=$postcode
&DeliveryCountry=UK
&AllowGiftAid=1"

表格:

<form action="https://live.sagepay.com/gateway/service/vspform-register.vsp" method="POST" id="SagePayForm" name="SagePayForm">
    <input type="hidden" name="VPSProtocol" value="2.23" />
    <input type="hidden" name="TxType" value="PAYMENT" />
    <input type="hidden" name="Vendor" value="MYVENDORID" />
    <input type="hidden" name="Crypt" value="<?= $PAYMENT_CRYPT ?>">    
    <input type="image" src="images/buynow-sagepay.png" />
</form>

Sage给我一个错误,如下所示,这毫无意义,因为货币字段肯定是经过传递的.

Sage is giving me an error as follows, which makes no sense since the currency field is most definitely being passed.

此交易尝试失败.我们无法将您重定向回您购买的网上商店.失败的详细信息如下.

This transaction attempt has failed. We are unable to redirect you back to the web store from which you were purchasing. The details of the failure are given below.

状态:格式错误

状态详细信息:3045:货币"字段丢失.

Status Detail: 3045 : The Currency field is missing.

任何帮助将不胜感激!

里克

推荐答案

您似乎根本没有对数据进行加密. 以下内容将帮助您检查并在代码中包含相关功能.

you appear not to be encrypting your data at all. The following will help you check and include in your code the relevant functionality.

<?php
function pkcs5_pad($text, $blocksize)
{
    $pad = $blocksize - (strlen($text) % $blocksize);
    return $text . str_repeat(chr($pad), $pad);
}

function encryptFieldData($input)
{
    $key = "use your SagePAY encryption key here";
    $iv = $key;

    $cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, "", MCRYPT_MODE_CBC, "");
    if (mcrypt_generic_init($cipher, $key, $iv) != -1)
    {
        $cipherText = mcrypt_generic($cipher,$input );
        mcrypt_generic_deinit($cipher);

        $enc = bin2hex($cipherText);
    }
    return $enc;
}
$str = "Currency=GBP";
$datapadded = pkcs5_pad($str,16);
$cryptpadded = "@" . encryptFieldData($datapadded);
?>
<html>
    <form name="pp_form" action="SagePay test url" method="post">
    <input name="VPSProtocol" type="hidden" value=3.00 />
    <input name="TxType" type="hidden" value=PAYMENT />
    <input name="Vendor" type="hidden" value="YOUR SAGEPAY ACCOUNT NAME HERE"     />
    <input name="Crypt" type="hidden" value=<?php echo $cryptpadded;?> />
    <p>Click here to submit 
        <input type="submit" value="here">
    </p>
    </form>
</html>

您可以在此处看到更完整的说明 SagePay与PHP的表单集成

You can see a fuller explanation here SagePay form integration with PHP

这篇关于sagepay表单集成-错误3045的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆