# Companies (Admin)

Companies informations inside W3block ecosystem is maintained by the ID service. Here, you can only change companies configurations about the commerce service. Available configurations:

* **Payment providers**: You can enable and configure some available payment providers such as paypal, pagar.me and stripe.
* **Deliver delays:** You can configure how much time you want to wait until transfer token to the client/user after the payment was approved. This is very useful since credit card payments can be easier cancelled 3 days after payment was completed. You can specify that for each payment type as PIX, credit card, or transfer.
* **Logo**: You can change company logo from our lightweight commerce front-end
* **Banners:** You can change home-page banners from our lightweight commerce front-end

## Payment

#### 1. Payment Distribution (Fees and income)

Every order transaction is divided in 3 parts:

* **Service Fee**: This fee is the W3Block transaction part, it can be paid from client, company or both depending of the W3Block contract
* **Gas Fee:** This fee is used to pay blockchain transactions under the tokens transfer
* **Company Income:** Is the rest of the money that will be directly transferred to the company&#x20;

#### 2. Payment Splitting to Separate Service Fee, Gas Fee and Company Income

Stripe payment provider has a native payment splitting functionality which transfer to W3block the service fee and transactions gas fees automatically without the need of the company to receive and/or declare that income.

{% hint style="warning" %}
*Other payment providers can also offer that functionality, but that's under construction*
{% endhint %}

<details>

<summary>Company Configuration Model (Example)</summary>

```json
{
  "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "createdAt": "2022-11-03T22:33:20.215Z",
  "updatedAt": "2022-11-03T22:33:20.215Z",
  "companyId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "company": {
    "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "createdAt": "2022-11-03T22:33:20.215Z",
    "updatedAt": "2022-11-03T22:33:20.215Z",
    "name": "W3Block testing company"
  },
  "banners": [
    {
      "text": "Banner description",
      "buttonText": "Click",
      "buttonLink": "https://w3block.io",
      "image": {
        "thumb": "https://dummyimage.com/200x200/fff/000",
        "original": "https://dummyimage.com/600x400/fff/000",
        "assetId": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
      }
    }
  ],
  "deliveryDelays": [
    {
      "paymentMethod": "credit_card",
      "delay": 259200000
    }
  ],
  "domain": "string",
  "logo": "string",
  "operatorWalletAddress": "string",
  "paymentProviders": [],
  "clientServiceFeePercentage": 0,
  "companyServiceFeePercentage": 0
}
```

</details>

## Service Methods

### Gets company configurations

<details>

<summary>Using SDK</summary>

{% code lineNumbers="true" %}

```typescript
// init your sdk as defined in main page of Commerce service
import { W3blockCommerceSDK } from '@w3block/sdk-commerce';
const sdk: W3blockCommerceSDK;
...

const companyId = '<Your companyId/TenantId>';
const configurations = await sdk.api.admin.getCompanyConfigurations(companyId);
console.log('configurations', configurations);
```

{% endcode %}

</details>

Rest API reference:

{% openapi src="<https://commerce.pixway.io/sdk-json>" path="/admin/companies/{companyId}/configurations" method="get" %}
<https://commerce.pixway.io/sdk-json>
{% endopenapi %}

### Updates some company configurations

<details>

<summary>Using SDK</summary>

{% code lineNumbers="true" %}

```typescript
// init your sdk as defined in main page of Commerce service
import { W3blockCommerceSDK, PaymentMethod } from '@w3block/sdk-commerce';
const sdk: W3blockCommerceSDK;
...

const companyId = '<Your companyId/TenantId>';
await sdk.api.admin.updateCompanyConfigurations(companyId, {
      deliverDelays: [
            {
                  paymentMethod: PaymentMethod.CreditCard,
                  delay: 0,
            }
      ],
});
```

{% endcode %}

</details>

Rest API reference:

{% openapi src="<https://commerce.pixway.io/sdk-json>" path="/admin/companies/{companyId}/configurations" method="patch" %}
<https://commerce.pixway.io/sdk-json>
{% endopenapi %}

### Set a specific payment provider to be used into some currency

<details>

<summary>Using SDK</summary>

{% code lineNumbers="true" %}

```typescript
// init your sdk as defined in main page of Commerce service
import { W3blockCommerceSDK, PaymentProviderEnum } from '@w3block/sdk-commerce';
const sdk: W3blockCommerceSDK;
...

const companyId = '<Your companyId/TenantId>';
const currencyId = '<currencyId>';
await sdk.api.admin.setCompanyCurrencyPaymentProvider(companyId, currencyId, {
      paymentProvider: PaymentProviderEnum.Stripe
});
```

{% endcode %}

</details>

Rest API reference:

{% openapi src="<https://commerce.pixway.io/sdk-json>" path="/admin/companies/{companyId}/configurations/currencies/{currencyId}" method="patch" %}
<https://commerce.pixway.io/sdk-json>
{% endopenapi %}

### Configures Pagar.me payment provider

Rest API reference:

{% openapi src="<https://commerce.pixway.io/sdk-json>" path="/admin/companies/{companyId}/configurations/providers/pagar-me" method="patch" %}
<https://commerce.pixway.io/sdk-json>
{% endopenapi %}

### Configures Paypal payment provider

Rest API reference:

{% openapi src="<https://commerce.pixway.io/sdk-json>" path="/admin/companies/{companyId}/configurations/providers/paypal" method="patch" %}
<https://commerce.pixway.io/sdk-json>
{% endopenapi %}

### Request Stripe payment provider configuration

Rest API reference:

{% openapi src="<https://commerce.pixway.io/sdk-json>" path="/admin/companies/{companyId}/configurations/providers/stripe" method="patch" %}
<https://commerce.pixway.io/sdk-json>
{% endopenapi %}

### Finish stripe payment provider configuration

Rest API reference:

{% openapi src="<https://commerce.pixway.io/sdk-json>" path="/admin/companies/{companyId}/configurations/providers/stripe/finish-connection" method="patch" %}
<https://commerce.pixway.io/sdk-json>
{% endopenapi %}

### Refresh stripe payment provider configuration

Rest API reference:

{% openapi src="<https://commerce.pixway.io/sdk-json>" path="/admin/companies/{companyId}/configurations/providers/stripe/refresh-connection" method="patch" %}
<https://commerce.pixway.io/sdk-json>
{% endopenapi %}

### Deletes some payment provider configuration

Rest API reference:

{% openapi src="<https://commerce.pixway.io/sdk-json>" path="/admin/companies/{companyId}/configurations/providers/{provider}" method="delete" %}
<https://commerce.pixway.io/sdk-json>
{% endopenapi %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://w3block.gitbook.io/w3block-eng/dev-docs/api/commerce-api-services/company-administration/companies-admin.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
