Ошибка: [16 мая 2018 22:16:06 UTC] Неустранимая ошибка PHP: необработанное исключение «Stripe \ Error \ InvalidRequest» с сообщением «Неверный исходный объект: должен бытьсловарь или непустая строка.См. Документы API по адресу https://stripe.com/docs'' в /home/autravelservice/public_html/wp-content/plugins/ats/libraries/stripe-php-6.0.0/lib/ApiRequestor.php:120 из запроса API 'req_6uGybuHR3adjqW'
Пожалуйста, посмотрите на меня, код, я что-то не так делаю?
// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
\Stripe\Stripe::setApiKey($sk);
// Token is created using Checkout or Elements!
// Get the payment token ID submitted by the form:
$token = $payment_details['token'];
//echo 'pay:' . $pay_amount;
// Create customer:
$i = 0;
foreach(get_field('applicant', $post_id) as $applicant) {
if($i++ == 0) {
$applicant_details = $applicant['applicant_details'];
$contact_details = $applicant['contact_details'];
$name_first = $applicant_details['first_name'];
$name_last = $applicant_details['last_name'];
$email = $contact_details['email'];
$user_info = array("First Name" => $name_first, "Last Name" => $name_last);
$customer = \Stripe\Customer::create(array(
"email" => $email,
"card" => $token,
"metadata" => $user_info
));
// Charge the user's card:
$charge = \Stripe\Charge::create(array(
"customer" => $customer->id,
"amount" => $pay_amount,
"currency" => "usd",
"description" => "Australian Travel Service"
));
}
}
if($charge->status == 'succeeded') {
$counter = range(1, 5);
$counter= shuffle($counter);
$orderid = 'AUS-CU-' . date('Ymd') . $post_id . $counter;
echo '<input type="hidden" name="orderid" id="app_order_id" value="'.$orderid.'">';
echo '<input type="hidden" id="applicant_count" value="'.$applicant_count.'">';
echo '<input type="hidden" id="processing_type" value="'.$processing_fee_type[0].'">';
echo '<input type="hidden" id="order_total" value="'.$pay_amount.'">';
appFormAdminMail($post_id, $orderid);
acf_form(array(
'id' => 'survey-form',
'post_id' => $post_id,
'field_groups' => array(158),
'return' => './survey-thank-you/?record=%post_id%',
'submit_value' => 'SUBMIT SURVEY',
'html_submit_button' => '<button type="submit" class="acf-btn red-btn rounded-btn">%s</button>'
));
} else {
echo 'Payment error...';
}