【问题标题】:local payment api failed to verify the transaction using php本地支付api使用php验证交易失败
【发布时间】:2020-11-14 15:15:15
【问题描述】:

这是https://www.cashmaal.com/api提供的API,我在我的cashmaal账户中存了一些现金,当我尝试通过交易ID验证付款时,我得到的交易ID显示错误

错误:错误!交易 ID () 无效。

$web_id="";   // Your Web ID here (you can found this on cashmaal account where you add site) 

if(isset($_POST['CM_TID'])) {

    $CM_TID=$_POST['CM_TID'];   // getting TID with user redirection   
    
    $url="https://www.cashmaal.com/Pay/verify_v2.php?CM_TID=".urlencode($CM_TID)."&web_id=".urlencode($web_id);
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_URL, $url);
    $result = curl_exec($ch);
    curl_close($ch);
    
    $obj = json_decode($result,true);
    
    if($obj['status'] == 1)
    { // it means payment received....
        
        //response format in JSON
        //Example Response
        /*
           {"status":"1","receiver_account":"8","USD_amount":"1.670","fee_in_USD":"0.000","PKR_amount":"280","fee_in_PKR":"0","USD_amount_with_fee":"1.670","PKR_amount_with_fee":"280","trx_website":"website.com","transaction_id":"2JW9651118P","trx_date":"25-03-2020 9:13:48 PM","order_id":"12345678","addi_info":"Test Payment","sender_details":"Fund Received From 161919","trx_details":"$1.67 Receive against TID: '2JW9651118P'"}
         
         */
        // Verify All things and Confirm user order here
        
        if($obj['USD_amount'] == '2')
        {         
            echo 'we received your payment';
        }
        else
        {
            echo "we didn't received the your mentioned payment ";
        }
    }
    else
    {
        echo "Error:".$obj['error'];
    }
}

【问题讨论】:

  • 这个api是一个交易回调,你是怎么做交易和获取交易id的,请分享一下代码以便更好的理解,
  • 没有更多代码,我只是通过表单发送交易 ID 并尝试验证它是有效还是无效。

标签: php api curl payment


【解决方案1】:

刚刚找到了一个解决方案,这个cashmaal api仅在交易由其他cashmaal帐户完成时才验证交易ID

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-11-02
    • 2014-06-13
    • 2014-09-28
    • 1970-01-01
    • 2019-01-04
    • 2011-07-04
    • 2021-09-30
    相关资源
    最近更新 更多