<?php
namespace App\Support;
use App\Models\Invoice;
final class PaymentQr {
 public static function forInvoice(Invoice $invoice): array {
  $amount=AtomicAmount::toDecimal((string)$invoice->quoted_pay_amount_atomic,$invoice->asset->decimals);
  $address=(string)($invoice->address?->address ?? '');
  $asset=$invoice->asset->code;
  $network=$invoice->asset->network;
  $payload=$asset.':'.$address.'?amount='.$amount.'&network='.$network;
  $qrUrl='https://api.qrserver.com/v1/create-qr-code/?size=240x240&data='.rawurlencode($payload);
  return ['payload'=>$payload,'image_url'=>$qrUrl];
 }
}