无法告诉IPN是否正在工作,因为它没有写入sqlDatabase

时间:2019-04-10 17:44:01

标签: php html paypal paypal-ipn

由于服务器无法处理所有错误,因此我无法告知其是否正常工作,也无法查看错误,因为我对这些语言非常陌生。据我所知,贝宝沙箱发送了ipn,但我不确定在我知道的所有内容之后,它没有显示在数据库中。我知道密码,并且一切都已正确配置并且数据库已建立。即时消息也可以帮助我https://www.evoluted.net/thinktank/web-development/paypal-php-integration 我只是想让菜鸟陷入php才能正确地遵循它。

  

这是发送和接收ipn的脚本

file.c:23:10: fatal error: 'CoreFoundation/CFString.h' file not found
#include <CoreFoundation/CFString.h>
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  

这是addPayment函数

<?php
// For test payments we want to enable the sandbox mode. If you want to put live
// payments through then this setting needs changing to `false`.
$enableSandbox = true;
// Database settings. Change these for your database configuration.

$dbConfig = [
    'host' => 'sql106.epizy.com',
    'username' => 'hidden',
    'password' => 'hidden',
    'name' => 'epiz_23648301_rod'
];
// PayPal settings. Change these to your account details and the relevant URLs
// for your site.
$paypalConfig = [
    'email' => 'hidden@gmail.com',
    'return_url' => 'http://rod.rf.gd/payment-successful.php',
    'cancel_url' => 'http://rod.rf.gd/payment-cancelled.php',
    'notify_url' => 'http://rod.rf.gd/payments.php'
];
$paypalUrl = $enableSandbox ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr';
// Product being purchased.
$itemName = 'Token';
$itemAmount = 1;
// Include Functions
require 'functions.php';
// Check if paypal request or response
if (!isset($_POST["txn_id"]) && !isset($_POST["txn_type"])) {
    // Grab the post data so that we can set up the query string for PayPal.
    // Ideally we'd use a whitelist here to check nothing is being injected into
    // our post data.
    $data = [];
    foreach ($_POST as $key => $value) {
        $data[$key] = stripslashes($value);
    }
    // Set the PayPal account.
    $data['business'] = $paypalConfig['email'];
    // Set the PayPal return addresses.
    $data['return'] = stripslashes($paypalConfig['return_url']);
    $data['cancel_return'] = stripslashes($paypalConfig['cancel_url']);
    $data['notify_url'] = stripslashes($paypalConfig['notify_url']);
    // Set the details about the product being purchased, including the amount
    // and currency so that these aren't overridden by the form data.
    $data['item_name'] = $itemName;
    $data['amount'] = $itemAmount;
    $data['currency_code'] = 'USD';
    // Add any custom fields for the query string.
    //$data['custom'] = USERID;
    // Build the query string from the data.
    $queryString = http_build_query($data);
    // Redirect to paypal IPN
    header('location:' . $paypalUrl . '?' . $queryString);
    exit();
} else {



    // Handle the PayPal response.
    // Create a connection to the database.
    $db = new mysqli($dbConfig['host'], $dbConfig['username'], $dbConfig['password'], $dbConfig['name']);
    // Assign posted variables to local data array.
    $data = [
        'item_name' => $_POST['item_name'],
        'item_number' => $_POST['item_number'],
        'payment_status' => $_POST['payment_status'],
        'payment_amount' => $_POST['mc_gross'],
        'payment_currency' => $_POST['mc_currency'],
        'txn_id' => $_POST['txn_id'],
        'receiver_email' => $_POST['receiver_email'],
        'payer_email' => $_POST['payer_email'],
        'custom' => $_POST['custom'],
    ];
    // We need to verify the transaction comes from PayPal and check we've not
    // already processed the transaction before adding the payment to our
    // database.
    if (verifyTransaction($_POST) && checkTxnid($data['txn_id'])) {
        if (addPayment($data) !== false) {
            // Payment successfully added.
        }
    }
}

0 个答案:

没有答案