首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用PHP实现Paynamics集成

使用PHP实现Paynamics集成
EN

Stack Overflow用户
提问于 2018-04-19 15:48:51
回答 2查看 526关注 0票数 1

我有一个需要paynamics支付网关的项目,我已经有了商家id和商家密钥,在提交了包含详细信息和金额的表单后,它必须去支付网址,但交易总是失败。paynamics后台保存成功,但状态为签名验证失败。

代码语言:javascript
复制
$_mid = "xxxxxxxxxxxxxxxxxxxxxx"; //<-- your merchant id
$_requestid = substr(uniqid(), 0, 13);
$_responseid = rand(9,100);
// $_ipaddress = "192.168.10.1";
$_ipaddress = "192.168.51.1";
$_noturl = "http://localhost/aspr/checkout-2/"; // url where response is posted
$_resurl = "http://localhost/aspr/checkout-2/"; //url of merchant landing page
$_cancelurl = "http://localhost/aspr/cancel/"; //url of merchant landing page
$_fname = "Juan"; // kindly set this to first name of the cutomer
$_mname = "O"; // kindly set this to middle name of the cutomer
$_lname = "Dela Cruz"; // kindly set this to last name of the cutomer
$_addr1 = "1609 Cityland 10 HV Dela Costa St.Salecedo Village"; // kindly set this to address1 of the cutomer
$_addr2 = "longos malolos";// kindly set this to address2 of the cutomer
$_city = "makati"; // kindly set this to city of the cutomer
$_state = "MM"; // kindly set this to state of the cutomer
$_country = "PH"; // kindly set this to country of the cutomer
$_zip = "1200"; // kindly set this to zip/postal of the cutomer
$_sec3d = "try3d"; // 
$_email = "technical@paynamics.net"; // kindly set this to email of the cutomer
$_phone = "3308772"; // kindly set this to phone number of the cutomer
$_mobile = "09178134828"; // kindly set this to mobile number of the cutomer
$_clientip = $_SERVER['REMOTE_ADDR'];

$_amount = number_format((float)20, 2, '.', ''); // kindly set this to the total amount of the transaction. Set the amount to 2 decimal point before generating signature.
$_currency = "PHP"; //PHP or USD

$forSign = $_mid . 
        $_requestid . 
        $_ipaddress . 
        $_noturl . 
        $_resurl .  
        $_fname . 
        $_lname . 
        $_mname . 
        $_addr1 . 
        $_addr2 . 
        $_city . 
        $_state . 
        $_country . 
        $_zip . 
        $_email . 
        $_phone . 
        $_clientip . 
        $_amount . 
        $_currency . 
        $_sec3d . 
        "xxxxxxxxxxxxxxxxxxxxxxxxxxx"; //<-- your merchant key


$_sign = hash("sha512", $forSign);


$strxml = "";
$strxml .= "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";

$strxml .= "<Request>";
    $strxml .= "<mid>" . $_mid . "</mid>";
    $strxml .= "<request_id>" . $_requestid . "</request_id>";
    $strxml .= "<ip_address>" . $_ipaddress . "</ip_address>";
    $strxml .= "<notification_url>" . $_noturl . "</notification_url>";
    $strxml .= "<response_url>" . $_resurl . "</response_url>";
    $strxml .= "<cancel_url>" . $_cancelurl . "</cancel_url>";
    $strxml .= "<mtac_url>".$_resurl."</mtac_url>"; // pls set this to the url where your terms and conditions are hosted
    $strxml .= "<descriptor_note></descriptor_note>"; // pls set this to the descriptor of the merchant ""
    $strxml .= "<fname>" . $_fname . "</fname>";
    $strxml .= "<lname>" . $_lname . "</lname>";
    $strxml .= "<mname>" . $_mname . "</mname>";
    $strxml .= "<address1>" . $_addr1 . "</address1>";
    $strxml .= "<address2>" . $_addr2 . "</address2>";
    $strxml .= "<city>" . $_city . "</city>";
    $strxml .= "<state>" . $_state . "</state>";
    $strxml .= "<country>" . $_country . "</country>";
    $strxml .= "<zip>" . $_zip . "</zip>";
    $strxml .= "<email>" . $_email . "</email>";
    $strxml .= "<phone>" . $_phone . "</phone>";
    $strxml .= "<mobile>" . $_mobile . "</mobile>";
    $strxml .= "<amount>" . $_amount . "</amount>";
    $strxml .= "<currency>" . $_currency . "</currency>";
    $strxml .= "<pmethod></pmethod>";
    $strxml .= "<expiry_limit></expiry_limit>";
    $strxml .= "<trxtype>Sale</trxtype>";
    $strxml .= "<client_ip>" . $_clientip . "</client_ip>";
    $strxml .= "<mlogo_url></mlogo_url>";// pls set this to the url where your logo is hosted

    // $item['name'] = 'item1';
    // $item['qty'] = 0;
    // $item['amount'] = 100.00;
    $amt = number_format((float)10, 2, '.', '');

    $strxml .= "<orders>";
        $strxml .= "<items>";
            // item 1
            $strxml .= "<Items>";
                $strxml .= "<itemname>item 1</itemname>";
                $strxml .= "<quantity>1</quantity>";
                $strxml .= "<amount>".$amt."</amount>";
            $strxml .= "</Items>";

            // item 2
            $strxml .= "<Items>";
                $strxml .= "<itemname>item 2</itemname>";
                $strxml .= "<quantity>1</quantity>";
                $strxml .= "<amount>".$amt."</amount>";
            $strxml .= "</Items>";
        $strxml .= "</items>";
    $strxml .= "</orders>";

    $strxml .= "<secure3d>" . $_sec3d . "</secure3d>";
    $strxml .= "<signature>" . $_sign . "</signature>";
$strxml .= "</Request>";


$b64string =  base64_encode($strxml);


 ?>

这是我的提交表格

代码语言:javascript
复制
<form name="surecollect" id="surecollect" method="post" action="https://testpti.payserv.net/webpaymentv2/default.aspx">
    <input type="hidden" name="paymentrequest" value="<?php echo $b64string; ?>">
    <input type="submit" name="submit" value="Submit">
</form>
EN

回答 2

Stack Overflow用户

发布于 2019-03-21 18:54:57

最近Paynamics有很多变化。请以此repl.it为例,将xxxx替换为Paynamics提供给enter code hereyou的密钥。paynamics.php

确保第41行等于$_amount。公式为Amount = <quantity /> * <amount />

票数 1
EN

Stack Overflow用户

发布于 2021-05-17 17:29:20

签名是密钥敏感的。你应该把所有字母都小写。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49915517

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档