# Payments

Emporix allows for configuration of a variety of payment methods. In the scenarios below, you can see how the configuration works with the example of Emporix demo storefront.

{% hint style="info" %}
To learn about the technical implementation of the Emporix payment gateway, see the [Payments](https://developer.emporix.io/ce/extensibility-and-integrations/payments) documentation in the System Management section.
{% endhint %}

## User scenarios

Examples of the payment methods seen from the user perspective when creating an order on a storefront.

### Credit Card with Spreedly Express

When users choose to pay with a credit card, they have to follow the standard payment process and provide their credit card details for payment authorization.

1. As a checkout step, the user sees a list of available payment methods and selects the **Credit card** payment option.

<figure><img src="https://3057647601-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbTY7EwZtYYQYC6GOcdTj%2Fuploads%2Fgit-blob-4df7358484d8a455e97fa5100b74a00569108066%2Fcredit_card.png?alt=media" alt=""><figcaption></figcaption></figure>

2. The user chooses the **Enter Payment Info** button and then provided the credit card details.

<figure><img src="https://3057647601-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbTY7EwZtYYQYC6GOcdTj%2Fuploads%2Fgit-blob-6692d7c0b0ae8fe7f47142793cb45822680dbd0e%2Fcredit_card_pay.png?alt=media" alt=""><figcaption></figcaption></figure>

3. The user chooses **Pay Now** and finished the checkout process. The payment amount is authorized automatically and it is captured during the invoice generation.

### Credit Card 3D Secure with Spreedly Express

Users can choose to pay with a 3D secure credit card. In comparison to the standard credit card, 3D secure adds an additional security layer to the payment process. Users have to provide an authorization token that is generated and sent to them during the payment process.

1. As a checkout step, the user sees a list of available payment methods and selects the **Credit card (3D Secure)** payment option.
2. The user chooses the **Enter Payment Info** button and then has to provide the credit card details.
3. The user chooses **Pay Now** and sees the 3D Secure window.

<figure><img src="https://3057647601-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbTY7EwZtYYQYC6GOcdTj%2Fuploads%2Fgit-blob-353c1877273d512bbc491124e7eda0eca0df1844%2F3ds.png?alt=media" alt=""><figcaption></figcaption></figure>

4. The user finishes the checkout with the credit card authorization. Spreedly sends a callback to the Emporix payment gateway with a result of the authorization. The payment amount is authorized automatically and it is captured during the invoice generation.

### Spreedly Sprel

Spreedly Sprel is a solution to use for the off-site payments. It means the payments are done after an order is placed.

1. As a checkout step, the user sees a list of available payment methods and selects the **Sprel** payment option.

<figure><img src="https://3057647601-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbTY7EwZtYYQYC6GOcdTj%2Fuploads%2Fgit-blob-2f359b144b82018bd86c6e3ca7f95a11d2f11736%2Fsprel.png?alt=media" alt=""><figcaption></figcaption></figure>

2. The user completes the checkout and after the order is completed sees the option to finish the payment.

<figure><img src="https://3057647601-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbTY7EwZtYYQYC6GOcdTj%2Fuploads%2Fgit-blob-d83395704f3930bc3275ac28e35c6d2d68c9a7ea%2Fsprel2.png?alt=media" alt=""><figcaption></figcaption></figure>

3. The user chose the **Finish Payment** button and completed the payment process. Spreedly sends a callback to the Emporix payment gateway with a result of the authorization. The payment amount is authorized automatically and it is captured during the invoice generation.

## Payment operations

Details of the payment possibilities, cancellations and returns.

### Payment statuses

To check a payment status of an order, go to Management Dashboard -> **Orders** -> **Payment Info** tab.

* In the **Payment information** section, you have information about the payment provider, payment method, transaction ID (an internal Emporix transaction ID), current status, authorized amount, paid amount and the last message.
* In the **Transaction logs** section you can see all the payment events. Usually the following events are included there:
  * AUTHORIZATION\_START - when an order is created
  * AUTHORIZATION\_CALLBACK - when Spreedly notifies Emporix Payment-Gateway service about authorization status)
  * CAPTURE\_SUCCESS - when an invoice is generated and capture operation finished with success

All possible statuses:

* PENDING - an order has been created but payment is not done yet
* AUTHORIZATION\_SUCESS - an authorization flow finished with success
* AUTHORIZATION\_FAILURE - an authorization flow finished with failure
* CAPTURE\_SUCCESS - a capture flow finished with success
* CAPTURE\_FAILURE - a capture flow finished with failure
* CANCELLATION\_SUCCESS - a cancellation flow finished with success
* CANCELLATION\_FAILURE - a cancellation flow finished with failure
* REFUND\_SUCCESS - a refund flow finished with success
* REFUND\_FAILURE - a refund flow finished with failure

### Payment capture

Capture is a process done during an invoice generation. It's when a payment is completed by settling funds for the transaction.

1. To generate the invoice, go to Management Dashboard -> **Orders**.
2. Select the order and go to the **Data** tab.
3. Choose the **Send Invoice** button.

<figure><img src="https://3057647601-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbTY7EwZtYYQYC6GOcdTj%2Fuploads%2Fgit-blob-4e8f7fa78e14fbb23221431d58a3563c56a72ca2%2Fcapture.png?alt=media" alt=""><figcaption></figcaption></figure>

**Result**: The payment capture is done with the invoice generation. After that, the invoice is sent to a customer.

### Payment refund

The payment refund is possible only when a payment has been invoiced and capture done. The user can get a full or partial refund of the order, but it's not possible to return more than the captured value.

1. To create the refund, go to Management Dashboard -> **Orders**.
2. Select the order for which the payment should be revoked and go to the **Payment Info** tab.
3. In the **Refund** section add a value that should be refunded and confirm it by choosing the **Refund** button.

<figure><img src="https://3057647601-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbTY7EwZtYYQYC6GOcdTj%2Fuploads%2Fgit-blob-16c5d3d64b7c717fd012825cbfeab525170ed555%2Frefund.png?alt=media" alt=""><figcaption></figcaption></figure>

**Result**: The refund is confirmed and the event is visible in the **Transaction logs**.

<figure><img src="https://3057647601-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbTY7EwZtYYQYC6GOcdTj%2Fuploads%2Fgit-blob-04ea56895a4bcdb855e476a84a4844e491919dca%2Frefund2.png?alt=media" alt=""><figcaption></figcaption></figure>

### Payment cancellation

Payment cancellation can happen for many reasons, for example when a user requests to cancel an order, or an order cannot be completed by a store.

If for any reason the order is not completed and the payment should be cancelled, the merchant can set the order status to cancelled. The cancellation is then done automatically after the status change.

1. To set the status as cancelled, go to Management Dashboard -> **Orders**.
2. Select the order for which the payment is cancelled and go to the **Data** tab.
3. In the **Order** section choose **Cancelled** as the **extended order status**.

<figure><img src="https://3057647601-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbTY7EwZtYYQYC6GOcdTj%2Fuploads%2Fgit-blob-9605f474c305e5783e1bbce9bceb3ccdfc499232%2Fpay_cancel.png?alt=media" alt=""><figcaption></figcaption></figure>

**Result**: The order payment cancellation is visible in the **Payment Info** tab. The status is displayed as **Cancellation Success**.

<figure><img src="https://3057647601-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbTY7EwZtYYQYC6GOcdTj%2Fuploads%2Fgit-blob-e96ee1850c9d217c2214060c2be49dc599e04627%2Fpay_cancel2.png?alt=media" alt=""><figcaption></figcaption></figure>
