首页 > 解决方案 > 是什么导致我的支付网关设置失败?

问题描述

<!doctype html>
<html class="no-js" lang="zxx">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="meta description">
    <!-- Favicons -->


    <!-- Title -->
    <title>Dar Al Maaref</title>

    <script src="https://ap-gateway.mastercard.com/checkout/version/55/checkout.js"
            data-error="errorCallback"
            data-cancel="cancelCallback"
            data-complete="http://localhost/ebook/receiptPage.php">
    </script>
    
</head>

<body>
        <!-- Main Content Wrapper Start -->

       <div id="content" class="main-content-wrapper">
            <div class="page-content-inner">
                <div class="container">
                   <div class="col-xl-12  col-lg-6 mt-md--40 pt--50" style="padding-bottom: 80px;">
                            <div class="order-details">
                                <div class="checkout-title mt--10">
                                    <h2>Your Order</h2>
                                </div>
                                <div class="table-content table-responsive mb--30">
                                    <table class="table order-table order-table-2">
                                        <thead>
                                            <tr>
                                                <th>Product</th>
                                                <th class="text-right">Total</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php 

                                            for ($i=0; $i < sizeof($cart); $i++) { 

                                                $stmt = $conn->prepare("SELECT *  FROM book WHERE id=?");
                                                $stmt->bind_param("s",$prid);
                                                $prid=$cart[$i]['prid'];
                                                    $stmt->execute();
                                                $result = $stmt->get_result();
                                         if ($result->num_rows > 0) {
                                                    while($row = $result->fetch_assoc()){
                                                    
                                                        $book[]=$row;
                                                          
                                                    }
                                                        
                                                }



                                           

                                            ?>

                                            <tr>
                                                <th><?php
                                if ($language=="FR") {
                                    echo $book[$i]['namefr'];
                                    
                                }else if($language=="AR"){
                                    echo $book[$i]['namear'];

                                }else{
                                    echo $book[$i]['name'];
                                }
                                ?>
                                                    
                                                </th>
                                                <td class="text-right">$<?php echo $book[$i]['price']; ?></td>

                                            </tr>
                                        <?php   $price = $book[$i]['price'] +$price;                                        
                                                $ship = 20;
                                                $tot = $price + $ship;
                                } ?>
                                        </tbody>
                                        <tfoot>
                                            <tr class="cart-subtotal">
                                                <th>Subtotal</th>
                                                <td class="text-right">$<?php echo $price; ?></td>
                                            </tr>
                                            <tr class="shipping">
                                                <th>Shipping</th>
                                                <td class="text-right">
                                                    <span>Flat Rate; $<?php echo $ship?></span>
                                                </td>
                                            </tr>
                                            <tr class="order-total">
                                                <th>Order Total</th>
                                                <td class="text-right"><span class="order-total-amount">$<?php echo $tot;?></span>
                                                </td>
                                            </tr>
                                        </tfoot>
                                    </table>
                                </div>
                                <div class="checkout-payment">                                    
                                    <div class="payment-group mt--20">
                                        <p class="mb--15">Your personal data will be used to process your order,
                                            support your experience throughout this website, and for other purposes
                                            described in our privacy policy.</p>
                                        <input type="button" value="Pay with Lightbox" onclick="Checkout.showLightbox();" />
                                        <input type="button" value="Pay with Payment Page" onclick="Checkout.showPaymentPage();" />
                                    </div>                                    
                                </div>
                            </div>
                        </div>
                </div>
            </div>
        </div>
        <script type="text/javascript">
            function errorCallback(error) {
                  console.log(JSON.stringify(error));
            }
            function cancelCallback() {
                  console.log('Payment cancelled');
            }
            
            Checkout.configure({
                merchant:'<my_merchanid_id>', //I've updated it on my server.
                order: {
                    amount: <?php echo $tot;?>,
                    currency: 'USD',
                    description: 'Ordered goods',
                    id: '1'
                    },
                    session: {
                      id: '<?php echo md5(1)?>'
                    },
                interaction: {
                    operation: 'PURCHASE',
                    merchant: {
                        name: 'Dar Al Maaref',
                        address: {
                            line1: '200 Sample St',
                            line2: '1234 Example Town'     
                        }    
                    }
                }
            });
        </script>
        <!-- Main Content Wrapper Start -->


       
    <!-- Main Wrapper End -->


</body>

</html>

截图

以上是我的代码,我无法设置我的支付网关。

当我点击支付按钮时,它说:

{cause:INVALID_REQUEST,explanation:Form Session not found or expired.}万事达卡支付网关。

我正在使用areeba 支付网关

我有一个商家 ID,我填写了测试服务器,但我不知道将 api 密码放在哪里。

参考网址

标签: javascriptphppayment-gatewaymastercard

解决方案


在您开始付款之前,请获取sessionId并将其插入Checkout.Configure函数 ( order.session.Id)。

以下是获取会话的方法:

curl https://ap-gateway.mastercard.com/api/nvp/version/55 \
-d "apiOperation=CREATE_CHECKOUT_SESSION" \
-d "apiPassword=$PWD" \
-d "apiUsername=merchant.<your_merchant_id>" \
-d "merchant=<your_merchant_id>" \
-d "interaction.operation=PAY" \
-d "order.id=<unique_order_id>" \
-d "order.amount=100.00" \
-d "order.currency=USD"

在此处查看 MPGS 文档


推荐阅读