首页 > 解决方案 > paygate payweb3 在 php 网站中的集成

问题描述

我正在尝试将集成paygate payment gateway集成到我的PHP API. 我已经浏览了他们的文档,但对我来说还不清楚。有三个端点

  1. 发起
  2. 返回
  3. 询问

我不知道使用哪个端点。现在我正在使用启动端点,但是在邮递员中进行测试时出现错误

ERROR=DATA_CHK 错误

谁能指导我解决这个问题...

public function subscription(Request $request) {   
        $validator = Validator::make(
            $request->all(),
            array(
                 'subscription' => 'required|integer',
                 'email' => 'required|exists:users,email',
                 'amount' => 'required|integer',
                 'payment_mode' => 'required|integer',
            ),
            array(
                'exists' => 'The :attribute doesn\'t exists',
            )
        );

        if ($validator->fails()) {

            $error_messages = implode(',', $validator->messages()->all());

            $response_array = array('success' => false, 'error' => Helper::get_error_message(101), 'error_code' => 101, 'error_messages'=>$error_messages);

        } else {
                
                $encryptionKey = 'AQ2Uted8BidhkIEv6oYgrqwS'; 

                $data = array(
                    'PAYGATE_ID'        => 1039433100014,
                    'REFERENCE'         => 'pgtest_123456789',
                    'AMOUNT'            => 3299,
                    'CURRENCY'          => 'ZAR',
                    'RETURN_URL'        => 'http://localhost/avvata/public/home',
                    'TRANSACTION_DATE'  => date('Y-m-d H:i:s'),
                    'LOCALE'            => 'en-za',
                    'COUNTRY'           => 'ZAF',
                    'EMAIL'             => $request->email,
                );

                $checksum = md5(implode('', $data) . $encryptionKey);

                $data['CHECKSUM'] = $checksum;

                $fieldsString = http_build_query($data);

                //open connection
                $ch = curl_init();

                //set the url, number of POST vars, POST data
                curl_setopt($ch, CURLOPT_URL, 'https://secure.paygate.co.za/payweb3/initiate.trans');
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($ch, CURLOPT_NOBODY, false);
                curl_setopt($ch, CURLOPT_REFERER, $_SERVER['HTTP_HOST']);
                curl_setopt($ch, CURLOPT_POST, true);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $fieldsString);

                //execute post
                $result = curl_exec($ch);
                 echo  $result;
                 exit();
                //close connection
                curl_close($ch); 
}`

提前致谢 :-)

标签: phplaravelpayment-gateway

解决方案


推荐阅读