Making a test payment: Difference between revisions

From Barion Documentation
Jump to navigation Jump to search
(first iteration. to-do: images, json formatting)
 
(added note about HTTP methods)
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{PageTitle|title=Making a test payment}}
{| style="margin-left:2em;" align="right"
| __TOC__
|}
Get a feel for how Barion works by using the Barion Gateway API to
Get a feel for how Barion works by using the Barion Gateway API to


Line 11: Line 15:
== Make a test payment using the Barion API ==
== Make a test payment using the Barion API ==


# Log in to [https://secure.test.barion.com to your Barion shop].
1. Log in to [https://secure.test.barion.com to your Barion shop].
# Click through to Shops>Actions>Details>Secret Key (POSKey), and copy the value to the clipboard.  [[File:/img/getting-started/posKey-1.png|Finding your shop’s POSKey]] ''Finding your shop’s POSKey''
 
# Start the Postman Desktop agent, and make a POST call to <code>https://api.test.barion.com/v2/payment/start</code>, passing the following JSON in the request body:  Replace the <code>POSKey</code> and the <code>Transactions</code>/<code>Payee</code> as indicated.<pre>{
2. Click through to Shops&#x3E;Actions&#x3E;Details&#x3E;Secret Key (POSKey), and copy the value to the clipboard.  [[File:PosKey-1.png|Finding your shop’s POSKey]]
     &quot;POSKey&quot;: &quot;[the POSKey you've just copied]&quot;,
 
     &quot;PaymentType&quot;: &quot;Immediate&quot;,
''Finding your shop’s POSKey''
     &quot;PaymentRequestId&quot;: &quot;DEV-TEST-615&quot;,
 
     &quot;FundingSources&quot;: [&quot;All&quot;],
{{NotificationBox|title=NOTE|text=All Barion API endpoints accept standard HTTP1.1 GET or POST method requests, but always one or the other only. Calling an endpoint with the incorrect HTTP method returns a JSON error message.|color=#1798DB}}
     &quot;OrderNumber&quot;: &quot;Order_01&quot;,
 
     &quot;RedirectUrl&quot;: &quot;https://example.com/&quot;,
3. Start the Postman Desktop agent, and make a POST call to <code>https://api.test.barion.com/v2/payment/start</code>, passing the following JSON in the request body:  Replace the <code>POSKey</code> and the <code>Transactions</code>/<code>Payee</code> as indicated.
     &quot;Currency&quot;: &quot;EUR&quot;,
<syntaxhighlight lang="json">
     &quot;Locale&quot;:&quot;en-US&quot;,
{
     &quot;GuestCheckOut&quot;: true,
     "POSKey": "[the POSKey you've just copied]",
     &quot;PaymentWindow&quot;:&quot;00:30:00&quot;,
     "PaymentType": "Immediate",
     &quot;Transactions&quot;: [
     "PaymentRequestId": "DEV-TEST-615",
     "FundingSources": ["All"],
     "OrderNumber": "Order_01",
     "RedirectUrl": "https://example.com/",
     "Currency": "EUR",
     "Locale":"en-US",
     "GuestCheckOut": true,
     "PaymentWindow":"00:30:00",
     "Transactions": [
         {
         {
             &quot;POSTransactionId&quot;: &quot;DEV-TEST-01-01&quot;,
             "POSTransactionId": "DEV-TEST-01-01",
             &quot;Payee&quot;: [the email address associated with the Barion shop],
             "Payee": "[the email address associated with the Barion shop]",
             &quot;Total&quot;: 100,
             "Total": 100,
             &quot;Comment&quot;: &quot;Test transaction&quot;,
             "Comment": "Test transaction",
             &quot;Items&quot;: [
             "Items": [
                 {
                 {
                     &quot;Name&quot;: &quot;Nada&quot;,
                     "Name": "Nada",
                     &quot;Description&quot;: &quot;Zilch&quot;,
                     "Description": "Zilch",
                     &quot;Quantity&quot;: 1,
                     "Quantity": 1,
                     &quot;Unit&quot;: &quot;db&quot;,
                     "Unit": "db",
                     &quot;UnitPrice&quot;: 1,
                     "UnitPrice": 1,
                     &quot;ItemTotal&quot;: 1,
                     "ItemTotal": 1,
                     &quot;SKU&quot;: &quot;SM-01&quot;
                     "SKU": "SM-01"
                 }
                 }
             ]
             ]
         }
         }
     ]
     ]
}</pre>For details on the various parameters you’re passing in the call, see [[05-api-reference/01-payment-resource/01-payment-start|the <code>Payment/Start</code> API endpoint reference]].<blockquote>Step result:  The API request returns the following JSON:  <br />{ "PaymentId": [the payment ID generated for the transaction], "PaymentRequestId": "DEV-TEST-187", "Status": "Prepared", "QRUrl": "<nowiki>https://api.test.barion.com/qr/generate?paymentId=</nowiki>[the payment ID generated for the transaction]&size=Large", "Transactions": [ { "POSTransactionId": "DEV-TEST-01-01", "TransactionId": [the payment ID generated for the transaction], "Status": "Prepared", "Currency": "EUR", "TransactionTime": "0001-01-01T00:00:00", "RelatedId": null } ], "RecurrenceResult": "None", "ThreeDSAuthClientData": null, "GatewayUrl": "<nowiki>https://secure.test.barion.com/Pay?Id=2</nowiki>[the payment ID generated for the transaction]", "RedirectUrl": "<nowiki>http://barion.com/?paymentId=</nowiki>[the payment ID generated for the transaction]", "CallbackUrl": "", "TraceId": null, "Errors": [] }</blockquote>
}</syntaxhighlight>
<blockquote>
Here's the cURL version, if that's more convenient:
<syntaxhighlight>
curl --location 'https://api.test.barion.com/v2/payment/start' \
--header 'Content-Type: application/json' \
--data-raw '{
    "POSKey": "5c224ce1-0f2c-4a7a-9ae7-d7c2b481cb71",
    "PaymentType": "Immediate",
    "PaymentRequestId": "DEV-TEST-615",
    "FundingSources": [
        "All"
    ],
    "RedirectUrl": "https://example.com/",
    "Currency": "EUR",
    "Locale": "en-US",
    "GuestCheckOut": true,
    "Transactions": [
        {
            "POSTransactionId": "DEV-TEST-01-01",
            "Payee": "[email protected]",
            "Total": 100,
            "Items": [
                {
                    "Name": "Nada",
                    "Description": "Zilch",
                    "Quantity": 1,
                    "Unit": "db",
                    "UnitPrice": 1,
                    "ItemTotal": 1
                }
            ]
        }
    ]
}'
</syntaxhighlight>
</blockquote>
For details on the various parameters you’re passing in the call, see [[Payment-Start-v2|the <code>Payment/Start</code> API endpoint reference]].
<blockquote>
Step result:  The API request returns the following JSON:  <br />
<syntaxhighlight lang="json">
{
    "PaymentId": "ee849878c554ef118c0c001dd8b71cc5",
    "PaymentRequestId": "DEV-TEST-615",
    "Status": "Prepared",
    "QRUrl": "https://api.test.barion.com/qr/generate?paymentId=ee849878-c554-ef11-8c0c-001dd8b71cc5&size=Large",
    "Transactions": [
        {
            "POSTransactionId": "DEV-TEST-01-01",
            "TransactionId": "ef849878c554ef118c0c001dd8b71cc5",
            "Status": "Prepared",
            "Currency": "EUR",
            "TransactionTime": "0001-01-01T00:00:00",
            "RelatedId": null
        }
    ],
    "RecurrenceResult": "None",
    "ThreeDSAuthClientData": null,
    "GatewayUrl": "https://secure.test.barion.com/Pay?Id=ee849878c554ef118c0c001dd8b71cc5",
    "RedirectUrl": "https://example.com/?paymentId=ee849878c554ef118c0c001dd8b71cc5",
    "CallbackUrl": "",
    "TraceId": null,
    "Errors": []
}
</syntaxhighlight>
</blockquote>


== Pay through the Barion Smart Gateway: ==
== Pay through the Barion Smart Gateway: ==
Line 51: Line 128:
* Expiration date: any future date
* Expiration date: any future date
* CVC: any 3-digit number
* CVC: any 3-digit number
![The Test Payment Gateway for Your API-prompted Transaction](/img/getting-started/gatewayUrl.png)
<nowiki>*</nowiki>The Test Payment Gateway for Your API-prompted Transaction*


== Next steps ==
== Next steps ==

Latest revision as of 09:32, 8 August 2024

Making a test payment

Get a feel for how Barion works by using the Barion Gateway API to

  1. set up a payment for the Barion shop you’ve created, and
  2. settle the payment with some test money from your Barion Wallet.

Prerequisites

Make a test payment using the Barion API

1. Log in to to your Barion shop.

2. Click through to Shops>Actions>Details>Secret Key (POSKey), and copy the value to the clipboard. Finding your shop’s POSKey

Finding your shop’s POSKey

NOTE
All Barion API endpoints accept standard HTTP1.1 GET or POST method requests, but always one or the other only. Calling an endpoint with the incorrect HTTP method returns a JSON error message.

3. Start the Postman Desktop agent, and make a POST call to https://api.test.barion.com/v2/payment/start, passing the following JSON in the request body: Replace the POSKey and the Transactions/Payee as indicated.

{
    "POSKey": "[the POSKey you've just copied]",
    "PaymentType": "Immediate",
    "PaymentRequestId": "DEV-TEST-615",
    "FundingSources": ["All"],
    "OrderNumber": "Order_01",
    "RedirectUrl": "https://example.com/",
    "Currency": "EUR",
    "Locale":"en-US",
    "GuestCheckOut": true,
    "PaymentWindow":"00:30:00",
    "Transactions": [
        {
            "POSTransactionId": "DEV-TEST-01-01",
            "Payee": "[the email address associated with the Barion shop]",
            "Total": 100,
            "Comment": "Test transaction",
            "Items": [
                {
                    "Name": "Nada",
                    "Description": "Zilch",
                    "Quantity": 1,
                    "Unit": "db",
                    "UnitPrice": 1,
                    "ItemTotal": 1,
                    "SKU": "SM-01"
                }
            ]
        }
    ]
}

Here's the cURL version, if that's more convenient:

curl --location 'https://api.test.barion.com/v2/payment/start' \
--header 'Content-Type: application/json' \
--data-raw '{
    "POSKey": "5c224ce1-0f2c-4a7a-9ae7-d7c2b481cb71",
    "PaymentType": "Immediate",
    "PaymentRequestId": "DEV-TEST-615",
    "FundingSources": [
        "All"
    ],
    "RedirectUrl": "https://example.com/",
    "Currency": "EUR",
    "Locale": "en-US",
    "GuestCheckOut": true,
    "Transactions": [
        {
            "POSTransactionId": "DEV-TEST-01-01",
            "Payee": "[email protected]",
            "Total": 100,
            "Items": [
                {
                    "Name": "Nada",
                    "Description": "Zilch",
                    "Quantity": 1,
                    "Unit": "db",
                    "UnitPrice": 1,
                    "ItemTotal": 1
                }
            ]
        }
    ]
}'

For details on the various parameters you’re passing in the call, see the Payment/Start API endpoint reference.

Step result: The API request returns the following JSON:

{
    "PaymentId": "ee849878c554ef118c0c001dd8b71cc5",
    "PaymentRequestId": "DEV-TEST-615",
    "Status": "Prepared",
    "QRUrl": "https://api.test.barion.com/qr/generate?paymentId=ee849878-c554-ef11-8c0c-001dd8b71cc5&size=Large",
    "Transactions": [
        {
            "POSTransactionId": "DEV-TEST-01-01",
            "TransactionId": "ef849878c554ef118c0c001dd8b71cc5",
            "Status": "Prepared",
            "Currency": "EUR",
            "TransactionTime": "0001-01-01T00:00:00",
            "RelatedId": null
        }
    ],
    "RecurrenceResult": "None",
    "ThreeDSAuthClientData": null,
    "GatewayUrl": "https://secure.test.barion.com/Pay?Id=ee849878c554ef118c0c001dd8b71cc5",
    "RedirectUrl": "https://example.com/?paymentId=ee849878c554ef118c0c001dd8b71cc5",
    "CallbackUrl": "",
    "TraceId": null,
    "Errors": []
}

Pay through the Barion Smart Gateway:

Go to the URL in the POST call’s GatewayURL return value, and complete the purchase using the following test card details:

  • Card number: 4444 8888 8888 5559
  • Expiration date: any future date
  • CVC: any 3-digit number

Next steps