true, "message" => "Ошибка" ]; if (!$error && count($data)) { $SITE_URL = $data['tildaspec-formid']; $formid = $data['tildaspec-formid']; $pageid = $data['tildaspec-pageid']; $projectid = $data['tildaspec-projectid']; $leadid = $data['leadid']; $orderid = $data['orderid']; $id = "orderid-{$orderid}"; $payment = json_decode($data['payment']); $currency = strtolower($payment->currency); $requestData = [ 'data' => [ 'type' => 'payment-invoices', 'attributes' => [ 'reference_id' => $id, 'service' => "payment_card_rub_hpp", 'currency' => 'RUB' , 'amount' => $payment->amount, 'description' => "Заявка на оплату. Номер заявки: {$orderid}", 'customer' => [ 'reference_id' => "beautyetc_{$id}", 'name' => $data['Name'], 'email' => $data['Email'] ], 'gateway_options' => [ 'cardgate' => [ 'theme_options' => [ 'locale' => 'ru' ] ] ] ] ] ]; if(isset($data['leadid']) && $data['leadid']){ $requestData['data']['attributes']['metadata']['leadid'] = $data['leadid']; } if(isset($data['orderid']) && $data['orderid']){ $requestData['data']['attributes']['metadata']['orderid'] = $data['orderid']; } if(isset($data['tildaspec-pageid']) && $data['tildaspec-pageid']){ $requestData['data']['attributes']['metadata']['pageid'] = $data['tildaspec-pageid']; } if(isset($data['tildaspec-projectid']) && $data['tildaspec-projectid']){ $requestData['data']['attributes']['metadata']['projectid'] = $data['tildaspec-projectid']; } if(isset($data['tildaspec-formid']) && $data['tildaspec-formid']){ $requestData['data']['attributes']['metadata']['formid'] = $data['tildaspec-formid']; } if(isset($data['Phone']) && $data['Phone']){ $requestData['data']['attributes']['customer']['phone'] = $data['Phone']; } if(isset($data['Страна']) && $data['Страна']){ $requestData['data']['attributes']['metadata']['country'] = $data['Страна']; } if(isset($data['Город']) && $data['Город']){ $requestData['data']['attributes']['metadata']['city'] = $data['Город']; } if(isset($data['Улица']) && $data['Улица']){ $requestData['data']['attributes']['metadata']['street'] = $data['Улица']; } if(isset($data['Номер дома']) && $data['Номер дома']){ $requestData['data']['attributes']['metadata']['house'] = $data['Номер дома']; } if(isset($data['Номер квартиры']) && $data['Номер квартиры']){ $requestData['data']['attributes']['metadata']['flat'] = $data['Номер квартиры']; } if(isset($data['Почтовый индекс']) && $data['Почтовый индекс']){ $requestData['data']['attributes']['metadata']['index'] = $data['Почтовый индекс']; } if(isset($data['tildaspec-referer']) && $data['tildaspec-referer']){ $requestData['data']['attributes']['metadata']['from'] = $data['tildaspec-referer']; } try { $payload = json_encode($requestData); $ch = curl_init('https://api.payelata.com/payment-invoices'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLINFO_HEADER_OUT, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', 'Accept: application/json', 'Content-Length: ' . strlen($payload), 'Authorization: Basic ' . base64_encode('coma_z2GbCkCsuUTVJMya:zTM3dg2rxZncpQJXutXkQTDQGOVe-m1pFnpm5kD3abk') ] ); $result = json_decode(curl_exec($ch)); curl_close($ch); $response = [ 'message' => $result->data->attributes->flow_data->action, 'error' => false ]; } catch (Exception $exception) { $response['message'] = 'Ошибка создания платежа'; } } echo json_encode($response);