2017 © Pedro PelĂĄez
 

library facturapi-php

Facturapi's PHP client library

image

facturapi/facturapi-php

Facturapi's PHP client library

  • Tuesday, July 24, 2018
  • by LagunaISW
  • Repository
  • 2 Watchers
  • 0 Stars
  • 43 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 6 Versions
  • 87 % Grown

The README.md

Facturapi PHP Library

This is the official PHP wrapper for https://www.facturapi.io, (*1)

FacturAPI makes it easy for developers to generate valid Invoices in Mexico (known as Factura ElectrĂłnica or CFDI)., (*2)

If you've ever used Stripe or Conekta, you'll find FacturAPI very straightforward to understand and integrate in your server app., (*3)

Install

composer require "facturapi/facturapi-php"

Before you begin

Make sure you have created your free account on FacturAPI and that you have your API Keys., (*4)

Getting started

Import the library

Don't forget to reference the library at the top of your code:, (*5)

use Facturapi\Facturapi;

Create a customer


// Create an instance of the client. // You can use different instances for uusing different API Keys $facturapi = new Facturapi( FACTURAPI_KEY ); $customer = array( "email" => "walterwhite@gmail.com", //Optional but useful to send invoice by email "legal_name" => "Walter White", // Razón social "tax_id" => "WIWA761018", //RFC "address" => array( "zip"=> "06800", "street" => "Av. de los Rosales", "exterior" => "123", "neighborhood" => "Tepito" // city, municipality and state are filled automatically from the zip code // but if you want to, you can override their values // city: 'México', // municipality: 'Cuauhtémoc', // state: 'Ciudad de México' ) ); // Remember to store the customer.id in your records. // You will need it to create an invoice for this customer. $new_customer = $facturapi->Customers->create($customer);

Create a product

$facturapi = new Facturapi( FACTURAPI_KEY );
$product = array(
  "product_key" => "4319150114", // Clave Producto/Servicio from SAT's catalog. Log in to FacturAPI and use our tool to look it up.
  "description" => "Apple iPhone 8",
  "price"       => 345.60 // price in MXN.
  // By default, taxes are calculated from the price with IVA 16%
  // But again, you can override that by explicitly providing a taxes array
  // "taxes" => array(
  //   array ( "type" => \Facturapi\TaxType::IVA, "rate" => 0.16 ),
  //   array ( "type" => \Facturapi\TaxType::ISR, "rate" => 0.03666, "withholding" => true )
  // )
);

$facturapi->Products->create( $product );

Create an invoice

$facturapi = new Facturapi( FACTURAPI_KEY );

$invoice = array(
  "customer"     => "YOUR_CUSTOMER_ID",
  "items"        => array(
    array(
      "quantity" => 1, // Optional. Defaults to 1.
      "product"  => "YOUR_PRODUCT_ID" // You can also pass a product object instead
    ),
    array( 
      "quantity" => 2,
        "product"  => array( 
        "description" => "Guitarra",
        "product_key" => "01234567",
        "price"       => 420.69,
        "sku"         => "ABC4567"
      )
    ) // Add as many products as you want to include in your invoice
  ),
  "payment_form" => \Facturapi\PaymentForm::EFECTIVO,
  "folio_number" => "581",
  "series"       => "F"
);

$facturapi->Invoices->create( $invoice );

Download your invoice

// Once you have successfully created your invoice, you can...
$facturapi = new Facturapi( FACTURAPI_KEY );

$facturapi->Invoices->download_zip("INVOICE_ID") // stream containing the PDF and XML as a ZIP file or

$facturapi->Invoices->download_pdf("INVOICE_ID") // stream containing the PDF file or

$facturapi->Invoices->download_xml("INVOICE_ID") // stream containing the XML file or

Send your invoice by email

// Send the invoice to your customer's email (if any)
$facturapi = new Facturapi( FACTURAPI_KEY );

$facturapi->Invoices->send_by_email("INVOICE_ID");

Documentation

There's more you can do with this library: List, retrieve, update, and remove Customers, Products and Invoices., (*6)

Visit the full documentation at http://docs.facturapi.io., (*7)

Help

Found a bug?

Please report it on the Issue Tracker, (*8)

Want to contribute?

Send us your PR! We appreciate your help :), (*9)

Contact us!

contacto@facturapi.io, (*10)

The Versions

24/07 2018

dev-master

9999999-dev https://www.facturapi.io/

Facturapi's PHP client library

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

api facturapi

24/07 2018

1.0.1

1.0.1.0 https://www.facturapi.io/

Facturapi's PHP client library

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

api facturapi

26/01 2018

1.0.0

1.0.0.0 https://www.facturapi.io/

Facturapi's PHP client library

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

api facturapi

26/01 2018

dev-dev

dev-dev https://www.facturapi.io/

Facturapi's PHP client library

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

api facturapi

26/01 2018

dev-revert-3-revert-2-dev

dev-revert-3-revert-2-dev https://www.facturapi.io/

Facturapi's PHP client library

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

api facturapi

26/01 2018

dev-revert-2-dev

dev-revert-2-dev https://www.facturapi.io/

Facturapi's PHP client library

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

api facturapi