• ledan297296

    (@ledan297296)


    class Paykit_Https_Webhook_Request
    {
    public DateTime $request_at;
    public Paykit_Payment $payment;
    public ?Paykit_Refund $refund;

    public function __construct(
    DateTime $request_at,
    Paykit_Payment $payment,
    ?Paykit_Refund $refund
    ) {
    $this->request_at = $request_at;
    $this->payment = $payment;
    $this->refund = $refund;
    }

    public static function from_json(array $data)
    {
    return new Paykit_Https_Webhook_Request(
    paykit_convert_iso8601_str_to_datetime($data['request_at']),
    Paykit_Payment::from_json($data['payment']),
    $data['refund'] ? Paykit_Refund::from_json($data['refund']) : null
    );
    }
    }

    S? d?ng DateTime mà kh?ng import ho?c alias

    Thi?u ki?m tra d? li?u tr??c khi truy c?p ph?n t? m?ng

    L?i khi refund kh?ng t?n t?i

    Kh?ng ki?m tra l?i khi g?i from_json

    • Các ph??ng th?c from_json() có th? phát sinh l?i n?u d? li?u kh?ng h?p l?.
    • Nên dùng try...catch ?? x? ly ngo?i l?.
    • l?i ? file https-paykit-webhook-request.php

    Còn l?i r?t nhi?u ch?a t??ng thích phiên 8.1 tr? lên mong ad c?p nh?t s?a l?i. T?i ?ang s? d?ng theme Woodmart và woocommerce 9.6

  • You must be logged in to reply to this topic.