Accepting your first online payment: Difference between revisions

From Barion Documentation
Jump to navigation Jump to search
(created page)
 
(fixed table formatting and links)
Line 6: Line 6:
== Prerequisites ==
== Prerequisites ==


A webshop in [[01-payments/02-basic-payment-concepts/02-barion-sandbox|the Barion Sandbox]] – see [[01-payments/01-quickstart-make-a-test-payment-online/00-setup|the setup section of the quickstart tutorial]] for details.
A webshop in [[Sandbox|the Barion Sandbox]] – see [[Creating a shop|the setup section of the quickstart tutorial]] for details.


<span id="steps"></span>
<span id="steps"></span>
Line 13: Line 13:
This is what you’ll need to set up your Barion shop to do each time a customer starts a purchase.
This is what you’ll need to set up your Barion shop to do each time a customer starts a purchase.


Note that [[01-payments/02-basic-payment-concepts/03-callback-mechanism|the callback mechanism, a nevertheless integral part of the payment flow]], has been left off this diagram for clarity.
Note that [[Callback mechanism|the callback mechanism, a nevertheless integral part of the payment flow]], has been left off this diagram for clarity.


[[File:/img/payment-scenarios/basic_accept_payment_no_callback.png|thumb|none|alt=The overview of the sequence of accepting a payment|The overview of the sequence of accepting a payment]]
[[File:/img/payment-scenarios/basic_accept_payment_no_callback.png|thumb|none|alt=The overview of the sequence of accepting a payment|The overview of the sequence of accepting a payment]]


