AyeCode / invoicing

GetPaid (Formerly the Invoicing plugin) is a lightweight Payments and Invoicing system for WordPress. It can be used to sell anything online via payment forms or buy now buttons that can be added to any landing page. It can also be used by freelancers to manage their Invoices or by 3rd party Themes and Plugins as their payment system. GeoDirectory currently uses GetPaid as its payment system
https://wpgetpaid.com/
Other
38 stars 23 forks source link

Add an option to add Invoice via third party plugin #675

Open dedanirungu opened 2 years ago

dedanirungu commented 2 years ago

I am working on a billing system for barber and salon businesses and I am using this plugin to generate invoices and manage user payments once they book a date.

I am currently doing it as shown below, and I think this is a hack that can be majorly affected by future updates.

Kindly provide a better way of generating invoices via api.

   $data = array(
        'user_id' => $user_id,
        'parent_id' => 0,
        'status' => 'wpi-pending',
        'version' => '',
        'date_created' => date('Y-m-d H:i:s'),
        'date_modified' => null,
        'due_date' => date('Y-m-d H:i:s'),
        'completed_date' => null,
        'number' => '',
        'title' => '',
        'path' => '',
        'key' => '',
        'description' => '',
        'author' => 1,
        'type' => 'invoice',
        'post_type' => 'wpi_invoice',
        'mode' => 'live',
        'user_ip' => null,
        'first_name' => $_GET['first_name'],
        'last_name' => $_GET['last_name'],
        'phone' => $_GET['phone'],
        'email' => $_GET['email'],
        'country' => $_GET['country'],
        'city' => $_GET['city'],
        'state' => $_GET['state'],
        'zip' => $_GET['zip'],
        'cart_details' => $_GET['cart_details'],
        'address' => $_GET['address'],
        'company' => 'N/A',
        'company_id' => null,
        'vat_number' => 'N/A',
        'vat_rate' => null,
        'address_confirmed' => false,
        'shipping' => null,
        'subtotal' => 0,
        'total_discount' => 0,
        'total_tax' => 0,
        'total_fees' => 0,
        'total' => 0,
        'fees' => array(),
        'discounts' => array(),
        'taxes' => array(),
        'items' => array(),
        'payment_form' => 1,
        'submission_id' => null,
        'discount_code' => null,
        'gateway' => 'none',
        'transaction_id' => '',
        'currency' => '',
        'disable_taxes' => false,
        'subscription_id' => null,
        'remote_subscription_id' => null,
        'is_viewed' => false,
        'email_cc' => '',
        'template' => 'quantity', // hours, amount only
        'created_via' => null,
    );

    $invoice = wpinv_insert_invoice($data);
pol76 commented 2 years ago

Hi, we created this plugin to do exactly what you need to do: to accept payment and create invoices programmatically from other applications. We mainly use it as the payment and invoicing system for our flagship plugin GeoDirectory, so if you follow our docs and examples, your code cannot be majorly affected by future updates. https://docs.wpgetpaid.com/article/584-how-to-create-an-invoice-programmatically If you have any questions, don't hesitate to ask. I hope this helps. Thanks

dedanirungu commented 2 years ago

Thank you for your response.

dedanirungu commented 2 years ago

How can I add an Invoice that is not associated with any user on the database via user_id?

Most customers in my use case might never register or log in to the system. The invoice might even be from a simple POS which handle a large number of walk-in customers. Creating user accounts for each will be wasteful.

Also, how can I make partial payments? eg 20% of invoiced amount in order to book a slot?

pol76 commented 2 years ago

Hi, sorry for missing your questions. Neither thing is possible without customizing the plugin, I'm sorry.