Invoices

From GExtension Wiki
Jump to navigation Jump to search

Invoices can be enabled in the settings. They are not saved anywhere but only displayed if requested.

Invoice notification URL

Additionally, an invoice notification URL can be set.

The URL can be set by adding this line to the config.php:

Config::Set('settings_donations_invoice_api', 'http://test.com/invoice');

When a user purchases a package, a HTTP POST request to this URL will be invoked, supplying the following data:

Array
(
    [id] => 15 // Purchase/Invoice ID
    [date] => 2020-04-26 13:22:42 // Purchase timestamp
    [currency] => USD
    [payment] => Array
        (
            [amount_total] => 8.43 // Total amount
            [amount_net] => 7.08 // Net amount
            [gateway] => stripe // Payment gateway (f.e. stripe, paypal, paysafecard, ..)
            [transaction_id] => ch_1Gc8ZJFNJrt3faid1WtuJLPi // Transaction ID from the payment gateway
        )

    [buyer] => Array
        (
            [steamid64] => 76561198054505143 // Buyer Steam ID
            [nick] => [E-G] ibot3 // Buyer nick
            [address] => [E-G] ibot3 // Buyer address (maybe multiline; includes nick; content depending on payment gateway)
Firstname Lastname
Examplestreet 42
12345 Examplecity
            [country] => US // ISO country code (may be empty)
            [email] => [email protected] // Buyer E-Mail address (may be empty)
        )

    [product] => Array
        (
            [id] => 1 // Package ID
            [serverbundle] => 1 // Serverbundle ID
            [name] => Test // Package title
            [days] => 1 // Package duration
        )

    [tax] => Array
        (
            [note] => This is a tax notice // Tax notice
            [rate] => 19 // Tax rate (%)
            [amount] => 1.35 // Tax amount
        )

)

The notification may be sent multiple times, so the operation on the receiver side must be idempotent.

It is possible to resend all invoice notifications by visiting /request.php?t=resend_invoice_notifications.