PHP致命错误:eu_增值税条带支付网关的未捕获(状态400)无效值

PHP致命错误:eu_增值税条带支付网关的未捕获(状态400)无效值,php,stripe-payments,Php,Stripe Payments,我根据stripe库编码,但我有一个404: [Wed Nov 25 09:35:26.2020][php7:error][pid 7014][client]PHP致命错误:未捕获(状态400)(请求请求请求…)欧盟增值税的值无效。\N在第38行的/home/http/data/https://.fr/wp-content/themes/sq/stripe-php-master/lib/Exception/apierroexception.php中抛出,参考:https://**.fr/chec

我根据stripe库编码,但我有一个404:

[Wed Nov 25 09:35:26.2020][php7:error][pid 7014][client]PHP致命错误:未捕获(状态400)(请求请求请求…)欧盟增值税的值无效。\N在第38行的/home/http/data/https://.fr/wp-content/themes/sq/stripe-php-master/lib/Exception/apierroexception.php中抛出,参考:https://**.fr/checkout/

 // STRIPE STRIPE STRIPE
<?php
    require_once('./stripe-php-master/init.php');

    $stripe = new \Stripe\StripeClient("sk_test_--------");
    $curl = new \Stripe\HttpClient\CurlClient([CURLOPT_PROXY => '*****:3128']);
    \Stripe\ApiRequestor::setHttpClient($curl);
    $address_line_1 = $_COOKIE["billing_address_1"];
    $phone = $_COOKIE["billing_phone"];
    $first_name = $_COOKIE["billing_first_name"];
    $last_name = $_COOKIE["billing_last_name"];
    $siret = $_COOKIE["billing_siret"];
    $TaxId = $_COOKIE["billing_TaxId"] ? $_COOKIE["billing_TaxId"] : ($_POST['TaxId'] ? $_POST['TaxId'] : NULL);
    $email = $_COOKIE["billing_email"];
   
    $cart = !empty($_COOKIE['cart']) ? $_COOKIE['cart'] : NULL;
     $billing_country = !empty($_COOKIE['billing_country']) ? $_COOKIE['billing_country'] : NULL;
    // $country = $_COOKIE["billing_country"];
    $company_name = $_COOKIE["billing_company"];
    // If Allemagne - Belgique - Autriche - Bosnie herzegovie - Russie - Suisse -> state mandatory
    $state = $_COOKIE["billing_state"];
    $post_code = $_COOKIE["billing_postcode"];
    $city = $_COOKIE["billing_city"];
    $stripe_token = !empty($_COOKIE['stripe_token']) ? $_COOKIE['stripe_token'] : NULL;
    // $stripe_token = $_COOKIE["stripe_tkn"];
    $arrival_date = !empty($_COOKIE['arrival_date']) ? $_COOKIE['arrival_date'] : NULL;
    // $arrival_date = $_COOKIE["arrival_date"];
    $engagement_period = !empty($_COOKIE['engagement_period']) ? $_COOKIE['engagement_period'] : NULL;
    // $engagement_period = $_COOKIE["engagement_period"];
    $monthly_frequency = !empty($_COOKIE['monthly_frequency']) ? $_COOKIE['monthly_frequency'] : NULL;
    // $monthly_frequency = $_COOKIE["monthly_frequency"];
    $quantity_office = !empty($_COOKIE['quantity_office']) ? $_COOKIE['quantity_office'] : NULL;
    // $quantity_office = $_COOKIE["quantity_office"];
    $parking_spot = !empty($_COOKIE['parking_spot']) ? $_COOKIE['parking_spot'] : NULL;
    // $parking_spot = $_COOKIE["parking_spot"];
    $price_str = $_COOKIE["price"];

    $created_customer = $stripe->customers->create([
        'address' => [
            'line1' => $address_line_1,
            'country' => $country,
            'state' => $state,
            'city' => $city,
        ],
        'email' => $email,
        'phone' => $phone,
        'metadata' => [
            'Periode_engagement' => $engagement_period,
            'Frequence_mensuelle' => $monthly_frequency,
            'Nombre_poste' => $quantity_office,
            'Place_parking' => $parking_spot,
        ],
        'name' => $company_name,
        'description' => $company_name,
        'invoice_settings' => [
            'custom_fields' => [
                [
                    'name' => 'SIRET',
                    'value' => 'FRAB123456789',
                ],
            ],
        ],
    ]);

    $customer_id = $created_customer->id;

    $tax_id = $stripe->customers->createTaxId(
        $created_customer->id,
        [
            'type' => 'eu_vat',
            'value' => $TaxId,
        ]
    );

    $customer_card = $stripe->customers->createSource(
        $customer_id,
        ['source' => $stripe_token]
    );

    $engagement_number = (int) filter_var($engagement_period, FILTER_SANITIZE_NUMBER_INT);
    $final_price = floatval(str_replace(',', '.', str_replace('.', '', $price_str))) / $engagement_number;
    $price = $stripe->prices->create([
        'currency' => 'eur',
        'unit_amount' => $final_price,
        'recurring' => [
            'interval' => 'month'
        ],
        'product_data' => [
            'name' => 'NS Subscription'
        ]
    ]);

    $engagement_period_string = "first day of +".$engagement_number." month";
    $date = new DateTime('now');
    $nowTimestamp = $date->getTimestamp();
    $date->modify('first day of next month');
    $firstDayOfNextMonthTimestamp = $date->getTimestamp();
    // check month subscriptions for cancel date

    $date_end = new DateTime('now');
    $date_end->modify($engagement_period_string);
    $cancel_date_timestamp = $date_end->getTimestamp();

    $sub = $stripe->subscriptions->create([
        'customer' => $customer_id,
        'items' => [
            [
                'price' => $price->id
            ],
        ],
        'billing_cycle_anchor' => $firstDayOfNextMonthTimestamp,
        'cancel_at' => $cancel_date_timestamp
    ]);
?>
//条带
它在本地工作,但是一旦在线,在相同的PHP版本下,我们就有一个bug。我承认我不明白。如果有人有解决方案


谢谢大家,

此错误是由于使用给定的stripe API版本升级 ,税号的行为发生了变化


检查您的本地和beta stripe API版本。如果版本相同,请将createTaxId调用包含在InvalidRequestException try catch块中

那里有很多代码,您没有通过包含所有注释掉的内容来简化阅读。您是否检查/调试了
$TaxId
值?它似乎设置了一个堆叠的三元表达式,因为它很容易出错。你确定这一切正常吗?税务ID
是必需的,但堆叠的三元代码似乎允许
,这可能解释了问题?可能您传递给
$TaxId
的任何值在某种程度上都是无效的,比如它不是真正的增值税ID,或者它的格式不正确,并且与当前的格式不匹配。首先,我要对代码进行注释,以便准确地记录您传递的值。