dongzhankou2090 2015-06-30 13:07
浏览 33
已采纳

使用PHP查询从Sagepay的SQL数据库返回值

The website I'm working on is sending the incorrect Billing Country information to Sagepay (this field is now mandetory on 3.00 update) and I'm trying to find a way to pass the correct information within the PHP file.

The current line to send this information is:

$crypt .= "&BillingCountry=".$orderArray["country"];

The problem with this is that the "country" field in the orderArray gives the country name as set in our CMS, not the ISO code that Sagepay requires.

The correct ISO codes are held within an SQL database so the information is available. The database table holds unique ID, name, ISO code, ISO number plus some other site-relavent information.

I need to replace the above crypt with this:

$crypt .="&BillingCountry=".$countryISO;

Where the $countryISO is added into the code as a query. This query should look in the ISO Code column (isocode) of the Countries database table and return the ISO code value in correspondance with the "country" name in the orderArray.

I've tried to put something together myself following php used in other files for the site which appear to be acheiving something similar. for example:

$countryISO = $dbA->query("SELECT isocode FROM $tableCountries WHERE name=".$orderArray["country"]);

I've also tried:

$countryISO = $dbA->retrieveAllRecordsFromQuery("SELECT isocode FROM $tableCountries WHERE name=".$orderArray["country"]);

There is a php file included on the site server that has the 'query' and 'retrieveAllRecordsFromQuery' functions, among others (e.g count, fetch, retrieveAllRecords) and also includes a funciton relating to $dbA which I believe connects to the database.

I need some advice as to how I can achieve pulling the ISO Code from the SQL database. Is my code anywhere near what I need?

  • 写回答

2条回答 默认 最新

  • dpp10181 2015-06-30 15:36
    关注

    I've managed to find a solution by using similar code used for another gateway for the website. This has solved the Billing Country issue and is now sending data successfully to Sagepay on the 3.00 protocol.

    Solution:

        $countryMatch = $orderArray["country"];
        $cResult = $dbA->query("select * from $tableCountries where name=\"$countryMatch\"");
        if (count($cResult) > 0) {
            $cRecord = $dbA->fetch($cResult);
            $customerCountry = $cRecord["isocode"];
        } else {
            $customerCountry = "";
        }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作