Marketplace Example: Difference between revisions

From Barion Documentation
Jump to navigation Jump to search
No edit summary
m (replaced reference to v2 GetPaymentState with v4 PaymentState)
 
(32 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{PageTitle|title=Detailed example of a marketplace payment}}
{{PageTitle|title=Detailed example of a marketplace payment}}


This guide's purpose to show a reservation payment process including a facilitator. After the payment, a refund will be showcased aswell.
{{TableOfContents}}


In this example a demo marketplace will be used as the facilitator. This facilitator will manage the payment  process, but it does not take part in the process as a payee. Neither the customer nor the payee(s) take any actions.
=== Introduction ===


The process starts with the shopping part. The user select  products on a given site. These products  belongs to manufacturers ( other "users" of the system), therefore the prices of their products will be transferred to them. Both manufacturers have a registered Barion wallet but they do not own a shop in the system.
This example is to show the full life cycle of a purchase made at a marketplace scenario. Through this you will be familiar with how the Barion payment system works in a complex payment situation - how the payments are processed, how the money travels between participants and how the systems communicate with each other. '''Please read this carefully.'''
The demo products will be the followings (including the manufacturers):
 
{{NotificationBox|title=WARNING|text=Do '''NOT''' copy any JSON content to your project - these are for demonstration purposes only!|color=#FF7A3D}}
 
Imagine Chef Chris would like to buy some groceries and products at the Marketplace. In this case, we are talking about a facilitated payment scenario, where the Marketplace is the facilitator. The facilitator manages and organizes the whole payment process, but they do not take part in it as a final payee. Instead, they distribute the money between the different sellers of the chosen products.
 
=== Starting the payment ===
 
The process starts with the shopping. Chris has put some products / services (referred to as ''items'') in his shopping cart on the Marketplace website. These items belong to different manufacturers / providers / distributors - other users of the Barion system, henceforth referred to as ''sellers''. They all have registered, active Barion wallets but they do not own a shop in the system.
 
Chris has selected four items from two sellers and went to checkout. The Marketplace informs him that there is a one-day period of confirmation from the sellers upon placing an order.


[[File:marketplace_products_example.png]]
[[File:marketplace_products_example.png]]


At this point, the Marketplace prepares the payment trough the Barion API, using the [[Payment-Start-v2|/v2/Payment/Start]] endpoint. Chris is purchasing items from two separate sellers, the payment will contain two payment transactions, with the respective items and payees set accordingly. Since there is a time window where the sellers should confirm the order, the Marketplace prepares a [[Reservation_payment|reservation payment]] with a reservation period of one day.


 
For this API call the request JSON looks like this :
The next step is to start the payment for the selected products via Barion. The facilitator prepares the payment trough the Barion API ([[Payment-Start-v2|/Payment/Start]]). Two transactions will be specified, with the manufacturers set as payees.
For this specific payment the required JSON content would look like this :


<syntaxhighlight lang="json">  
<syntaxhighlight lang="json">  
Line 20: Line 28:
     "PaymentType": "Reservation",
     "PaymentType": "Reservation",
     "ReservationPeriod": "1.00:00:00",
     "ReservationPeriod": "1.00:00:00",
     "PaymentRequestId": "TEST-01",
     "PaymentRequestId": "MARKETPAY-123456",
     "GuestCheckOut" : true,
     "GuestCheckOut" : true,
     "FundingSources": ["All"],
     "FundingSources": ["All"],
     "Locale":"en-US",
     "Locale":"en-US",
    "OrderNumber": "1234-5678",
     "Currency":"EUR",
     "Currency":"EUR",
     "Transactions": [
     "Transactions": [
         {
         {
             "POSTransactionId": "TEST-01-01",
             "POSTransactionId": "MP-TR-01",
             "Payee": "[email protected]",
             "Payee": "[email protected]",
             "Total": "49",
             "Total": "49",
Line 62: Line 71:
         },
         },
         {
         {
             "POSTransactionId": "TEST-01-02",
             "POSTransactionId": "MP-TR-02",
             "Payee": "[email protected]",
             "Payee": "[email protected]",
             "Total": "35",
             "Total": "35",
Line 82: Line 91:
</syntaxhighlight>
</syntaxhighlight>


{{NotificationBox|title=WARNING|text=Do '''NOT''' copy this JSON to your project without modifications, this is for demo purposes only.|color=#FF7A3D}}
The Barion API accepts the request and prepares the payment. The response JSON content is sent to the Marketplace:
 
 
The response JSON for this request would be the following:


<syntaxhighlight lang="json">  
<syntaxhighlight lang="json">  
{
{
     "PaymentId": "48257505a0541244bo7dffb85d5fb62ca",
     "PaymentId": "c2283b509e424b729cabca6437079d6e",
     "PaymentRequestId": "TEST-01",
     "PaymentRequestId": "MARKETPAY-123456",
     "Status": "Prepared",
     "Status": "Prepared",
     "QRUrl": "https://api.barion.com/qr/generate?paymentId=48257700-d044-344a-85df-fc75d5fu62cd&size=Large",
     "QRUrl": "https://api.barion.com/qr/generate?paymentId=48257700-d044-344a-85df-fc75d5fu62cd&size=Large",
     "Transactions": [
     "Transactions": [
         {
         {
             "POSTransactionId": "TEST-01-01",
             "POSTransactionId": "MP-TR-01",
             "TransactionId": "3db7ffbacuea463c93p5145e172fc3d6",
             "TransactionId": "07ecff0bb7404b40aeae1bb285ed38c8",
             "Status": "Prepared",
             "Status": "Prepared",
             "Currency": "EUR",
             "Currency": "EUR",
Line 103: Line 109:
         },
         },
         {
         {
             "POSTransactionId": "TEST-01-02",
             "POSTransactionId": "MP-TR-02",
             "TransactionId": "a2b7tfbncwpa663c96i2946g122fq3de",
             "TransactionId": "b673b95ee96746ca8e182a8596d67a9e",
             "Status": "Prepared",
             "Status": "Prepared",
             "Currency": "EUR",
             "Currency": "EUR",
Line 112: Line 118:
     ],
     ],
     "RecurrenceResult": "None",
     "RecurrenceResult": "None",
     "GatewayUrl": "https://secure.barion.com:443/Pay?Id=48257700d044344a85dffc75d5fu62cd",
     "GatewayUrl": "https://secure.barion.com:443/Pay?Id=c2283b509e424b729cabca6437079d6e",
     "RedirectUrl": "https://testshop.barion.com/Redirect?paymentId=48257700d044344a85dffc75d5fu62cd",
     "RedirectUrl": "https://testshop.barion.com/Redirect?paymentId=c2283b509e424b729cabca6437079d6e",
     "CallbackUrl": "https://testshop.barion.com/callback?paymentId=48257700d044344a85dffc75d5fu62cd",
     "CallbackUrl": "https://testshop.barion.com/callback?paymentId=c2283b509e424b729cabca6437079d6e",
     "Errors": []
     "Errors": []
}
}
</syntaxhighlight>
</syntaxhighlight>


{{NotificationBox|title=WARNING|text=Its important to save the PaymentId and the TransactionIds. These will be the key parameters for further requests.|color=#FF7A3D}}
The Marketplace system logs the result and stores the appropriate parameters of the order (eg. the identifiers for the payment and its transactions) for later use.
 
 
If the prepare is done, the user will be redirected to the following page:
 
[[File:marketplace_payment_example.png|750px]]
 
The customer will see the payee is the facilitator, while the sellers are the manufacturers.
 
 


At this point they can choose from paying using either with their Barion wallet or with bank card.
=== Paying on the Barion Smart Gateway ===
If they choose the Barion wallet option, and log in successfully, they can finish the payment with any of their saved cards ( or add a new one), or with the funds in their wallet:


[[File:marketplace_payment_payment_type_example.png | 700px]]
At this point, the Marketplace has all necessary data. It successfully processed the response from the Barion API, so they redirect Chris's browser to the Barion Smart Gateway:


In this case the reserved amount will stay in the payer's wallet.
[[File:marketplace_example_payment_gateway.png|800px]]


In case of bank card payment, they need to fill the required card datas and their email address. This way the amount is transferred the manufacturers, but stays in reserved status.
Chris logs in to the Barion system and chooses one of his saved bank cards to pay for the order.


When the user selected from the give payment options and completed the process, the system sends a callback to the facilitator about the reservation. The status of the payment becomes Reserved.
The payment is successfully finished in a few seconds. The Barion Smart Gateway confirms the successful payment in a summary window.


If the payment is successfully finished, they will be redirected to the following page:
[[File:marketplace_example_payment_completed.png|800px]]


[[File:marketplace_payment_finish.png | 700px]]
Chris's browser is redirected back to the Marketplace's website, where he may get another confirmation of the order being processed.
At this point, the reservation timer is started. The Marketplace has one day to finish the reservation.


The paid amount is transferred to the Barion wallets of Terry Wellington (€49) and Robert Craig (€84), but the amount is blocked and is not available to use until the reservation is finished.


The Barion system also sends a [[Callback_mechanism|callback]] to the Marketplace so they can process data accordingly even if Chris never returns to the Marketplace website.


After a short period of time, the user be redirected back to the shop's site (the RerdirectUrl can be specified at the  [[Payment-Start-v2|Payment Start]]).
=== Finishing the reservation ===
The reservation is started, but it has to be finished by the facilitator before the reservation period passes (in this example this time period is 24 hours).


{{NotificationBox|title=NOTE|text=''If the payment should be refunded at this point, the facilitator had to finish the reservation with a total amount of zero.''|color=#1993c7}}
The next day the facilitator is informed that one of the items (€9 worth of fresh potatoes) ran out of stock at Terry Wellington. The Marketplace removes this item from Chris's order and modifies the transaction accordingly. All other items are available.


Because the total amount due to the payment is changed, the Marketplace has to finish the reservation with an amount lower than the initial value. The Marketplace sends a request to the Barion API to finish the reservation, via the [[Payment-FinishReservation-v2|/v2/Payment/FinishReservation]] API endpoint, using the payment and transaction identifiers received earlier when preparing the payment.
The JSON content of the request looks like this:


The "next day" the facilitator  completes the reservation. However potatoes have tainted over the night, so it will be removed from the payment. This can be achieved by removing the said product from the finishing JSON:
<syntaxhighlight lang="json">  
<syntaxhighlight lang="json">  
{
{
     "POSKey": "60F99E979-S5U2-4AA2-BC9F-DF14ABA4P8F17",
     "POSKey": "60F99E979-S5U2-4AA2-BC9F-DF14ABA4P8F17",
     "PaymentId": "48257505a0541244bo7dffb85d5fb62ca",
     "PaymentId": "c2283b509e424b729cabca6437079d6e",
     "Transactions": [
     "Transactions": [
         {
         {
             "TransactionId": "3db7ffbacuea463c93p5145e172fc3d6",
             "TransactionId": "07ecff0bb7404b40aeae1bb285ed38c8",
             "Payee": "[email protected]",
             "Payee": "[email protected]",
             "Total": "40",
             "Total": "40",
Line 186: Line 185:
         },
         },
         {
         {
             "TransactionId": "a2b7tfbncwpa663c96i2946g122fq3de",
             "TransactionId": "b673b95ee96746ca8e182a8596d67a9e",
             "Payee": "[email protected]",
             "Payee": "[email protected]",
             "Total": "35",
             "Total": "35",
Line 206: Line 205:
</syntaxhighlight>
</syntaxhighlight>


{{NotificationBox|title=WARNING|text=Do '''NOT''' copy this JSON to your project without modifications, this is for demo purposes only.|color=#FF7A3D}}
{{NotificationBox|title=NOTE|text=See the items and the total amount for the first payment transaction has changed!|color=#1993c7}}


They PaymentId and TransactionIds are the same as the ones got in the response from /Payment/Start!
The Barion API accepts and processes the request. Both transactions are finished successfully. The payment is set to <code>Succeeded</code> state.


In case of a successful finish the following response should arrive:
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
{
{
     "IsSuccessful": true,
     "IsSuccessful": true,
     "PaymentId": "6ca30e4b-1d3d-467b-8b47-87e6a555523e",
     "PaymentId": "c2283b509e424b729cabca6437079d6e",
     "PaymentRequestId": "TEST-01",
     "PaymentRequestId": "MARKETPAY-123456",
     "Status": "Succeeded",
     "Status": "Succeeded",
     "Transactions": [
     "Transactions": [
         {
         {
             "POSTransactionId": "TEST-01-01",
             "POSTransactionId": "MP-TR-01",
             "TransactionId": "56f399b094d14a75afc7644a3c0ed84f",
             "TransactionId": "07ecff0bb7404b40aeae1bb285ed38c8",
             "Status": "Succeeded",
             "Status": "Succeeded",
             "Currency": "HUF",
             "Currency": "EUR",
             "TransactionTime": "2017-12-20T13:47:11.251Z",
             "TransactionTime": "2017-12-20T13:47:11.251Z",
             "RelatedId": null
             "RelatedId": null
         },
         },
         {
         {
             "POSTransactionId": "TEST-01-02",
             "POSTransactionId": "MP-TR-02",
             "TransactionId": "6f44d84031a6424d83208abcc5824fab",
             "TransactionId": "b673b95ee96746ca8e182a8596d67a9e",
             "Status": "Succeeded",
             "Status": "Succeeded",
             "Currency": "HUF",
             "Currency": "EUR",
             "TransactionTime": "2017-12-20T13:47:11.251Z",
             "TransactionTime": "2017-12-20T13:47:11.251Z",
             "RelatedId": null
             "RelatedId": null
Line 239: Line 237:
</syntaxhighlight>
</syntaxhighlight>


The difference between the finished and reserved amount (9 euros in this example) will be refunded to the payer. A callback sent to the facilitator.
Even though the Marketplace just received a response and probably processed it, the Barion system also sends a [[Callback_mechanism|callback]] to the respective callback URL of the payment - should there be any extra processing required in the Marketplace system.
Since this is a marketplace scenario, the payees will be the manufacturers(in this case Terry and Robert). They will pay a fee to the facilitator (they may pay for other third parties, however in this example no other payments will happen for simplicity) for its services. The distribution of the payed amount, and the applicable fee(s) is automatically managed by the Barion system (based on the specified payment transactions by the facilitator).


So the reservation is finished at this point, but when the products arrive it turns out that the 8 piece knives set, is actually contains only seven knives. Therefore the payer demands a full refund.
From the reserved amount of €49 in Terry Wellington's wallet, €40 is released and is now available for him to use. The €9 difference from the initially reserved amount is automatically refunded to Chris's bank card. Robert Craig receives the whole amount of €35.
The manufacturer initiates the refund. To start a refund the user must log in to their Barion wallet. The transaction details are under the activity tab. With the "Refund the transaction amount" button the user will be redirected to the refund page. A refund can not exceed the paid amount, but it can be lesser than that. In this example a full refund will happen so the refunded amount will be the same as the paid one (35 euros).
 
When the user (Robert for this case) clicks on "Refund" button the following JSON will be sent to [[Payment-Refund-v2|/Payment-Refund-v2]]:
The Marketplace informs Chris about the confirmed order and that the items are being shipped.
 
=== Refunding the payment ===
 
Chris receives the items he ordered and discovers that the knife set he ordered from Robert Craig has broken during shipment. He informs the Marketplace about this.
 
The Marketplace forwards his feedback to Robert, who arranges a full refund with Chris in compensation.  
Robert can do the refund via the Barion web user interface under the details of the corresponding payment after logging into his Barion wallet.
 
If Robert is not available for some reason, the Marketplace may also refund the payment via the Barion API, using the [[Payment-Refund-v2|/vs/Payment/Refund]] endpoint.
In this case, the following JSON content is sent in the request:


<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
{
{
     "POSKey": "60I98E979-Z592-4AA2-BC9F-DF14ABA4P8F17",
     "POSKey": "60I98E979-Z592-4AA2-BC9F-DF14ABA4P8F17",
     "PaymentId": "48257700-d044-344a-85df-fc75d5fu62cd",
     "PaymentId": "c2283b509e424b729cabca6437079d6e",
     "TransactionsToRefund": [{
     "TransactionsToRefund": [{
         "TransactionId": "6f44d84031a6424d83208abcc5824fab",
         "TransactionId": "b673b95ee96746ca8e182a8596d67a9e",
         "AmountToRefund": 35,
         "AmountToRefund": 35,
         "POSTransactionId": "TEST-01-02",
         "POSTransactionId": "MP-TR-02",
         "Comment": "Faulty product"
         "Comment": "Refund due to broken product sold at Marketplace"
     }],
     }],
}
}
</syntaxhighlight>
</syntaxhighlight>


{{NotificationBox|title=WARNING|text=Do '''NOT''' copy this JSON to your project without modifications, this is for demo purposes only.|color=#FF7A3D}}
The Barion API receives the refund request and processes it. The refund successfully takes place, although Chris might have to wait up to 30 days to receive the refund on his bank card, depending on the bank system.


If the refund was successful the response would look like this:
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
{
{
     "POSKey": "60I98E979-Z592-4AA2-BC9F-DF14ABA4P8F17",
     "POSKey": "60I98E979-Z592-4AA2-BC9F-DF14ABA4P8F17",
     "PaymentId": "48257700-d044-344a-85df-fc75d5fu62cd",
     "PaymentId": "c2283b509e424b729cabca6437079d6e",
     "RefundedTransactions": [{
     "RefundedTransactions": [{
         "TransactionId": "6f44d84031a6424d83208abcc5824fab",
         "TransactionId": "b673b95ee96746ca8e182a8596d67a9e",
         "Total": 35,
         "Total": 35,
         "POSTransactionId": "TEST-01-02",
         "POSTransactionId": "MP-TR-02",
         "Comment": "Faulty product",
         "Comment": "Refund due to broken product sold at Marketplace",
         "Status": "Succeded"
         "Status": "Succeeded"
     }],
     }],
     "Errors": []
     "Errors": []
Line 277: Line 283:
</syntaxhighlight>
</syntaxhighlight>


 
Whoever initiated the refund, the Barion system sends a [[Callback_mechanism|callback]] to the Marketplace so they can do additional processing if they need to.


== Reference ==
== Reference ==
* [[Payment-Start-v2|/Payment/Start]]
* [[Payment-Start-v2|/Payment/Start]]
* [[Marketplace|/Marketplace]]
* [[Payment-PaymentState-v4|/v4/Payment/<PaymentId>/PaymentState]]
* [[Reservation|/Reservation_payment]]
* [[Payment-FinishReservation-v2|/Payment/FinishReservation]]
* [[Finish reservation|/Payment-FinishReservation-v2]]
* [[Payment-Refund-v2|/Payment/Refund]]
* [[Refund|/Payment-Refund-v2]]

Latest revision as of 10:14, 25 March 2024

Detailed example of a marketplace payment

Introduction

This example is to show the full life cycle of a purchase made at a marketplace scenario. Through this you will be familiar with how the Barion payment system works in a complex payment situation - how the payments are processed, how the money travels between participants and how the systems communicate with each other. Please read this carefully.

WARNING
Do NOT copy any JSON content to your project - these are for demonstration purposes only!

Imagine Chef Chris would like to buy some groceries and products at the Marketplace. In this case, we are talking about a facilitated payment scenario, where the Marketplace is the facilitator. The facilitator manages and organizes the whole payment process, but they do not take part in it as a final payee. Instead, they distribute the money between the different sellers of the chosen products.

Starting the payment

The process starts with the shopping. Chris has put some products / services (referred to as items) in his shopping cart on the Marketplace website. These items belong to different manufacturers / providers / distributors - other users of the Barion system, henceforth referred to as sellers. They all have registered, active Barion wallets but they do not own a shop in the system.

Chris has selected four items from two sellers and went to checkout. The Marketplace informs him that there is a one-day period of confirmation from the sellers upon placing an order.

At this point, the Marketplace prepares the payment trough the Barion API, using the /v2/Payment/Start endpoint. Chris is purchasing items from two separate sellers, the payment will contain two payment transactions, with the respective items and payees set accordingly. Since there is a time window where the sellers should confirm the order, the Marketplace prepares a reservation payment with a reservation period of one day.

For this API call the request JSON looks like this :

 
{
    "POSKey": "60I98E979-Z592-4AA2-BC9F-DF14ABA4P8F17",
    "PaymentType": "Reservation",
    "ReservationPeriod": "1.00:00:00",
    "PaymentRequestId": "MARKETPAY-123456",
    "GuestCheckOut" : true,
    "FundingSources": ["All"],
    "Locale":"en-US",
    "OrderNumber": "1234-5678",
    "Currency":"EUR",
    "Transactions": [
        {
            "POSTransactionId": "MP-TR-01",
            "Payee": "[email protected]",
            "Total": "49",
            "Comment": "Order 1",
            "Items": [
                {
                    "Name": "Fresh potatoes",
                    "Description": "Fresh potatoes",
                    "Quantity": 3,
                    "Unit": "kg",
                    "UnitPrice": 3,
                    "ItemTotal": 9,
                    "SKU": "SM-01"
                },
                {
                    "Name": "Ginger, sliced",
                    "Description": "Ginger, sliced",
                    "Quantity": 2,
                    "Unit": "packs",
                    "UnitPrice": 10,
                    "ItemTotal": 20,
                    "SKU": "SM-02"
                },
                {
                    "Name": "Truffle box",
                    "Description": "Truffle box",
                    "Quantity": 1,
                    "Unit": "pc",
                    "UnitPrice": 20,
                    "ItemTotal": 20,
                    "SKU": "SM-03"
                }
            ]
        },
        {
            "POSTransactionId": "MP-TR-02",
            "Payee": "[email protected]",
            "Total": "35",
            "Comment": "Order  2",
            "Items": [
                {
                    "Name": "8 piece kitchen knives set",
                    "Description": "8 piece kitchen knives set",
                    "Quantity": 1,
                    "Unit": "pc",
                    "UnitPrice": 35,
                    "ItemTotal": 35,
                    "SKU": "SM-04"
                }
            ]
        }
    ]
}

The Barion API accepts the request and prepares the payment. The response JSON content is sent to the Marketplace:

 
{
    "PaymentId": "c2283b509e424b729cabca6437079d6e",
    "PaymentRequestId": "MARKETPAY-123456",
    "Status": "Prepared",
    "QRUrl": "https://api.barion.com/qr/generate?paymentId=48257700-d044-344a-85df-fc75d5fu62cd&size=Large",
    "Transactions": [
        {
            "POSTransactionId": "MP-TR-01",
            "TransactionId": "07ecff0bb7404b40aeae1bb285ed38c8",
            "Status": "Prepared",
            "Currency": "EUR",
            "TransactionTime": "2017-12-20T12:37:39.696",
            "RelatedId": null
        },
        {
            "POSTransactionId": "MP-TR-02",
            "TransactionId": "b673b95ee96746ca8e182a8596d67a9e",
            "Status": "Prepared",
            "Currency": "EUR",
            "TransactionTime": "2017-12-20T12:37:39.696",
            "RelatedId": null
        }
    ],
    "RecurrenceResult": "None",
    "GatewayUrl": "https://secure.barion.com:443/Pay?Id=c2283b509e424b729cabca6437079d6e",
    "RedirectUrl": "https://testshop.barion.com/Redirect?paymentId=c2283b509e424b729cabca6437079d6e",
    "CallbackUrl": "https://testshop.barion.com/callback?paymentId=c2283b509e424b729cabca6437079d6e",
    "Errors": []
}

The Marketplace system logs the result and stores the appropriate parameters of the order (eg. the identifiers for the payment and its transactions) for later use.

Paying on the Barion Smart Gateway

At this point, the Marketplace has all necessary data. It successfully processed the response from the Barion API, so they redirect Chris's browser to the Barion Smart Gateway:

Chris logs in to the Barion system and chooses one of his saved bank cards to pay for the order.

The payment is successfully finished in a few seconds. The Barion Smart Gateway confirms the successful payment in a summary window.

Chris's browser is redirected back to the Marketplace's website, where he may get another confirmation of the order being processed. At this point, the reservation timer is started. The Marketplace has one day to finish the reservation.

The paid amount is transferred to the Barion wallets of Terry Wellington (€49) and Robert Craig (€84), but the amount is blocked and is not available to use until the reservation is finished.

The Barion system also sends a callback to the Marketplace so they can process data accordingly even if Chris never returns to the Marketplace website.

Finishing the reservation

The next day the facilitator is informed that one of the items (€9 worth of fresh potatoes) ran out of stock at Terry Wellington. The Marketplace removes this item from Chris's order and modifies the transaction accordingly. All other items are available.

Because the total amount due to the payment is changed, the Marketplace has to finish the reservation with an amount lower than the initial value. The Marketplace sends a request to the Barion API to finish the reservation, via the /v2/Payment/FinishReservation API endpoint, using the payment and transaction identifiers received earlier when preparing the payment. The JSON content of the request looks like this:

 
{
    "POSKey": "60F99E979-S5U2-4AA2-BC9F-DF14ABA4P8F17",
    "PaymentId": "c2283b509e424b729cabca6437079d6e",
     "Transactions": [
        {
            "TransactionId": "07ecff0bb7404b40aeae1bb285ed38c8",
            "Payee": "[email protected]",
            "Total": "40",
            "Comment": "Order 1",
            "Items": [
                {
                    "Name": "Ginger, sliced",
                    "Description": "Ginger, sliced",
                    "Quantity": 2,
                    "Unit": "packs",
                    "UnitPrice": 10,
                    "ItemTotal": 20,
                    "SKU": "SM-02"
                },
                {
                    "Name": "Truffle box",
                    "Description": "Truffle box",
                    "Quantity": 1,
                    "Unit": "pc",
                    "UnitPrice": 20,
                    "ItemTotal": 20,
                    "SKU": "SM-03"
                }
            ]
        },
        {
            "TransactionId": "b673b95ee96746ca8e182a8596d67a9e",
            "Payee": "[email protected]",
            "Total": "35",
            "Comment": "Order  2",
            "Items": [
                {
                    "Name": "8 piece kitchen knives set",
                    "Description": "8 piece kitchen knives set",
                    "Quantity": 1,
                    "Unit": "pc",
                    "UnitPrice": 35,
                    "ItemTotal": 35,
                    "SKU": "SM-04"
                }
            ]
        }
    ]
}
NOTE
See the items and the total amount for the first payment transaction has changed!

The Barion API accepts and processes the request. Both transactions are finished successfully. The payment is set to Succeeded state.

{
    "IsSuccessful": true,
    "PaymentId": "c2283b509e424b729cabca6437079d6e",
    "PaymentRequestId": "MARKETPAY-123456",
    "Status": "Succeeded",
    "Transactions": [
        {
            "POSTransactionId": "MP-TR-01",
            "TransactionId": "07ecff0bb7404b40aeae1bb285ed38c8",
            "Status": "Succeeded",
            "Currency": "EUR",
            "TransactionTime": "2017-12-20T13:47:11.251Z",
            "RelatedId": null
        },
        {
            "POSTransactionId": "MP-TR-02",
            "TransactionId": "b673b95ee96746ca8e182a8596d67a9e",
            "Status": "Succeeded",
            "Currency": "EUR",
            "TransactionTime": "2017-12-20T13:47:11.251Z",
            "RelatedId": null
        }
    ],
    "Errors": []
}

Even though the Marketplace just received a response and probably processed it, the Barion system also sends a callback to the respective callback URL of the payment - should there be any extra processing required in the Marketplace system.

From the reserved amount of €49 in Terry Wellington's wallet, €40 is released and is now available for him to use. The €9 difference from the initially reserved amount is automatically refunded to Chris's bank card. Robert Craig receives the whole amount of €35.

The Marketplace informs Chris about the confirmed order and that the items are being shipped.

Refunding the payment

Chris receives the items he ordered and discovers that the knife set he ordered from Robert Craig has broken during shipment. He informs the Marketplace about this.

The Marketplace forwards his feedback to Robert, who arranges a full refund with Chris in compensation. Robert can do the refund via the Barion web user interface under the details of the corresponding payment after logging into his Barion wallet.

If Robert is not available for some reason, the Marketplace may also refund the payment via the Barion API, using the /vs/Payment/Refund endpoint. In this case, the following JSON content is sent in the request:

{
    "POSKey": "60I98E979-Z592-4AA2-BC9F-DF14ABA4P8F17",
    "PaymentId": "c2283b509e424b729cabca6437079d6e",
    "TransactionsToRefund": [{
        "TransactionId": "b673b95ee96746ca8e182a8596d67a9e",
        "AmountToRefund": 35,
        "POSTransactionId": "MP-TR-02",
        "Comment": "Refund due to broken product sold at Marketplace"
    }],
}

The Barion API receives the refund request and processes it. The refund successfully takes place, although Chris might have to wait up to 30 days to receive the refund on his bank card, depending on the bank system.

{
    "POSKey": "60I98E979-Z592-4AA2-BC9F-DF14ABA4P8F17",
    "PaymentId": "c2283b509e424b729cabca6437079d6e",
    "RefundedTransactions": [{
        "TransactionId": "b673b95ee96746ca8e182a8596d67a9e",
        "Total": 35,
        "POSTransactionId": "MP-TR-02",
        "Comment": "Refund due to broken product sold at Marketplace",
        "Status": "Succeeded"
    }],
    "Errors": []
}

Whoever initiated the refund, the Barion system sends a callback to the Marketplace so they can do additional processing if they need to.

Reference