=== CatCode Pix with Banco Inter for WooCommerce ===
Contributors: catcodestudio
Tags: pix, banco inter, payments, woocommerce, brazil
Requires at least: 6.4
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Pix payments through your own Banco Inter business account: QR code and copy-and-paste code, orders confirmed by the bank webhook.

== Description ==

Adds Pix as a payment method to WooCommerce, connected straight to the API of your Banco Inter business account (Inter Empresas). There is no intermediary: the charge is created in your account, the money lands on your Pix key, and you use your own integration credentials.

* **Dynamic Pix charge for every order** — a charge with the order total and an expiry you choose (60 minutes by default).
* **QR code and "Pix Copia e Cola"** — on the order page, in "My account" and in the e-mail the buyer receives. The QR picture is made by the plugin itself, the code is not sent to any QR service.
* **Confirmed by the bank** — the bank's webhook tells the shop about the payment. The plugin then reads the charge back from the bank and only that answer marks the order as paid; a Pix with a different amount puts the order on hold with a note.
* **The page updates by itself** — the buyer sees "Payment received" without reloading, also when the webhook is late.
* **Certificate upload** — the .crt and .key files of the integration are uploaded on the settings screen and stored encrypted in the database, together with the Client Secret.
* **Certificate reminder** — the integration certificate is valid for one year; the site administrator gets an e-mail 30 days and 7 days before it ends, so Pix does not stop unnoticed.
* **Check connection, register the webhook, test charge** — three buttons that tell in plain words what the bank answered.
* **Check payment status** — a button on the order screen asks the bank if the webhook did not arrive.
* Works with the classic and the block checkout and with HPOS. Offered in Brazilian reais only. Sandbox and production.
// @pro-begin
* Translations included: English and Brazilian Portuguese.
// @pro-end

// @pro-begin
= Pro =

The Pro version is sold on [catcode.com.ua](https://catcode.com.ua/modules/catcode-pix-with-banco-inter-for-woocommerce/), with a 7-day trial that never starts by itself:

* **BolePix** — a second payment method: a Banco Inter boleto that also carries a Pix QR code, with a due date, a late fine and monthly interest. The buyer gets the boleto line, the Pix code and the PDF.
* **Unpaid orders cancelled by themselves** — an order whose Pix code or BolePix has expired is checked at the bank and cancelled; WooCommerce returns its products to stock. An order cancelled in the shop cancels its unpaid boleto at the bank.
* **Pix refunds from WooCommerce** — a full or partial refund of an order is sent to the bank as a Pix devolution.
* **Discount for paying with Pix** — a percentage off the products total while Pix is the chosen method.
* **Request log** — the last 200 calls to the bank with their answers.
* Updates from catcode.com.ua.

The licence runs for 1-5 years and includes updates and support for that term; a purchased licence keeps its Pro features after the term ends. One key covers two sites: the shop and its test copy.
// @pro-end

Banco Inter and Inter Empresas are trademarks of Banco Inter S.A. This plugin is an independent integration made by CatCode; it is not an official plugin of Banco Inter and is not affiliated with or endorsed by it. You need your own Inter Empresas (business) account with an API integration.

== External services ==

The plugin connects to the Banco Inter API (Banco Inter S.A., [inter.co](https://inter.co/), documentation at [developers.inter.co](https://developers.inter.co/)) at `cdpj.partners.bancointer.com.br` (or `cdpj-sandbox.partners.uatinter.co` when you choose the sandbox), and only after you enter your credentials. Every request presents the certificate of your integration.

* When a token is needed (checking the connection, creating or reading a charge, registering the webhook): the Client ID, the Client Secret and the requested permissions.
* When the buyer places an order with Pix: the amount, your Pix key, the expiry, the text "Order number - shop name", and, when the order has them, the buyer's CPF or CNPJ and name.
* When a webhook arrives, the order page asks for the payment status, or you press "Check payment status": the identifier (txid) of the charge, to read it.
* When you press "Register the webhook at the bank": your Pix key and the webhook address of your site.
// @pro-begin
* BolePix (Pro): the amount, the due date, the fine and interest, the order number, and the payer's CPF or CNPJ, name, address, e-mail and phone — the bank requires them to issue a boleto. Later the identifier of the boleto, to read it, get its PDF or cancel it.
* On a refund (Pro): the identifier of the received Pix, the amount and the refund reason.
// @pro-end

[Banco Inter privacy policy](https://inter.co/politica-de-privacidade/) · [Banco Inter API terms and documentation](https://developers.inter.co/)

== Installation ==

1. Upload the plugin and activate it. WooCommerce must be active and the shop currency the Brazilian real.
2. In the Inter Empresas internet banking open "Soluções para sua empresa" → "Nova Integração", create an integration with the permissions `cob.write`, `cob.read`, `webhook.write` and `webhook.read`, copy the Client ID and the Client Secret and download the certificate and the key.
3. In WooCommerce → **Banco Inter** choose the environment, paste the credentials, upload the .crt and .key files, enter your Pix key and save.
4. Press "Check connection", then "Register the webhook at the bank". "Create a test Pix charge" shows that charges can be created.
5. WooCommerce → Settings → Payments: enable "Pix (Banco Inter)" and place a test order.

== Frequently Asked Questions ==

= Which Inter account do I need? =

An Inter Empresas (PJ) account: the API integration is created in its internet banking. The plugin does not open the account or the integration for you.

= How does the shop know that the Pix was paid? =

The bank calls the webhook address of your site. The plugin never trusts the content of that call: it asks the bank for the charge and settles the order from the answer. While the buyer keeps the order page open the plugin also asks the bank itself, so a late webhook does not hold the order.

= Is the webhook call signed? =

Banco Inter does not sign its webhook calls; it recommends checking its certificate on the web server. The plugin protects the address with a long random part and settles orders only from what the bank's API answers. If you can, also restrict the address to the bank's certificate or IP ranges on your server.

= Where are the certificate and the key kept? =

In the database, encrypted with a key derived from the secret salts of your wp-config.php. They are not written to a public folder.

= Why is the order "on hold" after checkout? =

It waits for the payment. It moves to Processing when the bank reports the Pix as received.

= The certificate expired. What now? =

The certificate of an integration is valid for one year. In the internet banking open your integrations and choose "Renovar" (the bank offers it from 90 days before the end), then upload the new .crt and .key files; the Client ID and the Client Secret stay the same. The settings screen shows until when the saved certificate is valid, and the plugin e-mails the site administrator 30 days and 7 days before the end.

== Changelog ==

= 1.0.0 =
* First release.
