'POST', 'headers' => [ "Accept" => "application/json", "Content-Type" => "application/json", "Authorization" => "JWS-AUTH-TOKEN " . JWT::createToken($projectId, $projectSecret) ], 'body' => json_encode([ "amount" => $order->get_total(), "referenceId" => (string)$orderId, "returnUrl" => "https://acceptcoin.io", "callBackUrl" => filter_var("https://" . sanitize_text_field($_SERVER['HTTP_HOST']) . "/wc-api/" . sanitize_text_field($id), FILTER_SANITIZE_STRING, FILTER_SANITIZE_URL) ]) ] ); if (!$response['body']) { throw new Exception('Acceptcoin: missing response body.'); } $responseData = json_decode($response['body'], true); if ($response['response']['code'] !== self::SUCCESS_CREATE_CODE) { throw new Exception('Acceptcoin: Failed to place the order. Check plugin settings or call the support.'); } if (!isset($responseData['link'])) { throw new Exception('Acceptcoin: Not found response link.'); } return $responseData['link']; } }