
$invoice


--> invoice

--> Click Paybutton

--> Show danh sách lấy từ BillingManager
--> User select one of those payments

Controller@select {
    $type = $request->payment_type;

    $gateway = BillingManager::getPaymentGateway($type);

    refirect->away($gateway->getCheckoutUrls($invoice));
}


cronjob xử lý việc pay duyệt qua các pending invoices


    function process($invoice)
    {
        if (!$invoice->isPending())
            throw

        // renew: quy ước là customer->getAutoBillingData() phải là json và chức 1 key type chức value là gateway->getType()
        // gatway nào cũng phải ghi vào 1 format như vậy (phải có field là type)
        // nếu mà 
        $autoBillingData = $invoice->customer->getAutoBillingData();

        // nếu không có auto billing data => không có auto billing được
        if ($autoBillingData) {
            return;
        }

        $gatewayType = $autoBillingData->type;
        $gateway = BillingManager::getGateway($gatewayType);

        if ($gateway) {
            return;
        }

        // pay
        $gateway->charge($invoice);
    }


StripeGateway

    function charge($invoice)
    {
        $card = $invoice->customer->payment_data['card']
        StripeService->charge([
            'amount' => $invoice->getAmount(),
            'card' => $card,
        ])
    }


    pk_test_fqKGTiyNkzQB2muKmYG6HzOM
    sk_test_2e514ad9c56adce5dbc821b5ecb7f772d1e502e1