<ol style="list-style-type: decimal;">
<ol style="list-style-type: decimal;">
<li><p>Request the Barion server to prepare the payment by querying the <code>/{API_version}/Payment/Start</code> endpoint, passing it the following details of your shop, and the purchase:</p>
<li><p>Request the Barion server to prepare the payment by querying [[Payment-Start-v2|the <code>Payment/Start</code> endpoint]], passing it the following details of your shop, and the purchase:</p>
<p>{% table %}</p>
{| class="wikitable"
<ul>
|PosKey
<li><p>PosKey</p></li>
|Identifies the Barion shop (yours) that’s preparing the payment.
<li><p>Identifies the Barion shop (yours) that’s preparing the payment. —</p></li>
|-
<li><p>PaymentType</p></li>
|PaymentType
<li><p>Configures whether the payment funds should be transferred immediately, or pending some later finalizing step.</p>
|Configures whether the payment funds should be transferred immediately, or pending some later finalizing step.<br/>Pass <code>"Immediate"</code>, we’ll get to reservation and delayed capture payments soon enough.
<p>Pass <code>&quot;Immediate&quot;</code>, we’ll get to reservation and delayed capture payments soon enough. —</p></li>
|-
<li><p>GuestCheckOut</p></li>
|GuestCheckOut
<li><p>Pass <code>true</code> to allow the customer to check out without using a Barion Wallet (or another supported digital wallet). —</p></li>
|Pass <code>true</code> to allow the customer to check out without using a Barion Wallet (or another supported digital wallet).
<li><p>FundingSources</p></li>
|-
<li><p>Pass <code>[&quot;ALL&quot;]</code> to allow all supported payment methods. —</p></li>
|FundingSources
<li><p>PaymentRequestId</p></li>
|Pass <code>["ALL"]</code> to allow all supported payment methods.
<li><p>This is your own identifier for the payment.</p>
|-
<p>Make sure that this is unique for each payment made in your webshop. —</p></li>
|PaymentRequestId
<li><p>RedirectUrl</p></li>
|This is your own identifier for the payment.<br/>Make sure that this is unique for each payment made in your webshop.
<li><p>The URL where you’d like your customer to be redirected after they paid - your “Thanks for your order.” page. —</p></li>
|-
<li><p>CallbackUrl</p></li>
|RedirectUrl
<li><p>Specifies where you’d like the Barion server to ping you whenever there’s a change in the payment’s state.</p>
|The URL where you’d like your customer to be redirected after they paid - your “Thanks for your order.” page.
<p>Read more about callbacks [[01-payments/02-basic-payment-concepts/03-callback-mechanism|here]]. —</p></li>
|-
<li><p>Transactions</p></li>
|CallbackUrl
<li><p>The list of payment transactions, themselves JSON objects with required keys, included in the payment.</p>
|Specifies where you’d like the Barion server to ping you whenever there’s a change in the payment’s state.<br/>Read more about callbacks [[01-payments/02-basic-payment-concepts/03-callback-mechanism|here]].
<p>Pay special attention that {% list type=“checkmark” %}</p>
|-
<ul>
|Transactions
<li>the <code>Payee</code> in the transactions in the email address associated with your shop’s Barion Wallet, and</li>
|The list of payment transactions, themselves JSON objects with required keys, included in the payment.<br/>Make sure that the <code>Payee</code> in the transactions is the email address associated with your shop's Barion Wallet, and that you assign a unique <code>POSTransactionId</code>to each transaction listed to identify it.<br/>At this stage, just copy the single transaction in the sample below. Read more about sub-transactions [[05-api-reference/01-payment-resource/00-payment-resource-objects/02-payee-transaction|here]].
<li>each transaction listed has a unique <code>POSTransactionId</code> to identify it {% /list%}</li></ul>
|-
|Locale
|Configures the language that the Barion Smart Gateway is displayed in. Pass <code>&quot;en-US&quot;</code> for now.
|-
|Currency
|Specifies the currency for all the transactions in the payment, as a three-letter code.<br/>“EUR”, “HUF”, “CZK”, and “USD”` are available, but your Barion Wallet must already have a balance in the currency you pass.
|-
|ChallengePreference
|Pass <code>"NoChallengeNeeded"</code> to keep things simple for now.<br/>This requests [[3DSecure|Transaction Risk Analysis (TRA) for the payment transaction]], and preferably get an exemption so the customer can skip Strong Customer Authentication (SCA) for the payment.<br/>There’s a number of endpoint properties designed to provide further information about the payer’s identity and details about the purchase to increase the likelihood of a TRA exemption. Read more about them on the [[05-api-reference/01-payment-resource/01-payment-start|/{API_version}/Payment/Start]] endpoint reference page.
|}


<p>At this stage, just copy the single transaction in the sample below. Read more about sub-transactions [[05-api-reference/01-payment-resource/00-payment-resource-objects/02-payee-transaction|here]]. —</p></li>
<blockquote><p>Note that [[Sandbox|the Barion Sandbox, especially when used with a test card]], will always skip the 2-factor authentication as required by PSD2, effectively granting the test customer a TRA exemption.</p>
<li><p>Locale</p></li>
<li><p>Configures the language that the Barion Smart Gateway is displayed in. Pass <code>&quot;en-US&quot;</code> for now. —</p></li>
<li><p>Currency</p></li>
<li><p>Specifies the currency for all the transactions in the payment, as a three-letter code.</p>
<p>“EUR”<code>,</code>“HUF”<code>,</code>“CZK”<code>and</code>“USD”` are available, but your Barion Wallet must already have a balance in the currency you pass. —</p></li>
<li><p>ChallengePreference</p></li>
<li><p>Pass <code>&quot;NoChallengeNeeded&quot;</code> to keep things simple for now.</p>
<p>This requests [[06-guides/3ds|Transaction Risk Analysis (TRA) for the payment transaction]], and preferably get an exemption so the customer can skip Strong Customer Authentication (SCA) for the payment.</p>
<p>There’s a number of endpoint properties designed to provide further information about the payer’s identity and details about the purchase to increase the likelihood of a TRA exemption:</p>
<p>Read more about them on the [[05-api-reference/01-payment-resource/01-payment-start|/{API_version}/Payment/Start]] endpoint reference page. {% /table %}</p></li></ul>
 
<blockquote><p>Note that [[01-payments/02-basic-payment-concepts/02-barion-sandbox|the Barion Sandbox, especially when used with a test card]], will always skip the 2-factor authentication as required by PSD2, effectively granting the test customer a TRA exemption.</p>
<p>Your live Barion shop, however, must be ready to request TRA exemptions on your customers’ behalf for frictionless payments.</p>
<p>Your live Barion shop, however, must be ready to request TRA exemptions on your customers’ behalf for frictionless payments.</p>
<p>[[06-guides/3ds|Read up on 3DS2]], the technology Barion uses to comply with SCA, to help configure your shop’s Barion Smart Gateway so that TRA exemptions are maximized.</p></blockquote>
<p>[[3DSecure|Read up on 3DS2]], the technology Barion uses to comply with SCA, to help configure your shop’s Barion Smart Gateway so that TRA exemptions are maximized.</p></blockquote>
<syntaxhighlight lang="json">    {
<syntaxhighlight lang="json">    {
     "PosKey": "placeholder",
     "PosKey": "placeholder",
Line 97: Line 94:
<li>the Barion-generated <code>TransactionId</code> for each transaction in the “Transactions” array</li></ul>
<li>the Barion-generated <code>TransactionId</code> for each transaction in the “Transactions” array</li></ul>


<blockquote><p>If something goes wrong, and you get an error response, [[05-api-reference/03-error-handling|here’s a troubleshooting guide]].</p></blockquote></li>
<blockquote><p>If something goes wrong, and you get an error response, [[Error codes notifications#Responsive web payment|here’s a troubleshooting guide]].</p></blockquote></li>
<li><p>Present the customer with the checkout page: Redirect them to <code>GatewayURL</code> parameter in the response, that is, the Barion Smart Gateway pre-populated with details of the payment.</p>
<li><p>Present the customer with the checkout page: Redirect them to <code>GatewayURL</code> parameter in the response, that is, the Barion Smart Gateway pre-populated with details of the payment.</p>
<blockquote><p>Presenting the Barion Smart Gateway in an iframe isn’t allowed.</p></blockquote></li>
<blockquote><p>Presenting the Barion Smart Gateway in an iframe isn’t allowed.</p></blockquote></li>
<li><p>Monitor the <code>CallbackURL</code> you passed to the <code>Payment/Start</code> call.</p>
<li><p>Monitor the <code>CallbackURL</code> you passed to the <code>Payment/Start</code> call.</p>
<p>When the status of the payment changes, the Barion server sends a callback to the URL. When the callback arrives, [[05-api-reference/01-payment-resource/01-payment-state|query the <code>Payment/State</code> endpoint]], passing it the <code>PaymentId</code> you’ve stored.</p>
<p>When the status of the payment changes, the Barion server sends a callback to the URL. When the callback arrives, [[Payment-PaymentState-v4|query the <code>Payment/State</code> endpoint]], passing it the <code>PaymentId</code> you’ve stored.</p>
<blockquote><p>Read more about the Barion callback mechanism [[01-payments/02-basic-payment-concepts/03-callback-mechanism|here]].</p></blockquote></li>
<blockquote><p>Read more about the Barion callback mechanism [[01-payments/02-basic-payment-concepts/03-callback-mechanism|here]].</p></blockquote></li>
<li><p>Notify the customer of the state of their payment.</p>
<li><p>Notify the customer of the state of their payment.</p>
<p>Typically, this is done on the <code>RedirectURL</code> page that you passed in the initial request, which is where the customer is redirected after completing the payment.</p></li></ol>
<p>Typically, this is done on the <code>RedirectURL</code> page that you passed in the initial request, which is where the customer is redirected after completing the payment.</p></li></ol>
<span id="related-links"></span>
== Related links ==
== Related links ==


* [[05-api-reference/01-payment-resource/01-payment-start|/{API_version}/Payment/Start]] endpoint reference
* [[Payment-Start-v2|/Payment/Start]] endpoint reference
* [[05-api-reference/01-payment-resource/02-payment-state|/{API_version}/Payment/{PaymentId}/paymentstate]] endpoint reference
* [[Payment-PaymentState-v4|/Payment/{PaymentId}/paymentstate]] endpoint reference
 
<span id="where-to-go-from-here"></span>
== Where to go from here ==
== Where to go from here ==


* [[01-payments/03-payment-scenarios/01-save-card|Save your customer’s card]]
* [[One-click payments: saving your customer's card|Save your customer’s card]]
* [[01-payments/03-payment-scenarios/02-set-up-subscription|Set up a subscription]]
* [[Subscriptions: set up recurring billing|Set up a subscription]]
* [[01-payments/03-payment-scenarios/05-digital-wallets|Accept payments with digital wallets]]
* [[Bank Transfer Payment|Accept OpenBanking transfer payments]]
* [[01-payments/03-payment-scenarios/06-bank-transfers|Accept bank transfer payments]]
* [[C2C Payments|Start an e-commerce platform]]
* [[01-payments/03-barion-bridge/00-barion-bridge|Start an e-commerce platform]]

Revision as of 15:43, 13 August 2024

Learn to implement an immediate oinline payment – the basic Barion payment scenario – in your webshop.

Being able to accept payments in your webshop is a prerequisite to being onboarded as a live Barion shop.

Prerequisites

A webshop in the Barion Sandbox – see the setup section of the quickstart tutorial for details.

Steps

This is what you’ll need to set up your Barion shop to do each time a customer starts a purchase.

Note that the callback mechanism, a nevertheless integral part of the payment flow, has been left off this diagram for clarity.

The overview of the sequence of accepting a payment
The overview of the sequence of accepting a payment
  1. Request the Barion server to prepare the payment by querying the Payment/Start endpoint, passing it the following details of your shop, and the purchase:

    PosKey Identifies the Barion shop (yours) that’s preparing the payment.
    PaymentType Configures whether the payment funds should be transferred immediately, or pending some later finalizing step.
    Pass "Immediate", we’ll get to reservation and delayed capture payments soon enough.
    GuestCheckOut Pass true to allow the customer to check out without using a Barion Wallet (or another supported digital wallet).
    FundingSources Pass ["ALL"] to allow all supported payment methods.
    PaymentRequestId This is your own identifier for the payment.
    Make sure that this is unique for each payment made in your webshop.
    RedirectUrl The URL where you’d like your customer to be redirected after they paid - your “Thanks for your order.” page.
    CallbackUrl Specifies where you’d like the Barion server to ping you whenever there’s a change in the payment’s state.
    Read more about callbacks here.
    Transactions The list of payment transactions, themselves JSON objects with required keys, included in the payment.
    Make sure that the Payee in the transactions is the email address associated with your shop's Barion Wallet, and that you assign a unique POSTransactionIdto each transaction listed to identify it.
    At this stage, just copy the single transaction in the sample below. Read more about sub-transactions here.
    Locale Configures the language that the Barion Smart Gateway is displayed in. Pass "en-US" for now.
    Currency Specifies the currency for all the transactions in the payment, as a three-letter code.
    “EUR”, “HUF”, “CZK”, and “USD”` are available, but your Barion Wallet must already have a balance in the currency you pass.
    ChallengePreference Pass "NoChallengeNeeded" to keep things simple for now.
    This requests Transaction Risk Analysis (TRA) for the payment transaction, and preferably get an exemption so the customer can skip Strong Customer Authentication (SCA) for the payment.
    There’s a number of endpoint properties designed to provide further information about the payer’s identity and details about the purchase to increase the likelihood of a TRA exemption. Read more about them on the /{API_version}/Payment/Start endpoint reference page.

    Note that the Barion Sandbox, especially when used with a test card, will always skip the 2-factor authentication as required by PSD2, effectively granting the test customer a TRA exemption.

    Your live Barion shop, however, must be ready to request TRA exemptions on your customers’ behalf for frictionless payments.

    Read up on 3DS2, the technology Barion uses to comply with SCA, to help configure your shop’s Barion Smart Gateway so that TRA exemptions are maximized.

        {
        "PosKey": "placeholder",
        "PaymentType": "Immediate",
        "PaymentRequestId": "placeholder",
        "GuestCheckOut": true,
        "FundingSources": [ "ALL" ],
        "Currency": "EUR",
        "RedirectUrl": "placeholder",
        "CallbackUrl": "placeholder",
        "Locale": "ab-AB",
        "Transactions": [
            {
            "POSTransactionId": "placeholder",
            "Payee": "placeholder",
            "Total": "placeholder",
            "Comment": "placeholder",
            "Items": [
                {
                "Name": "placeholder",
                "Description": "placeholder",
                "Quantity": 1,
                "Unit": "placeholder",
                "UnitPrice": 1000,
                "ItemTotal": 1000,
                "SKU": "placeholder"
                }
            ]
            }
        ]
        }

    The sample call includes all the required parameters for a basic immediate online payment. For an explanation of what each one configures and customization options, see the /{API_version}/Payment/Start endpoint reference.

  2. Extract and store the following parameters in the response to the request:

    • PaymentId
    • GatewayURL
    • the Barion-generated TransactionId for each transaction in the “Transactions” array

    If something goes wrong, and you get an error response, here’s a troubleshooting guide.

  3. Present the customer with the checkout page: Redirect them to GatewayURL parameter in the response, that is, the Barion Smart Gateway pre-populated with details of the payment.

    Presenting the Barion Smart Gateway in an iframe isn’t allowed.

  4. Monitor the CallbackURL you passed to the Payment/Start call.

    When the status of the payment changes, the Barion server sends a callback to the URL. When the callback arrives, query the Payment/State endpoint, passing it the PaymentId you’ve stored.

    Read more about the Barion callback mechanism here.

  5. Notify the customer of the state of their payment.

    Typically, this is done on the RedirectURL page that you passed in the initial request, which is where the customer is redirected after completing the payment.

Related links

Where to go from here