mirror of
https://github.com/aljazceru/breez-woocommerce.git
synced 2025-12-18 22:44:22 +01:00
fixed checkout status
This commit is contained in:
@@ -114,6 +114,10 @@ function breez_wc_init() {
|
|||||||
require_once $full_path;
|
require_once $full_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add hooks for payment instructions on order received page
|
||||||
|
add_action('woocommerce_thankyou_breez', 'breez_wc_thankyou_payment_instructions', 10);
|
||||||
|
add_action('woocommerce_order_details_after_order_table', 'breez_wc_order_received_payment_instructions', 10);
|
||||||
|
|
||||||
// Verify WooCommerce settings
|
// Verify WooCommerce settings
|
||||||
if (!get_option('woocommerce_currency')) {
|
if (!get_option('woocommerce_currency')) {
|
||||||
throw new Exception('WooCommerce currency not configured');
|
throw new Exception('WooCommerce currency not configured');
|
||||||
@@ -682,31 +686,67 @@ function breez_wc_filter_blocks_checkout_order_data($order, $request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display payment instructions on the payment page
|
* Display payment instructions on the thank you page
|
||||||
*/
|
*/
|
||||||
function breez_wc_display_payment_instructions() {
|
function breez_wc_thankyou_payment_instructions($order_id) {
|
||||||
if (!isset($_GET['show_payment']) || !isset($_GET['order_id'])) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$order_id = absint($_GET['order_id']);
|
|
||||||
$order = wc_get_order($order_id);
|
$order = wc_get_order($order_id);
|
||||||
|
|
||||||
if (!$order || $order->get_payment_method() !== 'breez') {
|
if (!$order || $order->get_payment_method() !== 'breez' || $order->has_status('processing')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify order key
|
// Get payment details from database
|
||||||
if (!isset($_GET['key']) || $_GET['key'] !== $order->get_order_key()) {
|
$db_manager = new Breez_DB_Manager();
|
||||||
|
$payment = $db_manager->get_payment_by_order($order_id);
|
||||||
|
|
||||||
|
if (!$payment) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gateway instance
|
// Load the payment instructions template
|
||||||
$gateways = WC()->payment_gateways->payment_gateways();
|
wc_get_template(
|
||||||
$gateway = isset($gateways['breez']) ? $gateways['breez'] : null;
|
'payment-instructions.php',
|
||||||
|
array(
|
||||||
if ($gateway) {
|
'order' => $order,
|
||||||
$gateway->payment_page($order_id);
|
'invoice_id' => $payment['invoice_id'],
|
||||||
}
|
'payment_method' => $payment['metadata']['payment_method'],
|
||||||
|
'expiry' => $payment['metadata']['expires_at'],
|
||||||
|
'current_time' => time(),
|
||||||
|
'payment_status' => $payment['status']
|
||||||
|
),
|
||||||
|
'',
|
||||||
|
BREEZ_WC_PLUGIN_DIR . 'templates/'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display payment instructions on the order received page
|
||||||
|
*/
|
||||||
|
function breez_wc_order_received_payment_instructions($order) {
|
||||||
|
if (!$order || $order->get_payment_method() !== 'breez' || $order->has_status('processing')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get payment details from database
|
||||||
|
$db_manager = new Breez_DB_Manager();
|
||||||
|
$payment = $db_manager->get_payment_by_order($order->get_id());
|
||||||
|
|
||||||
|
if (!$payment) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load the payment instructions template
|
||||||
|
wc_get_template(
|
||||||
|
'payment-instructions.php',
|
||||||
|
array(
|
||||||
|
'order' => $order,
|
||||||
|
'invoice_id' => $payment['invoice_id'],
|
||||||
|
'payment_method' => $payment['metadata']['payment_method'],
|
||||||
|
'expiry' => $payment['metadata']['expires_at'],
|
||||||
|
'current_time' => time(),
|
||||||
|
'payment_status' => $payment['status']
|
||||||
|
),
|
||||||
|
'',
|
||||||
|
BREEZ_WC_PLUGIN_DIR . 'templates/'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
add_action('woocommerce_receipt_breez', 'breez_wc_display_payment_instructions');
|
|
||||||
|
|||||||
@@ -254,100 +254,79 @@ class WC_Gateway_Breez extends WC_Payment_Gateway {
|
|||||||
*/
|
*/
|
||||||
protected function get_available_payment_methods() {
|
protected function get_available_payment_methods() {
|
||||||
if (empty($this->payment_methods)) {
|
if (empty($this->payment_methods)) {
|
||||||
return ['lightning']; // Default to lightning if nothing is set
|
return ['LIGHTNING']; // Default to LIGHTNING if nothing is set
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($this->payment_methods)) {
|
if (is_array($this->payment_methods)) {
|
||||||
return array_filter(array_map('trim', $this->payment_methods));
|
return array_map(function($method) {
|
||||||
|
return strtoupper(trim($method));
|
||||||
|
}, $this->payment_methods);
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_filter(array_map('trim', explode(',', $this->payment_methods)));
|
return array_map(function($method) {
|
||||||
|
return strtoupper(trim($method));
|
||||||
|
}, explode(',', $this->payment_methods));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process the payment and return the result
|
* Process the payment
|
||||||
*
|
*
|
||||||
* @param int $order_id
|
* @param int $order_id
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function process_payment($order_id) {
|
public function process_payment($order_id) {
|
||||||
try {
|
try {
|
||||||
$this->logger->log("Processing payment for order #$order_id", 'debug');
|
|
||||||
|
|
||||||
$order = wc_get_order($order_id);
|
$order = wc_get_order($order_id);
|
||||||
if (!$order) {
|
if (!$order) {
|
||||||
throw new Exception(__('Order not found', 'breez-woocommerce'));
|
throw new Exception(__('Order not found', 'breez-woocommerce'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for existing payment in database
|
$this->logger->log("Processing payment for order #$order_id", 'debug');
|
||||||
$existing_payment = $this->db_manager->get_payment_by_order($order_id);
|
|
||||||
$current_time = time();
|
// Get payment method from request
|
||||||
|
|
||||||
if ($existing_payment && $existing_payment['status'] === 'pending') {
|
|
||||||
$payment_created = strtotime($existing_payment['created_at']);
|
|
||||||
$expiry_time = $payment_created + ($this->expiry_minutes * 60);
|
|
||||||
|
|
||||||
if ($current_time < $expiry_time) {
|
|
||||||
$this->logger->log("Using existing valid payment for order #$order_id", 'debug');
|
|
||||||
return array(
|
|
||||||
'result' => 'success',
|
|
||||||
'redirect' => $this->get_return_url($order)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the selected payment method
|
|
||||||
$payment_method = $this->get_payment_method_from_request();
|
$payment_method = $this->get_payment_method_from_request();
|
||||||
|
|
||||||
// Check for blocks payment data in order meta
|
// Get order details
|
||||||
$blocks_payment_data = $order->get_meta('_breez_blocks_payment_data');
|
|
||||||
if (!$payment_method && $blocks_payment_data) {
|
|
||||||
$this->logger->log("Found blocks payment data in order meta", 'debug');
|
|
||||||
$data = is_string($blocks_payment_data) ? json_decode($blocks_payment_data, true) : $blocks_payment_data;
|
|
||||||
if (is_array($data) && isset($data['breez_payment_method'])) {
|
|
||||||
$payment_method = sanitize_text_field($data['breez_payment_method']);
|
|
||||||
$this->logger->log("Using payment method from blocks data: $payment_method", 'debug');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$payment_method) {
|
|
||||||
throw new Exception(__('No payment method selected', 'breez-woocommerce'));
|
|
||||||
}
|
|
||||||
$this->logger->log("Selected payment method: $payment_method", 'debug');
|
|
||||||
|
|
||||||
// Validate payment method
|
|
||||||
$available_methods = $this->get_available_payment_methods();
|
|
||||||
if (!in_array($payment_method, $available_methods)) {
|
|
||||||
throw new Exception(__('Invalid payment method', 'breez-woocommerce'));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the order total and convert to satoshis
|
|
||||||
$order_total = $order->get_total();
|
$order_total = $order->get_total();
|
||||||
$currency = $order->get_currency();
|
$currency = $order->get_currency();
|
||||||
|
|
||||||
// Get exchange rate and convert to satoshis
|
// Get exchange rate
|
||||||
$exchange_rate_response = $this->client->request('GET', "/exchange_rates/{$currency}");
|
$exchange_rate_response = $this->client->request('GET', "/exchange_rates/{$currency}");
|
||||||
|
$this->logger->log("Exchange rate response: " . print_r($exchange_rate_response, true), 'debug');
|
||||||
|
|
||||||
if (!$exchange_rate_response || !isset($exchange_rate_response['rate'])) {
|
if (!$exchange_rate_response || !isset($exchange_rate_response['rate'])) {
|
||||||
throw new Exception(__('Failed to get exchange rate', 'breez-woocommerce'));
|
throw new Exception(__('Failed to get exchange rate', 'breez-woocommerce'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Calculate amount in satoshis
|
||||||
|
// The exchange rate is in fiat/BTC, so we need to:
|
||||||
|
// 1. Convert order total to BTC by dividing by the rate
|
||||||
|
// 2. Convert BTC to satoshis
|
||||||
$btc_amount = $order_total / $exchange_rate_response['rate'];
|
$btc_amount = $order_total / $exchange_rate_response['rate'];
|
||||||
$amount_sat = (int)($btc_amount * 100000000); // Convert BTC to sats
|
$amount_sat = (int)round($btc_amount * 100000000);
|
||||||
|
|
||||||
$this->logger->log("Order total: {$order_total} {$currency}, Amount in sats: {$amount_sat}", 'debug');
|
// Validate amount is within reasonable range (1000 to 100000000 sats)
|
||||||
|
if ($amount_sat < 1000 || $amount_sat > 100000000) {
|
||||||
if ($amount_sat <= 0) {
|
throw new Exception(sprintf(
|
||||||
throw new Exception(__('Invalid amount conversion', 'breez-woocommerce'));
|
__('Invalid payment amount calculated: %d sats. Please check exchange rate calculation.', 'breez-woocommerce'),
|
||||||
|
$amount_sat
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create payment request
|
$this->logger->log("Exchange rate calculation:", 'debug');
|
||||||
|
$this->logger->log("Order total ({$currency}): {$order_total}", 'debug');
|
||||||
|
$this->logger->log("Exchange rate ({$currency}/BTC): {$exchange_rate_response['rate']}", 'debug');
|
||||||
|
$this->logger->log("BTC amount: {$btc_amount}", 'debug');
|
||||||
|
$this->logger->log("Final amount (sats): {$amount_sat}", 'debug');
|
||||||
|
|
||||||
|
// Prepare payment data
|
||||||
$payment_data = array(
|
$payment_data = array(
|
||||||
'amount' => $amount_sat,
|
'amount' => $amount_sat,
|
||||||
'method' => $payment_method === 'onchain' ? 'BITCOIN_ADDRESS' : 'LIGHTNING',
|
'method' => $payment_method,
|
||||||
'description' => sprintf(__('Payment for order #%s', 'breez-woocommerce'), $order->get_order_number())
|
'description' => sprintf(__('Order #%s', 'breez-woocommerce'), $order->get_order_number()),
|
||||||
|
'source' => 'woocommerce'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Log the payment data being sent
|
|
||||||
$this->logger->log("Creating payment with data: " . print_r($payment_data, true), 'debug');
|
$this->logger->log("Creating payment with data: " . print_r($payment_data, true), 'debug');
|
||||||
|
|
||||||
// Create the payment
|
// Create the payment
|
||||||
@@ -402,21 +381,14 @@ class WC_Gateway_Breez extends WC_Payment_Gateway {
|
|||||||
// Empty cart
|
// Empty cart
|
||||||
WC()->cart->empty_cart();
|
WC()->cart->empty_cart();
|
||||||
|
|
||||||
// Return success with redirect to payment instructions page
|
// Store payment URL in order meta
|
||||||
$redirect_url = add_query_arg(
|
$order->update_meta_data('_breez_payment_url', $response['destination']);
|
||||||
array(
|
$order->save();
|
||||||
'order_id' => $order->get_id(),
|
|
||||||
'key' => $order->get_order_key(),
|
|
||||||
'show_payment' => true
|
|
||||||
),
|
|
||||||
$order->get_checkout_payment_url(true)
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->logger->log("Redirecting to payment page: $redirect_url", 'debug');
|
|
||||||
|
|
||||||
|
// Return success and redirect to order received page
|
||||||
return array(
|
return array(
|
||||||
'result' => 'success',
|
'result' => 'success',
|
||||||
'redirect' => $redirect_url
|
'redirect' => $order->get_checkout_order_received_url()
|
||||||
);
|
);
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
@@ -438,7 +410,7 @@ class WC_Gateway_Breez extends WC_Payment_Gateway {
|
|||||||
public function get_payment_method_from_request() {
|
public function get_payment_method_from_request() {
|
||||||
// Priority 1: Direct POST parameter for breez_payment_method (from blocks)
|
// Priority 1: Direct POST parameter for breez_payment_method (from blocks)
|
||||||
if (isset($_POST['breez_payment_method'])) {
|
if (isset($_POST['breez_payment_method'])) {
|
||||||
$method = sanitize_text_field($_POST['breez_payment_method']);
|
$method = strtoupper(sanitize_text_field($_POST['breez_payment_method']));
|
||||||
$this->logger->log("Payment method found in direct POST: $method", 'debug');
|
$this->logger->log("Payment method found in direct POST: $method", 'debug');
|
||||||
return $method;
|
return $method;
|
||||||
}
|
}
|
||||||
@@ -462,7 +434,7 @@ class WC_Gateway_Breez extends WC_Payment_Gateway {
|
|||||||
|
|
||||||
// Extract payment method
|
// Extract payment method
|
||||||
if (is_array($raw_data) && isset($raw_data['breez_payment_method'])) {
|
if (is_array($raw_data) && isset($raw_data['breez_payment_method'])) {
|
||||||
$method = sanitize_text_field($raw_data['breez_payment_method']);
|
$method = strtoupper(sanitize_text_field($raw_data['breez_payment_method']));
|
||||||
$this->logger->log("Payment method found in payment_data: $method", 'debug');
|
$this->logger->log("Payment method found in payment_data: $method", 'debug');
|
||||||
return $method;
|
return $method;
|
||||||
}
|
}
|
||||||
@@ -473,7 +445,7 @@ class WC_Gateway_Breez extends WC_Payment_Gateway {
|
|||||||
if (isset($_POST['wc-breez-payment-data'])) {
|
if (isset($_POST['wc-breez-payment-data'])) {
|
||||||
$blocks_data = json_decode(wp_unslash($_POST['wc-breez-payment-data']), true);
|
$blocks_data = json_decode(wp_unslash($_POST['wc-breez-payment-data']), true);
|
||||||
if (is_array($blocks_data) && isset($blocks_data['breez_payment_method'])) {
|
if (is_array($blocks_data) && isset($blocks_data['breez_payment_method'])) {
|
||||||
$method = sanitize_text_field($blocks_data['breez_payment_method']);
|
$method = strtoupper(sanitize_text_field($blocks_data['breez_payment_method']));
|
||||||
$this->logger->log("Payment method found in blocks data: $method", 'debug');
|
$this->logger->log("Payment method found in blocks data: $method", 'debug');
|
||||||
return $method;
|
return $method;
|
||||||
}
|
}
|
||||||
@@ -481,7 +453,7 @@ class WC_Gateway_Breez extends WC_Payment_Gateway {
|
|||||||
|
|
||||||
// Default fallback
|
// Default fallback
|
||||||
$available_methods = $this->get_available_payment_methods();
|
$available_methods = $this->get_available_payment_methods();
|
||||||
$default_method = reset($available_methods); // Get first available method
|
$default_method = strtoupper(reset($available_methods)); // Get first available method
|
||||||
$this->logger->log("Using default payment method: $default_method", 'debug');
|
$this->logger->log("Using default payment method: $default_method", 'debug');
|
||||||
return $default_method;
|
return $default_method;
|
||||||
}
|
}
|
||||||
@@ -531,17 +503,18 @@ class WC_Gateway_Breez extends WC_Payment_Gateway {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check current payment status
|
// Check current payment status (API status is in UPPERCASE)
|
||||||
$payment_status = 'pending';
|
$api_payment_status = 'PENDING';
|
||||||
try {
|
try {
|
||||||
$payment_status = $this->client->check_payment_status($invoice_id);
|
$status_response = $this->client->check_payment_status($invoice_id);
|
||||||
$this->logger->log("Current payment status for order #$order_id: $payment_status", 'debug');
|
$api_payment_status = $status_response['status'];
|
||||||
|
$this->logger->log("Current API payment status for order #$order_id: $api_payment_status", 'debug');
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->logger->log("Error checking payment status: " . $e->getMessage(), 'error');
|
$this->logger->log("Error checking payment status: " . $e->getMessage(), 'error');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update order status if needed
|
// Update order status if needed (WooCommerce status is in lowercase)
|
||||||
if ($payment_status === 'SUCCEEDED' && $order->get_status() === 'pending') {
|
if (($api_payment_status === 'SUCCEEDED' || $api_payment_status === 'WAITING_CONFIRMATION') && $order->get_status() === 'pending') {
|
||||||
$order->payment_complete();
|
$order->payment_complete();
|
||||||
$order->add_order_note(__('Payment confirmed via Breez API.', 'breez-woocommerce'));
|
$order->add_order_note(__('Payment confirmed via Breez API.', 'breez-woocommerce'));
|
||||||
$this->logger->log("Payment for order #$order_id confirmed via API check", 'debug');
|
$this->logger->log("Payment for order #$order_id confirmed via API check", 'debug');
|
||||||
@@ -565,7 +538,7 @@ class WC_Gateway_Breez extends WC_Payment_Gateway {
|
|||||||
'payment_method' => $payment_method,
|
'payment_method' => $payment_method,
|
||||||
'expiry' => $expiry,
|
'expiry' => $expiry,
|
||||||
'current_time' => $current_time,
|
'current_time' => $current_time,
|
||||||
'payment_status' => $payment_status
|
'payment_status' => $api_payment_status
|
||||||
),
|
),
|
||||||
'',
|
'',
|
||||||
BREEZ_WC_PLUGIN_DIR . 'templates/'
|
BREEZ_WC_PLUGIN_DIR . 'templates/'
|
||||||
@@ -662,12 +635,12 @@ class WC_Gateway_Breez extends WC_Payment_Gateway {
|
|||||||
|
|
||||||
// Check exchange rate
|
// Check exchange rate
|
||||||
try {
|
try {
|
||||||
$rate = $this->payment_handler->get_btc_rate();
|
$rate_response = $this->client->request('GET', '/exchange_rates/USD');
|
||||||
if (!$rate) {
|
if (!$rate_response || !isset($rate_response['rate'])) {
|
||||||
$this->logger->log("Unable to get exchange rate", 'error');
|
$this->logger->log("Unable to get exchange rate", 'error');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$this->logger->log("Exchange rate: $rate", 'debug');
|
$this->logger->log("Exchange rate: " . $rate_response['rate'], 'debug');
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->logger->log("Exchange rate error: " . $e->getMessage(), 'error');
|
$this->logger->log("Exchange rate error: " . $e->getMessage(), 'error');
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -128,19 +128,16 @@ class Breez_API_Client {
|
|||||||
// If the payment is not found, return pending instead of throwing an error
|
// If the payment is not found, return pending instead of throwing an error
|
||||||
if ($response['status'] === 'UNKNOWN') {
|
if ($response['status'] === 'UNKNOWN') {
|
||||||
return array(
|
return array(
|
||||||
'status' => 'pending',
|
'status' => 'PENDING',
|
||||||
'destination' => $invoice_id,
|
'destination' => $invoice_id,
|
||||||
'sdk_status' => 'UNKNOWN'
|
'sdk_status' => 'UNKNOWN'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Map SDK payment states to WooCommerce states
|
// Build response with all available details - keep original SDK status
|
||||||
$status = $this->map_payment_status($response['status']);
|
|
||||||
|
|
||||||
// Build response with all available details
|
|
||||||
$result = array(
|
$result = array(
|
||||||
'status' => $status,
|
'status' => $response['status'], // Keep original SDK status (SUCCEEDED, WAITING_CONFIRMATION, etc)
|
||||||
'sdk_status' => $response['status'], // Include original SDK status
|
'sdk_status' => $response['status'],
|
||||||
'destination' => $invoice_id,
|
'destination' => $invoice_id,
|
||||||
'amount_sat' => $response['amount_sat'] ?? null,
|
'amount_sat' => $response['amount_sat'] ?? null,
|
||||||
'fees_sat' => $response['fees_sat'] ?? null,
|
'fees_sat' => $response['fees_sat'] ?? null,
|
||||||
@@ -162,7 +159,7 @@ class Breez_API_Client {
|
|||||||
$this->logger->log('Payment status check error: ' . $e->getMessage(), 'error');
|
$this->logger->log('Payment status check error: ' . $e->getMessage(), 'error');
|
||||||
// Return pending status instead of throwing an error
|
// Return pending status instead of throwing an error
|
||||||
return array(
|
return array(
|
||||||
'status' => 'pending',
|
'status' => 'PENDING',
|
||||||
'sdk_status' => 'UNKNOWN',
|
'sdk_status' => 'UNKNOWN',
|
||||||
'destination' => $invoice_id,
|
'destination' => $invoice_id,
|
||||||
'error' => $e->getMessage()
|
'error' => $e->getMessage()
|
||||||
|
|||||||
@@ -39,444 +39,317 @@ if ($payment_method === 'LIGHTNING' && strpos($qr_data, 'lightning:') !== 0 && s
|
|||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="breez-payment-box">
|
<div class="breez-payment-box">
|
||||||
<h3><?php _e('Bitcoin/Lightning Payment', 'breez-woocommerce'); ?></h3>
|
<?php if ($payment_status === 'SUCCEEDED' || $payment_status === 'WAITING_CONFIRMATION'): ?>
|
||||||
|
|
||||||
<?php if ($payment_status === 'completed'): ?>
|
|
||||||
<div class="breez-payment-status breez-payment-completed">
|
<div class="breez-payment-status breez-payment-completed">
|
||||||
<p><?php _e('Payment received! Thank you for your payment.', 'breez-woocommerce'); ?></p>
|
<p><?php _e('Payment received! Thank you for your payment.', 'breez-woocommerce'); ?></p>
|
||||||
<p><?php _e('Your order is now being processed.', 'breez-woocommerce'); ?></p>
|
<p><?php _e('Your order is now being processed.', 'breez-woocommerce'); ?></p>
|
||||||
</div>
|
</div>
|
||||||
<?php elseif ($payment_status === 'failed'): ?>
|
<?php elseif ($payment_status === 'FAILED'): ?>
|
||||||
<div class="breez-payment-status breez-payment-failed">
|
<div class="breez-payment-status breez-payment-failed">
|
||||||
<p><?php _e('Payment failed or expired.', 'breez-woocommerce'); ?></p>
|
<p><?php _e('Payment failed or expired.', 'breez-woocommerce'); ?></p>
|
||||||
<p><?php _e('Please contact us for assistance.', 'breez-woocommerce'); ?></p>
|
<p><?php _e('Please contact us for assistance.', 'breez-woocommerce'); ?></p>
|
||||||
</div>
|
</div>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?php if ($time_left > 0): ?>
|
<div class="breez-payment-instructions">
|
||||||
<div class="breez-payment-countdown" data-expiry="<?php echo esc_attr($expiry); ?>">
|
<h3><?php _e('Complete Your Payment', 'breez-woocommerce'); ?></h3>
|
||||||
<p><?php _e('Time remaining: ', 'breez-woocommerce'); ?><span class="breez-countdown"><?php printf('%02d:%02d', $minutes_left, $seconds_left); ?></span></p>
|
<p><?php echo esc_html(get_option('woocommerce_breez_instructions')); ?></p>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="breez-payment-qr" id="breez-qr-container" data-qr-data="<?php echo esc_attr($qr_data); ?>">
|
<?php if ($time_left > 0): ?>
|
||||||
<div class="breez-qr-loading">
|
<div class="breez-payment-countdown" data-expiry="<?php echo esc_attr($expiry); ?>">
|
||||||
<div class="breez-spinner"></div>
|
<p><?php _e('Time remaining: ', 'breez-woocommerce'); ?><span class="breez-countdown"><?php printf('%02d:%02d', $minutes_left, $seconds_left); ?></span></p>
|
||||||
<p><?php _e('Generating QR Code...', 'breez-woocommerce'); ?></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="breez-payment-details">
|
|
||||||
<p><strong><?php _e('Invoice/Address:', 'breez-woocommerce'); ?></strong></p>
|
|
||||||
<div class="breez-invoice-container">
|
|
||||||
<textarea readonly class="breez-invoice-text" rows="4"><?php echo esc_html($invoice_id); ?></textarea>
|
|
||||||
<button class="breez-copy-button" data-clipboard-text="<?php echo esc_attr($invoice_id); ?>">
|
|
||||||
<?php _e('Copy', 'breez-woocommerce'); ?>
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="breez-payment-info">
|
<div class="breez-payment-qr" id="breez-qr-container" data-qr-data="<?php echo esc_attr($qr_data); ?>">
|
||||||
<?php echo esc_html(get_option('woocommerce_breez_instructions')); ?>
|
<div class="breez-qr-loading">
|
||||||
</p>
|
<div class="breez-spinner"></div>
|
||||||
</div>
|
<p><?php _e('Generating QR Code...', 'breez-woocommerce'); ?></p>
|
||||||
<?php else: ?>
|
</div>
|
||||||
<div class="breez-payment-expired">
|
</div>
|
||||||
<p><?php _e('Payment time expired. Please contact support or place a new order.', 'breez-woocommerce'); ?></p>
|
|
||||||
</div>
|
<div class="breez-payment-details">
|
||||||
<?php endif; ?>
|
<p><strong><?php _e('Invoice/Address:', 'breez-woocommerce'); ?></strong></p>
|
||||||
|
<div class="breez-invoice-container">
|
||||||
|
<textarea readonly class="breez-invoice-text" rows="4"><?php echo esc_html($invoice_id); ?></textarea>
|
||||||
|
<button class="breez-copy-button" data-clipboard-text="<?php echo esc_attr($invoice_id); ?>">
|
||||||
|
<?php _e('Copy', 'breez-woocommerce'); ?>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="breez-payment-status" id="breez-payment-status">
|
||||||
|
<div class="breez-payment-pending">
|
||||||
|
<p><?php _e('Waiting for payment...', 'breez-woocommerce'); ?></p>
|
||||||
|
<div class="breez-spinner"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php else: ?>
|
||||||
|
<div class="breez-payment-expired">
|
||||||
|
<p><?php _e('Payment time expired. Please contact support or place a new order.', 'breez-woocommerce'); ?></p>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
// QR Code generation
|
||||||
// QR Code generation
|
var qrContainer = document.getElementById('breez-qr-container');
|
||||||
var qrContainer = document.getElementById('breez-qr-container');
|
if (qrContainer) {
|
||||||
if (qrContainer) {
|
var qrData = qrContainer.getAttribute('data-qr-data');
|
||||||
var qrData = qrContainer.getAttribute('data-qr-data');
|
if (qrData) {
|
||||||
generateQRCode(qrData);
|
var qrScript = document.createElement('script');
|
||||||
|
qrScript.src = 'https://cdn.jsdelivr.net/npm/qrcode-generator@1.4.4/qrcode.min.js';
|
||||||
|
qrScript.onload = function() {
|
||||||
|
var qr = qrcode(0, 'M');
|
||||||
|
qr.addData(qrData);
|
||||||
|
qr.make();
|
||||||
|
qrContainer.innerHTML = qr.createImgTag(5);
|
||||||
|
};
|
||||||
|
document.head.appendChild(qrScript);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get API configuration
|
// Countdown timer
|
||||||
var apiUrl = '<?php echo esc_js(get_option('woocommerce_breez_api_url')); ?>';
|
var countdownEl = document.querySelector('.breez-countdown');
|
||||||
var apiKey = '<?php echo esc_js(get_option('woocommerce_breez_api_key')); ?>';
|
var expiryTime = document.querySelector('.breez-payment-countdown')?.getAttribute('data-expiry');
|
||||||
var invoiceId = '<?php echo esc_js($invoice_id); ?>';
|
|
||||||
|
|
||||||
// Ensure API URL ends with a slash
|
if (countdownEl && expiryTime) {
|
||||||
apiUrl = apiUrl.replace(/\/?$/, '/');
|
var countdownInterval = setInterval(function() {
|
||||||
|
var now = Math.floor(Date.now() / 1000);
|
||||||
// Countdown functionality
|
var timeLeft = expiryTime - now;
|
||||||
var countdownEl = document.querySelector('.breez-countdown');
|
|
||||||
var expiryTime = parseInt(document.querySelector('.breez-payment-countdown')?.dataset.expiry, 10);
|
|
||||||
|
|
||||||
if (countdownEl && expiryTime) {
|
|
||||||
var countdownInterval = setInterval(function() {
|
|
||||||
var now = Math.floor(Date.now() / 1000);
|
|
||||||
var timeLeft = expiryTime - now;
|
|
||||||
|
|
||||||
if (timeLeft <= 0) {
|
|
||||||
clearInterval(countdownInterval);
|
|
||||||
clearInterval(statusCheckInterval); // Also clear status check
|
|
||||||
document.querySelector('.breez-payment-countdown').innerHTML = '<p><?php _e('Payment time expired.', 'breez-woocommerce'); ?></p>';
|
|
||||||
document.querySelector('.breez-payment-qr').style.opacity = '0.3';
|
|
||||||
|
|
||||||
// Show expired message
|
|
||||||
var paymentBox = document.querySelector('.breez-payment-box');
|
|
||||||
if (paymentBox) {
|
|
||||||
paymentBox.innerHTML = `
|
|
||||||
<h3><?php _e('Bitcoin/Lightning Payment', 'breez-woocommerce'); ?></h3>
|
|
||||||
<div class="breez-payment-expired">
|
|
||||||
<p><?php _e('Payment time expired. Please contact support or place a new order.', 'breez-woocommerce'); ?></p>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var minutes = Math.floor(timeLeft / 60);
|
|
||||||
var seconds = timeLeft % 60;
|
|
||||||
countdownEl.textContent = (minutes < 10 ? '0' : '') + minutes + ':' + (seconds < 10 ? '0' : '') + seconds;
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Payment status check functionality
|
|
||||||
function checkPaymentStatus() {
|
|
||||||
var paymentBox = document.querySelector('.breez-payment-box');
|
|
||||||
|
|
||||||
// Stop checking if payment box doesn't exist
|
if (timeLeft <= 0) {
|
||||||
if (!paymentBox) {
|
clearInterval(countdownInterval);
|
||||||
clearInterval(statusCheckInterval);
|
clearInterval(statusCheckInterval);
|
||||||
|
document.querySelector('.breez-payment-countdown').innerHTML = '<p><?php _e('Payment time expired.', 'breez-woocommerce'); ?></p>';
|
||||||
|
document.querySelector('.breez-payment-qr').style.opacity = '0.3';
|
||||||
|
|
||||||
|
// Show expired message
|
||||||
|
var paymentBox = document.querySelector('.breez-payment-box');
|
||||||
|
if (paymentBox) {
|
||||||
|
paymentBox.innerHTML = `
|
||||||
|
<div class="breez-payment-expired">
|
||||||
|
<p><?php _e('Payment time expired. Please contact support or place a new order.', 'breez-woocommerce'); ?></p>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop checking if payment is already completed or failed
|
|
||||||
if (paymentBox.querySelector('.breez-payment-completed') ||
|
|
||||||
paymentBox.querySelector('.breez-payment-failed') ||
|
|
||||||
paymentBox.querySelector('.breez-payment-expired')) {
|
|
||||||
clearInterval(statusCheckInterval);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Show loading indicator
|
|
||||||
var statusIndicator = paymentBox.querySelector('.breez-payment-status');
|
|
||||||
if (!statusIndicator) {
|
|
||||||
statusIndicator = document.createElement('div');
|
|
||||||
statusIndicator.className = 'breez-payment-status';
|
|
||||||
paymentBox.appendChild(statusIndicator);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use WordPress REST API endpoint instead of direct Breez API call
|
var minutes = Math.floor(timeLeft / 60);
|
||||||
fetch('/wp-json/breez-wc/v1/check-payment-status/' + invoiceId, {
|
var seconds = timeLeft % 60;
|
||||||
headers: {
|
countdownEl.textContent = (minutes < 10 ? '0' : '') + minutes + ':' + (seconds < 10 ? '0' : '') + seconds;
|
||||||
'Accept': 'application/json'
|
}, 1000);
|
||||||
}
|
}
|
||||||
})
|
|
||||||
.then(response => {
|
// Payment status check
|
||||||
if (!response.ok) {
|
var invoiceId = '<?php echo esc_js($invoice_id); ?>';
|
||||||
throw new Error('Network response error: ' + response.status);
|
var orderId = '<?php echo esc_js($order->get_id()); ?>';
|
||||||
}
|
|
||||||
return response.json();
|
function checkPaymentStatus() {
|
||||||
})
|
fetch('/wp-json/breez-wc/v1/check-payment-status/' + invoiceId, {
|
||||||
.then(data => {
|
headers: {
|
||||||
// Use the 'data' property from our API wrapper
|
'Accept': 'application/json'
|
||||||
const paymentData = data.data || data;
|
}
|
||||||
|
})
|
||||||
// Clear any existing error message
|
.then(response => response.json())
|
||||||
statusIndicator.classList.remove('breez-payment-error');
|
.then(data => {
|
||||||
|
var paymentData = data.data || data;
|
||||||
// Update status message based on SDK status
|
var statusContainer = document.getElementById('breez-payment-status');
|
||||||
if (paymentData.sdk_status === 'PENDING' || paymentData.sdk_status === 'WAITING_FEE_ACCEPTANCE') {
|
|
||||||
statusIndicator.innerHTML = `
|
if (!statusContainer) return;
|
||||||
<div class="breez-payment-pending">
|
|
||||||
<p>${paymentData.status_description || '<?php _e('Payment is being processed...', 'breez-woocommerce'); ?>'}</p>
|
if (paymentData.status === 'SUCCEEDED' || paymentData.status === 'WAITING_CONFIRMATION') {
|
||||||
<div class="breez-spinner"></div>
|
clearInterval(statusCheckInterval);
|
||||||
</div>
|
statusContainer.innerHTML = `
|
||||||
`;
|
<div class="breez-payment-completed">
|
||||||
return;
|
<p><?php _e('Payment received! Thank you for your payment.', 'breez-woocommerce'); ?></p>
|
||||||
}
|
<p><?php _e('Your order is now being processed.', 'breez-woocommerce'); ?></p>
|
||||||
|
</div>
|
||||||
if (paymentData.sdk_status === 'WAITING_CONFIRMATION') {
|
`;
|
||||||
statusIndicator.innerHTML = `
|
// Reload page after successful payment
|
||||||
<div class="breez-payment-confirming">
|
setTimeout(() => window.location.reload(), 2000);
|
||||||
<p>${paymentData.status_description || '<?php _e('Payment received! Waiting for confirmation...', 'breez-woocommerce'); ?>'}</p>
|
} else if (paymentData.status === 'FAILED') {
|
||||||
<div class="breez-spinner"></div>
|
clearInterval(statusCheckInterval);
|
||||||
</div>
|
statusContainer.innerHTML = `
|
||||||
`;
|
<div class="breez-payment-failed">
|
||||||
return;
|
<p><?php _e('Payment failed or expired.', 'breez-woocommerce'); ?></p>
|
||||||
}
|
<p><?php _e('Please try again or contact support if the problem persists.', 'breez-woocommerce'); ?></p>
|
||||||
|
</div>
|
||||||
if (paymentData.sdk_status === 'SUCCEEDED') {
|
`;
|
||||||
// Stop checking status immediately
|
} else {
|
||||||
clearInterval(statusCheckInterval);
|
// For PENDING or any other status
|
||||||
|
statusContainer.innerHTML = `
|
||||||
// Format amounts with commas for better readability
|
<div class="breez-payment-pending">
|
||||||
const amountSats = paymentData.amount_sat ? Number(paymentData.amount_sat).toLocaleString() : '0';
|
<p><?php _e('Waiting for payment...', 'breez-woocommerce'); ?></p>
|
||||||
const feesSats = paymentData.fees_sat ? Number(paymentData.fees_sat).toLocaleString() : '0';
|
|
||||||
|
|
||||||
// Update UI to show payment completed with amount details
|
|
||||||
paymentBox.innerHTML = `
|
|
||||||
<h3><?php _e('Bitcoin/Lightning Payment', 'breez-woocommerce'); ?></h3>
|
|
||||||
<div class="breez-payment-status breez-payment-completed">
|
|
||||||
<p>${paymentData.status_description || '<?php _e('Payment confirmed! Thank you for your payment.', 'breez-woocommerce'); ?>'}</p>
|
|
||||||
<p><?php _e('Your order is now being processed.', 'breez-woocommerce'); ?></p>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
|
|
||||||
// Notify WordPress about the completed payment
|
|
||||||
notifyServer(paymentData);
|
|
||||||
|
|
||||||
// Double check interval is cleared
|
|
||||||
if (statusCheckInterval) {
|
|
||||||
clearInterval(statusCheckInterval);
|
|
||||||
statusCheckInterval = null;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (paymentData.sdk_status === 'FAILED') {
|
|
||||||
// Stop checking status immediately
|
|
||||||
clearInterval(statusCheckInterval);
|
|
||||||
|
|
||||||
// Show error message
|
|
||||||
paymentBox.innerHTML = `
|
|
||||||
<h3><?php _e('Bitcoin/Lightning Payment', 'breez-woocommerce'); ?></h3>
|
|
||||||
<div class="breez-payment-status breez-payment-failed">
|
|
||||||
<p>${paymentData.status_description || '<?php _e('Payment failed or expired.', 'breez-woocommerce'); ?>'}</p>
|
|
||||||
<p>${paymentData.error || ''}</p>
|
|
||||||
<p><?php _e('Please try again or contact support if the problem persists.', 'breez-woocommerce'); ?></p>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// For unknown status, show generic message
|
|
||||||
statusIndicator.innerHTML = `
|
|
||||||
<div class="breez-payment-unknown">
|
|
||||||
<p>${paymentData.status_description || '<?php _e('Checking payment status...', 'breez-woocommerce'); ?>'}</p>
|
|
||||||
<div class="breez-spinner"></div>
|
<div class="breez-spinner"></div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
})
|
}
|
||||||
.catch(error => {
|
})
|
||||||
console.error('Error checking payment status:', error);
|
.catch(error => console.error('Error checking payment status:', error));
|
||||||
// Don't show error message for status check failures
|
}
|
||||||
// Just log to console and continue checking
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function to notify WordPress about payment status changes
|
// Check payment status every 5 seconds
|
||||||
function notifyServer(paymentData) {
|
var statusCheckInterval = setInterval(checkPaymentStatus, 5000);
|
||||||
fetch('/wp-json/breez-wc/v1/check-payment-status?order_id=<?php echo esc_js($order->get_id()); ?>', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'X-WP-Nonce': '<?php echo esc_js(wp_create_nonce('wp_rest')); ?>'
|
|
||||||
},
|
|
||||||
body: JSON.stringify(paymentData)
|
|
||||||
})
|
|
||||||
.catch(error => console.error('Error notifying server:', error));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check payment status every 5 seconds
|
// Initial check
|
||||||
var statusCheckInterval = setInterval(checkPaymentStatus, 5000);
|
checkPaymentStatus();
|
||||||
|
|
||||||
// Do an initial check immediately
|
|
||||||
checkPaymentStatus();
|
|
||||||
|
|
||||||
// Copy invoice button functionality
|
// Copy invoice functionality
|
||||||
var copyButton = document.querySelector('.breez-copy-button');
|
var copyButton = document.querySelector('.breez-copy-button');
|
||||||
if (copyButton) {
|
if (copyButton) {
|
||||||
copyButton.addEventListener('click', function() {
|
copyButton.addEventListener('click', function() {
|
||||||
var textToCopy = this.dataset.clipboardText;
|
var textToCopy = this.dataset.clipboardText;
|
||||||
var textarea = document.createElement('textarea');
|
var textarea = document.createElement('textarea');
|
||||||
textarea.value = textToCopy;
|
textarea.value = textToCopy;
|
||||||
document.body.appendChild(textarea);
|
document.body.appendChild(textarea);
|
||||||
textarea.select();
|
textarea.select();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
document.execCommand('copy');
|
document.execCommand('copy');
|
||||||
this.textContent = '<?php _e('Copied!', 'breez-woocommerce'); ?>';
|
this.textContent = '<?php _e('Copied!', 'breez-woocommerce'); ?>';
|
||||||
setTimeout(function() {
|
setTimeout(() => {
|
||||||
copyButton.textContent = '<?php _e('Copy', 'breez-woocommerce'); ?>';
|
this.textContent = '<?php _e('Copy', 'breez-woocommerce'); ?>';
|
||||||
}, 2000);
|
}, 2000);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to copy: ', err);
|
console.error('Failed to copy:', err);
|
||||||
}
|
}
|
||||||
|
|
||||||
document.body.removeChild(textarea);
|
document.body.removeChild(textarea);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// QR Code generation function
|
|
||||||
function generateQRCode(data) {
|
|
||||||
// Try QRServer.com first
|
|
||||||
var primaryUrl = 'https://api.qrserver.com/v1/create-qr-code/?' + new URLSearchParams({
|
|
||||||
data: data,
|
|
||||||
size: '300x300',
|
|
||||||
margin: '10',
|
|
||||||
format: 'svg',
|
|
||||||
qzone: '1',
|
|
||||||
color: '000000',
|
|
||||||
bgcolor: 'FFFFFF'
|
|
||||||
}).toString();
|
|
||||||
|
|
||||||
// Fallback URL (Google Charts)
|
|
||||||
var fallbackUrl = 'https://chart.googleapis.com/chart?' + new URLSearchParams({
|
|
||||||
chs: '300x300',
|
|
||||||
cht: 'qr',
|
|
||||||
chl: data,
|
|
||||||
choe: 'UTF-8',
|
|
||||||
chld: 'M|4'
|
|
||||||
}).toString();
|
|
||||||
|
|
||||||
// Create image element
|
|
||||||
var img = new Image();
|
|
||||||
img.style.cssText = 'display:block; max-width:300px; height:auto;';
|
|
||||||
img.alt = 'QR Code';
|
|
||||||
|
|
||||||
// Try primary service first
|
|
||||||
img.onerror = function() {
|
|
||||||
// If primary fails, try fallback
|
|
||||||
img.src = fallbackUrl;
|
|
||||||
};
|
|
||||||
|
|
||||||
img.onload = function() {
|
|
||||||
qrContainer.innerHTML = '';
|
|
||||||
var wrapper = document.createElement('div');
|
|
||||||
wrapper.className = 'breez-qr-wrapper';
|
|
||||||
wrapper.style.cssText = 'background:white; padding:15px; border-radius:8px; box-shadow:0 2px 4px rgba(0,0,0,0.1); display:inline-block;';
|
|
||||||
wrapper.appendChild(img);
|
|
||||||
qrContainer.appendChild(wrapper);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Start loading primary QR code
|
|
||||||
img.src = primaryUrl;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.breez-payment-box {
|
.breez-payment-box {
|
||||||
max-width: 600px;
|
max-width: 600px;
|
||||||
margin: 0 auto;
|
margin: 2em auto;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
background: #f8f8f8;
|
background: #f8f8f8;
|
||||||
border-radius: 5px;
|
border-radius: 8px;
|
||||||
text-align: center;
|
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.breez-payment-status {
|
|
||||||
padding: 15px;
|
|
||||||
border-radius: 5px;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.breez-payment-completed {
|
|
||||||
background: #d4edda;
|
|
||||||
color: #155724;
|
|
||||||
}
|
|
||||||
|
|
||||||
.breez-payment-failed {
|
|
||||||
background: #f8d7da;
|
|
||||||
color: #721c24;
|
|
||||||
}
|
|
||||||
|
|
||||||
.breez-payment-countdown {
|
|
||||||
font-size: 18px;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.breez-countdown {
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
.breez-payment-qr {
|
|
||||||
margin-bottom: 20px;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.breez-qr-loading {
|
.breez-payment-instructions {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 20px;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.breez-spinner {
|
.breez-payment-instructions h3 {
|
||||||
display: inline-block;
|
margin-bottom: 1em;
|
||||||
width: 40px;
|
color: #333;
|
||||||
height: 40px;
|
}
|
||||||
border: 4px solid #f3f3f3;
|
|
||||||
border-top: 4px solid #3498db;
|
|
||||||
border-radius: 50%;
|
|
||||||
animation: spin 1s linear infinite;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes spin {
|
.breez-payment-status {
|
||||||
0% { transform: rotate(0deg); }
|
padding: 15px;
|
||||||
100% { transform: rotate(360deg); }
|
margin: 10px 0;
|
||||||
}
|
border-radius: 4px;
|
||||||
|
text-align: center;
|
||||||
.breez-invoice-container {
|
}
|
||||||
position: relative;
|
|
||||||
margin-bottom: 20px;
|
.breez-payment-completed {
|
||||||
}
|
background-color: #d4edda;
|
||||||
|
border: 1px solid #c3e6cb;
|
||||||
.breez-invoice-text {
|
color: #155724;
|
||||||
width: 100%;
|
}
|
||||||
padding: 10px;
|
|
||||||
font-family: monospace;
|
.breez-payment-failed {
|
||||||
font-size: 14px;
|
background-color: #f8d7da;
|
||||||
resize: none;
|
border: 1px solid #f5c6cb;
|
||||||
border: 1px solid #ddd;
|
color: #721c24;
|
||||||
border-radius: 4px;
|
}
|
||||||
}
|
|
||||||
|
.breez-payment-countdown {
|
||||||
.breez-copy-button {
|
font-size: 18px;
|
||||||
position: absolute;
|
margin: 1em 0;
|
||||||
right: 10px;
|
color: #666;
|
||||||
top: 10px;
|
}
|
||||||
padding: 5px 10px;
|
|
||||||
background: #0073aa;
|
.breez-countdown {
|
||||||
color: white;
|
font-weight: bold;
|
||||||
border: none;
|
color: #333;
|
||||||
border-radius: 3px;
|
}
|
||||||
cursor: pointer;
|
|
||||||
}
|
.breez-payment-qr {
|
||||||
|
margin: 2em auto;
|
||||||
.breez-copy-button:hover {
|
max-width: 300px;
|
||||||
background: #005177;
|
}
|
||||||
}
|
|
||||||
|
.breez-payment-qr img {
|
||||||
.breez-payment-info {
|
max-width: 100%;
|
||||||
margin-bottom: 20px;
|
height: auto;
|
||||||
}
|
display: block;
|
||||||
|
margin: 0 auto;
|
||||||
.breez-payment-expired {
|
}
|
||||||
background: #f8d7da;
|
|
||||||
color: #721c24;
|
.breez-invoice-container {
|
||||||
padding: 15px;
|
position: relative;
|
||||||
border-radius: 5px;
|
margin: 1em auto;
|
||||||
margin-bottom: 20px;
|
max-width: 500px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.breez-payment-error {
|
.breez-invoice-text {
|
||||||
background: #fff3cd;
|
width: 100%;
|
||||||
color: #856404;
|
padding: 10px 40px 10px 10px;
|
||||||
padding: 10px;
|
font-family: monospace;
|
||||||
margin: 10px 0;
|
font-size: 14px;
|
||||||
border-radius: 4px;
|
resize: none;
|
||||||
border: 1px solid #ffeeba;
|
border: 1px solid #ddd;
|
||||||
}
|
border-radius: 4px;
|
||||||
|
background: #fff;
|
||||||
.breez-error-details {
|
}
|
||||||
font-size: 0.9em;
|
|
||||||
margin-top: 5px;
|
.breez-copy-button {
|
||||||
color: #721c24;
|
position: absolute;
|
||||||
}
|
right: 10px;
|
||||||
|
top: 50%;
|
||||||
.breez-payment-details {
|
transform: translateY(-50%);
|
||||||
font-size: 0.9em;
|
padding: 5px 10px;
|
||||||
margin-top: 15px;
|
background: #0073aa;
|
||||||
padding: 10px;
|
color: white;
|
||||||
background: rgba(0, 0, 0, 0.05);
|
border: none;
|
||||||
border-radius: 4px;
|
border-radius: 3px;
|
||||||
}
|
cursor: pointer;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.breez-copy-button:hover {
|
||||||
|
background: #005177;
|
||||||
|
}
|
||||||
|
|
||||||
|
.breez-spinner {
|
||||||
|
display: inline-block;
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
border: 2px solid #f3f3f3;
|
||||||
|
border-top: 2px solid #3498db;
|
||||||
|
border-radius: 50%;
|
||||||
|
animation: spin 1s linear infinite;
|
||||||
|
margin: 0 10px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes spin {
|
||||||
|
0% { transform: rotate(0deg); }
|
||||||
|
100% { transform: rotate(360deg); }
|
||||||
|
}
|
||||||
|
|
||||||
|
.breez-payment-pending,
|
||||||
|
.breez-payment-confirming {
|
||||||
|
background-color: #fff3cd;
|
||||||
|
border: 1px solid #ffeeba;
|
||||||
|
color: #856404;
|
||||||
|
padding: 15px;
|
||||||
|
margin: 1em 0;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.breez-payment-expired {
|
||||||
|
background-color: #f8d7da;
|
||||||
|
border: 1px solid #f5c6cb;
|
||||||
|
color: #721c24;
|
||||||
|
padding: 15px;
|
||||||
|
margin: 1em 0;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user