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 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答