<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.barion.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Botza</id>
	<title>Barion Documentation - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.barion.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Botza"/>
	<link rel="alternate" type="text/html" href="https://docs.barion.com/Special:Contributions/Botza"/>
	<updated>2026-11-21T08:55:10Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://docs.barion.com/index.php?title=Withdraw-BankTransfer-v3&amp;diff=3421</id>
		<title>Withdraw-BankTransfer-v3</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Withdraw-BankTransfer-v3&amp;diff=3421"/>
		<updated>2022-06-08T16:03:32Z</updated>

		<summary type="html">&lt;p&gt;Botza: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Barion API: Initiate a bank transfer}}&lt;br /&gt;
&lt;br /&gt;
{{TableOfContents}}&lt;br /&gt;
&lt;br /&gt;
{{api_callmethod&lt;br /&gt;
|method=POST&lt;br /&gt;
|uri=/v3/Withdraw/BankTransfer&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;/withdraw/banktransfer&amp;lt;/code&amp;gt; API endpoint is used to send money out of the Barion system via bank (wire) transfer.&lt;br /&gt;
&lt;br /&gt;
Prerequisites before use:&lt;br /&gt;
* [[Creating_an_account|Creating an account in Barion]]&lt;br /&gt;
* [[Calling_the_API|Calling the Barion API]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v3&amp;lt;/span&amp;gt; This API endpoint is available in &#039;&#039;&#039;API v3&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Authentication ==&lt;br /&gt;
&lt;br /&gt;
Barion users are authenticated either with username/password provided in the querystring or with basic authentication. You can find more information about basic authentication [[Basic_authentication|here]]&lt;br /&gt;
&lt;br /&gt;
== Input properties ==&lt;br /&gt;
&lt;br /&gt;
{{api_input_table_header}}&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| UserName || string || &lt;br /&gt;
* Required&lt;br /&gt;
|| Your e-mail address in the Barion system.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Password || string || &lt;br /&gt;
* Required&lt;br /&gt;
|| Your password in the Barion system.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Currency || string || &lt;br /&gt;
* Required&lt;br /&gt;
* Required length: 3 characters&lt;br /&gt;
* Accepted values: &lt;br /&gt;
** &amp;quot;CZK&amp;quot; (Czech crown)&lt;br /&gt;
** &amp;quot;EUR&amp;quot; (Euro)&lt;br /&gt;
** &amp;quot;HUF&amp;quot; (Hungarian forint)&lt;br /&gt;
** &amp;quot;USD&amp;quot; (U.S. dollar)&lt;br /&gt;
|| The currency of the bank transfer. &lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Barion does not do currency rate conversion. The caller must have an active account with the selected currency, and must ensure that the target bank accepts the selected currency.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Amount || decimal || &lt;br /&gt;
* Required&lt;br /&gt;
* Must be greater than zero&lt;br /&gt;
|| The total amount to withdraw, excluding fees.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Comment|| string || &lt;br /&gt;
* Optional&lt;br /&gt;
* Maximum length: 90 characters&lt;br /&gt;
|| The comment of the bank transfer.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| BankAccount|| [[BankAccountDetails]] || &lt;br /&gt;
* Required&lt;br /&gt;
|| Information about the recipient&#039;s bank account.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Bank|| [[BankDetails]] || &lt;br /&gt;
* Required for foreign withdrawals&lt;br /&gt;
|| Information about the recipient&#039;s bank.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Recipient|| [[RecipientDetails]] || &lt;br /&gt;
* Required&lt;br /&gt;
|| Information about the recipient.&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
== Example requests ==&lt;br /&gt;
[[Withdraw-BankTransfer-v3-examples]]&lt;br /&gt;
&lt;br /&gt;
== Output properties ==&lt;br /&gt;
&lt;br /&gt;
{{api_output_table_header}}&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| TransactionId || Guid || The unique identifier of the bank transfer, generated by the Barion system.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Currency || string || The currency of the bank transfer.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Amount || decimal || The total amount transferred.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Comment || string || The comment of the bank transfer&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| BankAccount|| [[BankAccountDetails]] || Information about the recipient&#039;s bank account.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Bank|| [[BankDetails]] || Information about the recipient&#039;s bank.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Recipient|| [[RecipientDetails]] || Information about the recipient.&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Possible error responses  ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| ModelValidationError || This happens when some of the input properties fail the basic validation. For example a string property exceeds its allowed length.&lt;br /&gt;
|-&lt;br /&gt;
| AuthenticationFailed || The provided UserName or Password are not correct.&lt;br /&gt;
|-&lt;br /&gt;
| MinimumWithdrawAmountNotReached || The amount specified does not reach the minimum bank transfer amount. &#039;&#039;&#039;This is not in production yet&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| InvalidCharacter || One of the characters is invalid for the bank transfer process&lt;br /&gt;
|-&lt;br /&gt;
| InvalidAccount || There is no account belonging to the user with the specified currency.&lt;br /&gt;
|-&lt;br /&gt;
| InappropriateVerificationLevel || The user does not have the verification level to be able to transfer.&lt;br /&gt;
|-&lt;br /&gt;
| InvalidCurrency || The system does not support the specified currency&lt;br /&gt;
|-&lt;br /&gt;
| InvalidCountry || The Country specified in the BankAccount field is invalid.&lt;br /&gt;
|-&lt;br /&gt;
| LowBalance || There are not enough funds to cover the withdraw amount and the fee.&lt;br /&gt;
|-&lt;br /&gt;
| BankAccountNumberBlackListed || The target bankaccount number is on blacklist, the withdraw process is terminated and the customer gets suspended. &lt;br /&gt;
|-&lt;br /&gt;
| UserIsOverWithdrawLimit|| The withdraw amount exceeded the allowed limit for non-verified customers, the withdraw process is terminated and the customer gets suspended. &lt;br /&gt;
|-&lt;br /&gt;
| UserIsDeleted || The user is deleted from the system, the withdraw is not possible. &lt;br /&gt;
|-&lt;br /&gt;
| UserIsSuspended || The user is suspended until the suspension is lifted no withdraws are allowed.&lt;br /&gt;
|-&lt;br /&gt;
| WithdrawFromCustomerAccountToSystemAccount || Withdraw to the specified target account is not allowed.&lt;br /&gt;
|-&lt;br /&gt;
| BankAccountNumberNotAllowed|| Target Bank account number not in the list of allowed bank account numbers for this account.&lt;br /&gt;
|-&lt;br /&gt;
| InternalServerError || Something unexpected happened&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Bank transfer amount limitations  ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Currency || Target country || Amount limitation&lt;br /&gt;
|-&lt;br /&gt;
| HUF || Anywhere || No limitation&lt;br /&gt;
|-&lt;br /&gt;
| EUR || Anywhere || No limitation&lt;br /&gt;
|-&lt;br /&gt;
| USD || Anywhere || No limitation&lt;br /&gt;
|-&lt;br /&gt;
| CZK || Czechia || No limitation&lt;br /&gt;
|-&lt;br /&gt;
| CZK || Not Czechia || Minimum 100 CZK&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Bank transfer character limitations  ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Currency || Target country || Character limitation&lt;br /&gt;
|-&lt;br /&gt;
| HUF || Anywhere || No limitation&lt;br /&gt;
|-&lt;br /&gt;
| EUR || Anywhere || No limitation&lt;br /&gt;
|-&lt;br /&gt;
| USD || Anywhere || No limitation&lt;br /&gt;
|-&lt;br /&gt;
| CZK || Czechia || Allowed characters: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, á, ä, č, ď, é, ě, í, ľ, ň, ó, ô, ö, ř, ŕ, š, ť, ú, ů, ü, ý, ž, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, Á, Ä, Č, Ď, É, Ě, Í, Ľ, Ň, Ó, Ô, Ö, Ř, Ŕ, Š, Ť, Ú, Ů, Ü, Ý, Ž, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /, -, ?, :, (, ), ., ,, &#039;, +, !, &amp;quot;, #, $, %, &amp;amp;, *, ;, &amp;lt;, =, &amp;gt;, @, [, ], ^, `, {, |, }, ~, §, SPACE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| CZK || Not Czechia || Allowed characters: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /, -, ?, :, (, ), ., ,, &#039;, +, SPACE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Withdraw-BankTransfer-v2&amp;diff=3420</id>
		<title>Withdraw-BankTransfer-v2</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Withdraw-BankTransfer-v2&amp;diff=3420"/>
		<updated>2022-06-08T16:02:07Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* Possible error responses */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Barion API: Initiate a bank transfer}}&lt;br /&gt;
&lt;br /&gt;
{{TableOfContents}}&lt;br /&gt;
&lt;br /&gt;
{{api_callmethod&lt;br /&gt;
|method=POST&lt;br /&gt;
|uri=/v2/Withdraw/BankTransfer&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;/withdraw/banktransfer&amp;lt;/code&amp;gt; API endpoint is used to send money out of the Barion system via bank (wire) transfer.&lt;br /&gt;
&lt;br /&gt;
Prerequisites before use:&lt;br /&gt;
* [[Creating_an_account|Creating an account in Barion]]&lt;br /&gt;
* [[Calling_the_API|Calling the Barion API]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v2&amp;lt;/span&amp;gt; This API endpoint is available in &#039;&#039;&#039;API v2&#039;&#039;&#039; only.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #FF7A3D; background: #fee4b4; display: inline-block; padding:0 20px 20px 20px;&amp;quot;&amp;gt;&lt;br /&gt;
== Change for foreign CZK transfers ==&lt;br /&gt;
This API endpoint won&#039;t process foreign CZK transactions (targeted outside of Czechia) from the second half of August. &amp;lt;br/&amp;gt;Please upgrade to the [[Withdraw-BankTransfer-v3|v3 version]].&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Authentication ==&lt;br /&gt;
&lt;br /&gt;
Barion users are authenticated either with username/password provided in the query string or with basic authentication. You can find more information about basic authentication [[Basic_authentication|here]]&lt;br /&gt;
&lt;br /&gt;
== Input properties ==&lt;br /&gt;
&lt;br /&gt;
{{api_input_table_header}}&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| UserName || string || &lt;br /&gt;
* Required&lt;br /&gt;
|| Your e-mail address in the Barion system.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Password || string || &lt;br /&gt;
* Required&lt;br /&gt;
|| Your password in the Barion system.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Currency || string || &lt;br /&gt;
* Required&lt;br /&gt;
* Required length: 3 characters&lt;br /&gt;
* Accepted values: &lt;br /&gt;
** &amp;quot;CZK&amp;quot; (Czech crown)&lt;br /&gt;
** &amp;quot;EUR&amp;quot; (Euro)&lt;br /&gt;
** &amp;quot;HUF&amp;quot; (Hungarian forint)&lt;br /&gt;
** &amp;quot;USD&amp;quot; (U.S. dollar)&lt;br /&gt;
|| The currency of the bank transfer. &lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Barion does not do currency rate conversion. The caller must have an active account with the selected currency, and must ensure that the target bank accepts the selected currency.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Amount || decimal || &lt;br /&gt;
* Required&lt;br /&gt;
* Must be greater than zero&lt;br /&gt;
|| The total amount to withdraw, excluding fees.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| RecipientName || string || &lt;br /&gt;
* Required&lt;br /&gt;
|| The name of the recipient of the bank transfer.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Comment|| string || &lt;br /&gt;
* Optional&lt;br /&gt;
* Maximum length: 90 characters&lt;br /&gt;
|| The comment of the bank transfer.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| BankAccount|| [[BankAccount]] || &lt;br /&gt;
* Required&lt;br /&gt;
|| Information about the recipient&#039;s bank account.&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Output properties ==&lt;br /&gt;
&lt;br /&gt;
{{api_output_table_header}}&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| TransactionId || Guid || The unique identifier of the bank transfer, generated by the Barion system.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Currency || string || The currency of the bank transfer.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Amount || decimal || The total amount transferred.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| RecipientName || string || The name of the recipient of the transfer.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Comment || string || The comment of the bank transfer&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| BankAccount|| [[BankAccount]] || The bank account data.&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Possible error responses  ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| ModelValidationError || This happens when some of the input properties fail the basic validation. For example a string property exceeds its allowed length.&lt;br /&gt;
|-&lt;br /&gt;
| AuthenticationFailed || The provided UserName or Password are not correct.&lt;br /&gt;
|-&lt;br /&gt;
| MinimumWithdrawAmountNotReached || The amount specified does not reach the minimum bank transfer amount. &#039;&#039;&#039;This is not in production yet&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| InvalidCharacter || One of the characters is invalid for the bank transfer process&lt;br /&gt;
|-&lt;br /&gt;
| InvalidAccount || There is no account belonging to the user with the specified currency.&lt;br /&gt;
|-&lt;br /&gt;
| InappropriateVerificationLevel || The user does not have the verification level to be able to transfer.&lt;br /&gt;
|-&lt;br /&gt;
| InvalidCurrency || The system does not support the specified currency&lt;br /&gt;
|-&lt;br /&gt;
| InvalidCountry || The Country specified in the BankAccount field is invalid.&lt;br /&gt;
|-&lt;br /&gt;
| LowBalance || There are not enough funds to cover the withdraw amount and the fee.&lt;br /&gt;
|-&lt;br /&gt;
| BankAccountNumberBlackListed || The target bankaccount number is on blacklist, the withdraw process is terminated and the customer gets suspended. &lt;br /&gt;
|-&lt;br /&gt;
| UserIsOverWithdrawLimit|| The withdraw amount exceeded the allowed limit for non-verified customers, the withdraw process is terminated and the customer gets suspended. &lt;br /&gt;
|-&lt;br /&gt;
| UserIsDeleted || The user is deleted from the system, the withdraw is not possible. &lt;br /&gt;
|-&lt;br /&gt;
| UserIsSuspended || The user is suspended until the suspension is lifted no withdraws are allowed.&lt;br /&gt;
|-&lt;br /&gt;
| WithdrawFromCustomerAccountToSystemAccount || Withdraw to the specified target account is not allowed.&lt;br /&gt;
|-&lt;br /&gt;
| BankAccountNumberNotAllowed|| Target Bank account number not in the list of allowed bank account numbers for this account.&lt;br /&gt;
|-&lt;br /&gt;
| InternalServerError || Something unexpected happened&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;span style=&amp;quot;background:orange;padding:0 5px; color:white;&amp;quot;&amp;gt;SOON&amp;lt;/span&amp;gt; UnsupportedWithdraw || In the case of foreign CZK transfers (targeted outside of Czechia) this endpoint is not suitable to start the transfer. Please upgrade to the [[Withdraw-BankTransfer-v3|v3 version]].&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Bank transfer amount limitations  ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Currency || Target country || Amount limitation&lt;br /&gt;
|-&lt;br /&gt;
| HUF || Anywhere || No limitation&lt;br /&gt;
|-&lt;br /&gt;
| EUR || Anywhere || No limitation&lt;br /&gt;
|-&lt;br /&gt;
| USD || Anywhere || No limitation&lt;br /&gt;
|-&lt;br /&gt;
| CZK || Czechia || No limitation&lt;br /&gt;
|-&lt;br /&gt;
| CZK || Not Czechia || Minimum 100 CZK&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Bank transfer character limitations  ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Currency || Target country || Character limitation&lt;br /&gt;
|-&lt;br /&gt;
| HUF || Anywhere || No limitation&lt;br /&gt;
|-&lt;br /&gt;
| EUR || Anywhere || No limitation&lt;br /&gt;
|-&lt;br /&gt;
| USD || Anywhere || No limitation&lt;br /&gt;
|-&lt;br /&gt;
| CZK || Czechia || Allowed characters: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, á, ä, č, ď, é, ě, í, ľ, ň, ó, ô, ö, ř, ŕ, š, ť, ú, ů, ü, ý, ž, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, Á, Ä, Č, Ď, É, Ě, Í, Ľ, Ň, Ó, Ô, Ö, Ř, Ŕ, Š, Ť, Ú, Ů, Ü, Ý, Ž, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /, -, ?, :, (, ), ., ,, &#039;, +, !, &amp;quot;, #, $, %, &amp;amp;, *, ;, &amp;lt;, =, &amp;gt;, @, [, ], ^, `, {, |, }, ~, §, SPACE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| CZK || Not Czechia || Allowed characters: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /, -, ?, :, (, ), ., ,, &#039;, +, SPACE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Withdraw-BankTransfer-v2&amp;diff=3419</id>
		<title>Withdraw-BankTransfer-v2</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Withdraw-BankTransfer-v2&amp;diff=3419"/>
		<updated>2022-06-08T15:55:58Z</updated>

		<summary type="html">&lt;p&gt;Botza: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Barion API: Initiate a bank transfer}}&lt;br /&gt;
&lt;br /&gt;
{{TableOfContents}}&lt;br /&gt;
&lt;br /&gt;
{{api_callmethod&lt;br /&gt;
|method=POST&lt;br /&gt;
|uri=/v2/Withdraw/BankTransfer&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;/withdraw/banktransfer&amp;lt;/code&amp;gt; API endpoint is used to send money out of the Barion system via bank (wire) transfer.&lt;br /&gt;
&lt;br /&gt;
Prerequisites before use:&lt;br /&gt;
* [[Creating_an_account|Creating an account in Barion]]&lt;br /&gt;
* [[Calling_the_API|Calling the Barion API]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v2&amp;lt;/span&amp;gt; This API endpoint is available in &#039;&#039;&#039;API v2&#039;&#039;&#039; only.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #FF7A3D; background: #fee4b4; display: inline-block; padding:0 20px 20px 20px;&amp;quot;&amp;gt;&lt;br /&gt;
== Change for foreign CZK transfers ==&lt;br /&gt;
This API endpoint won&#039;t process foreign CZK transactions (targeted outside of Czechia) from the second half of August. &amp;lt;br/&amp;gt;Please upgrade to the [[Withdraw-BankTransfer-v3|v3 version]].&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Authentication ==&lt;br /&gt;
&lt;br /&gt;
Barion users are authenticated either with username/password provided in the query string or with basic authentication. You can find more information about basic authentication [[Basic_authentication|here]]&lt;br /&gt;
&lt;br /&gt;
== Input properties ==&lt;br /&gt;
&lt;br /&gt;
{{api_input_table_header}}&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| UserName || string || &lt;br /&gt;
* Required&lt;br /&gt;
|| Your e-mail address in the Barion system.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Password || string || &lt;br /&gt;
* Required&lt;br /&gt;
|| Your password in the Barion system.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Currency || string || &lt;br /&gt;
* Required&lt;br /&gt;
* Required length: 3 characters&lt;br /&gt;
* Accepted values: &lt;br /&gt;
** &amp;quot;CZK&amp;quot; (Czech crown)&lt;br /&gt;
** &amp;quot;EUR&amp;quot; (Euro)&lt;br /&gt;
** &amp;quot;HUF&amp;quot; (Hungarian forint)&lt;br /&gt;
** &amp;quot;USD&amp;quot; (U.S. dollar)&lt;br /&gt;
|| The currency of the bank transfer. &lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Barion does not do currency rate conversion. The caller must have an active account with the selected currency, and must ensure that the target bank accepts the selected currency.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Amount || decimal || &lt;br /&gt;
* Required&lt;br /&gt;
* Must be greater than zero&lt;br /&gt;
|| The total amount to withdraw, excluding fees.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| RecipientName || string || &lt;br /&gt;
* Required&lt;br /&gt;
|| The name of the recipient of the bank transfer.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Comment|| string || &lt;br /&gt;
* Optional&lt;br /&gt;
* Maximum length: 90 characters&lt;br /&gt;
|| The comment of the bank transfer.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| BankAccount|| [[BankAccount]] || &lt;br /&gt;
* Required&lt;br /&gt;
|| Information about the recipient&#039;s bank account.&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Output properties ==&lt;br /&gt;
&lt;br /&gt;
{{api_output_table_header}}&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| TransactionId || Guid || The unique identifier of the bank transfer, generated by the Barion system.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Currency || string || The currency of the bank transfer.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Amount || decimal || The total amount transferred.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| RecipientName || string || The name of the recipient of the transfer.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Comment || string || The comment of the bank transfer&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| BankAccount|| [[BankAccount]] || The bank account data.&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Possible error responses  ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| ModelValidationError || This happens when some of the input properties fail the basic validation. For example a string property exceeds its allowed length.&lt;br /&gt;
|-&lt;br /&gt;
| AuthenticationFailed || The provided UserName or Password are not correct.&lt;br /&gt;
|-&lt;br /&gt;
| MinimumWithdrawAmountNotReached || The amount specified does not reach the minimum bank transfer amount. &#039;&#039;&#039;This is not in production yet&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| InvalidCharacter || One of the characters is invalid for the bank transfer process&lt;br /&gt;
|-&lt;br /&gt;
| InvalidAccount || There is no account belonging to the user with the specified currency.&lt;br /&gt;
|-&lt;br /&gt;
| InappropriateVerificationLevel || The user does not have the verification level to be able to transfer.&lt;br /&gt;
|-&lt;br /&gt;
| InvalidCurrency || The system does not support the specified currency&lt;br /&gt;
|-&lt;br /&gt;
| InvalidCountry || The Country specified in the BankAccount field is invalid.&lt;br /&gt;
|-&lt;br /&gt;
| LowBalance || There are not enough funds to cover the withdraw amount and the fee.&lt;br /&gt;
|-&lt;br /&gt;
| BankAccountNumberBlackListed || The target bankaccount number is on blacklist, the withdraw process is terminated and the customer gets suspended. &lt;br /&gt;
|-&lt;br /&gt;
| UserIsOverWithdrawLimit|| The withdraw amount exceeded the allowed limit for non-verified customers, the withdraw process is terminated and the customer gets suspended. &lt;br /&gt;
|-&lt;br /&gt;
| UserIsDeleted || The user is deleted from the system, the withdraw is not possible. &lt;br /&gt;
|-&lt;br /&gt;
| UserIsSuspended || The user is suspended until the suspension is lifted no withdraws are allowed.&lt;br /&gt;
|-&lt;br /&gt;
| WithdrawFromCustomerAccountToSystemAccount || Withdraw to the specified target account is not allowed.&lt;br /&gt;
|-&lt;br /&gt;
| BankAccountNumberNotAllowed|| Target Bank account number not in the list of allowed bank account numbers for this account.&lt;br /&gt;
|-&lt;br /&gt;
| InternalServerError || Something unexpected happened&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Bank transfer amount limitations  ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Currency || Target country || Amount limitation&lt;br /&gt;
|-&lt;br /&gt;
| HUF || Anywhere || No limitation&lt;br /&gt;
|-&lt;br /&gt;
| EUR || Anywhere || No limitation&lt;br /&gt;
|-&lt;br /&gt;
| USD || Anywhere || No limitation&lt;br /&gt;
|-&lt;br /&gt;
| CZK || Czechia || No limitation&lt;br /&gt;
|-&lt;br /&gt;
| CZK || Not Czechia || Minimum 100 CZK&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Bank transfer character limitations  ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Currency || Target country || Character limitation&lt;br /&gt;
|-&lt;br /&gt;
| HUF || Anywhere || No limitation&lt;br /&gt;
|-&lt;br /&gt;
| EUR || Anywhere || No limitation&lt;br /&gt;
|-&lt;br /&gt;
| USD || Anywhere || No limitation&lt;br /&gt;
|-&lt;br /&gt;
| CZK || Czechia || Allowed characters: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, á, ä, č, ď, é, ě, í, ľ, ň, ó, ô, ö, ř, ŕ, š, ť, ú, ů, ü, ý, ž, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, Á, Ä, Č, Ď, É, Ě, Í, Ľ, Ň, Ó, Ô, Ö, Ř, Ŕ, Š, Ť, Ú, Ů, Ü, Ý, Ž, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /, -, ?, :, (, ), ., ,, &#039;, +, !, &amp;quot;, #, $, %, &amp;amp;, *, ;, &amp;lt;, =, &amp;gt;, @, [, ], ^, `, {, |, }, ~, §, SPACE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| CZK || Not Czechia || Allowed characters: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /, -, ?, :, (, ), ., ,, &#039;, +, SPACE&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_upgrade_to_3DS&amp;diff=3031</id>
		<title>Token payment upgrade to 3DS</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_upgrade_to_3DS&amp;diff=3031"/>
		<updated>2021-07-15T09:34:02Z</updated>

		<summary type="html">&lt;p&gt;Botza: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Upgrading token payment implementation to comply with 3DS}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=NOTE|text=This tutorial was created to help merchants that already have token payment integration with Barion. First, please read through the detailed description of the new [[Token_payment_3D_Secure|token payment with 3DS]]!|color=#1993c7}}&lt;br /&gt;
= Background =&lt;br /&gt;
[[Token_payment_3D_Secure|Token payment]] is a solution that enables the merchant to charge the payer without the presence of them. It is a powerful tool to conduct subscription-like or payer-not-present scenarios. This scenario requires the merchant to create a token that would act as an identifier for the payer&#039;s funding source. To attach that token to a valid funding source the merchant had to do several things:&lt;br /&gt;
# Create an alphanumeric token&lt;br /&gt;
# Conduct an initial payment in which this token gets registered in the Barion system &lt;br /&gt;
# Refer to this token in a subsequent payment attempt&lt;br /&gt;
&lt;br /&gt;
[[File:Recurring-pre3ds.png|1280px]]&lt;br /&gt;
&lt;br /&gt;
This meant that as far as this token referenced a valid (and still available) funding source the merchant could create payments without any limitations. Basically, this token symbolized the funding source. It was up to the merchant to decide what it is used for, neither Barion nor the card issuer was aware of the nature of the subsequent payments. &lt;br /&gt;
&lt;br /&gt;
This funding source can be either a card or an e-money wallet and this is up to the payer to choose. In case the payer chooses to fund the payment from their e-money wallet there is no further need for extra security. On the other hand, when it comes to card payment the authentication process changed with the new Strong Customer Authentication directive and the 3DS v2 protocol.&lt;br /&gt;
&lt;br /&gt;
= Changes =&lt;br /&gt;
To make sure that the payer has more control over these token scenarios and the card issuer knows more about the payment scenarios several things need to be changed. &lt;br /&gt;
&lt;br /&gt;
== Token payment scenarios ==&lt;br /&gt;
&lt;br /&gt;
First of all the merchant has to decide what kind of token payment scenario is suitable. These scenarios are the following:&lt;br /&gt;
* &#039;&#039;&#039;One-click payment&#039;&#039;&#039;: The payer clicks on the &amp;quot;Purchase&amp;quot; button but the charge happens in the background without the payer leaving the merchant&#039;s site.&lt;br /&gt;
* &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: The payer authorizes the merchant (at the initial payment) to charge their card periodically without being present with the same amount.&lt;br /&gt;
* &#039;&#039;&#039;Merchant initiated payment&#039;&#039;&#039;: The payer authorizes the merchant to charge their card without restrictions (eg. amounts can vary).&lt;br /&gt;
&lt;br /&gt;
To decide on a suitable scenario, please [[Token_payment_3D_Secure#Token_payment_scenarios|read this detailed description]]&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=CHANGE|text=The intended scenario must be specified in the new [[RecurrenceType|RecurrenceType]] property (located in the [[Payment-Start-v2|Payment/Start]] request)|color=#20c400}}&lt;br /&gt;
&lt;br /&gt;
== Usage of TraceId ==&lt;br /&gt;
&lt;br /&gt;
3DS authentication requires another identifier. This new identifier is used to differentiate these token payment scenarios and help the issuer control what is a non-fraudulent transaction.&lt;br /&gt;
&lt;br /&gt;
So from now on, there will be two IDs for every payer-not-present scenario:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; for the funding source: this identifies the source of the money (could be card or wallet)&lt;br /&gt;
* &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; (new) for the &#039;&#039;nature of the charge:&#039;&#039; this identifies the type of token payment scenario the merchant is conducting.&lt;br /&gt;
&lt;br /&gt;
This new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is generated and stored by the card issuer. The Id is available in the [[Payment-GetPaymentState-v2|GetPaymentState]] response once the charge is successfully completed.&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=CHANGE|text=The TraceId must processed from the [[Payment-GetPaymentState-v2|GetPaymentState]] response and must be attached to the payment in merchant&#039;s system. |color=#20c400}}&lt;br /&gt;
&lt;br /&gt;
Once the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is acquired it must be sent in the [[Payment-Start-v2|Payment/Start]] request to identify the scenario. This is crucial for the card transactions otherwise they could be declined. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=CHANGE|text=The TraceId must specified in the [[Payment-Start-v2|Payment/Start]] for the subsequent token charges. |color=#20c400}}&lt;br /&gt;
&lt;br /&gt;
== 3DS v2 authentication ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be conducted for every online card payment. These token payment scenarios also need to use these new secure way of authentication. &lt;br /&gt;
The initial payment must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Technical changes required =&lt;br /&gt;
The technical changes depend on what type of token scenario is needed for the business. It is important to notice that these scenarios can be implemented beside each other, a merchant is not required to choose only one type of token payment. The main goal is to appropriately use each scenario.&lt;br /&gt;
&lt;br /&gt;
== Technical changes for Recurring payments ==&lt;br /&gt;
&lt;br /&gt;
#&#039;&#039;&#039; For the token registration&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request the new properties have to be specified:&lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;RecurringPayment&amp;quot;&amp;lt;/code&amp;gt; to indicate the scenario&lt;br /&gt;
#* &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; for the limitations &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt; &lt;br /&gt;
#Once the callback is received get the response of [[Payment-GetPaymentState-v2|GetPaymentState]]. In case the charge was successful, there will be a &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; property for the payment. The value of it must be saved and attached to the payment.  &lt;br /&gt;
#&#039;&#039;&#039;For subsequent payments&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request specify the &lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;RecurringPayment&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
#* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; you received for the initial payment.&lt;br /&gt;
&lt;br /&gt;
== Technical changes for Merchant initiated payments ==&lt;br /&gt;
&lt;br /&gt;
#&#039;&#039;&#039; For the token registration&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request the new property has to be specified:&lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;MerchantInitiatedPayment&amp;quot;&amp;lt;/code&amp;gt; to indicate the scenario&lt;br /&gt;
#Once the callback is received get the response of [[Payment-GetPaymentState-v2|GetPaymentState]]. In case the charge was successful, there will be a &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; property for the payment. The value of it must be saved and attached to the payment.  &lt;br /&gt;
#&#039;&#039;&#039;For subsequent payments&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request specify the &lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;MerchantInitiatedPayment&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
#* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; you received for the initial payment.&lt;br /&gt;
&lt;br /&gt;
== Technical changes for One-click payments ==&lt;br /&gt;
&lt;br /&gt;
This modification needs the most attention since the merchant has to implement client-side functionality and add a new step at the end of the flow.&lt;br /&gt;
&lt;br /&gt;
#&#039;&#039;&#039; For the token registration&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request the new property has to be specified:&lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;OneClickPayment&amp;quot;&amp;lt;/code&amp;gt; to indicate the scenario&lt;br /&gt;
#&#039;&#039;&#039;For subsequent payments&#039;&#039;&#039; the merchant has to integrate the barion.offsitegw.js to be able to authenticate the payer via 3DS v2 on the merchant&#039;s site. To do this read the tutorial on [[Token_payment_3D_Secure#OneClick payment|how to integrate this]].&lt;br /&gt;
# After a successful authentication a new Barion API endpoint ([[Payment-Complete-v2|/Payment/Complete]]) must be called to finalize the process and charge the card&lt;br /&gt;
&lt;br /&gt;
Please notice that in case this scenario is used there is no need to use the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; since the 3DS authentication will be performed every time.&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=CHANGE|text=In case of one-click token scenario the merchant has to authenticate every card payment with 3DS v2|color=#20c400}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What happens if the merchant doesn&#039;t upgrade its implementation ==&lt;br /&gt;
&lt;br /&gt;
There will be a two-phase ramp-up period to make sure that integrations can be upgraded.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Until December 31, 2020&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In this period the integrations that are not up-to-date and are not capable to handle 3DS v2 transactions &#039;&#039;&#039;will work&#039;&#039;&#039;. &lt;br /&gt;
* New tokens can be initiated (without RecurrenceType and TraceId) and the 3DSv2 authentication will be performed by the Barion Smart Gateway.&lt;br /&gt;
* Subsequent payments can use existing tokens (RecurrenceId) without specifying the TraceId.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Between January 1 and January 31, 2021 &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In this period the integrations that are not up-to-date and are not capable to handle 3DS v2 transactions &#039;&#039;&#039;will work&#039;&#039;&#039;. However, to comply with the card scheme mandates Barion has to substitute the missing information.&lt;br /&gt;
* New tokens can be initiated (without RecurrenceType and TraceId) and the 3DSv2 authentication will be performed by the Barion Smart Gateway. The payment will be marked as an initial MIT transaction. The MerchantInitiatedPayment RecurrenceType will be used as a fallback.&lt;br /&gt;
* Subsequent payments can use existing tokens (RecurrenceId) without specifying the TraceId. They will be handled as the subsequent MIT payment of the initial transaction. The TraceId will be filled in by Barion.&lt;br /&gt;
* This period allows all merchants to finish upgrading their integrations, receive TraceIds during subsequent payments, and send it back with the next subsequent payment, so Barion doesn&#039;t have to substitute it with a static value anymore.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;From February 1, 2021&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Until this date, all integrations must be upgraded. &lt;br /&gt;
* New tokens can only be initiated with the appropriate 3DSv2 information (RecurrenceType set). Otherwise, the payment/start will result in a validation error.&lt;br /&gt;
* Subsequent payments can use existing tokens (RecurrenceId) without specifying the TraceId. They will be handled as the subsequent MIT payment of the initial transaction. The TraceId will be filled in by Barion. This can be used until the card schemes allow this kind of TraceId substitution.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=SUPPORT|text=In case you have difficulties with the upgrade please contact our developers at devsupport@barion.com |color=#1993c7}}&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Barion_for_Shopify&amp;diff=3028</id>
		<title>Barion for Shopify</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Barion_for_Shopify&amp;diff=3028"/>
		<updated>2021-07-09T14:42:56Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* Error messages and actions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Barion for Shopify=&lt;br /&gt;
&lt;br /&gt;
==New to Shopify? Upgrade your business with a fully functional webshop in no time==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- Bring your business online: Create an e-commerce website backed by powerful tools that help you find customers, drive sales, and manage your day-to-day&lt;br /&gt;
&lt;br /&gt;
- Make the most out of your online business: Powerful tools already integrated into Shopify shops like insights, order management, and many integrated payment solutions&lt;br /&gt;
&lt;br /&gt;
- Online payment with Barion: Make the most out of your online business by providing online payment for customers. Barion Smart Gateway has you covered&lt;br /&gt;
&lt;br /&gt;
- Payments made international: Enjoy the benefits of Barion&#039;s many features. For example multiple languages and currencies, card payments, wire transfer payment, and mobile payments&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Have a Shopify shop? Downgrade your payment costs with Barion==&lt;br /&gt;
&lt;br /&gt;
- Join Barion and integrate our safe, secure and cost-effective solution with your shop in a few steps and start paying less fees.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Onboarding steps=&lt;br /&gt;
&lt;br /&gt;
=== Register » Create a Shop ===&lt;br /&gt;
&lt;br /&gt;
# [https://secure.barion.com/Registration/Organization?isEmailLocked=False Register a Barion account for your Business]&lt;br /&gt;
# [https://www.barion.com/en/support/how-can-i-create-a-barion-shop-does-this-require-an-approval/ Create a Shop]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Add Barion logo to your Shop&#039;s footer ====&lt;br /&gt;
&lt;br /&gt;
# [https://download.barion.com/barion/barion-smart-payment-banners.zip Get the Barion logo in multiple formats]&lt;br /&gt;
# [https://community.shopify.com/c/Shopify-Design/Adding-image-in-Supply-theme-Footer/td-p/352036 Insert them as image into your Shopify footer]&lt;br /&gt;
&lt;br /&gt;
==== Add Barion Pixel to your Shop&#039;s header ====&lt;br /&gt;
&lt;br /&gt;
# [https://docs.barion.com/Getting_started_with_the_Barion_Pixel Getting started with the Pixel]&lt;br /&gt;
# [https://support.pixelunion.net/hc/en-us/articles/360047807193-Adding-app-code-to-the-head-tag-in-your-theme-liquid Adding code into your Shopify shop&#039;s theme]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Get verified » Integrate Barion for Shopify ===&lt;br /&gt;
&lt;br /&gt;
# [https://www.barion.com/en/support/what-is-the-process-of-video-identification/ Get verified], &lt;br /&gt;
# [https://www.barion.com/en/support/documents-required-for-video-identification/ The documents you need] &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Connect your Shopify shop with Barion ==&lt;br /&gt;
&lt;br /&gt;
=== How to create Shopify keys ===&lt;br /&gt;
[[File:Create_private_app_001.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
In the Shopify admin interface please go to &amp;quot;Apps&amp;quot; and click to &amp;quot;Manage private apps&amp;quot; option: (https://YOUR_SHOPIFY_SUBDOMAIN.myshopify.com/admin/apps/private)&lt;br /&gt;
&lt;br /&gt;
[[File:Create_private_app_002.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
# Click to &amp;quot;Create a new private app&amp;quot; button and give a name and an e-mail address you wish to use. &lt;br /&gt;
# Choose &amp;quot;Show inactive Admin Api permission&amp;quot; and &lt;br /&gt;
# Set the option of &amp;quot;Orders&amp;quot; to &amp;quot;Read and write&amp;quot;, then click to &amp;quot;Save&amp;quot; button.&lt;br /&gt;
&lt;br /&gt;
[[File:Create_private_app_003.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
When the private app has been created successfully, API key and Password (from Admin API) have to be provided on the interface of Barion. To have the password presented, please click to &amp;quot;Show&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
[[File:Create_private_app_004.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== Filling Barion details out ===&lt;br /&gt;
[[File:Barion_shop_poskey.png]]&lt;br /&gt;
&lt;br /&gt;
To get your Barion Shop&#039;s Secret key (POSKey), go to [https://secure.barion.com/Shop your Barion shops] click on the &amp;quot;Actions&amp;quot; and Details to find your key. Copy it to the Shopify plugins Settings page, set there the primary currency and the shops language and hit &#039;&#039;&#039;Save&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Adding the integration code to Shopify Admin interface ===&lt;br /&gt;
&lt;br /&gt;
[[File:Add_js_code_001.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
On the Shopify Admin interface please go to &amp;quot;Settings&amp;quot; --&amp;gt; &amp;quot;Checkout&amp;quot; menu and add the following code to the section &amp;quot;Additional scripts&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT&#039;&#039;&#039;: The steps until now is the same for test shops, and for production shops, but this code snippet is different.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TEST&#039;&#039;&#039; script:&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;script src=&amp;quot;https://shopify.test.barion.com/js/barion/barion.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;Barion.init({&lt;br /&gt;
orderId: {{ order.id }},&lt;br /&gt;
domain: &#039;{{shop.permanent_domain}}&#039;,&lt;br /&gt;
gateway: &#039;{{order.gateway}}&#039;,&lt;br /&gt;
orderStatus: &#039;{{order.financial_status}}&#039;,&lt;br /&gt;
sandboxMode: true&lt;br /&gt;
})&amp;lt;/script&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;PRODUCTION&#039;&#039;&#039; script:&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;script src=&amp;quot;https://shopify.barion.com/js/barion/barion.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;Barion.init({&lt;br /&gt;
orderId: {{ order.id }},&lt;br /&gt;
domain: &#039;{{shop.permanent_domain}}&#039;,&lt;br /&gt;
gateway: &#039;{{order.gateway}}&#039;,&lt;br /&gt;
orderStatus: &#039;{{order.financial_status}}&#039;&lt;br /&gt;
})&amp;lt;/script&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Adding a payment method on Shopify Admin interface ===&lt;br /&gt;
&lt;br /&gt;
[[File:Create_manual_payment_001.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
On Shopify Admin interface go to &amp;quot;Settings&amp;quot; -&amp;gt; &amp;quot;Payments&amp;quot; and &amp;quot;Manual payment methods&amp;quot;. Click to &amp;quot;Manual payment methods&amp;quot; then choose &amp;quot;Create custom payment methods&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Provide the following details:&lt;br /&gt;
&lt;br /&gt;
- Custom payment method name: &#039;&#039;&#039;Barion Payments&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Additional details: after making an order you will be directed to the billing interface of Barion.&lt;br /&gt;
&lt;br /&gt;
After you have provided everything, click to &amp;quot;Active&amp;quot; button.&lt;br /&gt;
&lt;br /&gt;
[[File:Create_manual_payment_002.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
= TROUBLESHOOTING =&lt;br /&gt;
&lt;br /&gt;
== Error messages and actions ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The store is closed in the Barion system, payment is not allowed.&#039;&#039;&#039;&lt;br /&gt;
In this case your Barion Shop is not &#039;&#039;&#039;approved&#039;&#039;&#039; yet. If the POSKey you used is for the right shop, you have to wait until it is approved.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Application not installed&#039;&#039;&#039;&lt;br /&gt;
# The javascript code you pasted from here to the Shopify Checkout settings / Additional scripts field is most likely wrong. Keep in mind that the script is a bit different for the test/sandbox and for production.&lt;br /&gt;
# Order API rights were not set to read/write for the private app&lt;br /&gt;
# The plugin (shopify.barion.com) is set to a different domain than the shop itself (has to match the domain that is visible on the checkout page).&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=3027</id>
		<title>Token payment 3D Secure</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=3027"/>
		<updated>2021-07-09T10:08:31Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* Possible error responses for the subsequent payment requests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Token Payment with 3D Secure}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This payment scenario allows the integrator shop to register a token for a customer (and a funding source) in the Barion system and then, later on, using this token, charge the customer without redirecting her to the Barion Smart Gateway UI. The user may be present at the site of the merchant or she can be off-session as well, so the merchant can charge her e.g. for subscriptions. This means that the customer authorizes the shop to charge her card or Barion balance without typing in the card information or Barion login again.&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurring.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=Premium feature|text=This scenario is not allowed automatically for every approved shop and should be requested from Barion!|color=#1993c7}}&lt;br /&gt;
&lt;br /&gt;
= Token payment scenarios =&lt;br /&gt;
Token payment can be used in three use cases: &lt;br /&gt;
* &#039;&#039;&#039;Customer Initiated Payments&#039;&#039;&#039;: when the user is present on the website of the merchant and she decides to pay :&lt;br /&gt;
** &#039;&#039;&#039;OneClick payment&#039;&#039;&#039;: the user is charged upon her request initiated on the website of the merchant. Subsequent payments are subject to PSD2 SCA and as the user is present, she has to go through the authentication process.&lt;br /&gt;
* &#039;&#039;&#039;Merchant Initiated Payments&#039;&#039;&#039;: when the merchant initiates the payment without the user being present. It has two subtypes:&lt;br /&gt;
** &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: the user is charged with the same amount on a regular basis, typically in case of subscriptions. Subsequent payments are exempted from PSD2 SCA, but liability still shifts to the card issuer.&lt;br /&gt;
** &#039;&#039;&#039;MIT (merchant initiated transaction)&#039;&#039;&#039;: the user is charged on an irregular basis and/or with a different amount. Subsequent payments of this type are excluded from PSD2 SCA, the liability is on the merchant.&lt;br /&gt;
&lt;br /&gt;
== Customer participation ==&lt;br /&gt;
&lt;br /&gt;
Since the token scenario is suitable for both customer and merchant initiated payments here is a comparison about who starts the payment. This includes the regular, non-tokenized payment scenario as well:&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot; | Scenario&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Initial payment&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW &lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW&lt;br /&gt;
|-&lt;br /&gt;
| Non token (regular) payment || YES || YES || YES || YES &lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || YES || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| MIT || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #aaa; background-color:#eee; font-size: 0.8em; padding:5px 10px; display:inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; Token payment scenarios can be initiated with already registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; as well, in this case the customer may remain on the merchant&#039;s site. &lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements for the scenarios ==&lt;br /&gt;
&lt;br /&gt;
These token payment scenarios have different requirements, this table below summarizes the key differences.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Payment amount&lt;br /&gt;
! Payment frequency&lt;br /&gt;
! Liability in case of fraud&lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || Various || Various || Card issuer&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || Subsequent amounts must be equal or less than the initial amount  || Initial payment must define a minimum amount of days to wait between charges || Card issuer &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || Various  || Various || Merchant&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 3DS authentication of the payer ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be performed for every online card payment. These token payment scenarios also have to use this new secure way of authentication. &lt;br /&gt;
The initial payment of a token scenario must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
Here is a table to compare the 3DS authentication requirements:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Initial payment&lt;br /&gt;
! Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
| One-click payment || ✔️ || ✔️&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;IMPORTANT:&#039;&#039; when performing subsequent One-click payments with the &amp;lt;code&amp;gt;ChallengePreference&amp;lt;/code&amp;gt; parameter set to &amp;lt;code&amp;gt;NoChallengeNeeded&amp;lt;/code&amp;gt; (indicating a request for Transaction Risk Analysis), only a fraud analysis will be performed, and the customer is not required to undergo a 3DS challenge.&lt;br /&gt;
&lt;br /&gt;
== Real life examples ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phone bill&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Payer has a usage-based phone subscription that wants to pay without being present for every charge. She authorizes the phone company to charge her card every month.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, the amount of the subsequent payments may exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TV subscription&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to online streaming of a television channel. She authorizes the tv company to charge her card every month. The subscription fee is the same for every month.&lt;br /&gt;
* Scenario: Recurring payment&lt;br /&gt;
* Explanation: The amount of the subsequent payments will not exceed the initial payment and the charge is regularly monthly-based.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bookclub with &amp;quot;free first month&amp;quot; bonus&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to a book renting service. he authorizes the book club to charge her card for a selection of books each month. The subscription fee is the same for every month however, the first month is free. To ensure the subscription the service requires her to register her card details.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, and the fee will stay the same, the initial payment is zero. So the amount of the next payment will exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Online food delivery service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The food delivery company wants to provide a quick and easy experience for its customer. They decide that the order will be quicker if the customers don&#039;t leave the website to pay for the goods.&lt;br /&gt;
* Scenario: OneClick payment&lt;br /&gt;
* Explanation: The customer will always be there so the other two scenarios are not available.&lt;br /&gt;
&lt;br /&gt;
== How to decide ==&lt;br /&gt;
&lt;br /&gt;
To help you decide on a suitable scenario, please use the decision graph below:&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurrencetype-decision.png|520px]]&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
To be able to integrate your webshop with the Barion Payment Gateway: &lt;br /&gt;
* You must [[Creating_an_account|register a Barion wallet]] at the Barion website or in the Sandbox environment. Learn more about the Sandbox environment [[Sandbox|here]].&lt;br /&gt;
* For this wallet you have to [[Creating_a_shop|create a shop]] which should be approved by Barion.&lt;br /&gt;
* For every currency you plan to conduct payments in you have to make sure there is an account created in your Barion wallet. This means that if you plan to have USD payments then there should be a USD account created in your wallet.&lt;br /&gt;
* To make sure every corner case scenario works for your webshop it is best to top up that account with a small amount (approx. 5-10EUR or your choice of currency around the same value).&lt;br /&gt;
* For the technical communication guide please read this: [[Calling_the_API|Calling the API]]&lt;br /&gt;
&lt;br /&gt;
= The payment process =&lt;br /&gt;
&lt;br /&gt;
The process is divided into two major steps:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 1:  Creating the funding source token|Creating the token]] that represents one of the customer&#039;s funding sources (credit card or e-money wallet)&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Preparing the payment via the Barion API&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Redirecting the customer to the Barion Smart Gateway to select a funding source&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Processing the callback and requesting information about the result of the payment&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 2: Using the token|Using the registered token]] to charge the customer&amp;lt;/li&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1:  Creating the funding source token ==&lt;br /&gt;
To be able to use a token payment scenario first the merchant has to register the token with Barion. The merchant has to make sure that the customer is well aware of the fact that they are giving consent to a tokenized payment. The Barion Smart Gateway UI does not indicate in any way that the payment is a token payment.&lt;br /&gt;
&lt;br /&gt;
The token is registered to the shop and not to the merchant&#039;s Barion account. So if the merchant has multiple shops in its Barion account, the registered tokens can not be shared among them even if the customer is the same. If you want to use tokens in multiple shops, please contact Barion in the Customer center.&lt;br /&gt;
&lt;br /&gt;
=== 1.1 Preparing the payment===&lt;br /&gt;
&lt;br /&gt;
The token registration is basically a [[Responsive_web_payment|normal payment]] with three extra properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* InitiateRecurrence&lt;br /&gt;
* RecurrenceId&lt;br /&gt;
* RecurrenceType&lt;br /&gt;
&lt;br /&gt;
==== InitiateRecurrence====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; is a bool property. If you set it to &#039;&#039;&#039;true&#039;&#039;&#039; then the payment gateway will consider the payment as a token registration. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This happens even if the customer is already has a registered token, so you are able to re-register a funding source or even a customer. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceId ====&lt;br /&gt;
The next required property for a token registration is the token itself. This is generated by the shop and has to be unique for every registration. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property of the [[Payment-Start-v2|Payment/Start]] request. This token must be saved in the webshops database. A &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; token represents the funding source (bank card or Barion balance) of a customer. Since a customer can have multiple cards and accounts as a funding source make sure that in the webshop&#039;s system multiple tokens can belong to a single customer.&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceType ====&lt;br /&gt;
The third required property is the [[RecurrenceType|Recurrence Type]]. This specifies the scenario. In case of Recurring Payment &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; must also be set.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Merchant Initiated Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The response will be the same as to a [[Responsive_web_payment#Processing_the_successful_response|basic &#039;&#039;&#039;Immediate&#039;&#039;&#039; scenario]]. The &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; property at this point is &#039;&#039;&#039;None&#039;&#039;&#039; since the token is not registered to a funding source yet.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Recurring Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Recurring Payment&#039;&#039;&#039; scenario has some extra restrictions. The merchant has to specify two additional properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt;: The date after subsequent charges should not be accepted.&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt;: The minimum days the merchant has to wait between payments.&lt;br /&gt;
&lt;br /&gt;
Both properties are located in the [[PurchaseInformation]] property and must be specified if this scenario is selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7, 30-33&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;PurchaseInformation&amp;quot;:{&lt;br /&gt;
        &amp;quot;RecurringFrequency&amp;quot;: 10,&lt;br /&gt;
        &amp;quot;RecurringExpiry&amp;quot;: &amp;quot;2022-10-01&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Possible error responses ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentNotAllowed || The token payment is not allowed for the shop identified by the &#039;&#039;&#039;POSKey&#039;&#039;&#039;. Contact Barion to request this feature.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 1.2 Redirecting the customer to the Barion Smart Gateway to select a funding source ===&lt;br /&gt;
&lt;br /&gt;
After a successful payment preparation, the customer is redirected to the secure Barion Smart Gateway to choose a funding source. The funding source the customer selects will be registered to the token. The funding source can either be a Barion e-money balance or a bank card. This means that even though the customer may own multiple cards only the one that was registered to the token can be used for future token payments. To change the funding source attached to the token a new registration should be requested.&lt;br /&gt;
&lt;br /&gt;
=== 1.3 Processing the callback and requesting information about the result of the payment ===&lt;br /&gt;
&lt;br /&gt;
When the payment is completed (either successfully or unsuccessfully) a callback message is sent to the merchant&#039;s system. Once received a [[Payment-GetPaymentState-v2|GetPaymentState]] request must be sent to the Barion API. On how to implement this please read the article about the  [[Callback_mechanism|Callback mechanism]].&lt;br /&gt;
&lt;br /&gt;
The full response of the GetPaymentState request depends on the payment scenario and the structure of the payment. When it comes to token payment there are several properties to look out for. &lt;br /&gt;
* In case the &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; is &#039;&#039;&#039;Succeeded&#039;&#039;&#039; the funding source token is registered and ready to use.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; contains the ID of the token process. This specifies the nature of the token payment. &lt;br /&gt;
&lt;br /&gt;
==== TraceId ====&lt;br /&gt;
&lt;br /&gt;
In case of Recurring payment or Merchant initiated payment scenarios the [[Payment-GetPaymentState-v2|GetPaymentState]] response returns an additional field called &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. The value of this property is generated by the card issuer and is up to a 100 characters, and should be left intact (whitespaces and 0s can&#039;t be trimmed). The merchant has to save it and submit it in all subsequent Recurring or Merchant initiated payments of the same type, otherwise, the payments can be declined by the issuer. The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; represents the first, customer-present payment and helps the issuer to connect subsequent payments to this initial payment.&lt;br /&gt;
&lt;br /&gt;
====Example GetPaymentState response====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;8, 11-12&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;OrderNumber&amp;quot;: null,&lt;br /&gt;
    &amp;quot;POSId&amp;quot;: &amp;quot;[[SHOPS_PUBLIC_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSName&amp;quot;: &amp;quot;[[MERCHANTS_BARION_SHOPNAME]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSOwnerEmail&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSource&amp;quot;: &amp;quot;BankCard&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;AllowedFundingSources&amp;quot;: [&lt;br /&gt;
        &amp;quot;All&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;GuestCheckout&amp;quot;: true,&lt;br /&gt;
    &amp;quot;CreatedAt&amp;quot;: &amp;quot;2020-11-26T07:52:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ValidUntil&amp;quot;: &amp;quot;2020-11-26T08:22:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;CompletedAt&amp;quot;: &amp;quot;2020-11-26T08:11:54.118Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ReservedUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;DelayedCaptureUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
           ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;Total&amp;quot;: 25.20,&lt;br /&gt;
    &amp;quot;SuggestedLocale&amp;quot;: &amp;quot;hu-HU&amp;quot;,&lt;br /&gt;
    &amp;quot;FraudRiskScore&amp;quot;: null,&lt;br /&gt;
    &amp;quot;RedirectUrl&amp;quot;: &amp;quot;https://merchanturl/Redirect?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;CallbackUrl&amp;quot;: &amp;quot;https://merchanturl/Callback?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Displaying the funding source in a GUI ====&lt;br /&gt;
We strongly advise saving the complete response for future reference. The &amp;lt;code&amp;gt;FundingSource&amp;lt;/code&amp;gt; field tells if the funding source is a Barion balance or a card. If it is a card, it is useful to save [[FundingInformation]] for displaying it for the user, when requesting future payments. The usual way to display funding sources is to show the last 4 digits of the card, with 4 stars, eg: *** 1234. The card used can be obtained from FundingInformation&#039;s [[BankCard]] field. The [[CardType]] field can be used to display the appropriate card logo. You can even show, if the card is expired, and offer to register another one.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; FundingInformation part of the GetPaymentState response &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=json&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be displayed for example as &amp;lt;code&amp;gt;VISA **** 0425 (12/20)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a request-response diagram of the token registration process:&lt;br /&gt;
 &lt;br /&gt;
[[File:Token_payment_initiation.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Step 2: Using the token =&lt;br /&gt;
&lt;br /&gt;
To use an already registered token for a payment, you have to use the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property. To be able to use a token, the initial payment must be in a successful state.&lt;br /&gt;
&lt;br /&gt;
At this point, the merchant has to decide whether this subsequent payment is used for the same token payment scenario or something changed. This is important because the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used for the same scenario, otherwise, the card issuer will decline the charge.&lt;br /&gt;
A &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used again if:&lt;br /&gt;
* the funding source is the same (technically the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* the token payment scenario is the same (technically the &amp;lt;code&amp;gt;RecurrenceType&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* this subsequent request complies with the scenario restrictions (eg: in case of recurring payment the amount of the subsequent payment does not exceed the initial amount)&lt;br /&gt;
&lt;br /&gt;
If the funding source changes, new &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the funding source|described in detail here]]. If the funding source stays the same but the scenario changes or the restrictions are no longer met new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the token payment scenario with an existing token|described here]].&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Recurring payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this case, three extra conditions must be met:&lt;br /&gt;
* the amount of the subsequent payment must not be higher than the initial amount&lt;br /&gt;
* at least that much days must be spent as defined in the initial &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; property&lt;br /&gt;
* the date of the payment must not exceed the day specified in the initial &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; property&lt;br /&gt;
&lt;br /&gt;
Please be aware that in case any of these are no longer valid the merchant has to request a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; as [[#Changing the token payment scenario with an existing token|described here]]. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=These conditions are not enforced by the Barion system so the violation of them will result in a declined charge.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
Payment/start must not include the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; properties (since they are already fixed during the initial payment).&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Recurring payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Merchant Initiated Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario there are no restrictions.&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Merchant Initiated Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 75,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Phone bill&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of OneClick Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario, the merchant has to prepare to perform the [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]] of the payer. 3DS authentication is not required in the following cases:&lt;br /&gt;
* the token (&amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;) was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is not used in this scenario since the payer is present during the transaction. &lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent OneClick Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 17,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Book: How to shop online&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;How to shop online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Book about shopping online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;piece&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
In this scenario, the response contains the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; property that is used to perform an [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8-9&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: &amp;quot;ewoJIkNhcmRQdWJs...WZXJzaW9uIjogIjIuMS4wIgp9Cg==&amp;quot;,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Possible error responses for the subsequent payment requests ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| InvalidRecurrenceId|| The token specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is invalid. Check if the token registration was successful.&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentDenied|| Something happened to the user since the token registration, either deleted, suspended, or blocked. The payment s not allowed in these cases.&lt;br /&gt;
|-&lt;br /&gt;
| InsufficientFunds|| If the original payment was with an e-money wallet and the customer doesn&#039;t have enough money to fulfill this charge this error happens.&lt;br /&gt;
|-&lt;br /&gt;
| OriginalPaymentWasntSuccessful || This means that the token belongs to an originally unsuccessful payment so this token can not be used anymore. This could only happen if the original payment was financed with a credit card.&lt;br /&gt;
|-&lt;br /&gt;
|InvalidCurrency || If the original payment was paid with e-money and the current token payment is in a currency that the wallet does not have an account in this error happens.&lt;br /&gt;
|-&lt;br /&gt;
|CardExpired || The card that was used to fulfill the initial payment is no longer valid. The &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; has to be re-initialized.&lt;br /&gt;
|-&lt;br /&gt;
|TopUpFailed || The attempt to charge the card that was use to fulfill the initial payment was unsuccessful. Often accompanied by other more specific errors.&lt;br /&gt;
|-&lt;br /&gt;
|ThreeDsNotEnabled || The card issuer rejected the card due to lack of Strong Customer Authentication. Check whether the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is specified correctly (in case the scenario requires it).&lt;br /&gt;
|-&lt;br /&gt;
|InvalidUser || The payee defined in the transaction is not a valid Barion wallet. Either does not exist or not fully activated.&lt;br /&gt;
|-&lt;br /&gt;
|UserCantMakeOutgoingTransaction || The payee specified in the transaction is not allowed to make payeetransactions since the wallet is suspended or does not exist.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is the request-response diagram of the subsequent payments:&lt;br /&gt;
&lt;br /&gt;
[[File:Token_payment_2.png]]&lt;br /&gt;
&lt;br /&gt;
== RecurrenceResult: ThreeDSAuthenticationRequired ==&lt;br /&gt;
&lt;br /&gt;
In response to a subsequent payment, this RecurrenceResult can be received. This means that the payment can not be processed due to the lack of 3DS v2 information. &lt;br /&gt;
&lt;br /&gt;
This can happen if the initial payment was successfully authenticated via 3DS v2 but the subsequent payment does not refer to the original authentication with the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To fix this, request and store the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; of the initial payment and then specify it in the subsequent [[Payment-Start-v2]].&lt;br /&gt;
&lt;br /&gt;
To learn the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; of a previous payment just simply request the payment information via the [[Payment-GetPaymentState-v2]] endpoint.&lt;br /&gt;
&lt;br /&gt;
= Changing funding source or token scenarios =&lt;br /&gt;
&lt;br /&gt;
==Changing the funding source==&lt;br /&gt;
&lt;br /&gt;
This could happen if the funding source becomes invalid for some reason (card gets deleted or expires) or the merchant decides to use that token for another payer. In this case, the merchant has to register the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; again. &lt;br /&gt;
To do this a new payment must be started and in the [[Payment-Start-v2|Payment/Start]] request the following setup should be specified:&lt;br /&gt;
* the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; field has to be set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; &lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; has to be specified.&lt;br /&gt;
* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; should not be specified.&lt;br /&gt;
&lt;br /&gt;
[[File:Funding-source-change.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is bound to the payer and the process if the funding source changes new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be generated. This new ID must be saved to this payment and must be used from this moment on for subsequent payments.&lt;br /&gt;
&lt;br /&gt;
==Changing the token payment scenario with an existing token==&lt;br /&gt;
&lt;br /&gt;
This could occur when the merchant wants to get authorization from the payer to a new token scenario for the already registered funding source. To be able to do this the merchant has to have a valid and registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
Let&#039;s see some examples when this may be necessary:&lt;br /&gt;
* The payer subscribed to the merchant&#039;s service beforehand and the merchant decided to use the recurring payment token scenario. The payer wants to subscribe to another service and this requires a different payment schedule. This means that the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; that was specified initially can not be maintained so it is required to acquire a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;&lt;br /&gt;
* The payer bought something on the merchant&#039;s website and uses the one-click feature for subsequent fast non-redirect payments. After a while, the payer decides to subscribe to a service provided by this same merchant. This means that the merchant has to create a new token scenario (not a one-click payment but a recurring payment). For this, the merchant has to acquire a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. This can be done without redirecting the payer to Barion using the existing &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; and performing a 3DS authentication on the merchant&#039;s website.&lt;br /&gt;
&lt;br /&gt;
To do these a new payment must be started and in the [[Payment-Start-v2|Payment/Start]] request the following setup should be specified:&lt;br /&gt;
* the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; field has to be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; &lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; has to be specified.&lt;br /&gt;
* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; should not be specified.&lt;br /&gt;
&lt;br /&gt;
After this, a 3DS authentication has to be completed to acquire a new trace ID. This can be done on the merchant&#039;s site if the merchant implements the barion.offsitegw.js for off-site 3DS authentication.&lt;br /&gt;
&lt;br /&gt;
This means that it can be achieved to acquire different Trace IDs for different scenarios with only one &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
This is basically categorizing the different token scenarios as opposed to using every subsequent payment as an unmarked charge.&lt;br /&gt;
&lt;br /&gt;
[[File:Mutiple-traceid.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
= Off-site 3DS v2 authentication =&lt;br /&gt;
&lt;br /&gt;
In certain scenarios, the payer has to be authenticated to lower the risk of the card transaction. This can be either performed &lt;br /&gt;
* on the Barion Smart Gateway (on-site) by redirecting the customer to Barion &lt;br /&gt;
* or on the merchant&#039;s website (off-site) by integrating the Barion Off-site client library.&lt;br /&gt;
&lt;br /&gt;
This section describes how to integrate the Barion off-site authentication library into the merchant&#039;s site.&lt;br /&gt;
&lt;br /&gt;
== Step 1 : Initialize the off-site authentication library  ==&lt;br /&gt;
You have to include the following css and javascript files in the code of your site. &lt;br /&gt;
&amp;lt;source lang=html&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source &amp;gt;&lt;br /&gt;
These files include all the necessary javascript code and styling to handle the 3DS authentication and display the challenge if necessary.&lt;br /&gt;
&lt;br /&gt;
Then you have to initialize the Barion javascript client. To do that, you have to define a configuration object that specifies your functions that handle the off-site authentication events. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; Authentication events&#039;&#039;&#039;&lt;br /&gt;
* &amp;lt;code&amp;gt;onAuthenticationSucceeded&amp;lt;/code&amp;gt;: the 3DS v2 authentication successfully completed&lt;br /&gt;
* &amp;lt;code&amp;gt;onAuthenticationFailed&amp;lt;/code&amp;gt;:  the 3DS v2 authentication failed&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const configuration = {&lt;br /&gt;
    onAuthenticationSucceeded: function () {&lt;br /&gt;
        // handle successful authentication by calling the Barion API via merchant&#039;s backend&lt;br /&gt;
        // Call the v2/payment/complete endpoint&lt;br /&gt;
    },&lt;br /&gt;
    onAuthenticationFailed: function () {&lt;br /&gt;
        // Handle unsuccessful authentication result, no charge was made.&lt;br /&gt;
        // The payment might be still valid only the authentication failed&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to pass this config object to the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const gw = new Barion.OffsiteGw(configuration);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once the DOM is loaded you have to initialize the library:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
document.addEventListener(&amp;quot;DOMContentLoaded&amp;quot;, function () {&lt;br /&gt;
    // Initiate the Barion Offiste GW library&lt;br /&gt;
    gw.init();&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2: Start the authentication process ==&lt;br /&gt;
Once the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; is acquired from the payment/start you can start the authentication process by calling the &amp;lt;code&amp;gt;authenticate()&amp;lt;/code&amp;gt; method of the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
gw.authenticate(threeDsClientData);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will start the authentication process and present the challenge if needed. Visually this will create a modal window over the merchant&#039;s site and show the payer every necessary information.&lt;br /&gt;
Once the authentication process finished (either with or without a challenge) the appropriate event will be fired.&lt;br /&gt;
&lt;br /&gt;
== Step 3: Completing the payment ==&lt;br /&gt;
&lt;br /&gt;
In case of successful authentication, you have to call our [[Payment-Complete-v3|/Payment/Complete]] endpoint, where the actual charge will happen.&lt;br /&gt;
&lt;br /&gt;
=== Possible error responses for the subsequent payment requests ===&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
== Suggested implementation flow for off-site authentication ==&lt;br /&gt;
&lt;br /&gt;
Ideally, an off-site authentication should be part of a client-side experience without any postbacks or page reloads. This is our recommendation to achieve this:&lt;br /&gt;
&lt;br /&gt;
# After the customer clicks on the &amp;quot;Pay&amp;quot; button make an AJAX call from your client-side code to your back-end. &lt;br /&gt;
# Have your backend make a request to our payment/start endpoint (with the appropriate settings for the desired token scenario)&lt;br /&gt;
# Have your backend process the response and pass the value of the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; property to your client-side code.&lt;br /&gt;
# Use the Barion off-site library to perform the authentication&lt;br /&gt;
# Once the authentication succeeds send another AJAX request from your client-side code to your back-end.&lt;br /&gt;
# Have your back-end code call our [[Payment-Complete-v3|/Payment/Complete]]&lt;br /&gt;
# Have your backend process the response and pass the result to your client-side code.&lt;br /&gt;
# Display the result for the customer&lt;br /&gt;
&lt;br /&gt;
= Testing the integration =&lt;br /&gt;
&lt;br /&gt;
3D Secure has no environment for end-to-end testing, therefore merchants have to split their testings into two parts: Testing the payment flow with and without challenge. Getting a challenge is only possible with real-life cards, merchants have to use their own (there will be no real charging at the end on the Sandbox of the Payment Gateway, but using a real card will result initiating a real 3DS authentication).&lt;br /&gt;
&lt;br /&gt;
== Testing the whole payment flow, without challenge ==&lt;br /&gt;
&lt;br /&gt;
Use the [[https://docs.barion.com/Sandbox#Test_cards Barion test cards]], they will always get a &amp;quot;frictionless&amp;quot; flow, where the 3DS process is presented on the UI, but you will never see a challenge screen. &lt;br /&gt;
&lt;br /&gt;
This is good for testing your integration itself because it will lead to a successful charge, and you will get a TraceId as well.&lt;br /&gt;
&lt;br /&gt;
== Testing the challenge itself ==&lt;br /&gt;
&lt;br /&gt;
Use your own card, and let the card issuer decide whether your payment will get a challenge or not during the 3DS authentication procedure. Your payment will fail at the end, and you won&#039;t get the TraceId. &lt;br /&gt;
&lt;br /&gt;
This is good to test, how the challenge screens look like in your shop - especially when you integrated OneClick payment directly to your shop. You might also check how your customers see your checkout flow on popular devices.&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=3026</id>
		<title>Token payment 3D Secure</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=3026"/>
		<updated>2021-07-09T10:04:06Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* Possible error responses for the subsequent payment requests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Token Payment with 3D Secure}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This payment scenario allows the integrator shop to register a token for a customer (and a funding source) in the Barion system and then, later on, using this token, charge the customer without redirecting her to the Barion Smart Gateway UI. The user may be present at the site of the merchant or she can be off-session as well, so the merchant can charge her e.g. for subscriptions. This means that the customer authorizes the shop to charge her card or Barion balance without typing in the card information or Barion login again.&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurring.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=Premium feature|text=This scenario is not allowed automatically for every approved shop and should be requested from Barion!|color=#1993c7}}&lt;br /&gt;
&lt;br /&gt;
= Token payment scenarios =&lt;br /&gt;
Token payment can be used in three use cases: &lt;br /&gt;
* &#039;&#039;&#039;Customer Initiated Payments&#039;&#039;&#039;: when the user is present on the website of the merchant and she decides to pay :&lt;br /&gt;
** &#039;&#039;&#039;OneClick payment&#039;&#039;&#039;: the user is charged upon her request initiated on the website of the merchant. Subsequent payments are subject to PSD2 SCA and as the user is present, she has to go through the authentication process.&lt;br /&gt;
* &#039;&#039;&#039;Merchant Initiated Payments&#039;&#039;&#039;: when the merchant initiates the payment without the user being present. It has two subtypes:&lt;br /&gt;
** &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: the user is charged with the same amount on a regular basis, typically in case of subscriptions. Subsequent payments are exempted from PSD2 SCA, but liability still shifts to the card issuer.&lt;br /&gt;
** &#039;&#039;&#039;MIT (merchant initiated transaction)&#039;&#039;&#039;: the user is charged on an irregular basis and/or with a different amount. Subsequent payments of this type are excluded from PSD2 SCA, the liability is on the merchant.&lt;br /&gt;
&lt;br /&gt;
== Customer participation ==&lt;br /&gt;
&lt;br /&gt;
Since the token scenario is suitable for both customer and merchant initiated payments here is a comparison about who starts the payment. This includes the regular, non-tokenized payment scenario as well:&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot; | Scenario&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Initial payment&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW &lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW&lt;br /&gt;
|-&lt;br /&gt;
| Non token (regular) payment || YES || YES || YES || YES &lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || YES || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| MIT || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #aaa; background-color:#eee; font-size: 0.8em; padding:5px 10px; display:inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; Token payment scenarios can be initiated with already registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; as well, in this case the customer may remain on the merchant&#039;s site. &lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements for the scenarios ==&lt;br /&gt;
&lt;br /&gt;
These token payment scenarios have different requirements, this table below summarizes the key differences.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Payment amount&lt;br /&gt;
! Payment frequency&lt;br /&gt;
! Liability in case of fraud&lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || Various || Various || Card issuer&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || Subsequent amounts must be equal or less than the initial amount  || Initial payment must define a minimum amount of days to wait between charges || Card issuer &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || Various  || Various || Merchant&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 3DS authentication of the payer ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be performed for every online card payment. These token payment scenarios also have to use this new secure way of authentication. &lt;br /&gt;
The initial payment of a token scenario must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
Here is a table to compare the 3DS authentication requirements:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Initial payment&lt;br /&gt;
! Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
| One-click payment || ✔️ || ✔️&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;IMPORTANT:&#039;&#039; when performing subsequent One-click payments with the &amp;lt;code&amp;gt;ChallengePreference&amp;lt;/code&amp;gt; parameter set to &amp;lt;code&amp;gt;NoChallengeNeeded&amp;lt;/code&amp;gt; (indicating a request for Transaction Risk Analysis), only a fraud analysis will be performed, and the customer is not required to undergo a 3DS challenge.&lt;br /&gt;
&lt;br /&gt;
== Real life examples ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phone bill&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Payer has a usage-based phone subscription that wants to pay without being present for every charge. She authorizes the phone company to charge her card every month.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, the amount of the subsequent payments may exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TV subscription&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to online streaming of a television channel. She authorizes the tv company to charge her card every month. The subscription fee is the same for every month.&lt;br /&gt;
* Scenario: Recurring payment&lt;br /&gt;
* Explanation: The amount of the subsequent payments will not exceed the initial payment and the charge is regularly monthly-based.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bookclub with &amp;quot;free first month&amp;quot; bonus&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to a book renting service. he authorizes the book club to charge her card for a selection of books each month. The subscription fee is the same for every month however, the first month is free. To ensure the subscription the service requires her to register her card details.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, and the fee will stay the same, the initial payment is zero. So the amount of the next payment will exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Online food delivery service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The food delivery company wants to provide a quick and easy experience for its customer. They decide that the order will be quicker if the customers don&#039;t leave the website to pay for the goods.&lt;br /&gt;
* Scenario: OneClick payment&lt;br /&gt;
* Explanation: The customer will always be there so the other two scenarios are not available.&lt;br /&gt;
&lt;br /&gt;
== How to decide ==&lt;br /&gt;
&lt;br /&gt;
To help you decide on a suitable scenario, please use the decision graph below:&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurrencetype-decision.png|520px]]&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
To be able to integrate your webshop with the Barion Payment Gateway: &lt;br /&gt;
* You must [[Creating_an_account|register a Barion wallet]] at the Barion website or in the Sandbox environment. Learn more about the Sandbox environment [[Sandbox|here]].&lt;br /&gt;
* For this wallet you have to [[Creating_a_shop|create a shop]] which should be approved by Barion.&lt;br /&gt;
* For every currency you plan to conduct payments in you have to make sure there is an account created in your Barion wallet. This means that if you plan to have USD payments then there should be a USD account created in your wallet.&lt;br /&gt;
* To make sure every corner case scenario works for your webshop it is best to top up that account with a small amount (approx. 5-10EUR or your choice of currency around the same value).&lt;br /&gt;
* For the technical communication guide please read this: [[Calling_the_API|Calling the API]]&lt;br /&gt;
&lt;br /&gt;
= The payment process =&lt;br /&gt;
&lt;br /&gt;
The process is divided into two major steps:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 1:  Creating the funding source token|Creating the token]] that represents one of the customer&#039;s funding sources (credit card or e-money wallet)&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Preparing the payment via the Barion API&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Redirecting the customer to the Barion Smart Gateway to select a funding source&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Processing the callback and requesting information about the result of the payment&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 2: Using the token|Using the registered token]] to charge the customer&amp;lt;/li&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1:  Creating the funding source token ==&lt;br /&gt;
To be able to use a token payment scenario first the merchant has to register the token with Barion. The merchant has to make sure that the customer is well aware of the fact that they are giving consent to a tokenized payment. The Barion Smart Gateway UI does not indicate in any way that the payment is a token payment.&lt;br /&gt;
&lt;br /&gt;
The token is registered to the shop and not to the merchant&#039;s Barion account. So if the merchant has multiple shops in its Barion account, the registered tokens can not be shared among them even if the customer is the same. If you want to use tokens in multiple shops, please contact Barion in the Customer center.&lt;br /&gt;
&lt;br /&gt;
=== 1.1 Preparing the payment===&lt;br /&gt;
&lt;br /&gt;
The token registration is basically a [[Responsive_web_payment|normal payment]] with three extra properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* InitiateRecurrence&lt;br /&gt;
* RecurrenceId&lt;br /&gt;
* RecurrenceType&lt;br /&gt;
&lt;br /&gt;
==== InitiateRecurrence====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; is a bool property. If you set it to &#039;&#039;&#039;true&#039;&#039;&#039; then the payment gateway will consider the payment as a token registration. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This happens even if the customer is already has a registered token, so you are able to re-register a funding source or even a customer. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceId ====&lt;br /&gt;
The next required property for a token registration is the token itself. This is generated by the shop and has to be unique for every registration. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property of the [[Payment-Start-v2|Payment/Start]] request. This token must be saved in the webshops database. A &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; token represents the funding source (bank card or Barion balance) of a customer. Since a customer can have multiple cards and accounts as a funding source make sure that in the webshop&#039;s system multiple tokens can belong to a single customer.&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceType ====&lt;br /&gt;
The third required property is the [[RecurrenceType|Recurrence Type]]. This specifies the scenario. In case of Recurring Payment &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; must also be set.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Merchant Initiated Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The response will be the same as to a [[Responsive_web_payment#Processing_the_successful_response|basic &#039;&#039;&#039;Immediate&#039;&#039;&#039; scenario]]. The &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; property at this point is &#039;&#039;&#039;None&#039;&#039;&#039; since the token is not registered to a funding source yet.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Recurring Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Recurring Payment&#039;&#039;&#039; scenario has some extra restrictions. The merchant has to specify two additional properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt;: The date after subsequent charges should not be accepted.&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt;: The minimum days the merchant has to wait between payments.&lt;br /&gt;
&lt;br /&gt;
Both properties are located in the [[PurchaseInformation]] property and must be specified if this scenario is selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7, 30-33&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;PurchaseInformation&amp;quot;:{&lt;br /&gt;
        &amp;quot;RecurringFrequency&amp;quot;: 10,&lt;br /&gt;
        &amp;quot;RecurringExpiry&amp;quot;: &amp;quot;2022-10-01&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Possible error responses ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentNotAllowed || The token payment is not allowed for the shop identified by the &#039;&#039;&#039;POSKey&#039;&#039;&#039;. Contact Barion to request this feature.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 1.2 Redirecting the customer to the Barion Smart Gateway to select a funding source ===&lt;br /&gt;
&lt;br /&gt;
After a successful payment preparation, the customer is redirected to the secure Barion Smart Gateway to choose a funding source. The funding source the customer selects will be registered to the token. The funding source can either be a Barion e-money balance or a bank card. This means that even though the customer may own multiple cards only the one that was registered to the token can be used for future token payments. To change the funding source attached to the token a new registration should be requested.&lt;br /&gt;
&lt;br /&gt;
=== 1.3 Processing the callback and requesting information about the result of the payment ===&lt;br /&gt;
&lt;br /&gt;
When the payment is completed (either successfully or unsuccessfully) a callback message is sent to the merchant&#039;s system. Once received a [[Payment-GetPaymentState-v2|GetPaymentState]] request must be sent to the Barion API. On how to implement this please read the article about the  [[Callback_mechanism|Callback mechanism]].&lt;br /&gt;
&lt;br /&gt;
The full response of the GetPaymentState request depends on the payment scenario and the structure of the payment. When it comes to token payment there are several properties to look out for. &lt;br /&gt;
* In case the &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; is &#039;&#039;&#039;Succeeded&#039;&#039;&#039; the funding source token is registered and ready to use.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; contains the ID of the token process. This specifies the nature of the token payment. &lt;br /&gt;
&lt;br /&gt;
==== TraceId ====&lt;br /&gt;
&lt;br /&gt;
In case of Recurring payment or Merchant initiated payment scenarios the [[Payment-GetPaymentState-v2|GetPaymentState]] response returns an additional field called &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. The value of this property is generated by the card issuer and is up to a 100 characters, and should be left intact (whitespaces and 0s can&#039;t be trimmed). The merchant has to save it and submit it in all subsequent Recurring or Merchant initiated payments of the same type, otherwise, the payments can be declined by the issuer. The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; represents the first, customer-present payment and helps the issuer to connect subsequent payments to this initial payment.&lt;br /&gt;
&lt;br /&gt;
====Example GetPaymentState response====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;8, 11-12&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;OrderNumber&amp;quot;: null,&lt;br /&gt;
    &amp;quot;POSId&amp;quot;: &amp;quot;[[SHOPS_PUBLIC_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSName&amp;quot;: &amp;quot;[[MERCHANTS_BARION_SHOPNAME]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSOwnerEmail&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSource&amp;quot;: &amp;quot;BankCard&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;AllowedFundingSources&amp;quot;: [&lt;br /&gt;
        &amp;quot;All&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;GuestCheckout&amp;quot;: true,&lt;br /&gt;
    &amp;quot;CreatedAt&amp;quot;: &amp;quot;2020-11-26T07:52:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ValidUntil&amp;quot;: &amp;quot;2020-11-26T08:22:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;CompletedAt&amp;quot;: &amp;quot;2020-11-26T08:11:54.118Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ReservedUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;DelayedCaptureUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
           ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;Total&amp;quot;: 25.20,&lt;br /&gt;
    &amp;quot;SuggestedLocale&amp;quot;: &amp;quot;hu-HU&amp;quot;,&lt;br /&gt;
    &amp;quot;FraudRiskScore&amp;quot;: null,&lt;br /&gt;
    &amp;quot;RedirectUrl&amp;quot;: &amp;quot;https://merchanturl/Redirect?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;CallbackUrl&amp;quot;: &amp;quot;https://merchanturl/Callback?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Displaying the funding source in a GUI ====&lt;br /&gt;
We strongly advise saving the complete response for future reference. The &amp;lt;code&amp;gt;FundingSource&amp;lt;/code&amp;gt; field tells if the funding source is a Barion balance or a card. If it is a card, it is useful to save [[FundingInformation]] for displaying it for the user, when requesting future payments. The usual way to display funding sources is to show the last 4 digits of the card, with 4 stars, eg: *** 1234. The card used can be obtained from FundingInformation&#039;s [[BankCard]] field. The [[CardType]] field can be used to display the appropriate card logo. You can even show, if the card is expired, and offer to register another one.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; FundingInformation part of the GetPaymentState response &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=json&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be displayed for example as &amp;lt;code&amp;gt;VISA **** 0425 (12/20)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a request-response diagram of the token registration process:&lt;br /&gt;
 &lt;br /&gt;
[[File:Token_payment_initiation.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Step 2: Using the token =&lt;br /&gt;
&lt;br /&gt;
To use an already registered token for a payment, you have to use the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property. To be able to use a token, the initial payment must be in a successful state.&lt;br /&gt;
&lt;br /&gt;
At this point, the merchant has to decide whether this subsequent payment is used for the same token payment scenario or something changed. This is important because the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used for the same scenario, otherwise, the card issuer will decline the charge.&lt;br /&gt;
A &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used again if:&lt;br /&gt;
* the funding source is the same (technically the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* the token payment scenario is the same (technically the &amp;lt;code&amp;gt;RecurrenceType&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* this subsequent request complies with the scenario restrictions (eg: in case of recurring payment the amount of the subsequent payment does not exceed the initial amount)&lt;br /&gt;
&lt;br /&gt;
If the funding source changes, new &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the funding source|described in detail here]]. If the funding source stays the same but the scenario changes or the restrictions are no longer met new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the token payment scenario with an existing token|described here]].&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Recurring payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this case, three extra conditions must be met:&lt;br /&gt;
* the amount of the subsequent payment must not be higher than the initial amount&lt;br /&gt;
* at least that much days must be spent as defined in the initial &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; property&lt;br /&gt;
* the date of the payment must not exceed the day specified in the initial &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; property&lt;br /&gt;
&lt;br /&gt;
Please be aware that in case any of these are no longer valid the merchant has to request a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; as [[#Changing the token payment scenario with an existing token|described here]]. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=These conditions are not enforced by the Barion system so the violation of them will result in a declined charge.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
Payment/start must not include the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; properties (since they are already fixed during the initial payment).&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Recurring payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Merchant Initiated Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario there are no restrictions.&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Merchant Initiated Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 75,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Phone bill&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of OneClick Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario, the merchant has to prepare to perform the [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]] of the payer. 3DS authentication is not required in the following cases:&lt;br /&gt;
* the token (&amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;) was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is not used in this scenario since the payer is present during the transaction. &lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent OneClick Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 17,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Book: How to shop online&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;How to shop online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Book about shopping online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;piece&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
In this scenario, the response contains the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; property that is used to perform an [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8-9&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: &amp;quot;ewoJIkNhcmRQdWJs...WZXJzaW9uIjogIjIuMS4wIgp9Cg==&amp;quot;,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Possible error responses for the subsequent payment requests ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| InvalidRecurrenceId|| The token specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is invalid. Check if the token registration was successful.&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentDenied|| Something happened to the user since the token registration, either deleted, suspended, or blocked. The payment s not allowed in these cases.&lt;br /&gt;
|-&lt;br /&gt;
| InsufficientFunds|| If the original payment was with an e-money wallet and the customer doesn&#039;t have enough money to fulfill this charge this error happens.&lt;br /&gt;
|-&lt;br /&gt;
| OriginalPaymentWasntSuccessful || This means that the token belongs to an originally unsuccessful payment so this token can not be used anymore. This could only happen if the original payment was financed with a credit card.&lt;br /&gt;
|-&lt;br /&gt;
|InvalidCurrency || If the original payment was paid with e-money and the current token payment is in a currency that the wallet does not have an account in this error happens.&lt;br /&gt;
|-&lt;br /&gt;
|CardExpired || The card that was used to fulfill the initial payment is no longer valid. The &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; has to be re-initialized.&lt;br /&gt;
|-&lt;br /&gt;
|TopUpFailed || The attempt to charge the card that was use to fulfill the initial payment was unsuccessful. Often accompanied by other more specific errors.&lt;br /&gt;
|-&lt;br /&gt;
|ThreeDsNotEnabled || The card issuer rejected the card due to lack of Strong Customer Authentication. Check whether the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is specified correctly (in case the scenario requires it).&lt;br /&gt;
|-&lt;br /&gt;
|InvalidUser || The payee defined in the transaction is not a valid Barion wallet. Either does not exist or not fully activated.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is the request-response diagram of the subsequent payments:&lt;br /&gt;
&lt;br /&gt;
[[File:Token_payment_2.png]]&lt;br /&gt;
&lt;br /&gt;
== RecurrenceResult: ThreeDSAuthenticationRequired ==&lt;br /&gt;
&lt;br /&gt;
In response to a subsequent payment, this RecurrenceResult can be received. This means that the payment can not be processed due to the lack of 3DS v2 information. &lt;br /&gt;
&lt;br /&gt;
This can happen if the initial payment was successfully authenticated via 3DS v2 but the subsequent payment does not refer to the original authentication with the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To fix this, request and store the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; of the initial payment and then specify it in the subsequent [[Payment-Start-v2]].&lt;br /&gt;
&lt;br /&gt;
To learn the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; of a previous payment just simply request the payment information via the [[Payment-GetPaymentState-v2]] endpoint.&lt;br /&gt;
&lt;br /&gt;
= Changing funding source or token scenarios =&lt;br /&gt;
&lt;br /&gt;
==Changing the funding source==&lt;br /&gt;
&lt;br /&gt;
This could happen if the funding source becomes invalid for some reason (card gets deleted or expires) or the merchant decides to use that token for another payer. In this case, the merchant has to register the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; again. &lt;br /&gt;
To do this a new payment must be started and in the [[Payment-Start-v2|Payment/Start]] request the following setup should be specified:&lt;br /&gt;
* the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; field has to be set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; &lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; has to be specified.&lt;br /&gt;
* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; should not be specified.&lt;br /&gt;
&lt;br /&gt;
[[File:Funding-source-change.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is bound to the payer and the process if the funding source changes new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be generated. This new ID must be saved to this payment and must be used from this moment on for subsequent payments.&lt;br /&gt;
&lt;br /&gt;
==Changing the token payment scenario with an existing token==&lt;br /&gt;
&lt;br /&gt;
This could occur when the merchant wants to get authorization from the payer to a new token scenario for the already registered funding source. To be able to do this the merchant has to have a valid and registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
Let&#039;s see some examples when this may be necessary:&lt;br /&gt;
* The payer subscribed to the merchant&#039;s service beforehand and the merchant decided to use the recurring payment token scenario. The payer wants to subscribe to another service and this requires a different payment schedule. This means that the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; that was specified initially can not be maintained so it is required to acquire a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;&lt;br /&gt;
* The payer bought something on the merchant&#039;s website and uses the one-click feature for subsequent fast non-redirect payments. After a while, the payer decides to subscribe to a service provided by this same merchant. This means that the merchant has to create a new token scenario (not a one-click payment but a recurring payment). For this, the merchant has to acquire a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. This can be done without redirecting the payer to Barion using the existing &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; and performing a 3DS authentication on the merchant&#039;s website.&lt;br /&gt;
&lt;br /&gt;
To do these a new payment must be started and in the [[Payment-Start-v2|Payment/Start]] request the following setup should be specified:&lt;br /&gt;
* the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; field has to be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; &lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; has to be specified.&lt;br /&gt;
* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; should not be specified.&lt;br /&gt;
&lt;br /&gt;
After this, a 3DS authentication has to be completed to acquire a new trace ID. This can be done on the merchant&#039;s site if the merchant implements the barion.offsitegw.js for off-site 3DS authentication.&lt;br /&gt;
&lt;br /&gt;
This means that it can be achieved to acquire different Trace IDs for different scenarios with only one &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
This is basically categorizing the different token scenarios as opposed to using every subsequent payment as an unmarked charge.&lt;br /&gt;
&lt;br /&gt;
[[File:Mutiple-traceid.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
= Off-site 3DS v2 authentication =&lt;br /&gt;
&lt;br /&gt;
In certain scenarios, the payer has to be authenticated to lower the risk of the card transaction. This can be either performed &lt;br /&gt;
* on the Barion Smart Gateway (on-site) by redirecting the customer to Barion &lt;br /&gt;
* or on the merchant&#039;s website (off-site) by integrating the Barion Off-site client library.&lt;br /&gt;
&lt;br /&gt;
This section describes how to integrate the Barion off-site authentication library into the merchant&#039;s site.&lt;br /&gt;
&lt;br /&gt;
== Step 1 : Initialize the off-site authentication library  ==&lt;br /&gt;
You have to include the following css and javascript files in the code of your site. &lt;br /&gt;
&amp;lt;source lang=html&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source &amp;gt;&lt;br /&gt;
These files include all the necessary javascript code and styling to handle the 3DS authentication and display the challenge if necessary.&lt;br /&gt;
&lt;br /&gt;
Then you have to initialize the Barion javascript client. To do that, you have to define a configuration object that specifies your functions that handle the off-site authentication events. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; Authentication events&#039;&#039;&#039;&lt;br /&gt;
* &amp;lt;code&amp;gt;onAuthenticationSucceeded&amp;lt;/code&amp;gt;: the 3DS v2 authentication successfully completed&lt;br /&gt;
* &amp;lt;code&amp;gt;onAuthenticationFailed&amp;lt;/code&amp;gt;:  the 3DS v2 authentication failed&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const configuration = {&lt;br /&gt;
    onAuthenticationSucceeded: function () {&lt;br /&gt;
        // handle successful authentication by calling the Barion API via merchant&#039;s backend&lt;br /&gt;
        // Call the v2/payment/complete endpoint&lt;br /&gt;
    },&lt;br /&gt;
    onAuthenticationFailed: function () {&lt;br /&gt;
        // Handle unsuccessful authentication result, no charge was made.&lt;br /&gt;
        // The payment might be still valid only the authentication failed&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to pass this config object to the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const gw = new Barion.OffsiteGw(configuration);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once the DOM is loaded you have to initialize the library:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
document.addEventListener(&amp;quot;DOMContentLoaded&amp;quot;, function () {&lt;br /&gt;
    // Initiate the Barion Offiste GW library&lt;br /&gt;
    gw.init();&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2: Start the authentication process ==&lt;br /&gt;
Once the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; is acquired from the payment/start you can start the authentication process by calling the &amp;lt;code&amp;gt;authenticate()&amp;lt;/code&amp;gt; method of the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
gw.authenticate(threeDsClientData);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will start the authentication process and present the challenge if needed. Visually this will create a modal window over the merchant&#039;s site and show the payer every necessary information.&lt;br /&gt;
Once the authentication process finished (either with or without a challenge) the appropriate event will be fired.&lt;br /&gt;
&lt;br /&gt;
== Step 3: Completing the payment ==&lt;br /&gt;
&lt;br /&gt;
In case of successful authentication, you have to call our [[Payment-Complete-v3|/Payment/Complete]] endpoint, where the actual charge will happen.&lt;br /&gt;
&lt;br /&gt;
=== Possible error responses for the subsequent payment requests ===&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
== Suggested implementation flow for off-site authentication ==&lt;br /&gt;
&lt;br /&gt;
Ideally, an off-site authentication should be part of a client-side experience without any postbacks or page reloads. This is our recommendation to achieve this:&lt;br /&gt;
&lt;br /&gt;
# After the customer clicks on the &amp;quot;Pay&amp;quot; button make an AJAX call from your client-side code to your back-end. &lt;br /&gt;
# Have your backend make a request to our payment/start endpoint (with the appropriate settings for the desired token scenario)&lt;br /&gt;
# Have your backend process the response and pass the value of the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; property to your client-side code.&lt;br /&gt;
# Use the Barion off-site library to perform the authentication&lt;br /&gt;
# Once the authentication succeeds send another AJAX request from your client-side code to your back-end.&lt;br /&gt;
# Have your back-end code call our [[Payment-Complete-v3|/Payment/Complete]]&lt;br /&gt;
# Have your backend process the response and pass the result to your client-side code.&lt;br /&gt;
# Display the result for the customer&lt;br /&gt;
&lt;br /&gt;
= Testing the integration =&lt;br /&gt;
&lt;br /&gt;
3D Secure has no environment for end-to-end testing, therefore merchants have to split their testings into two parts: Testing the payment flow with and without challenge. Getting a challenge is only possible with real-life cards, merchants have to use their own (there will be no real charging at the end on the Sandbox of the Payment Gateway, but using a real card will result initiating a real 3DS authentication).&lt;br /&gt;
&lt;br /&gt;
== Testing the whole payment flow, without challenge ==&lt;br /&gt;
&lt;br /&gt;
Use the [[https://docs.barion.com/Sandbox#Test_cards Barion test cards]], they will always get a &amp;quot;frictionless&amp;quot; flow, where the 3DS process is presented on the UI, but you will never see a challenge screen. &lt;br /&gt;
&lt;br /&gt;
This is good for testing your integration itself because it will lead to a successful charge, and you will get a TraceId as well.&lt;br /&gt;
&lt;br /&gt;
== Testing the challenge itself ==&lt;br /&gt;
&lt;br /&gt;
Use your own card, and let the card issuer decide whether your payment will get a challenge or not during the 3DS authentication procedure. Your payment will fail at the end, and you won&#039;t get the TraceId. &lt;br /&gt;
&lt;br /&gt;
This is good to test, how the challenge screens look like in your shop - especially when you integrated OneClick payment directly to your shop. You might also check how your customers see your checkout flow on popular devices.&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=3025</id>
		<title>Token payment 3D Secure</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=3025"/>
		<updated>2021-07-09T09:47:24Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* Possible error responses for the subsequent payment requests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Token Payment with 3D Secure}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This payment scenario allows the integrator shop to register a token for a customer (and a funding source) in the Barion system and then, later on, using this token, charge the customer without redirecting her to the Barion Smart Gateway UI. The user may be present at the site of the merchant or she can be off-session as well, so the merchant can charge her e.g. for subscriptions. This means that the customer authorizes the shop to charge her card or Barion balance without typing in the card information or Barion login again.&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurring.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=Premium feature|text=This scenario is not allowed automatically for every approved shop and should be requested from Barion!|color=#1993c7}}&lt;br /&gt;
&lt;br /&gt;
= Token payment scenarios =&lt;br /&gt;
Token payment can be used in three use cases: &lt;br /&gt;
* &#039;&#039;&#039;Customer Initiated Payments&#039;&#039;&#039;: when the user is present on the website of the merchant and she decides to pay :&lt;br /&gt;
** &#039;&#039;&#039;OneClick payment&#039;&#039;&#039;: the user is charged upon her request initiated on the website of the merchant. Subsequent payments are subject to PSD2 SCA and as the user is present, she has to go through the authentication process.&lt;br /&gt;
* &#039;&#039;&#039;Merchant Initiated Payments&#039;&#039;&#039;: when the merchant initiates the payment without the user being present. It has two subtypes:&lt;br /&gt;
** &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: the user is charged with the same amount on a regular basis, typically in case of subscriptions. Subsequent payments are exempted from PSD2 SCA, but liability still shifts to the card issuer.&lt;br /&gt;
** &#039;&#039;&#039;MIT (merchant initiated transaction)&#039;&#039;&#039;: the user is charged on an irregular basis and/or with a different amount. Subsequent payments of this type are excluded from PSD2 SCA, the liability is on the merchant.&lt;br /&gt;
&lt;br /&gt;
== Customer participation ==&lt;br /&gt;
&lt;br /&gt;
Since the token scenario is suitable for both customer and merchant initiated payments here is a comparison about who starts the payment. This includes the regular, non-tokenized payment scenario as well:&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot; | Scenario&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Initial payment&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW &lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW&lt;br /&gt;
|-&lt;br /&gt;
| Non token (regular) payment || YES || YES || YES || YES &lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || YES || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| MIT || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #aaa; background-color:#eee; font-size: 0.8em; padding:5px 10px; display:inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; Token payment scenarios can be initiated with already registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; as well, in this case the customer may remain on the merchant&#039;s site. &lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements for the scenarios ==&lt;br /&gt;
&lt;br /&gt;
These token payment scenarios have different requirements, this table below summarizes the key differences.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Payment amount&lt;br /&gt;
! Payment frequency&lt;br /&gt;
! Liability in case of fraud&lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || Various || Various || Card issuer&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || Subsequent amounts must be equal or less than the initial amount  || Initial payment must define a minimum amount of days to wait between charges || Card issuer &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || Various  || Various || Merchant&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 3DS authentication of the payer ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be performed for every online card payment. These token payment scenarios also have to use this new secure way of authentication. &lt;br /&gt;
The initial payment of a token scenario must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
Here is a table to compare the 3DS authentication requirements:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Initial payment&lt;br /&gt;
! Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
| One-click payment || ✔️ || ✔️&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;IMPORTANT:&#039;&#039; when performing subsequent One-click payments with the &amp;lt;code&amp;gt;ChallengePreference&amp;lt;/code&amp;gt; parameter set to &amp;lt;code&amp;gt;NoChallengeNeeded&amp;lt;/code&amp;gt; (indicating a request for Transaction Risk Analysis), only a fraud analysis will be performed, and the customer is not required to undergo a 3DS challenge.&lt;br /&gt;
&lt;br /&gt;
== Real life examples ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phone bill&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Payer has a usage-based phone subscription that wants to pay without being present for every charge. She authorizes the phone company to charge her card every month.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, the amount of the subsequent payments may exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TV subscription&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to online streaming of a television channel. She authorizes the tv company to charge her card every month. The subscription fee is the same for every month.&lt;br /&gt;
* Scenario: Recurring payment&lt;br /&gt;
* Explanation: The amount of the subsequent payments will not exceed the initial payment and the charge is regularly monthly-based.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bookclub with &amp;quot;free first month&amp;quot; bonus&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to a book renting service. he authorizes the book club to charge her card for a selection of books each month. The subscription fee is the same for every month however, the first month is free. To ensure the subscription the service requires her to register her card details.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, and the fee will stay the same, the initial payment is zero. So the amount of the next payment will exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Online food delivery service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The food delivery company wants to provide a quick and easy experience for its customer. They decide that the order will be quicker if the customers don&#039;t leave the website to pay for the goods.&lt;br /&gt;
* Scenario: OneClick payment&lt;br /&gt;
* Explanation: The customer will always be there so the other two scenarios are not available.&lt;br /&gt;
&lt;br /&gt;
== How to decide ==&lt;br /&gt;
&lt;br /&gt;
To help you decide on a suitable scenario, please use the decision graph below:&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurrencetype-decision.png|520px]]&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
To be able to integrate your webshop with the Barion Payment Gateway: &lt;br /&gt;
* You must [[Creating_an_account|register a Barion wallet]] at the Barion website or in the Sandbox environment. Learn more about the Sandbox environment [[Sandbox|here]].&lt;br /&gt;
* For this wallet you have to [[Creating_a_shop|create a shop]] which should be approved by Barion.&lt;br /&gt;
* For every currency you plan to conduct payments in you have to make sure there is an account created in your Barion wallet. This means that if you plan to have USD payments then there should be a USD account created in your wallet.&lt;br /&gt;
* To make sure every corner case scenario works for your webshop it is best to top up that account with a small amount (approx. 5-10EUR or your choice of currency around the same value).&lt;br /&gt;
* For the technical communication guide please read this: [[Calling_the_API|Calling the API]]&lt;br /&gt;
&lt;br /&gt;
= The payment process =&lt;br /&gt;
&lt;br /&gt;
The process is divided into two major steps:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 1:  Creating the funding source token|Creating the token]] that represents one of the customer&#039;s funding sources (credit card or e-money wallet)&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Preparing the payment via the Barion API&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Redirecting the customer to the Barion Smart Gateway to select a funding source&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Processing the callback and requesting information about the result of the payment&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 2: Using the token|Using the registered token]] to charge the customer&amp;lt;/li&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1:  Creating the funding source token ==&lt;br /&gt;
To be able to use a token payment scenario first the merchant has to register the token with Barion. The merchant has to make sure that the customer is well aware of the fact that they are giving consent to a tokenized payment. The Barion Smart Gateway UI does not indicate in any way that the payment is a token payment.&lt;br /&gt;
&lt;br /&gt;
The token is registered to the shop and not to the merchant&#039;s Barion account. So if the merchant has multiple shops in its Barion account, the registered tokens can not be shared among them even if the customer is the same. If you want to use tokens in multiple shops, please contact Barion in the Customer center.&lt;br /&gt;
&lt;br /&gt;
=== 1.1 Preparing the payment===&lt;br /&gt;
&lt;br /&gt;
The token registration is basically a [[Responsive_web_payment|normal payment]] with three extra properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* InitiateRecurrence&lt;br /&gt;
* RecurrenceId&lt;br /&gt;
* RecurrenceType&lt;br /&gt;
&lt;br /&gt;
==== InitiateRecurrence====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; is a bool property. If you set it to &#039;&#039;&#039;true&#039;&#039;&#039; then the payment gateway will consider the payment as a token registration. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This happens even if the customer is already has a registered token, so you are able to re-register a funding source or even a customer. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceId ====&lt;br /&gt;
The next required property for a token registration is the token itself. This is generated by the shop and has to be unique for every registration. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property of the [[Payment-Start-v2|Payment/Start]] request. This token must be saved in the webshops database. A &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; token represents the funding source (bank card or Barion balance) of a customer. Since a customer can have multiple cards and accounts as a funding source make sure that in the webshop&#039;s system multiple tokens can belong to a single customer.&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceType ====&lt;br /&gt;
The third required property is the [[RecurrenceType|Recurrence Type]]. This specifies the scenario. In case of Recurring Payment &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; must also be set.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Merchant Initiated Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The response will be the same as to a [[Responsive_web_payment#Processing_the_successful_response|basic &#039;&#039;&#039;Immediate&#039;&#039;&#039; scenario]]. The &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; property at this point is &#039;&#039;&#039;None&#039;&#039;&#039; since the token is not registered to a funding source yet.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Recurring Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Recurring Payment&#039;&#039;&#039; scenario has some extra restrictions. The merchant has to specify two additional properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt;: The date after subsequent charges should not be accepted.&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt;: The minimum days the merchant has to wait between payments.&lt;br /&gt;
&lt;br /&gt;
Both properties are located in the [[PurchaseInformation]] property and must be specified if this scenario is selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7, 30-33&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;PurchaseInformation&amp;quot;:{&lt;br /&gt;
        &amp;quot;RecurringFrequency&amp;quot;: 10,&lt;br /&gt;
        &amp;quot;RecurringExpiry&amp;quot;: &amp;quot;2022-10-01&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Possible error responses ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentNotAllowed || The token payment is not allowed for the shop identified by the &#039;&#039;&#039;POSKey&#039;&#039;&#039;. Contact Barion to request this feature.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 1.2 Redirecting the customer to the Barion Smart Gateway to select a funding source ===&lt;br /&gt;
&lt;br /&gt;
After a successful payment preparation, the customer is redirected to the secure Barion Smart Gateway to choose a funding source. The funding source the customer selects will be registered to the token. The funding source can either be a Barion e-money balance or a bank card. This means that even though the customer may own multiple cards only the one that was registered to the token can be used for future token payments. To change the funding source attached to the token a new registration should be requested.&lt;br /&gt;
&lt;br /&gt;
=== 1.3 Processing the callback and requesting information about the result of the payment ===&lt;br /&gt;
&lt;br /&gt;
When the payment is completed (either successfully or unsuccessfully) a callback message is sent to the merchant&#039;s system. Once received a [[Payment-GetPaymentState-v2|GetPaymentState]] request must be sent to the Barion API. On how to implement this please read the article about the  [[Callback_mechanism|Callback mechanism]].&lt;br /&gt;
&lt;br /&gt;
The full response of the GetPaymentState request depends on the payment scenario and the structure of the payment. When it comes to token payment there are several properties to look out for. &lt;br /&gt;
* In case the &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; is &#039;&#039;&#039;Succeeded&#039;&#039;&#039; the funding source token is registered and ready to use.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; contains the ID of the token process. This specifies the nature of the token payment. &lt;br /&gt;
&lt;br /&gt;
==== TraceId ====&lt;br /&gt;
&lt;br /&gt;
In case of Recurring payment or Merchant initiated payment scenarios the [[Payment-GetPaymentState-v2|GetPaymentState]] response returns an additional field called &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. The value of this property is generated by the card issuer and is up to a 100 characters, and should be left intact (whitespaces and 0s can&#039;t be trimmed). The merchant has to save it and submit it in all subsequent Recurring or Merchant initiated payments of the same type, otherwise, the payments can be declined by the issuer. The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; represents the first, customer-present payment and helps the issuer to connect subsequent payments to this initial payment.&lt;br /&gt;
&lt;br /&gt;
====Example GetPaymentState response====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;8, 11-12&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;OrderNumber&amp;quot;: null,&lt;br /&gt;
    &amp;quot;POSId&amp;quot;: &amp;quot;[[SHOPS_PUBLIC_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSName&amp;quot;: &amp;quot;[[MERCHANTS_BARION_SHOPNAME]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSOwnerEmail&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSource&amp;quot;: &amp;quot;BankCard&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;AllowedFundingSources&amp;quot;: [&lt;br /&gt;
        &amp;quot;All&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;GuestCheckout&amp;quot;: true,&lt;br /&gt;
    &amp;quot;CreatedAt&amp;quot;: &amp;quot;2020-11-26T07:52:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ValidUntil&amp;quot;: &amp;quot;2020-11-26T08:22:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;CompletedAt&amp;quot;: &amp;quot;2020-11-26T08:11:54.118Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ReservedUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;DelayedCaptureUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
           ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;Total&amp;quot;: 25.20,&lt;br /&gt;
    &amp;quot;SuggestedLocale&amp;quot;: &amp;quot;hu-HU&amp;quot;,&lt;br /&gt;
    &amp;quot;FraudRiskScore&amp;quot;: null,&lt;br /&gt;
    &amp;quot;RedirectUrl&amp;quot;: &amp;quot;https://merchanturl/Redirect?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;CallbackUrl&amp;quot;: &amp;quot;https://merchanturl/Callback?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Displaying the funding source in a GUI ====&lt;br /&gt;
We strongly advise saving the complete response for future reference. The &amp;lt;code&amp;gt;FundingSource&amp;lt;/code&amp;gt; field tells if the funding source is a Barion balance or a card. If it is a card, it is useful to save [[FundingInformation]] for displaying it for the user, when requesting future payments. The usual way to display funding sources is to show the last 4 digits of the card, with 4 stars, eg: *** 1234. The card used can be obtained from FundingInformation&#039;s [[BankCard]] field. The [[CardType]] field can be used to display the appropriate card logo. You can even show, if the card is expired, and offer to register another one.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; FundingInformation part of the GetPaymentState response &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=json&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be displayed for example as &amp;lt;code&amp;gt;VISA **** 0425 (12/20)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a request-response diagram of the token registration process:&lt;br /&gt;
 &lt;br /&gt;
[[File:Token_payment_initiation.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Step 2: Using the token =&lt;br /&gt;
&lt;br /&gt;
To use an already registered token for a payment, you have to use the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property. To be able to use a token, the initial payment must be in a successful state.&lt;br /&gt;
&lt;br /&gt;
At this point, the merchant has to decide whether this subsequent payment is used for the same token payment scenario or something changed. This is important because the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used for the same scenario, otherwise, the card issuer will decline the charge.&lt;br /&gt;
A &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used again if:&lt;br /&gt;
* the funding source is the same (technically the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* the token payment scenario is the same (technically the &amp;lt;code&amp;gt;RecurrenceType&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* this subsequent request complies with the scenario restrictions (eg: in case of recurring payment the amount of the subsequent payment does not exceed the initial amount)&lt;br /&gt;
&lt;br /&gt;
If the funding source changes, new &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the funding source|described in detail here]]. If the funding source stays the same but the scenario changes or the restrictions are no longer met new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the token payment scenario with an existing token|described here]].&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Recurring payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this case, three extra conditions must be met:&lt;br /&gt;
* the amount of the subsequent payment must not be higher than the initial amount&lt;br /&gt;
* at least that much days must be spent as defined in the initial &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; property&lt;br /&gt;
* the date of the payment must not exceed the day specified in the initial &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; property&lt;br /&gt;
&lt;br /&gt;
Please be aware that in case any of these are no longer valid the merchant has to request a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; as [[#Changing the token payment scenario with an existing token|described here]]. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=These conditions are not enforced by the Barion system so the violation of them will result in a declined charge.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
Payment/start must not include the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; properties (since they are already fixed during the initial payment).&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Recurring payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Merchant Initiated Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario there are no restrictions.&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Merchant Initiated Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 75,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Phone bill&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of OneClick Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario, the merchant has to prepare to perform the [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]] of the payer. 3DS authentication is not required in the following cases:&lt;br /&gt;
* the token (&amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;) was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is not used in this scenario since the payer is present during the transaction. &lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent OneClick Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 17,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Book: How to shop online&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;How to shop online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Book about shopping online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;piece&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
In this scenario, the response contains the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; property that is used to perform an [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8-9&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: &amp;quot;ewoJIkNhcmRQdWJs...WZXJzaW9uIjogIjIuMS4wIgp9Cg==&amp;quot;,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Possible error responses for the subsequent payment requests ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| InvalidRecurrenceId|| The token specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is invalid. Check if the token registration was successful.&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentDenied|| Something happened to the user since the token registration, either deleted, suspended, or blocked. The payment s not allowed in these cases.&lt;br /&gt;
|-&lt;br /&gt;
| InsufficientFunds|| If the original payment was with an e-money wallet and the customer doesn&#039;t have enough money to fulfill this charge this error happens.&lt;br /&gt;
|-&lt;br /&gt;
| OriginalPaymentWasntSuccessful || This means that the token belongs to an originally unsuccessful payment so this token can not be used anymore. This could only happen if the original payment was financed with a credit card.&lt;br /&gt;
|-&lt;br /&gt;
|InvalidCurrency || If the original payment was paid with e-money and the current token payment is in a currency that the wallet does not have an account in this error happens.&lt;br /&gt;
|-&lt;br /&gt;
|CardExpired || The card that was used to fulfill the initial payment is no longer valid. The &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; has to be re-initialized.&lt;br /&gt;
|-&lt;br /&gt;
|TopUpFailed || The attempt to charge the card that was use to fulfill the initial payment was unsuccessful. Often accompanied by other more specific errors.&lt;br /&gt;
|-&lt;br /&gt;
|ThreeDsNotEnabled || The card issuer rejected the card due to lack of Strong Customer Authentication. Check whether the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is specified correctly (in case the scenario requires it).&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is the request-response diagram of the subsequent payments:&lt;br /&gt;
&lt;br /&gt;
[[File:Token_payment_2.png]]&lt;br /&gt;
&lt;br /&gt;
== RecurrenceResult: ThreeDSAuthenticationRequired ==&lt;br /&gt;
&lt;br /&gt;
In response to a subsequent payment, this RecurrenceResult can be received. This means that the payment can not be processed due to the lack of 3DS v2 information. &lt;br /&gt;
&lt;br /&gt;
This can happen if the initial payment was successfully authenticated via 3DS v2 but the subsequent payment does not refer to the original authentication with the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To fix this, request and store the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; of the initial payment and then specify it in the subsequent [[Payment-Start-v2]].&lt;br /&gt;
&lt;br /&gt;
To learn the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; of a previous payment just simply request the payment information via the [[Payment-GetPaymentState-v2]] endpoint.&lt;br /&gt;
&lt;br /&gt;
= Changing funding source or token scenarios =&lt;br /&gt;
&lt;br /&gt;
==Changing the funding source==&lt;br /&gt;
&lt;br /&gt;
This could happen if the funding source becomes invalid for some reason (card gets deleted or expires) or the merchant decides to use that token for another payer. In this case, the merchant has to register the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; again. &lt;br /&gt;
To do this a new payment must be started and in the [[Payment-Start-v2|Payment/Start]] request the following setup should be specified:&lt;br /&gt;
* the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; field has to be set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; &lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; has to be specified.&lt;br /&gt;
* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; should not be specified.&lt;br /&gt;
&lt;br /&gt;
[[File:Funding-source-change.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is bound to the payer and the process if the funding source changes new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be generated. This new ID must be saved to this payment and must be used from this moment on for subsequent payments.&lt;br /&gt;
&lt;br /&gt;
==Changing the token payment scenario with an existing token==&lt;br /&gt;
&lt;br /&gt;
This could occur when the merchant wants to get authorization from the payer to a new token scenario for the already registered funding source. To be able to do this the merchant has to have a valid and registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
Let&#039;s see some examples when this may be necessary:&lt;br /&gt;
* The payer subscribed to the merchant&#039;s service beforehand and the merchant decided to use the recurring payment token scenario. The payer wants to subscribe to another service and this requires a different payment schedule. This means that the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; that was specified initially can not be maintained so it is required to acquire a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;&lt;br /&gt;
* The payer bought something on the merchant&#039;s website and uses the one-click feature for subsequent fast non-redirect payments. After a while, the payer decides to subscribe to a service provided by this same merchant. This means that the merchant has to create a new token scenario (not a one-click payment but a recurring payment). For this, the merchant has to acquire a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. This can be done without redirecting the payer to Barion using the existing &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; and performing a 3DS authentication on the merchant&#039;s website.&lt;br /&gt;
&lt;br /&gt;
To do these a new payment must be started and in the [[Payment-Start-v2|Payment/Start]] request the following setup should be specified:&lt;br /&gt;
* the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; field has to be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; &lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; has to be specified.&lt;br /&gt;
* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; should not be specified.&lt;br /&gt;
&lt;br /&gt;
After this, a 3DS authentication has to be completed to acquire a new trace ID. This can be done on the merchant&#039;s site if the merchant implements the barion.offsitegw.js for off-site 3DS authentication.&lt;br /&gt;
&lt;br /&gt;
This means that it can be achieved to acquire different Trace IDs for different scenarios with only one &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
This is basically categorizing the different token scenarios as opposed to using every subsequent payment as an unmarked charge.&lt;br /&gt;
&lt;br /&gt;
[[File:Mutiple-traceid.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
= Off-site 3DS v2 authentication =&lt;br /&gt;
&lt;br /&gt;
In certain scenarios, the payer has to be authenticated to lower the risk of the card transaction. This can be either performed &lt;br /&gt;
* on the Barion Smart Gateway (on-site) by redirecting the customer to Barion &lt;br /&gt;
* or on the merchant&#039;s website (off-site) by integrating the Barion Off-site client library.&lt;br /&gt;
&lt;br /&gt;
This section describes how to integrate the Barion off-site authentication library into the merchant&#039;s site.&lt;br /&gt;
&lt;br /&gt;
== Step 1 : Initialize the off-site authentication library  ==&lt;br /&gt;
You have to include the following css and javascript files in the code of your site. &lt;br /&gt;
&amp;lt;source lang=html&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source &amp;gt;&lt;br /&gt;
These files include all the necessary javascript code and styling to handle the 3DS authentication and display the challenge if necessary.&lt;br /&gt;
&lt;br /&gt;
Then you have to initialize the Barion javascript client. To do that, you have to define a configuration object that specifies your functions that handle the off-site authentication events. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; Authentication events&#039;&#039;&#039;&lt;br /&gt;
* &amp;lt;code&amp;gt;onAuthenticationSucceeded&amp;lt;/code&amp;gt;: the 3DS v2 authentication successfully completed&lt;br /&gt;
* &amp;lt;code&amp;gt;onAuthenticationFailed&amp;lt;/code&amp;gt;:  the 3DS v2 authentication failed&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const configuration = {&lt;br /&gt;
    onAuthenticationSucceeded: function () {&lt;br /&gt;
        // handle successful authentication by calling the Barion API via merchant&#039;s backend&lt;br /&gt;
        // Call the v2/payment/complete endpoint&lt;br /&gt;
    },&lt;br /&gt;
    onAuthenticationFailed: function () {&lt;br /&gt;
        // Handle unsuccessful authentication result, no charge was made.&lt;br /&gt;
        // The payment might be still valid only the authentication failed&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to pass this config object to the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const gw = new Barion.OffsiteGw(configuration);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once the DOM is loaded you have to initialize the library:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
document.addEventListener(&amp;quot;DOMContentLoaded&amp;quot;, function () {&lt;br /&gt;
    // Initiate the Barion Offiste GW library&lt;br /&gt;
    gw.init();&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2: Start the authentication process ==&lt;br /&gt;
Once the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; is acquired from the payment/start you can start the authentication process by calling the &amp;lt;code&amp;gt;authenticate()&amp;lt;/code&amp;gt; method of the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
gw.authenticate(threeDsClientData);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will start the authentication process and present the challenge if needed. Visually this will create a modal window over the merchant&#039;s site and show the payer every necessary information.&lt;br /&gt;
Once the authentication process finished (either with or without a challenge) the appropriate event will be fired.&lt;br /&gt;
&lt;br /&gt;
== Step 3: Completing the payment ==&lt;br /&gt;
&lt;br /&gt;
In case of successful authentication, you have to call our [[Payment-Complete-v3|/Payment/Complete]] endpoint, where the actual charge will happen.&lt;br /&gt;
&lt;br /&gt;
=== Possible error responses for the subsequent payment requests ===&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
== Suggested implementation flow for off-site authentication ==&lt;br /&gt;
&lt;br /&gt;
Ideally, an off-site authentication should be part of a client-side experience without any postbacks or page reloads. This is our recommendation to achieve this:&lt;br /&gt;
&lt;br /&gt;
# After the customer clicks on the &amp;quot;Pay&amp;quot; button make an AJAX call from your client-side code to your back-end. &lt;br /&gt;
# Have your backend make a request to our payment/start endpoint (with the appropriate settings for the desired token scenario)&lt;br /&gt;
# Have your backend process the response and pass the value of the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; property to your client-side code.&lt;br /&gt;
# Use the Barion off-site library to perform the authentication&lt;br /&gt;
# Once the authentication succeeds send another AJAX request from your client-side code to your back-end.&lt;br /&gt;
# Have your back-end code call our [[Payment-Complete-v3|/Payment/Complete]]&lt;br /&gt;
# Have your backend process the response and pass the result to your client-side code.&lt;br /&gt;
# Display the result for the customer&lt;br /&gt;
&lt;br /&gt;
= Testing the integration =&lt;br /&gt;
&lt;br /&gt;
3D Secure has no environment for end-to-end testing, therefore merchants have to split their testings into two parts: Testing the payment flow with and without challenge. Getting a challenge is only possible with real-life cards, merchants have to use their own (there will be no real charging at the end on the Sandbox of the Payment Gateway, but using a real card will result initiating a real 3DS authentication).&lt;br /&gt;
&lt;br /&gt;
== Testing the whole payment flow, without challenge ==&lt;br /&gt;
&lt;br /&gt;
Use the [[https://docs.barion.com/Sandbox#Test_cards Barion test cards]], they will always get a &amp;quot;frictionless&amp;quot; flow, where the 3DS process is presented on the UI, but you will never see a challenge screen. &lt;br /&gt;
&lt;br /&gt;
This is good for testing your integration itself because it will lead to a successful charge, and you will get a TraceId as well.&lt;br /&gt;
&lt;br /&gt;
== Testing the challenge itself ==&lt;br /&gt;
&lt;br /&gt;
Use your own card, and let the card issuer decide whether your payment will get a challenge or not during the 3DS authentication procedure. Your payment will fail at the end, and you won&#039;t get the TraceId. &lt;br /&gt;
&lt;br /&gt;
This is good to test, how the challenge screens look like in your shop - especially when you integrated OneClick payment directly to your shop. You might also check how your customers see your checkout flow on popular devices.&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=3024</id>
		<title>Token payment 3D Secure</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=3024"/>
		<updated>2021-07-09T05:25:14Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* Possible error responses for the subsequent payment requests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Token Payment with 3D Secure}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This payment scenario allows the integrator shop to register a token for a customer (and a funding source) in the Barion system and then, later on, using this token, charge the customer without redirecting her to the Barion Smart Gateway UI. The user may be present at the site of the merchant or she can be off-session as well, so the merchant can charge her e.g. for subscriptions. This means that the customer authorizes the shop to charge her card or Barion balance without typing in the card information or Barion login again.&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurring.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=Premium feature|text=This scenario is not allowed automatically for every approved shop and should be requested from Barion!|color=#1993c7}}&lt;br /&gt;
&lt;br /&gt;
= Token payment scenarios =&lt;br /&gt;
Token payment can be used in three use cases: &lt;br /&gt;
* &#039;&#039;&#039;Customer Initiated Payments&#039;&#039;&#039;: when the user is present on the website of the merchant and she decides to pay :&lt;br /&gt;
** &#039;&#039;&#039;OneClick payment&#039;&#039;&#039;: the user is charged upon her request initiated on the website of the merchant. Subsequent payments are subject to PSD2 SCA and as the user is present, she has to go through the authentication process.&lt;br /&gt;
* &#039;&#039;&#039;Merchant Initiated Payments&#039;&#039;&#039;: when the merchant initiates the payment without the user being present. It has two subtypes:&lt;br /&gt;
** &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: the user is charged with the same amount on a regular basis, typically in case of subscriptions. Subsequent payments are exempted from PSD2 SCA, but liability still shifts to the card issuer.&lt;br /&gt;
** &#039;&#039;&#039;MIT (merchant initiated transaction)&#039;&#039;&#039;: the user is charged on an irregular basis and/or with a different amount. Subsequent payments of this type are excluded from PSD2 SCA, the liability is on the merchant.&lt;br /&gt;
&lt;br /&gt;
== Customer participation ==&lt;br /&gt;
&lt;br /&gt;
Since the token scenario is suitable for both customer and merchant initiated payments here is a comparison about who starts the payment. This includes the regular, non-tokenized payment scenario as well:&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot; | Scenario&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Initial payment&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW &lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW&lt;br /&gt;
|-&lt;br /&gt;
| Non token (regular) payment || YES || YES || YES || YES &lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || YES || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| MIT || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #aaa; background-color:#eee; font-size: 0.8em; padding:5px 10px; display:inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; Token payment scenarios can be initiated with already registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; as well, in this case the customer may remain on the merchant&#039;s site. &lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements for the scenarios ==&lt;br /&gt;
&lt;br /&gt;
These token payment scenarios have different requirements, this table below summarizes the key differences.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Payment amount&lt;br /&gt;
! Payment frequency&lt;br /&gt;
! Liability in case of fraud&lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || Various || Various || Card issuer&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || Subsequent amounts must be equal or less than the initial amount  || Initial payment must define a minimum amount of days to wait between charges || Card issuer &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || Various  || Various || Merchant&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 3DS authentication of the payer ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be performed for every online card payment. These token payment scenarios also have to use this new secure way of authentication. &lt;br /&gt;
The initial payment of a token scenario must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
Here is a table to compare the 3DS authentication requirements:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Initial payment&lt;br /&gt;
! Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
| One-click payment || ✔️ || ✔️&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;IMPORTANT:&#039;&#039; when performing subsequent One-click payments with the &amp;lt;code&amp;gt;ChallengePreference&amp;lt;/code&amp;gt; parameter set to &amp;lt;code&amp;gt;NoChallengeNeeded&amp;lt;/code&amp;gt; (indicating a request for Transaction Risk Analysis), only a fraud analysis will be performed, and the customer is not required to undergo a 3DS challenge.&lt;br /&gt;
&lt;br /&gt;
== Real life examples ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phone bill&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Payer has a usage-based phone subscription that wants to pay without being present for every charge. She authorizes the phone company to charge her card every month.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, the amount of the subsequent payments may exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TV subscription&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to online streaming of a television channel. She authorizes the tv company to charge her card every month. The subscription fee is the same for every month.&lt;br /&gt;
* Scenario: Recurring payment&lt;br /&gt;
* Explanation: The amount of the subsequent payments will not exceed the initial payment and the charge is regularly monthly-based.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bookclub with &amp;quot;free first month&amp;quot; bonus&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to a book renting service. he authorizes the book club to charge her card for a selection of books each month. The subscription fee is the same for every month however, the first month is free. To ensure the subscription the service requires her to register her card details.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, and the fee will stay the same, the initial payment is zero. So the amount of the next payment will exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Online food delivery service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The food delivery company wants to provide a quick and easy experience for its customer. They decide that the order will be quicker if the customers don&#039;t leave the website to pay for the goods.&lt;br /&gt;
* Scenario: OneClick payment&lt;br /&gt;
* Explanation: The customer will always be there so the other two scenarios are not available.&lt;br /&gt;
&lt;br /&gt;
== How to decide ==&lt;br /&gt;
&lt;br /&gt;
To help you decide on a suitable scenario, please use the decision graph below:&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurrencetype-decision.png|520px]]&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
To be able to integrate your webshop with the Barion Payment Gateway: &lt;br /&gt;
* You must [[Creating_an_account|register a Barion wallet]] at the Barion website or in the Sandbox environment. Learn more about the Sandbox environment [[Sandbox|here]].&lt;br /&gt;
* For this wallet you have to [[Creating_a_shop|create a shop]] which should be approved by Barion.&lt;br /&gt;
* For every currency you plan to conduct payments in you have to make sure there is an account created in your Barion wallet. This means that if you plan to have USD payments then there should be a USD account created in your wallet.&lt;br /&gt;
* To make sure every corner case scenario works for your webshop it is best to top up that account with a small amount (approx. 5-10EUR or your choice of currency around the same value).&lt;br /&gt;
* For the technical communication guide please read this: [[Calling_the_API|Calling the API]]&lt;br /&gt;
&lt;br /&gt;
= The payment process =&lt;br /&gt;
&lt;br /&gt;
The process is divided into two major steps:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 1:  Creating the funding source token|Creating the token]] that represents one of the customer&#039;s funding sources (credit card or e-money wallet)&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Preparing the payment via the Barion API&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Redirecting the customer to the Barion Smart Gateway to select a funding source&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Processing the callback and requesting information about the result of the payment&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 2: Using the token|Using the registered token]] to charge the customer&amp;lt;/li&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1:  Creating the funding source token ==&lt;br /&gt;
To be able to use a token payment scenario first the merchant has to register the token with Barion. The merchant has to make sure that the customer is well aware of the fact that they are giving consent to a tokenized payment. The Barion Smart Gateway UI does not indicate in any way that the payment is a token payment.&lt;br /&gt;
&lt;br /&gt;
The token is registered to the shop and not to the merchant&#039;s Barion account. So if the merchant has multiple shops in its Barion account, the registered tokens can not be shared among them even if the customer is the same. If you want to use tokens in multiple shops, please contact Barion in the Customer center.&lt;br /&gt;
&lt;br /&gt;
=== 1.1 Preparing the payment===&lt;br /&gt;
&lt;br /&gt;
The token registration is basically a [[Responsive_web_payment|normal payment]] with three extra properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* InitiateRecurrence&lt;br /&gt;
* RecurrenceId&lt;br /&gt;
* RecurrenceType&lt;br /&gt;
&lt;br /&gt;
==== InitiateRecurrence====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; is a bool property. If you set it to &#039;&#039;&#039;true&#039;&#039;&#039; then the payment gateway will consider the payment as a token registration. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This happens even if the customer is already has a registered token, so you are able to re-register a funding source or even a customer. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceId ====&lt;br /&gt;
The next required property for a token registration is the token itself. This is generated by the shop and has to be unique for every registration. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property of the [[Payment-Start-v2|Payment/Start]] request. This token must be saved in the webshops database. A &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; token represents the funding source (bank card or Barion balance) of a customer. Since a customer can have multiple cards and accounts as a funding source make sure that in the webshop&#039;s system multiple tokens can belong to a single customer.&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceType ====&lt;br /&gt;
The third required property is the [[RecurrenceType|Recurrence Type]]. This specifies the scenario. In case of Recurring Payment &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; must also be set.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Merchant Initiated Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The response will be the same as to a [[Responsive_web_payment#Processing_the_successful_response|basic &#039;&#039;&#039;Immediate&#039;&#039;&#039; scenario]]. The &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; property at this point is &#039;&#039;&#039;None&#039;&#039;&#039; since the token is not registered to a funding source yet.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Recurring Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Recurring Payment&#039;&#039;&#039; scenario has some extra restrictions. The merchant has to specify two additional properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt;: The date after subsequent charges should not be accepted.&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt;: The minimum days the merchant has to wait between payments.&lt;br /&gt;
&lt;br /&gt;
Both properties are located in the [[PurchaseInformation]] property and must be specified if this scenario is selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7, 30-33&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;PurchaseInformation&amp;quot;:{&lt;br /&gt;
        &amp;quot;RecurringFrequency&amp;quot;: 10,&lt;br /&gt;
        &amp;quot;RecurringExpiry&amp;quot;: &amp;quot;2022-10-01&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Possible error responses ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentNotAllowed || The token payment is not allowed for the shop identified by the &#039;&#039;&#039;POSKey&#039;&#039;&#039;. Contact Barion to request this feature.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 1.2 Redirecting the customer to the Barion Smart Gateway to select a funding source ===&lt;br /&gt;
&lt;br /&gt;
After a successful payment preparation, the customer is redirected to the secure Barion Smart Gateway to choose a funding source. The funding source the customer selects will be registered to the token. The funding source can either be a Barion e-money balance or a bank card. This means that even though the customer may own multiple cards only the one that was registered to the token can be used for future token payments. To change the funding source attached to the token a new registration should be requested.&lt;br /&gt;
&lt;br /&gt;
=== 1.3 Processing the callback and requesting information about the result of the payment ===&lt;br /&gt;
&lt;br /&gt;
When the payment is completed (either successfully or unsuccessfully) a callback message is sent to the merchant&#039;s system. Once received a [[Payment-GetPaymentState-v2|GetPaymentState]] request must be sent to the Barion API. On how to implement this please read the article about the  [[Callback_mechanism|Callback mechanism]].&lt;br /&gt;
&lt;br /&gt;
The full response of the GetPaymentState request depends on the payment scenario and the structure of the payment. When it comes to token payment there are several properties to look out for. &lt;br /&gt;
* In case the &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; is &#039;&#039;&#039;Succeeded&#039;&#039;&#039; the funding source token is registered and ready to use.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; contains the ID of the token process. This specifies the nature of the token payment. &lt;br /&gt;
&lt;br /&gt;
==== TraceId ====&lt;br /&gt;
&lt;br /&gt;
In case of Recurring payment or Merchant initiated payment scenarios the [[Payment-GetPaymentState-v2|GetPaymentState]] response returns an additional field called &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. The value of this property is generated by the card issuer and is up to a 100 characters, and should be left intact (whitespaces and 0s can&#039;t be trimmed). The merchant has to save it and submit it in all subsequent Recurring or Merchant initiated payments of the same type, otherwise, the payments can be declined by the issuer. The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; represents the first, customer-present payment and helps the issuer to connect subsequent payments to this initial payment.&lt;br /&gt;
&lt;br /&gt;
====Example GetPaymentState response====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;8, 11-12&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;OrderNumber&amp;quot;: null,&lt;br /&gt;
    &amp;quot;POSId&amp;quot;: &amp;quot;[[SHOPS_PUBLIC_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSName&amp;quot;: &amp;quot;[[MERCHANTS_BARION_SHOPNAME]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSOwnerEmail&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSource&amp;quot;: &amp;quot;BankCard&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;AllowedFundingSources&amp;quot;: [&lt;br /&gt;
        &amp;quot;All&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;GuestCheckout&amp;quot;: true,&lt;br /&gt;
    &amp;quot;CreatedAt&amp;quot;: &amp;quot;2020-11-26T07:52:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ValidUntil&amp;quot;: &amp;quot;2020-11-26T08:22:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;CompletedAt&amp;quot;: &amp;quot;2020-11-26T08:11:54.118Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ReservedUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;DelayedCaptureUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
           ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;Total&amp;quot;: 25.20,&lt;br /&gt;
    &amp;quot;SuggestedLocale&amp;quot;: &amp;quot;hu-HU&amp;quot;,&lt;br /&gt;
    &amp;quot;FraudRiskScore&amp;quot;: null,&lt;br /&gt;
    &amp;quot;RedirectUrl&amp;quot;: &amp;quot;https://merchanturl/Redirect?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;CallbackUrl&amp;quot;: &amp;quot;https://merchanturl/Callback?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Displaying the funding source in a GUI ====&lt;br /&gt;
We strongly advise saving the complete response for future reference. The &amp;lt;code&amp;gt;FundingSource&amp;lt;/code&amp;gt; field tells if the funding source is a Barion balance or a card. If it is a card, it is useful to save [[FundingInformation]] for displaying it for the user, when requesting future payments. The usual way to display funding sources is to show the last 4 digits of the card, with 4 stars, eg: *** 1234. The card used can be obtained from FundingInformation&#039;s [[BankCard]] field. The [[CardType]] field can be used to display the appropriate card logo. You can even show, if the card is expired, and offer to register another one.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; FundingInformation part of the GetPaymentState response &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=json&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be displayed for example as &amp;lt;code&amp;gt;VISA **** 0425 (12/20)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a request-response diagram of the token registration process:&lt;br /&gt;
 &lt;br /&gt;
[[File:Token_payment_initiation.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Step 2: Using the token =&lt;br /&gt;
&lt;br /&gt;
To use an already registered token for a payment, you have to use the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property. To be able to use a token, the initial payment must be in a successful state.&lt;br /&gt;
&lt;br /&gt;
At this point, the merchant has to decide whether this subsequent payment is used for the same token payment scenario or something changed. This is important because the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used for the same scenario, otherwise, the card issuer will decline the charge.&lt;br /&gt;
A &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used again if:&lt;br /&gt;
* the funding source is the same (technically the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* the token payment scenario is the same (technically the &amp;lt;code&amp;gt;RecurrenceType&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* this subsequent request complies with the scenario restrictions (eg: in case of recurring payment the amount of the subsequent payment does not exceed the initial amount)&lt;br /&gt;
&lt;br /&gt;
If the funding source changes, new &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the funding source|described in detail here]]. If the funding source stays the same but the scenario changes or the restrictions are no longer met new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the token payment scenario with an existing token|described here]].&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Recurring payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this case, three extra conditions must be met:&lt;br /&gt;
* the amount of the subsequent payment must not be higher than the initial amount&lt;br /&gt;
* at least that much days must be spent as defined in the initial &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; property&lt;br /&gt;
* the date of the payment must not exceed the day specified in the initial &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; property&lt;br /&gt;
&lt;br /&gt;
Please be aware that in case any of these are no longer valid the merchant has to request a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; as [[#Changing the token payment scenario with an existing token|described here]]. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=These conditions are not enforced by the Barion system so the violation of them will result in a declined charge.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
Payment/start must not include the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; properties (since they are already fixed during the initial payment).&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Recurring payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Merchant Initiated Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario there are no restrictions.&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Merchant Initiated Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 75,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Phone bill&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of OneClick Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario, the merchant has to prepare to perform the [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]] of the payer. 3DS authentication is not required in the following cases:&lt;br /&gt;
* the token (&amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;) was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is not used in this scenario since the payer is present during the transaction. &lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent OneClick Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 17,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Book: How to shop online&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;How to shop online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Book about shopping online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;piece&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
In this scenario, the response contains the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; property that is used to perform an [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8-9&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: &amp;quot;ewoJIkNhcmRQdWJs...WZXJzaW9uIjogIjIuMS4wIgp9Cg==&amp;quot;,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Possible error responses for the subsequent payment requests ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| InvalidRecurrenceId|| The token specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is invalid. Check if the token registration was successful.&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentDenied|| Something happened to the user since the token registration, either deleted, suspended, or blocked. The payment s not allowed in these cases.&lt;br /&gt;
|-&lt;br /&gt;
| InsufficientFunds|| If the original payment was with an e-money wallet and the customer doesn&#039;t have enough money to fulfill this charge this error happens.&lt;br /&gt;
|-&lt;br /&gt;
| OriginalPaymentWasntSuccessful || This means that the token belongs to an originally unsuccessful payment so this token can not be used anymore. This could only happen if the original payment was financed with a credit card.&lt;br /&gt;
|-&lt;br /&gt;
|InvalidCurrency || If the original payment was paid with e-money and the current token payment is in a currency that the wallet does not have an account in this error happens.&lt;br /&gt;
|-&lt;br /&gt;
|CardExpired || The card that was used to fulfill the initial payment is no longer valid. The &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; has to be re-initialized.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is the request-response diagram of the subsequent payments:&lt;br /&gt;
&lt;br /&gt;
[[File:Token_payment_2.png]]&lt;br /&gt;
&lt;br /&gt;
== RecurrenceResult: ThreeDSAuthenticationRequired ==&lt;br /&gt;
&lt;br /&gt;
In response to a subsequent payment, this RecurrenceResult can be received. This means that the payment can not be processed due to the lack of 3DS v2 information. &lt;br /&gt;
&lt;br /&gt;
This can happen if the initial payment was successfully authenticated via 3DS v2 but the subsequent payment does not refer to the original authentication with the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To fix this, request and store the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; of the initial payment and then specify it in the subsequent [[Payment-Start-v2]].&lt;br /&gt;
&lt;br /&gt;
To learn the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; of a previous payment just simply request the payment information via the [[Payment-GetPaymentState-v2]] endpoint.&lt;br /&gt;
&lt;br /&gt;
= Changing funding source or token scenarios =&lt;br /&gt;
&lt;br /&gt;
==Changing the funding source==&lt;br /&gt;
&lt;br /&gt;
This could happen if the funding source becomes invalid for some reason (card gets deleted or expires) or the merchant decides to use that token for another payer. In this case, the merchant has to register the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; again. &lt;br /&gt;
To do this a new payment must be started and in the [[Payment-Start-v2|Payment/Start]] request the following setup should be specified:&lt;br /&gt;
* the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; field has to be set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; &lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; has to be specified.&lt;br /&gt;
* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; should not be specified.&lt;br /&gt;
&lt;br /&gt;
[[File:Funding-source-change.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is bound to the payer and the process if the funding source changes new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be generated. This new ID must be saved to this payment and must be used from this moment on for subsequent payments.&lt;br /&gt;
&lt;br /&gt;
==Changing the token payment scenario with an existing token==&lt;br /&gt;
&lt;br /&gt;
This could occur when the merchant wants to get authorization from the payer to a new token scenario for the already registered funding source. To be able to do this the merchant has to have a valid and registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
Let&#039;s see some examples when this may be necessary:&lt;br /&gt;
* The payer subscribed to the merchant&#039;s service beforehand and the merchant decided to use the recurring payment token scenario. The payer wants to subscribe to another service and this requires a different payment schedule. This means that the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; that was specified initially can not be maintained so it is required to acquire a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;&lt;br /&gt;
* The payer bought something on the merchant&#039;s website and uses the one-click feature for subsequent fast non-redirect payments. After a while, the payer decides to subscribe to a service provided by this same merchant. This means that the merchant has to create a new token scenario (not a one-click payment but a recurring payment). For this, the merchant has to acquire a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. This can be done without redirecting the payer to Barion using the existing &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; and performing a 3DS authentication on the merchant&#039;s website.&lt;br /&gt;
&lt;br /&gt;
To do these a new payment must be started and in the [[Payment-Start-v2|Payment/Start]] request the following setup should be specified:&lt;br /&gt;
* the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; field has to be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; &lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; has to be specified.&lt;br /&gt;
* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; should not be specified.&lt;br /&gt;
&lt;br /&gt;
After this, a 3DS authentication has to be completed to acquire a new trace ID. This can be done on the merchant&#039;s site if the merchant implements the barion.offsitegw.js for off-site 3DS authentication.&lt;br /&gt;
&lt;br /&gt;
This means that it can be achieved to acquire different Trace IDs for different scenarios with only one &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
This is basically categorizing the different token scenarios as opposed to using every subsequent payment as an unmarked charge.&lt;br /&gt;
&lt;br /&gt;
[[File:Mutiple-traceid.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
= Off-site 3DS v2 authentication =&lt;br /&gt;
&lt;br /&gt;
In certain scenarios, the payer has to be authenticated to lower the risk of the card transaction. This can be either performed &lt;br /&gt;
* on the Barion Smart Gateway (on-site) by redirecting the customer to Barion &lt;br /&gt;
* or on the merchant&#039;s website (off-site) by integrating the Barion Off-site client library.&lt;br /&gt;
&lt;br /&gt;
This section describes how to integrate the Barion off-site authentication library into the merchant&#039;s site.&lt;br /&gt;
&lt;br /&gt;
== Step 1 : Initialize the off-site authentication library  ==&lt;br /&gt;
You have to include the following css and javascript files in the code of your site. &lt;br /&gt;
&amp;lt;source lang=html&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source &amp;gt;&lt;br /&gt;
These files include all the necessary javascript code and styling to handle the 3DS authentication and display the challenge if necessary.&lt;br /&gt;
&lt;br /&gt;
Then you have to initialize the Barion javascript client. To do that, you have to define a configuration object that specifies your functions that handle the off-site authentication events. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; Authentication events&#039;&#039;&#039;&lt;br /&gt;
* &amp;lt;code&amp;gt;onAuthenticationSucceeded&amp;lt;/code&amp;gt;: the 3DS v2 authentication successfully completed&lt;br /&gt;
* &amp;lt;code&amp;gt;onAuthenticationFailed&amp;lt;/code&amp;gt;:  the 3DS v2 authentication failed&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const configuration = {&lt;br /&gt;
    onAuthenticationSucceeded: function () {&lt;br /&gt;
        // handle successful authentication by calling the Barion API via merchant&#039;s backend&lt;br /&gt;
        // Call the v2/payment/complete endpoint&lt;br /&gt;
    },&lt;br /&gt;
    onAuthenticationFailed: function () {&lt;br /&gt;
        // Handle unsuccessful authentication result, no charge was made.&lt;br /&gt;
        // The payment might be still valid only the authentication failed&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to pass this config object to the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const gw = new Barion.OffsiteGw(configuration);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once the DOM is loaded you have to initialize the library:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
document.addEventListener(&amp;quot;DOMContentLoaded&amp;quot;, function () {&lt;br /&gt;
    // Initiate the Barion Offiste GW library&lt;br /&gt;
    gw.init();&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2: Start the authentication process ==&lt;br /&gt;
Once the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; is acquired from the payment/start you can start the authentication process by calling the &amp;lt;code&amp;gt;authenticate()&amp;lt;/code&amp;gt; method of the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
gw.authenticate(threeDsClientData);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will start the authentication process and present the challenge if needed. Visually this will create a modal window over the merchant&#039;s site and show the payer every necessary information.&lt;br /&gt;
Once the authentication process finished (either with or without a challenge) the appropriate event will be fired.&lt;br /&gt;
&lt;br /&gt;
== Step 3: Completing the payment ==&lt;br /&gt;
&lt;br /&gt;
In case of successful authentication, you have to call our [[Payment-Complete-v3|/Payment/Complete]] endpoint, where the actual charge will happen.&lt;br /&gt;
&lt;br /&gt;
=== Possible error responses for the subsequent payment requests ===&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
== Suggested implementation flow for off-site authentication ==&lt;br /&gt;
&lt;br /&gt;
Ideally, an off-site authentication should be part of a client-side experience without any postbacks or page reloads. This is our recommendation to achieve this:&lt;br /&gt;
&lt;br /&gt;
# After the customer clicks on the &amp;quot;Pay&amp;quot; button make an AJAX call from your client-side code to your back-end. &lt;br /&gt;
# Have your backend make a request to our payment/start endpoint (with the appropriate settings for the desired token scenario)&lt;br /&gt;
# Have your backend process the response and pass the value of the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; property to your client-side code.&lt;br /&gt;
# Use the Barion off-site library to perform the authentication&lt;br /&gt;
# Once the authentication succeeds send another AJAX request from your client-side code to your back-end.&lt;br /&gt;
# Have your back-end code call our [[Payment-Complete-v3|/Payment/Complete]]&lt;br /&gt;
# Have your backend process the response and pass the result to your client-side code.&lt;br /&gt;
# Display the result for the customer&lt;br /&gt;
&lt;br /&gt;
= Testing the integration =&lt;br /&gt;
&lt;br /&gt;
3D Secure has no environment for end-to-end testing, therefore merchants have to split their testings into two parts: Testing the payment flow with and without challenge. Getting a challenge is only possible with real-life cards, merchants have to use their own (there will be no real charging at the end on the Sandbox of the Payment Gateway, but using a real card will result initiating a real 3DS authentication).&lt;br /&gt;
&lt;br /&gt;
== Testing the whole payment flow, without challenge ==&lt;br /&gt;
&lt;br /&gt;
Use the [[https://docs.barion.com/Sandbox#Test_cards Barion test cards]], they will always get a &amp;quot;frictionless&amp;quot; flow, where the 3DS process is presented on the UI, but you will never see a challenge screen. &lt;br /&gt;
&lt;br /&gt;
This is good for testing your integration itself because it will lead to a successful charge, and you will get a TraceId as well.&lt;br /&gt;
&lt;br /&gt;
== Testing the challenge itself ==&lt;br /&gt;
&lt;br /&gt;
Use your own card, and let the card issuer decide whether your payment will get a challenge or not during the 3DS authentication procedure. Your payment will fail at the end, and you won&#039;t get the TraceId. &lt;br /&gt;
&lt;br /&gt;
This is good to test, how the challenge screens look like in your shop - especially when you integrated OneClick payment directly to your shop. You might also check how your customers see your checkout flow on popular devices.&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Going_live&amp;diff=3017</id>
		<title>Going live</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Going_live&amp;diff=3017"/>
		<updated>2021-06-15T07:49:22Z</updated>

		<summary type="html">&lt;p&gt;Botza: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{NotificationBox|title=WARNING|text=TLS 1.0 will be switched off on the 20th of July 2018 on the live servers, switch to TLS 1.1 / 1.2 now!|color=#FF0000}}&lt;br /&gt;
{{PageTitle|title= Going live}}&lt;br /&gt;
&lt;br /&gt;
=Contracting=&lt;br /&gt;
To make real payments, you need a contract with Barion. Contracting is done by accepting the [https://www.barion.com/en/legal/ Terms &amp;amp; Conditions] in online registration. No paperwork or hassle. Each merchant needs a Barion account, or Wallet, as we call it. Payments are credited onto this account, immediately after payment. &lt;br /&gt;
&lt;br /&gt;
You can register on the live Barion server at https://secure.barion.com/Registration&lt;br /&gt;
&lt;br /&gt;
See alse:&lt;br /&gt;
*[[Creating_an_account|Creating an account]]&lt;br /&gt;
*[[Creating_a_shop|Creating a shop]]&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=NOTE|text=Always double-check which server you are using, it is easy to mix up live and sandbox accounts! |color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
==Approval &amp;amp; KYC==&lt;br /&gt;
Barion is a regulated business, many of our processes are bound by laws. We are mandated to check each shop and approve it manually. Only shops that are legal and comply with our [https://www.barion.com/en/legal/ Terms &amp;amp; Conditions] are allowed. Barion does not support gambling and adult content, even if it is legal. If you are in a risky business or not sure, consult our [https://www.barion.com/en/merchants/ experts] before starting development. &lt;br /&gt;
&lt;br /&gt;
Upon approval, you will be asked to provide additional information (such as company papers) about your shop. Providing inaccurate information may delay the approval of your shop. Upon reaching certain limits, or by the decision of our staff, you will be asked to go through a process called KYC (Know Your Customer), which is the identification process mandated by Anti Money Laundering (AML) laws.&lt;br /&gt;
&lt;br /&gt;
==Optional recurring==&lt;br /&gt;
Token or recurring payment must be further approved. Since token payment basically allows you to carry out payments at will, this option is only available for trustworthy companies. Contact our [https://www.barion.com/en/merchants/ experts] well in advance, if you plan to use this option.&lt;br /&gt;
&lt;br /&gt;
==Change URL and POSKey and it works==&lt;br /&gt;
To go live, the following changes must be made in the payment solution. We advise making these parameters, so you can easily switch between the sandbox and live servers.&lt;br /&gt;
*API endpoint URL must be changed to live (https://api.test.barion.com -&amp;gt; https://api.barion.com)&lt;br /&gt;
*Payment GUI redirect URL must be changed to live (https://secure.test.barion.com/pay -&amp;gt; https://secure.barion.com/pay)&lt;br /&gt;
*POSKey must be changed to the live and approved shop&#039;s POSKey (a common mistake to leave the sandbox here)&lt;br /&gt;
*Return URL must be changed, if you are using your own sandbox shop&lt;br /&gt;
*Callback URL must be changed, if you are using your own sandbox shop&lt;br /&gt;
*E-mail addresses of &amp;lt;tt&amp;gt;Payee&amp;lt;/tt&amp;gt;-s used in [[PaymentTransaction]] structure in [[Payment-Start-v2|/Payment/Start]] call, if different in sandbox&lt;br /&gt;
*Certificates, if checking server certificates&lt;br /&gt;
*If using token payment, sandbox Tokens will not work in the live system&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=NOTE|text=Always double-check this list before calling support, it is easy to mix up live and sandbox data! |color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
==Requirement for Smart Package==&lt;br /&gt;
Make sure you fulfill all requirements of your chosen price package. Please refer to [[Getting_started|Getting started]] for requirements.&lt;br /&gt;
&lt;br /&gt;
==Logo placement==&lt;br /&gt;
Logos are available in many formats and sizes (PNG, WMF, AI, PDF, CDR, SVG) and a PDF guide helps placement. Please follow the guide and do not make changes to the official logo.&lt;br /&gt;
&lt;br /&gt;
[[File:Barion-card-strip-intl_400px.png]]&lt;br /&gt;
&lt;br /&gt;
Please find the banner guide and logos here:  https://download.barion.com/barion/barion-smart-payment-banners.zip&lt;br /&gt;
&lt;br /&gt;
==T&amp;amp;C requirements==&lt;br /&gt;
You must include Barion payment in your own Terms &amp;amp; Conditions. Our staff will check it and will only approve shops with properly formulated legal texts.&lt;br /&gt;
&lt;br /&gt;
==Security==&lt;br /&gt;
Please refer to the [[Security Measures]] page for more information on IT security before going live.&lt;br /&gt;
{{NotificationBox|title=WARNING|text=TLS 1.0 will be switched off on the 20th of July 2018 on the live servers, switch to TLS 1.1 / 1.2 now!|color=#FF0000}}&lt;br /&gt;
&lt;br /&gt;
==Contact and support==&lt;br /&gt;
Please refer to [[Support|Getting support]] for more information.&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=File:Barion-card-payment-mark-2017-400px.png&amp;diff=3015</id>
		<title>File:Barion-card-payment-mark-2017-400px.png</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=File:Barion-card-payment-mark-2017-400px.png&amp;diff=3015"/>
		<updated>2021-06-15T07:47:00Z</updated>

		<summary type="html">&lt;p&gt;Botza: Botza uploaded a new version of File:Barion-card-payment-mark-2017-400px.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Going_live&amp;diff=3014</id>
		<title>Going live</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Going_live&amp;diff=3014"/>
		<updated>2021-06-15T07:45:07Z</updated>

		<summary type="html">&lt;p&gt;Botza: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{{NotificationBox|title=WARNING|text=TLS 1.0 will be switched off on the 20th of July 2018 on the live servers, switch to TLS 1.1 / 1.2 now!|color=#FF0000}}&lt;br /&gt;
{{PageTitle|title= Going live}}&lt;br /&gt;
&lt;br /&gt;
=Contracting=&lt;br /&gt;
To make real payments, you need a contract with Barion. Contracting is done by accepting the [https://www.barion.com/en/legal/ Terms &amp;amp; Conditions] in an online registration. No paperwork or hassle. Each merchant needs a Barion account, or Wallet, as we call it. Payments are credited onto this account, immediately after payment. &lt;br /&gt;
&lt;br /&gt;
You can register on the live Barion server at https://secure.barion.com/Registration&lt;br /&gt;
&lt;br /&gt;
See alse:&lt;br /&gt;
*[[Creating_an_account|Creating an account]]&lt;br /&gt;
*[[Creating_a_shop|Creating a shop]]&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=NOTE|text=Always double-check which server you are using, it is easy to mix up live and sandbox accounts! |color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
==Approval &amp;amp; KYC==&lt;br /&gt;
Barion is a regulated business, many of our processes are bound by laws. We are mandated to check each shop and approve it manually. Only shops that are legal and comply with our [https://www.barion.com/en/legal/ Terms &amp;amp; Conditions] are allowed. Barion does not support gambling and adult content, even if it is legal. If you are in a risky business or not sure, consult our [https://www.barion.com/en/merchants/ experts] before starting development. &lt;br /&gt;
&lt;br /&gt;
Upon approval, you will be asked to provide additional information (such as company papers) about your shop. Providing inaccurate information may delay the approval of your shop. Upon reaching certain limits, or by the decision of our staff, you will be asked to go through a process called KYC (Know Your Customer), which is the identification process mandated by Anti Money Laundering (AML) laws.&lt;br /&gt;
&lt;br /&gt;
==Optional recurring==&lt;br /&gt;
Token or recurring payment must be further approved. Since token payment basically allows you to carry out payments at will, this option is only available for trustworthy companies. Contact our [https://www.barion.com/en/merchants/ experts] well in advance, if you plan to use this option.&lt;br /&gt;
&lt;br /&gt;
==Change URL and POSKey and it works==&lt;br /&gt;
To go live, the following changes must be made in the payment solution. We advise to make these parameters, so you can easily switch between the sandbox and live servers.&lt;br /&gt;
*API endpoint URL must be changed to live (https://api.test.barion.com -&amp;gt; https://api.barion.com)&lt;br /&gt;
*Payment GUI redirect URL must be changes to live (https://secure.test.barion.com/pay -&amp;gt; https://secure.barion.com/pay)&lt;br /&gt;
*POSKey must be changed to the live and approved shop&#039;s POSKey (a common mistake to leave the sandbox here)&lt;br /&gt;
*Return URL must be changed, if you are using your own sandbox shop&lt;br /&gt;
*Callback URL must be changed, if you are using your own sandbox shop&lt;br /&gt;
*E-mail addresses of &amp;lt;tt&amp;gt;Payee&amp;lt;/tt&amp;gt;-s used in [[PaymentTransaction]] structure in [[Payment-Start-v2|/Payment/Start]] call, if different in sandbox&lt;br /&gt;
*Certificates, if checking server certificates&lt;br /&gt;
*If using token payment, sandbox Tokens will not work in the live system&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=NOTE|text=Always double-check this list before calling support, it is easy to mix up live and sandbox data! |color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
==Requirement for Smart Package==&lt;br /&gt;
Make sure you fulfill all requirements of your choosen price package. Please refer to [[Getting_started|Getting started]] for requirements.&lt;br /&gt;
&lt;br /&gt;
==Logo placement==&lt;br /&gt;
Logos are available in many formats and sizes (PNG, WMF, AI, PDF, CDR, SVG) and a PDF guide helps placement. Please follow the guide and do not make changes to the official logo.&lt;br /&gt;
&lt;br /&gt;
[[file:Barion-card-payment-mark-2017-400px.png]]&lt;br /&gt;
&lt;br /&gt;
Please find the banner guide and logos here:  https://download.barion.com/barion/barion-smart-payment-banners.zip&lt;br /&gt;
&lt;br /&gt;
==T&amp;amp;C requirements==&lt;br /&gt;
You must include Barion payment in your own Terms &amp;amp; Conditions. Our staff will check it and will only approve shops with properly formulated legal texts.&lt;br /&gt;
&lt;br /&gt;
==Security==&lt;br /&gt;
Please refer to the [[Security Measures]] page for more information on IT security before going live.&lt;br /&gt;
{{NotificationBox|title=WARNING|text=TLS 1.0 will be switched off on the 20th of July 2018 on the live servers, switch to TLS 1.1 / 1.2 now!|color=#FF0000}}&lt;br /&gt;
&lt;br /&gt;
==Contact and support==&lt;br /&gt;
Please refer to [[Support|Getting support]] for more information.&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Payment-Complete-v2&amp;diff=3008</id>
		<title>Payment-Complete-v2</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Payment-Complete-v2&amp;diff=3008"/>
		<updated>2021-04-19T14:12:09Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* Output properties */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Barion API: Complete a payment}}&lt;br /&gt;
&lt;br /&gt;
{{TableOfContents}}&lt;br /&gt;
&lt;br /&gt;
{{api_callmethod | method=POST |uri=/v2/Payment/Complete }}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;/payment/CompletePayment&amp;lt;/code&amp;gt; API endpoint is used to complete a formerly prepared and 3DS authenticated payment in the Barion system.&lt;br /&gt;
&lt;br /&gt;
Prerequisites before use:&lt;br /&gt;
* [[Creating_an_account|Creating an account in Barion]]&lt;br /&gt;
* [[Creating_a_shop|Creating a shop in Barion]]&lt;br /&gt;
* [[Calling_the_API|Calling the Barion API]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v2&amp;lt;/span&amp;gt; This API endpoint is available in &#039;&#039;&#039;API v2&#039;&#039;&#039; only.&lt;br /&gt;
&lt;br /&gt;
== Use cases ==&lt;br /&gt;
&lt;br /&gt;
This API endpoint is designed to be used in the following scenarios:&lt;br /&gt;
* [[Token_payment_3D_Secure|Token Payment]]&lt;br /&gt;
&lt;br /&gt;
== Input properties ==&lt;br /&gt;
&lt;br /&gt;
{{api_input_table_header}}&lt;br /&gt;
|-&lt;br /&gt;
| POSKey || Guid || * Required|| The secret API key of the shop, generated by Barion. This lets the shop to authenticate through the Barion API, but does not provide access to the account owning the shop itself.&lt;br /&gt;
|-&lt;br /&gt;
| PaymentId || Guid || * Required|| The identifier of the formerly initialized and authenticated payment, generated by the Barion system.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Output properties ==&lt;br /&gt;
&lt;br /&gt;
{{api_output_table_header}}&lt;br /&gt;
|-&lt;br /&gt;
| PaymentId || Guid || The identifier of the payment, generated by the Barion system.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| PaymentRequestId || string || The payment identifier supplied by the API caller in the request.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| PaymentStatus || [[PaymentStatus]]|| The status of the payment in the Barion system. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| IsSuccessful || bool || Indicates whether the charge was successful&lt;br /&gt;
|-&lt;br /&gt;
| TraceId || string || Identifies the nature of the token payment. &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=PurchaseInformation&amp;diff=2997</id>
		<title>PurchaseInformation</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=PurchaseInformation&amp;diff=2997"/>
		<updated>2021-03-03T16:44:00Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* Purchase information structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Purchase information structure =&lt;br /&gt;
&lt;br /&gt;
This structure represents information about the purchase related to a payment. The data provided here is used to analyze and avoid possible fraud attempts and assure frictionless 3D secure flow.&lt;br /&gt;
&lt;br /&gt;
== API usage == &lt;br /&gt;
&lt;br /&gt;
This structure is used by the following API endpoints:&lt;br /&gt;
* [[Payment-Start-v2-3DS]]&lt;br /&gt;
&lt;br /&gt;
== Property list ==&lt;br /&gt;
&lt;br /&gt;
{{api_input_table_header}}&lt;br /&gt;
|-&lt;br /&gt;
| DeliveryTimeframe|| [[DeliveryTimeframeType]] || &lt;br /&gt;
* Optional&lt;br /&gt;
|| The speed of the delivery method.&lt;br /&gt;
|-&lt;br /&gt;
| DeliveryEmailAddress || string || &lt;br /&gt;
* Optional&lt;br /&gt;
|| If the goods are sent electronically to the payer, here should be the e-mail address where the payer asked the goods to.&lt;br /&gt;
|-&lt;br /&gt;
| PreOrderDate || datetime|| &lt;br /&gt;
* Optional &lt;br /&gt;
* In UTC &lt;br /&gt;
* Expected format: &amp;quot;2019-06-27T07:15:51.327&amp;quot;&lt;br /&gt;
|| If the payer pre-ordered the goods, here should be the date when the goods will be available.&lt;br /&gt;
|-&lt;br /&gt;
| AvailabilityIndicator|| [[AvailabilityIndicator]] || &lt;br /&gt;
* Optional &lt;br /&gt;
|| When will the goods be available.&lt;br /&gt;
|-&lt;br /&gt;
| ReOrderIndicator || [[ReOrderIndicator]] || &lt;br /&gt;
* Optional &lt;br /&gt;
|| Is this purchase a re-order of a previous one.&lt;br /&gt;
|-&lt;br /&gt;
| ShippingAddressIndicator || [[ShippingAddressIndicator]] || &lt;br /&gt;
* Optional &lt;br /&gt;
|| What kind of shipping is used.&lt;br /&gt;
|-&lt;br /&gt;
| RecurringExpiry|| datetime || &lt;br /&gt;
* Required in case of initial [[RecurrenceType|Recurring]] payment, otherwise not&lt;br /&gt;
* In UTC &lt;br /&gt;
* Expected format: &amp;quot;2019-06-27T07:15:51.327&amp;quot;&lt;br /&gt;
|| What is the last date when the payment can be used as a recurring source.&lt;br /&gt;
|-&lt;br /&gt;
| RecurringFrequency|| int || &lt;br /&gt;
* Required in case of initial [[RecurrenceType|Recurring]] payment, otherwise not&lt;br /&gt;
* Must be between 0 and 9999 inclusive&lt;br /&gt;
|| What is the minimum number of days between subsequent payments.&lt;br /&gt;
|-&lt;br /&gt;
| PurchaseType || [[PurchaseType]] || &lt;br /&gt;
* Optional &lt;br /&gt;
|| The type of the purchase.&lt;br /&gt;
|-&lt;br /&gt;
| GiftCardPurchase || [[GiftCardPurchase]] || &lt;br /&gt;
* Optional &lt;br /&gt;
|| If the purchased items included gift cards, fill out the information about them.&lt;br /&gt;
|-&lt;br /&gt;
| PurchaseDate || datetime|| &lt;br /&gt;
* Optional &lt;br /&gt;
* In UTC &lt;br /&gt;
* Expected format: &amp;quot;2019-06-27T07:15:51.327&amp;quot;&lt;br /&gt;
|| The time of the purchase. &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=SuspiciousActivityIndicator&amp;diff=2994</id>
		<title>SuspiciousActivityIndicator</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=SuspiciousActivityIndicator&amp;diff=2994"/>
		<updated>2021-03-02T17:36:36Z</updated>

		<summary type="html">&lt;p&gt;Botza: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=SuspiciousActivityIndicator enumeration}}&lt;br /&gt;
&lt;br /&gt;
This enum indicates whether there was any suspicious activity regarding the payer&lt;br /&gt;
&lt;br /&gt;
= Included in =&lt;br /&gt;
&lt;br /&gt;
Suspicious activity indicator are used in the following structures:&lt;br /&gt;
* [[PayerAccountInformation]]&lt;br /&gt;
&lt;br /&gt;
= Enum list =&lt;br /&gt;
&lt;br /&gt;
{{api_enum_table_header}}&lt;br /&gt;
|-&lt;br /&gt;
| NoSuspiciousActivityObserved || 0 || There was nothing suspicious.&lt;br /&gt;
|-&lt;br /&gt;
| SuspiciousActivityObserved ||10|| There was suspicious activity.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_upgrade_to_3DS&amp;diff=2991</id>
		<title>Token payment upgrade to 3DS</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_upgrade_to_3DS&amp;diff=2991"/>
		<updated>2021-03-02T08:56:09Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* Background */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Upgrading token payment implementation to comply with 3DS}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=NOTE|text=This tutorial was created to help merchants that already have token payment integration with Barion. First, please read through the detailed description of the new [[Token_payment_3D_Secure|token payment with 3DS]]!|color=#1993c7}}&lt;br /&gt;
= Background =&lt;br /&gt;
[[Token_payment_3D_Secure|Token payment]] is a solution that enables the merchant to charge the payer without the presence of them. It is a powerful tool to conduct subscription-like or payer-not-present scenarios. This scenario requires the merchant to create a token that would act as an identifier for the payer&#039;s funding source. To attach that token to a valid funding source the merchant had to do several things:&lt;br /&gt;
# Create an alphanumeric token&lt;br /&gt;
# Conduct an initial payment in which this token gets registered in the Barion system &lt;br /&gt;
# Refer to this token in a subsequent payment attempt&lt;br /&gt;
&lt;br /&gt;
[[File:Recurring-pre3ds.png|1280px]]&lt;br /&gt;
&lt;br /&gt;
This meant that as far as this token referenced a valid (and still available) funding source the merchant could create payments without any limitations. Basically, this token symbolized the funding source. It was up to the merchant to decide what it is used for, neither Barion nor the card issuer was aware of the nature of the subsequent payments. &lt;br /&gt;
&lt;br /&gt;
This funding source can be either a card or an e-money wallet and this is up to the payer to choose. In case the payer chooses to fund the payment from their e-money wallet there is no further need for extra security. On the other hand, when it comes to card payment the authentication process changed with the new Strong Customer Authentication directive and the 3DS v2 protocol.&lt;br /&gt;
&lt;br /&gt;
= Changes =&lt;br /&gt;
To make sure that the payer has more control over these token scenarios and the card issuer knows more about the payment scenarios several things need to be changed. &lt;br /&gt;
&lt;br /&gt;
== Token payment scenarios ==&lt;br /&gt;
&lt;br /&gt;
First of all the merchant has to decide what kind of token payment scenario is suitable. These scenarios are the following:&lt;br /&gt;
* &#039;&#039;&#039;One-click payment&#039;&#039;&#039;: The payer clicks on the &amp;quot;Purchase&amp;quot; button but the charge happens in the background without the payer leaving the merchant&#039;s site.&lt;br /&gt;
* &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: The payer authorizes the merchant (at the initial payment) to charge their card periodically without being present with the same amount.&lt;br /&gt;
* &#039;&#039;&#039;Merchant initiated payment&#039;&#039;&#039;: The payer authorizes the merchant to charge their card without restrictions (eg. amounts can vary).&lt;br /&gt;
&lt;br /&gt;
To decide on a suitable scenario, please [[Token_payment_3D_Secure#Token_payment_scenarios|read this detailed description]]&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=CHANGE|text=The intended scenario must be specified in the new [[RecurrenceType|ReccurenceType]] property (located in the [[Payment-Start-v2|Payment/Start]] request)|color=#20c400}}&lt;br /&gt;
&lt;br /&gt;
== Usage of TraceId ==&lt;br /&gt;
&lt;br /&gt;
3DS authentication requires another identifier. This new identifier is used to differentiate these token payment scenarios and help the issuer control what is a non-fraudulent transaction.&lt;br /&gt;
&lt;br /&gt;
So from now on, there will be two IDs for every payer-not-present scenario:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; for the funding source: this identifies the source of the money (could be card or wallet)&lt;br /&gt;
* &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; (new) for the &#039;&#039;nature of the charge:&#039;&#039; this identifies the type of token payment scenario the merchant is conducting.&lt;br /&gt;
&lt;br /&gt;
This new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is generated and stored by the card issuer. The Id is available in the [[Payment-GetPaymentState-v2|GetPaymentState]] response once the charge is successfully completed.&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=CHANGE|text=The TraceId must processed from the [[Payment-GetPaymentState-v2|GetPaymentState]] response and must be attached to the payment in merchant&#039;s system. |color=#20c400}}&lt;br /&gt;
&lt;br /&gt;
Once the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is acquired it must be sent in the [[Payment-Start-v2|Payment/Start]] request to identify the scenario. This is crucial for the card transactions otherwise they could be declined. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=CHANGE|text=The TraceId must specified in the [[Payment-Start-v2|Payment/Start]] for the subsequent token charges. |color=#20c400}}&lt;br /&gt;
&lt;br /&gt;
== 3DS v2 authentication ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be conducted for every online card payment. These token payment scenarios also need to use these new secure way of authentication. &lt;br /&gt;
The initial payment must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Technical changes required =&lt;br /&gt;
The technical changes depend on what type of token scenario is needed for the business. It is important to notice that these scenarios can be implemented beside each other, a merchant is not required to choose only one type of token payment. The main goal is to appropriately use each scenario.&lt;br /&gt;
&lt;br /&gt;
== Technical changes for Recurring payments ==&lt;br /&gt;
&lt;br /&gt;
#&#039;&#039;&#039; For the token registration&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request the new properties have to be specified:&lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;RecurringPayment&amp;quot;&amp;lt;/code&amp;gt; to indicate the scenario&lt;br /&gt;
#* &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; for the limitations &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt; &lt;br /&gt;
#Once the callback is received get the response of [[Payment-GetPaymentState-v2|GetPaymentState]]. In case the charge was successful, there will be a &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; property for the payment. The value of it must be saved and attached to the payment.  &lt;br /&gt;
#&#039;&#039;&#039;For subsequent payments&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request specify the &lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;RecurringPayment&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
#* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; you received for the initial payment.&lt;br /&gt;
&lt;br /&gt;
== Technical changes for Merchant initiated payments ==&lt;br /&gt;
&lt;br /&gt;
#&#039;&#039;&#039; For the token registration&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request the new property has to be specified:&lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;MerchantInitiatedPayment&amp;quot;&amp;lt;/code&amp;gt; to indicate the scenario&lt;br /&gt;
#Once the callback is received get the response of [[Payment-GetPaymentState-v2|GetPaymentState]]. In case the charge was successful, there will be a &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; property for the payment. The value of it must be saved and attached to the payment.  &lt;br /&gt;
#&#039;&#039;&#039;For subsequent payments&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request specify the &lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;MerchantInitiatedPayment&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
#* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; you received for the initial payment.&lt;br /&gt;
&lt;br /&gt;
== Technical changes for One-click payments ==&lt;br /&gt;
&lt;br /&gt;
This modification needs the most attention since the merchant has to implement client-side functionality and add a new step at the end of the flow.&lt;br /&gt;
&lt;br /&gt;
#&#039;&#039;&#039; For the token registration&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request the new property has to be specified:&lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;OneClickPayment&amp;quot;&amp;lt;/code&amp;gt; to indicate the scenario&lt;br /&gt;
#&#039;&#039;&#039;For subsequent payments&#039;&#039;&#039; the merchant has to integrate the barion.offsitegw.js to be able to authenticate the payer via 3DS v2 on the merchant&#039;s site. To do this read the tutorial on [[Token_payment_3D_Secure#OneClick payment|how to integrate this]].&lt;br /&gt;
# After a successful authentication a new Barion API endpoint ([[Payment-Complete-v2|/Payment/Complete]]) must be called to finalize the process and charge the card&lt;br /&gt;
&lt;br /&gt;
Please notice that in case this scenario is used there is no need to use the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; since the 3DS authentication will be performed every time.&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=CHANGE|text=In case of one-click token scenario the merchant has to authenticate every card payment with 3DS v2|color=#20c400}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What happens if the merchant doesn&#039;t upgrade its implementation ==&lt;br /&gt;
&lt;br /&gt;
There will be a two-phase ramp-up period to make sure that integrations can be upgraded.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Until December 31, 2020&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In this period the integrations that are not up-to-date and are not capable to handle 3DS v2 transactions &#039;&#039;&#039;will work&#039;&#039;&#039;. &lt;br /&gt;
* New tokens can be initiated (without RecurrenceType and TraceId) and the 3DSv2 authentication will be performed by the Barion Smart Gateway.&lt;br /&gt;
* Subsequent payments can use existing tokens (RecurrenceId) without specifying the TraceId.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Between January 1 and January 31, 2021 &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In this period the integrations that are not up-to-date and are not capable to handle 3DS v2 transactions &#039;&#039;&#039;will work&#039;&#039;&#039;. However, to comply with the card scheme mandates Barion has to substitute the missing information.&lt;br /&gt;
* New tokens can be initiated (without RecurrenceType and TraceId) and the 3DSv2 authentication will be performed by the Barion Smart Gateway. The payment will be marked as an initial MIT transaction. The MerchantInitiatedPayment RecurrenceType will be used as a fallback.&lt;br /&gt;
* Subsequent payments can use existing tokens (RecurrenceId) without specifying the TraceId. They will be handled as the subsequent MIT payment of the initial transaction. The TraceId will be filled in by Barion.&lt;br /&gt;
* This period allows all merchants to finish upgrading their integrations, receive TraceIds during subsequent payments, and send it back with the next subsequent payment, so Barion doesn&#039;t have to substitute it with a static value anymore.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;From February 1, 2021&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Until this date, all integrations must be upgraded. &lt;br /&gt;
* New tokens can only be initiated with the appropriate 3DSv2 information (RecurrenceType set). Otherwise, the payment/start will result in a validation error.&lt;br /&gt;
* Subsequent payments can use existing tokens (RecurrenceId) without specifying the TraceId. They will be handled as the subsequent MIT payment of the initial transaction. The TraceId will be filled in by Barion. This can be used until the card schemes allow this kind of TraceId substitution.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=SUPPORT|text=In case you have difficulties with the upgrade please contact our developers at devsupport@barion.com |color=#1993c7}}&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2988</id>
		<title>Token payment 3D Secure</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2988"/>
		<updated>2021-02-19T17:55:53Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* Possible error responses for the subsequent payment requests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Token Payment with 3D Secure}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This payment scenario allows the integrator shop to register a token for a customer (and a funding source) in the Barion system and then, later on, using this token, charge the customer without redirecting her to the Barion Smart Gateway UI. The user may be present at the site of the merchant or she can be off-session as well, so the merchant can charge her e.g. for subscriptions. This means that the customer authorizes the shop to charge her card or Barion balance without typing in the card information or Barion login again.&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurring.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=Premium feature|text=This scenario is not allowed automatically for every approved shop and should be requested from Barion!|color=#1993c7}}&lt;br /&gt;
&lt;br /&gt;
= Token payment scenarios =&lt;br /&gt;
Token payment can be used in three use cases: &lt;br /&gt;
* &#039;&#039;&#039;Customer Initiated Payments&#039;&#039;&#039;: when the user is present on the website of the merchant and she decides to pay :&lt;br /&gt;
** &#039;&#039;&#039;OneClick payment&#039;&#039;&#039;: the user is charged upon her request initiated on the website of the merchant. Subsequent payments are subject to PSD2 SCA and as the user is present, she has to go through the authentication process.&lt;br /&gt;
* &#039;&#039;&#039;Merchant Initiated Payments&#039;&#039;&#039;: when the merchant initiates the payment without the user being present. It has two subtypes:&lt;br /&gt;
** &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: the user is charged with the same amount on a regular basis, typically in case of subscriptions. Subsequent payments are exempted from PSD2 SCA, but liability still shifts to the card issuer.&lt;br /&gt;
** &#039;&#039;&#039;MIT (merchant initiated transaction)&#039;&#039;&#039;: the user is charged on an irregular basis and/or with a different amount. Subsequent payments of this type are excluded from PSD2 SCA, the liability is on the merchant.&lt;br /&gt;
&lt;br /&gt;
== Customer participation ==&lt;br /&gt;
&lt;br /&gt;
Since the token scenario is suitable for both customer and merchant initiated payments here is a comparison about who starts the payment. This includes the regular, non-tokenized payment scenario as well:&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot; | Scenario&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Initial payment&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW &lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW&lt;br /&gt;
|-&lt;br /&gt;
| Non token (regular) payment || YES || YES || YES || YES &lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || YES || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| MIT || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #aaa; background-color:#eee; font-size: 0.8em; padding:5px 10px; display:inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; Token payment scenarios can be initiated with already registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; as well, in this case the customer may remain on the merchant&#039;s site. &lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements for the scenarios ==&lt;br /&gt;
&lt;br /&gt;
These token payment scenarios have different requirements, this table below summarizes the key differences.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Payment amount&lt;br /&gt;
! Payment frequency&lt;br /&gt;
! Liability in case of fraud&lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || Various || Various || Card issuer&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || Subsequent amounts must be equal or less than the initial amount  || Initial payment must define a minimum amount of days to wait between charges || Card issuer &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || Various  || Various || Merchant&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 3DS authentication of the payer ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be performed for every online card payment. These token payment scenarios also have to use this new secure way of authentication. &lt;br /&gt;
The initial payment of a token scenario must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
Here is a table to compare the 3DS authentication requirements:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Initial payment&lt;br /&gt;
! Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
| One-click payment || ✔️ || ✔️&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Real life examples ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phone bill&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Payer has a usage-based phone subscription that wants to pay without being present for every charge. She authorizes the phone company to charge her card every month.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, the amount of the subsequent payments may exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TV subscription&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to online streaming of a television channel. She authorizes the tv company to charge her card every month. The subscription fee is the same for every month.&lt;br /&gt;
* Scenario: Recurring payment&lt;br /&gt;
* Explanation: The amount of the subsequent payments will not exceed the initial payment and the charge is regularly monthly-based.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bookclub with &amp;quot;free first month&amp;quot; bonus&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to a book renting service. he authorizes the book club to charge her card for a selection of books each month. The subscription fee is the same for every month however, the first month is free. To ensure the subscription the service requires her to register her card details.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, and the fee will stay the same, the initial payment is zero. So the amount of the next payment will exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Online food delivery service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The food delivery company wants to provide a quick and easy experience for its customer. They decide that the order will be quicker if the customers don&#039;t leave the website to pay for the goods.&lt;br /&gt;
* Scenario: OneClick payment&lt;br /&gt;
* Explanation: The customer will always be there so the other two scenarios are not available.&lt;br /&gt;
&lt;br /&gt;
== How to decide ==&lt;br /&gt;
&lt;br /&gt;
To help you decide on a suitable scenario, please use the decision graph below:&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurrencetype-decision.png|520px]]&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
To be able to integrate your webshop with the Barion Payment Gateway: &lt;br /&gt;
* You must [[Creating_an_account|register a Barion wallet]] at the Barion website or in the Sandbox environment. Learn more about the Sandbox environment [[Sandbox|here]].&lt;br /&gt;
* For this wallet you have to [[Creating_a_shop|create a shop]] which should be approved by Barion.&lt;br /&gt;
* For every currency you plan to conduct payments in you have to make sure there is an account created in your Barion wallet. This means that if you plan to have USD payments then there should be a USD account created in your wallet.&lt;br /&gt;
* To make sure every corner case scenario works for your webshop it is best to top up that account with a small amount (approx. 5-10EUR or your choice of currency around the same value).&lt;br /&gt;
* For the technical communication guide please read this: [[Calling_the_API|Calling the API]]&lt;br /&gt;
&lt;br /&gt;
= The payment process =&lt;br /&gt;
&lt;br /&gt;
The process is divided into two major steps:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 1:  Creating the funding source token|Creating the token]] that represents one of the customer&#039;s funding sources (credit card or e-money wallet)&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Preparing the payment via the Barion API&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Redirecting the customer to the Barion Smart Gateway to select a funding source&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Processing the callback and requesting information about the result of the payment&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 2: Using the token|Using the registered token]] to charge the customer&amp;lt;/li&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1:  Creating the funding source token ==&lt;br /&gt;
To be able to use a token payment scenario first the merchant has to register the token with Barion. The merchant has to make sure that the customer is well aware of the fact that they are giving consent to a tokenized payment. The Barion Smart Gateway UI does not indicate in any way that the payment is a token payment.&lt;br /&gt;
&lt;br /&gt;
The token is registered to the shop and not to the merchant&#039;s Barion account. So if the merchant has multiple shops in its Barion account, the registered tokens can not be shared among them even if the customer is the same. If you want to use tokens in multiple shops, please contact Barion in the Customer center.&lt;br /&gt;
&lt;br /&gt;
=== 1.1 Preparing the payment===&lt;br /&gt;
&lt;br /&gt;
The token registration is basically a [[Responsive_web_payment|normal payment]] with three extra properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* InitiateRecurrence&lt;br /&gt;
* RecurrenceId&lt;br /&gt;
* RecurrenceType&lt;br /&gt;
&lt;br /&gt;
==== InitiateRecurrence====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; is a bool property. If you set it to &#039;&#039;&#039;true&#039;&#039;&#039; then the payment gateway will consider the payment as a token registration. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This happens even if the customer is already has a registered token, so you are able to re-register a funding source or even a customer. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceId ====&lt;br /&gt;
The next required property for a token registration is the token itself. This is generated by the shop and has to be unique for every registration. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property of the [[Payment-Start-v2|Payment/Start]] request. This token must be saved in the webshops database. A &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; token represents the funding source (bank card or Barion balance) of a customer. Since a customer can have multiple cards and accounts as a funding source make sure that in the webshop&#039;s system multiple tokens can belong to a single customer.&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceType ====&lt;br /&gt;
The third required property is the [[RecurrenceType|Recurrence Type]]. This specifies the scenario. In case of Recurring Payment &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; must also be set.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Merchant Initiated Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The response will be the same as to a [[Responsive_web_payment#Processing_the_successful_response|basic &#039;&#039;&#039;Immediate&#039;&#039;&#039; scenario]]. The &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; property at this point is &#039;&#039;&#039;None&#039;&#039;&#039; since the token is not registered to a funding source yet.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Recurring Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Recurring Payment&#039;&#039;&#039; scenario has some extra restrictions. The merchant has to specify two additional properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt;: The date after subsequent charges should not be accepted.&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt;: The minimum days the merchant has to wait between payments.&lt;br /&gt;
&lt;br /&gt;
Both properties are located in the [[PurchaseInformation]] property and must be specified if this scenario is selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7, 30-33&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;PurchaseInformation&amp;quot;:{&lt;br /&gt;
        &amp;quot;RecurringFrequency&amp;quot;: 10,&lt;br /&gt;
        &amp;quot;RecurringExpiry&amp;quot;: &amp;quot;2022-10-01&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Possible error responses ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentNotAllowed || The token payment is not allowed for the shop identified by the &#039;&#039;&#039;POSKey&#039;&#039;&#039;. Contact Barion to request this feature.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 1.2 Redirecting the customer to the Barion Smart Gateway to select a funding source ===&lt;br /&gt;
&lt;br /&gt;
After a successful payment preparation, the customer is redirected to the secure Barion Smart Gateway to choose a funding source. The funding source the customer selects will be registered to the token. The funding source can either be a Barion e-money balance or a bank card. This means that even though the customer may own multiple cards only the one that was registered to the token can be used for future token payments. To change the funding source attached to the token a new registration should be requested.&lt;br /&gt;
&lt;br /&gt;
=== 1.3 Processing the callback and requesting information about the result of the payment ===&lt;br /&gt;
&lt;br /&gt;
When the payment is completed (either successfully or unsuccessfully) a callback message is sent to the merchant&#039;s system. Once received a [[Payment-GetPaymentState-v2|GetPaymentState]] request must be sent to the Barion API. On how to implement this please read the article about the  [[Callback_mechanism|Callback mechanism]].&lt;br /&gt;
&lt;br /&gt;
The full response of the GetPaymentState request depends on the payment scenario and the structure of the payment. When it comes to token payment there are several properties to look out for. &lt;br /&gt;
* In case the &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; is &#039;&#039;&#039;Succeeded&#039;&#039;&#039; the funding source token is registered and ready to use.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; contains the ID of the token process. This specifies the nature of the token payment. &lt;br /&gt;
&lt;br /&gt;
==== TraceId ====&lt;br /&gt;
&lt;br /&gt;
In case of Recurring payment or Merchant initiated payment scenarios the [[Payment-GetPaymentState-v2|GetPaymentState]] response returns an additional field called &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. The value of this property is generated by the card issuer and is up to a 100 characters, and should be left intact (whitespaces and 0s can&#039;t be trimmed). The merchant has to save it and submit it in all subsequent Recurring or Merchant initiated payments of the same type, otherwise, the payments can be declined by the issuer. The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; represents the first, customer-present payment and helps the issuer to connect subsequent payments to this initial payment.&lt;br /&gt;
&lt;br /&gt;
====Example GetPaymentState response====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;8, 11-12&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;OrderNumber&amp;quot;: null,&lt;br /&gt;
    &amp;quot;POSId&amp;quot;: &amp;quot;[[SHOPS_PUBLIC_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSName&amp;quot;: &amp;quot;[[MERCHANTS_BARION_SHOPNAME]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSOwnerEmail&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSource&amp;quot;: &amp;quot;BankCard&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;AllowedFundingSources&amp;quot;: [&lt;br /&gt;
        &amp;quot;All&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;GuestCheckout&amp;quot;: true,&lt;br /&gt;
    &amp;quot;CreatedAt&amp;quot;: &amp;quot;2020-11-26T07:52:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ValidUntil&amp;quot;: &amp;quot;2020-11-26T08:22:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;CompletedAt&amp;quot;: &amp;quot;2020-11-26T08:11:54.118Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ReservedUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;DelayedCaptureUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
           ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;Total&amp;quot;: 25.20,&lt;br /&gt;
    &amp;quot;SuggestedLocale&amp;quot;: &amp;quot;hu-HU&amp;quot;,&lt;br /&gt;
    &amp;quot;FraudRiskScore&amp;quot;: null,&lt;br /&gt;
    &amp;quot;RedirectUrl&amp;quot;: &amp;quot;https://merchanturl/Redirect?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;CallbackUrl&amp;quot;: &amp;quot;https://merchanturl/Callback?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Displaying the funding source in a GUI ====&lt;br /&gt;
We strongly advise saving the complete response for future reference. The &amp;lt;code&amp;gt;FundingSource&amp;lt;/code&amp;gt; field tells if the funding source is a Barion balance or a card. If it is a card, it is useful to save [[FundingInformation]] for displaying it for the user, when requesting future payments. The usual way to display funding sources is to show the last 4 digits of the card, with 4 stars, eg: *** 1234. The card used can be obtained from FundingInformation&#039;s [[BankCard]] field. The [[CardType]] field can be used to display the appropriate card logo. You can even show, if the card is expired, and offer to register another one.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; FundingInformation part of the GetPaymentState response &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=json&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be displayed for example as &amp;lt;code&amp;gt;VISA **** 0425 (12/20)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a request-response diagram of the token registration process:&lt;br /&gt;
 &lt;br /&gt;
[[File:Token_payment_initiation.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Step 2: Using the token =&lt;br /&gt;
&lt;br /&gt;
To use an already registered token for a payment, you have to use the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property. To be able to use a token, the initial payment must be in a successful state.&lt;br /&gt;
&lt;br /&gt;
At this point, the merchant has to decide whether this subsequent payment is used for the same token payment scenario or something changed. This is important because the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used for the same scenario, otherwise, the card issuer will decline the charge.&lt;br /&gt;
A &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used again if:&lt;br /&gt;
* the funding source is the same (technically the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* the token payment scenario is the same (technically the &amp;lt;code&amp;gt;RecurrenceType&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* this subsequent request complies with the scenario restrictions (eg: in case of recurring payment the amount of the subsequent payment does not exceed the initial amount)&lt;br /&gt;
&lt;br /&gt;
If the funding source changes, new &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the funding source|described in detail here]]. If the funding source stays the same but the scenario changes or the restrictions are no longer met new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the token payment scenario with an existing token|described here]].&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Recurring payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this case, three extra conditions must be met:&lt;br /&gt;
* the amount of the subsequent payment must not be higher than the initial amount&lt;br /&gt;
* at least that much days must be spent as defined in the initial &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; property&lt;br /&gt;
* the date of the payment must not exceed the day specified in the initial &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; property&lt;br /&gt;
&lt;br /&gt;
Please be aware that in case any of these are no longer valid the merchant has to request a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; as [[#Changing the token payment scenario with an existing token|described here]]. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=These conditions are not enforced by the Barion system so the violation of them will result in a declined charge.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
Payment/start must not include the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; properties (since they are already fixed during the initial payment).&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Recurring payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Merchant Initiated Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario there are no restrictions.&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Merchant Initiated Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 75,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Phone bill&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of OneClick Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario, the merchant has to prepare to perform the [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]] of the payer. 3DS authentication is not required in the following cases:&lt;br /&gt;
* the token (&amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;) was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is not used in this scenario since the payer is present during the transaction. &lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent OneClick Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 17,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Book: How to shop online&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;How to shop online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Book about shopping online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;piece&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
In this scenario, the response contains the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; property that is used to perform an [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8-9&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: &amp;quot;ewoJIkNhcmRQdWJs...WZXJzaW9uIjogIjIuMS4wIgp9Cg==&amp;quot;,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Possible error responses for the subsequent payment requests ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| InvalidRecurrenceId|| The token specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is invalid. Check if the token registration was successful.&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentDenied|| Something happened to the user since the token registration, either deleted, suspended, or blocked. The payment s not allowed in these cases.&lt;br /&gt;
|-&lt;br /&gt;
| InsufficientFunds|| If the original payment was with an e-money wallet and the customer doesn&#039;t have enough money to fulfill this charge this error happens.&lt;br /&gt;
|-&lt;br /&gt;
| OriginalPaymentWasntSuccessful || This means that the token belongs to an originally unsuccessful payment so this token can not be used anymore. This could only happen if the original payment was financed with a credit card.&lt;br /&gt;
|-&lt;br /&gt;
|InvalidCurrency || If the original payment was paid with e-money and the current token payment is in a currency that the wallet does not have an account in this error happens.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is the request-response diagram of the subsequent payments:&lt;br /&gt;
&lt;br /&gt;
[[File:Token_payment_2.png]]&lt;br /&gt;
&lt;br /&gt;
== RecurrenceResult: ThreeDSAuthenticationRequired ==&lt;br /&gt;
&lt;br /&gt;
In response to a subsequent payment, this RecurrenceResult can be received. This means that the payment can not be processed due to the lack of 3DS v2 information. &lt;br /&gt;
&lt;br /&gt;
This can happen if the initial payment was successfully authenticated via 3DS v2 but the subsequent payment does not refer to the original authentication with the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To fix this, request and store the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; of the initial payment and then specify it in the subsequent [[Payment-Start-v2]].&lt;br /&gt;
&lt;br /&gt;
To learn the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; of a previous payment just simply request the payment information via the [[Payment-GetPaymentState-v2]] endpoint.&lt;br /&gt;
&lt;br /&gt;
= Changing funding source or token scenarios =&lt;br /&gt;
&lt;br /&gt;
==Changing the funding source==&lt;br /&gt;
&lt;br /&gt;
This could happen if the funding source becomes invalid for some reason (card gets deleted or expires) or the merchant decides to use that token for another payer. In this case, the merchant has to register the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; again. &lt;br /&gt;
To do this a new payment must be started and in the [[Payment-Start-v2|Payment/Start]] request the following setup should be specified:&lt;br /&gt;
* the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; field has to be set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; &lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; has to be specified.&lt;br /&gt;
* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; should not be specified.&lt;br /&gt;
&lt;br /&gt;
[[File:Funding-source-change.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is bound to the payer and the process if the funding source changes new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be generated. This new ID must be saved to this payment and must be used from this moment on for subsequent payments.&lt;br /&gt;
&lt;br /&gt;
==Changing the token payment scenario with an existing token==&lt;br /&gt;
&lt;br /&gt;
This could occur when the merchant wants to get authorization from the payer to a new token scenario for the already registered funding source. To be able to do this the merchant has to have a valid and registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
Let&#039;s see some examples when this may be necessary:&lt;br /&gt;
* The payer subscribed to the merchant&#039;s service beforehand and the merchant decided to use the recurring payment token scenario. The payer wants to subscribe to another service and this requires a different payment schedule. This means that the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; that was specified initially can not be maintained so it is required to acquire a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;&lt;br /&gt;
* The payer bought something on the merchant&#039;s website and uses the one-click feature for subsequent fast non-redirect payments. After a while, the payer decides to subscribe to a service provided by this same merchant. This means that the merchant has to create a new token scenario (not a one-click payment but a recurring payment). For this, the merchant has to acquire a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. This can be done without redirecting the payer to Barion using the existing &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; and performing a 3DS authentication on the merchant&#039;s website.&lt;br /&gt;
&lt;br /&gt;
To do these a new payment must be started and in the [[Payment-Start-v2|Payment/Start]] request the following setup should be specified:&lt;br /&gt;
* the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; field has to be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; &lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; has to be specified.&lt;br /&gt;
* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; should not be specified.&lt;br /&gt;
&lt;br /&gt;
After this, a 3DS authentication has to be completed to acquire a new trace ID. This can be done on the merchant&#039;s site if the merchant implements the barion.offsitegw.js for off-site 3DS authentication.&lt;br /&gt;
&lt;br /&gt;
This means that it can be achieved to acquire different Trace IDs for different scenarios with only one &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
This is basically categorizing the different token scenarios as opposed to using every subsequent payment as an unmarked charge.&lt;br /&gt;
&lt;br /&gt;
[[File:Mutiple-traceid.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
= Off-site 3DS v2 authentication =&lt;br /&gt;
&lt;br /&gt;
In certain scenarios, the payer has to be authenticated to lower the risk of the card transaction. This can be either performed &lt;br /&gt;
* on the Barion Smart Gateway (on-site) by redirecting the customer to Barion &lt;br /&gt;
* or on the merchant&#039;s website (off-site) by integrating the Barion Off-site client library.&lt;br /&gt;
&lt;br /&gt;
This section describes how to integrate the Barion off-site authentication library into the merchant&#039;s site.&lt;br /&gt;
&lt;br /&gt;
== Step 1 : Initialize the off-site authentication library  ==&lt;br /&gt;
You have to include the following css and javascript files in the code of your site. &lt;br /&gt;
&amp;lt;source lang=html&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source &amp;gt;&lt;br /&gt;
These files include all the necessary javascript code and styling to handle the 3DS authentication and display the challenge if necessary.&lt;br /&gt;
&lt;br /&gt;
Then you have to initialize the Barion javascript client. To do that, you have to define a configuration object that specifies your functions that handle the off-site authentication events. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; Authentication events&#039;&#039;&#039;&lt;br /&gt;
* &amp;lt;code&amp;gt;onAuthenticationSucceeded&amp;lt;/code&amp;gt;: the 3DS v2 authentication successfully completed&lt;br /&gt;
* &amp;lt;code&amp;gt;onAuthenticationFailed&amp;lt;/code&amp;gt;:  the 3DS v2 authentication failed&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const configuration = {&lt;br /&gt;
    onAuthenticationSucceeded: function () {&lt;br /&gt;
        // handle successful authentication by calling the Barion API via merchant&#039;s backend&lt;br /&gt;
        // Call the v2/payment/complete endpoint&lt;br /&gt;
    },&lt;br /&gt;
    onAuthenticationFailed: function () {&lt;br /&gt;
        // Handle unsuccessful authentication result, no charge was made.&lt;br /&gt;
        // The payment might be still valid only the authentication failed&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to pass this config object to the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const gw = new Barion.OffsiteGw(configuration);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once the DOM is loaded you have to initialize the library:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
document.addEventListener(&amp;quot;DOMContentLoaded&amp;quot;, function () {&lt;br /&gt;
    // Initiate the Barion Offiste GW library&lt;br /&gt;
    gw.init();&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2: Start the authentication process ==&lt;br /&gt;
Once the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; is acquired from the payment/start you can start the authentication process by calling the &amp;lt;code&amp;gt;authenticate()&amp;lt;/code&amp;gt; method of the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
gw.authenticate(threeDsClientData);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will start the authentication process and present the challenge if needed. Visually this will create a modal window over the merchant&#039;s site and show the payer every necessary information.&lt;br /&gt;
Once the authentication process finished (either with or without a challenge) the appropriate event will be fired.&lt;br /&gt;
&lt;br /&gt;
== Step 3: Completing the payment ==&lt;br /&gt;
&lt;br /&gt;
In case of successful authentication, you have to call our [[Payment-Complete-v3|/Payment/Complete]] endpoint, where the actual charge will happen.&lt;br /&gt;
&lt;br /&gt;
=== Possible error responses for the subsequent payment requests ===&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
== Suggested implementation flow for off-site authentication ==&lt;br /&gt;
&lt;br /&gt;
Ideally, an off-site authentication should be part of a client-side experience without any postbacks or page reloads. This is our recommendation to achieve this:&lt;br /&gt;
&lt;br /&gt;
# After the customer clicks on the &amp;quot;Pay&amp;quot; button make an AJAX call from your client-side code to your back-end. &lt;br /&gt;
# Have your backend make a request to our payment/start endpoint (with the appropriate settings for the desired token scenario)&lt;br /&gt;
# Have your backend process the response and pass the value of the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; property to your client-side code.&lt;br /&gt;
# Use the Barion off-site library to perform the authentication&lt;br /&gt;
# Once the authentication succeeds send another AJAX request from your client-side code to your back-end.&lt;br /&gt;
# Have your back-end code call our [[Payment-Complete-v3|/Payment/Complete]]&lt;br /&gt;
# Have your backend process the response and pass the result to your client-side code.&lt;br /&gt;
# Display the result for the customer&lt;br /&gt;
&lt;br /&gt;
= Testing the integration =&lt;br /&gt;
&lt;br /&gt;
3D Secure has no environment for end-to-end testing, therefore merchants have to split their testings into two parts: Testing the payment flow with and without challenge. Getting a challenge is only possible with real-life cards, merchants have to use their own (there will be no real charging at the end on the Sandbox of the Payment Gateway, but using a real card will result initiating a real 3DS authentication).&lt;br /&gt;
&lt;br /&gt;
== Testing the whole payment flow, without challenge ==&lt;br /&gt;
&lt;br /&gt;
Use the [[https://docs.barion.com/Sandbox#Test_cards Barion test cards]], they will always get a &amp;quot;frictionless&amp;quot; flow, where the 3DS process is presented on the UI, but you will never see a challenge screen. &lt;br /&gt;
&lt;br /&gt;
This is good for testing your integration itself because it will lead to a successful charge, and you will get a TraceId as well.&lt;br /&gt;
&lt;br /&gt;
== Testing the challenge itself ==&lt;br /&gt;
&lt;br /&gt;
Use your own card, and let the card issuer decide whether your payment will get a challenge or not during the 3DS authentication procedure. Your payment will fail at the end, and you won&#039;t get the TraceId. &lt;br /&gt;
&lt;br /&gt;
This is good to test, how the challenge screens look like in your shop - especially when you integrated OneClick payment directly to your shop. You might also check how your customers see your checkout flow on popular devices.&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Payment-Start-v2&amp;diff=2987</id>
		<title>Payment-Start-v2</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Payment-Start-v2&amp;diff=2987"/>
		<updated>2021-02-19T17:36:26Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* Output properties */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Barion API: Initialize a new payment}}&lt;br /&gt;
&lt;br /&gt;
{{TableOfContents}}&lt;br /&gt;
&lt;br /&gt;
{{api_callmethod&lt;br /&gt;
|method=POST&lt;br /&gt;
|uri=/v2/Payment/Start&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;/payment/start&amp;lt;/code&amp;gt; API endpoint is used to create a new payment in the Barion system.&lt;br /&gt;
&lt;br /&gt;
Prerequisites before use:&lt;br /&gt;
* [[Creating_an_account|Creating an account in Barion]]&lt;br /&gt;
* [[Creating_a_shop|Creating a shop in Barion]]&lt;br /&gt;
* [[Calling_the_API|Calling the Barion API]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v2&amp;lt;/span&amp;gt; This API endpoint is available in &#039;&#039;&#039;API v2&#039;&#039;&#039; only.&lt;br /&gt;
&lt;br /&gt;
== Use cases ==&lt;br /&gt;
&lt;br /&gt;
This API endpoint is designed to be used in the following scenarios:&lt;br /&gt;
* [[Responsive_web_payment|Responsive Web Payment]]&lt;br /&gt;
&lt;br /&gt;
== Input properties ==&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|{{3dsfield}} || Properties marked with this must be provided to comply with 3D Secure authentication. The more attributes you provide the more chance you have to avoid the challenge flow.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&#039;&#039;&#039;Important:&#039;&#039;&#039; if the merchant does not provide 3DS-related properties, it doesn&#039;t mean that the payment will fail. It means that the payer will have a higher chance of getting a challenge during payment.&lt;br /&gt;
&lt;br /&gt;
{{api_input_table_header}}&lt;br /&gt;
|-&lt;br /&gt;
| POSKey || Guid || &lt;br /&gt;
* Required&lt;br /&gt;
|| The secret API key of the shop, generated by Barion. This lets the shop to authenticate through the Barion API, but does not provide access to the account owning the shop itself.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| PaymentType || string || &lt;br /&gt;
* Required&lt;br /&gt;
* Accepted values: &lt;br /&gt;
** &amp;quot;Immediate&amp;quot;&lt;br /&gt;
** &amp;quot;Reservation&amp;quot;&lt;br /&gt;
** &amp;quot;DelayedCapture&amp;quot; &lt;br /&gt;
|| The type of payment, which can be either immediate or a money reservation. Reservation means that the shop has a time window to finish the payment (even though the money transaction still takes place immediately). Reservation amounts can be modified during this time window unless the new amount is lower than the original. &lt;br /&gt;
Click here to learn more about reservation payments: [[Reservation_payment|Reservation payments]], and delayed capture: [[Delayed_Capture|Delayed capture]].&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| ReservationPeriod || TimeSpan (d.hh:mm:ss) || &lt;br /&gt;
* Required only if PaymentType is &amp;quot;Reservation&amp;quot;&lt;br /&gt;
* Minimum value: one minute&lt;br /&gt;
* Maximum value: one year&lt;br /&gt;
* Default value: 30 minutes&lt;br /&gt;
|| Only makes sense at reservation payments. This is the time window that allows the shop to finish (finalize) the payment. If this does not happen within the time window, the system refunds the payment amount to the payer.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| DelayedCapturePeriod || TimeSpan (d.hh:mm:ss) || &lt;br /&gt;
* Required only if PaymentType is &amp;quot;DelayedCapture&amp;quot;&lt;br /&gt;
* Minimum value: one minute&lt;br /&gt;
* Maximum value: seven days&lt;br /&gt;
* Default value: seven days&lt;br /&gt;
|| This is the time window that allows the shop to complete (finalize) the payment. If this does not happen within the time window, the system releases the payment amount.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| PaymentWindow || TimeSpan (d.hh:mm:ss) || &lt;br /&gt;
* Optional&lt;br /&gt;
* Minimum value: one minute&lt;br /&gt;
* Maximum value: one week&lt;br /&gt;
* Default value: 30 minutes&lt;br /&gt;
|| Time window for the payment to be completed. The payer must execute the payment before this elapses, or else the payment will expire and can no longer be completed.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| GuestCheckOut || bool || &lt;br /&gt;
* Required&lt;br /&gt;
* Value must be &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot;, integer evaluation is not supported&lt;br /&gt;
|| Flag indicating whether the payment can be completed without a registered Barion wallet. Guest checkout can only be done with bank cards, and the payer must supply a valid e-mail address - this is necessary for fraud control.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| InitiateRecurrence || bool || &lt;br /&gt;
* Optional&lt;br /&gt;
|| This flag indicates that the shop would like to initialize a token payment. This means that the shop is authorized to charge the funding source of the payer in the future without redirecting her/him to the Barion Smart Gateway. It can be used for one-click and subscription payment scenarios. &lt;br /&gt;
Click here to learn more about token payments: [[Token_payment]]&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| RecurrenceId || string || &lt;br /&gt;
* Required when executing token payments&lt;br /&gt;
* Maximum length: 100 characters&lt;br /&gt;
* Must be unique per shop and per user&lt;br /&gt;
* [https://docs.barion.com/Token_payment#Creating_the_token Generated by the shop]&lt;br /&gt;
|| A string used to identify a given token payment. Its purpose is determined by the value of the &#039;&#039;&#039;InitiateRecurrence&#039;&#039;&#039; property.&lt;br /&gt;
* If &#039;&#039;&#039;InitiateRecurrence&#039;&#039;&#039; is &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;, this property must contain a &amp;lt;u&amp;gt;new&amp;lt;/u&amp;gt; desired identifier for a new token payment. This should be generated and stored by the shop before calling the API. Also, the shop must ensure that this is unique per user in its own system.&lt;br /&gt;
* If &#039;&#039;&#039;InitiateRecurrence&#039;&#039;&#039; is &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;, this property must contain an &amp;lt;u&amp;gt;existing&amp;lt;/u&amp;gt; identifier for a token payment. This should be used to charge a payer&#039;s funding source (either bank card or Barion wallet) that was already used successfully for a payment in the shop.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| FundingSources || string[] || &lt;br /&gt;
* Required&lt;br /&gt;
* Accepted values: &lt;br /&gt;
** &amp;quot;All&amp;quot;&lt;br /&gt;
** &amp;quot;Balance&amp;quot;&lt;br /&gt;
|| An array of strings containing the allowed funding sources that can be used to complete the payment. &amp;quot;Balance&amp;quot; means that the payer can only use their Barion wallet balance, while &amp;quot;All&amp;quot; means the payment can be completed with either a Barion wallet or a bank card.&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; There is no option to disallow payment by balance since that would deny Barion Wallet users with a balance the ability to pay. There is an option to exclude cards, but not balance.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; this must be supplied as an array because more funding source types are planned in the future.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| PaymentRequestId || string || &lt;br /&gt;
* Required&lt;br /&gt;
* Maximum length: 100 characters&lt;br /&gt;
|| The unique identifier for the payment generated by the shop. This is so the shop can track its own payment identifiers. It is also useful for bookkeeping purposes since this shows up in the monthly account statement and the transaction history export, making identification of payments easier for the shop.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| PayerHint || string || &lt;br /&gt;
* Required for {{3dsfield}}&lt;br /&gt;
* Optional, but recommended&lt;br /&gt;
* Maximum length: 256 characters&lt;br /&gt;
|| The shop can supply an e-mail address as a hint on who should complete the payment. This can be used if the shop is certain about that the payer has an active Barion wallet or the shop would like to help the guest payer with filling in the email field for her/him. If provided, the Barion Smart Gateway automatically fills out the e-mail address field in the Barion wallet login form and the guest payer form, speeding up the payment process.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| CardHolderNameHint || string || &lt;br /&gt;
* Required for {{3dsfield}}&lt;br /&gt;
* Optional, but recommended&lt;br /&gt;
* Between 2 and 45 characters&lt;br /&gt;
|| The shop can provide a hint for the customer&#039;s name on the card to speed up the payment flow. If a value is provided, the cardholder name input will be pre-filled with it and the customer can use the pre-filled value instead of typing it out on its own, which speeds up the payment process.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| RecurrenceType || [[RecurrenceType]] || &lt;br /&gt;
* Required for {{3dsfield}}, when executing token payments&lt;br /&gt;
|| Describes the nature of the token payment.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| TraceId || string || &lt;br /&gt;
* Required for {{3dsfield}}, when executing token payments&lt;br /&gt;
* Maximum length: 100 characters&lt;br /&gt;
|| Identifies the nature of the token payment. &lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| RedirectUrl || string || &lt;br /&gt;
* Required &lt;br /&gt;
* Maximum length: 2000 characters&lt;br /&gt;
|| The URL where the payer should be redirected after the payment is completed or canceled. The payment identifier is added to the query string part of this URL in the &amp;lt;code&amp;gt;paymentId&amp;lt;/code&amp;gt; parameter. If not provided, the system will use the redirect URL assigned to the shop that started the payment.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| CallbackUrl || string || &lt;br /&gt;
* Required &lt;br /&gt;
* Maximum length: 2000 characters&lt;br /&gt;
|| The URL where the Barion system sends a request whenever there is a change in the state of the payment. The payment identifier is added to the query string part of this URL in the &amp;lt;code&amp;gt;paymentId&amp;lt;/code&amp;gt; parameter. Click here to learn more about the callback mechanism: [[Callback_mechanism|Payment callback mechanism (IPN)]]&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Transactions || [[PaymentTransaction]][] || &lt;br /&gt;
* Required&lt;br /&gt;
|| An array of payment transactions contained in the payment. A payment must contain at least one such transaction. See the [[PaymentTransaction]] page for the appropriate structure and syntax.&lt;br /&gt;
Defining multiple transactions allow the payment initiator to distribute the payment amount between multiple shops. See the following page to learn more: [[Facilitated payments]]&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| OrderNumber || string || &lt;br /&gt;
* Optional&lt;br /&gt;
* Maximum length: 100 characters&lt;br /&gt;
|| The order number generated by the shop. This is to aid the shop in identifying a given payment in its own system. This also shows up in generated monthly account statements and transaction history exports, so it also helps with bookkeeping.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| ShippingAddress || [[ShippingAddress]] || &lt;br /&gt;
* Required for {{3dsfield}}&lt;br /&gt;
|| The shipping address associated with the payment, if applicable. Providing this is recommended because it helps the automatic anti-fraud analysis get more accurate results. See the [[ShippingAddress]] page for the appropriate structure and syntax.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Locale || string || &lt;br /&gt;
* Required&lt;br /&gt;
* Maximum length: 10 characters&lt;br /&gt;
* Accepted values: &lt;br /&gt;
** &amp;quot;cs-CZ&amp;quot; (Czech)&lt;br /&gt;
** &amp;quot;de-DE&amp;quot; (German)&lt;br /&gt;
** &amp;quot;en-US&amp;quot; (English)&lt;br /&gt;
** &amp;quot;es-ES&amp;quot; (Spanish)&lt;br /&gt;
** &amp;quot;fr-FR&amp;quot; (French)&lt;br /&gt;
** &amp;quot;hu-HU&amp;quot; (Hungarian)&lt;br /&gt;
** &amp;quot;sk-SK&amp;quot; (Slovak)&lt;br /&gt;
** &amp;quot;sl-SI&amp;quot; (Slovenian)&lt;br /&gt;
|| This indicates in which language the Barion Smart Gateway should display for the payer upon redirect. &lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Currency || string || &lt;br /&gt;
* Required&lt;br /&gt;
* Required length: 3 characters&lt;br /&gt;
Accepted values: &lt;br /&gt;
{{CurrencyList}}&lt;br /&gt;
|| The currency of the payment. Must be supplied in ISO 4217 format. This affects all transactions included in the payment; it is not possible to define multiple transactions in different currencies.&lt;br /&gt;
|-&lt;br /&gt;
| PayerPhoneNumber || string || &lt;br /&gt;
* Required for {{3dsfield}}&lt;br /&gt;
* Max length: 30 characters&lt;br /&gt;
* Expected format: 36701231234 (where 36 is the country code)&lt;br /&gt;
* Required for using payment buttons&lt;br /&gt;
|| The &#039;&#039;&#039;mobile&#039;&#039;&#039; phone number of the payer. Must be set to enable [[Payment_Buttons|payment buttons]]. The number must be sent in the expected format, without + sign or leading zero(s).&lt;br /&gt;
|-&lt;br /&gt;
| PayerWorkPhoneNumber || string || &lt;br /&gt;
* Required for {{3dsfield}}&lt;br /&gt;
* Max length: 30 characters&lt;br /&gt;
* Expected format: 36701231234 (where 36 is the country code)&lt;br /&gt;
|| The work phone of the payer. The number must be sent in the expected format, without + sign or leading zero(s).&lt;br /&gt;
|-&lt;br /&gt;
| PayerHomeNumber || string || &lt;br /&gt;
* Required for {{3dsfield}}&lt;br /&gt;
* Max length: 30 characters&lt;br /&gt;
* Expected format: 36701231234 (where 36 is the country code)&lt;br /&gt;
|| The home phone number of the payer. The number must be sent in the expected format, without + sign or leading zero(s).&lt;br /&gt;
|-&lt;br /&gt;
| BillingAddress || [[BillingAddress]] || &lt;br /&gt;
* Required for {{3dsfield}}&lt;br /&gt;
|| The billing address associated with the payment, if applicable.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| PayerAccount || [[PayerAccountInformation]] || &lt;br /&gt;
* Required for {{3dsfield}}&lt;br /&gt;
|| Information about the account of the payer in the merchant&#039;s system.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| PurchaseInformation|| [[PurchaseInformation]] || &lt;br /&gt;
* Required for {{3dsfield}}&lt;br /&gt;
|| Information about current purchase.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| ChallengePreference || [[ChallengePreference]] || &lt;br /&gt;
* Required for {{3dsfield}}&lt;br /&gt;
|| The merchant&#039;s preference of the 3DS challenge. Here you can specify what 3DS authentication should be utilized.&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Output properties ==&lt;br /&gt;
&lt;br /&gt;
{{api_output_table_header}}&lt;br /&gt;
|-&lt;br /&gt;
| PaymentId || Guid || The identifier of the newly initialized payment, generated by the Barion system.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| PaymentRequestId || string || The payment identifier supplied by the API caller in the request.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Status || [[PaymentStatus]]|| The status of the payment in the Barion system. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| QRUrl || string || URL for a QR code representing the payment. This is useful in physical real life situations where the payer uses a mobile device.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| RecurrenceResult || RecurrenceResult || Indicates the result of an authorized payment scenario. The result depends on the values of the &#039;&#039;&#039;InitiateRecurrence&#039;&#039;&#039; and &#039;&#039;&#039;RecurrenceId&#039;&#039;&#039; properties supplied in the request.&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;InitiateRecurrence&#039;&#039;&#039; was &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;, and a new authorized payment was successfully created, this will be &amp;lt;code&amp;gt;None&amp;lt;/code&amp;gt; (because no actual token charge took place yet)&lt;br /&gt;
&lt;br /&gt;
* If &#039;&#039;&#039;InitiateRecurrence&#039;&#039;&#039; was &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;, but a previously authorized payment identifier was supplied in &#039;&#039;&#039;RecurrenceId&#039;&#039;&#039;, the system will try to charge the funding source associated with the authorized payment. If this charge is successful, the result is &amp;lt;code&amp;gt;Successful&amp;lt;/code&amp;gt;. If the system could not charge the funding source, the result is &amp;lt;code&amp;gt;Failed&amp;lt;/code&amp;gt;. If the given identifier is invalid or does not exist, the result is &amp;lt;code&amp;gt;NotFound&amp;lt;/code&amp;gt;. In case the payment can not be processed due to lack of 3DS v2 information &amp;lt;code&amp;gt;ThreeDSAuthenticationRequired&amp;lt;/code&amp;gt; is returned. In this case, either offsite 3DS v2 authentication should be performed or the TraceId of the initial payment should be sent as well.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Transactions || [[ProcessedTransaction]][] || An array containing all transactions associated with the payment. If the Barion system deducts fees from the shop after payments, this also contains these additional fee transactions beside the payment transactions that were sent in the request.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| GatewayUrl || string || The URL of the Barion Smart Gateway (including the payment identifier), where the API caller should redirect the payer.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| CallbackUrl || string || The URL (including the payment identifier) where the Barion system will send a request to whenever there is a change in the state of the payment. If an explicit URL was not supplied, this will be the callback URL associated with the shop that started the payment.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| RedirectUrl || string|| The URL (including the payment identifier) where the payer gets redirected to after the payment is completed or cancelled. If an explicit URL was not supplied, this will be the redirect URL associated with the shop that started the payment.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2897</id>
		<title>Token payment 3D Secure</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2897"/>
		<updated>2020-12-18T15:26:24Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* Step 1 : Initialize the off-site authentication library */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Token Payment with 3D Secure}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This payment scenario allows the integrator shop to register a token for a customer (and a funding source) in the Barion system and then, later on, using this token, charge the customer without redirecting her to the Barion Smart Gateway UI. The user may be present at the site of the merchant or she can be off-session as well, so the merchant can charge her e.g. for subscriptions. This means that the customer authorizes the shop to charge her card or Barion balance without typing in the card information or Barion login again.&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurring.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=Premium feature|text=This scenario is not allowed automatically for every approved shop and should be requested from Barion!|color=#1993c7}}&lt;br /&gt;
&lt;br /&gt;
= Token payment scenarios =&lt;br /&gt;
Token payment can be used in three use cases: &lt;br /&gt;
* &#039;&#039;&#039;Customer Initiated Payments&#039;&#039;&#039;: when the user is present on the website of the merchant and she decides to pay :&lt;br /&gt;
** &#039;&#039;&#039;OneClick payment&#039;&#039;&#039;: the user is charged upon her request initiated on the website of the merchant. Subsequent payments are subject to PSD2 SCA and as the user is present, she has to go through the authentication process.&lt;br /&gt;
* &#039;&#039;&#039;Merchant Initiated Payments&#039;&#039;&#039;: when the merchant initiates the payment without the user being present. It has two subtypes:&lt;br /&gt;
** &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: the user is charged with the same amount on a regular basis, typically in case of subscriptions. Subsequent payments are exempted from PSD2 SCA, but liability still shifts to the card issuer.&lt;br /&gt;
** &#039;&#039;&#039;MIT (merchant initiated transaction)&#039;&#039;&#039;: the user is charged on an irregular basis and/or with a different amount. Subsequent payments of this type are excluded from PSD2 SCA, the liability is on the merchant.&lt;br /&gt;
&lt;br /&gt;
== Customer participation ==&lt;br /&gt;
&lt;br /&gt;
Since the token scenario is suitable for both customer and merchant initiated payments here is a comparison about who starts the payment. This includes the regular, non-tokenized payment scenario as well:&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot; | Scenario&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Initial payment&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW &lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW&lt;br /&gt;
|-&lt;br /&gt;
| Non token (regular) payment || YES || YES || YES || YES &lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || YES || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| MIT || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #aaa; background-color:#eee; font-size: 0.8em; padding:5px 10px; display:inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; Token payment scenarios can be initiated with already registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; as well, in this case the customer may remain on the merchant&#039;s site. &lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements for the scenarios ==&lt;br /&gt;
&lt;br /&gt;
These token payment scenarios have different requirements, this table below summarizes the key differences.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Payment amount&lt;br /&gt;
! Payment frequency&lt;br /&gt;
! Liability in case of fraud&lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || Various || Various || Card issuer&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || Subsequent amounts must be equal or less than the initial amount  || Initial payment must define a minimum amount of days to wait between charges || Card issuer &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || Various  || Various || Merchant&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 3DS authentication of the payer ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be performed for every online card payment. These token payment scenarios also have to use this new secure way of authentication. &lt;br /&gt;
The initial payment of a token scenario must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
Here is a table to compare the 3DS authentication requirements:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Initial payment&lt;br /&gt;
! Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
| One-click payment || ✔️ || ✔️&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Real life examples ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phone bill&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Payer has a usage-based phone subscription that wants to pay without being present for every charge. She authorizes the phone company to charge her card every month.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, the amount of the subsequent payments may exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TV subscription&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to online streaming of a television channel. She authorizes the tv company to charge her card every month. The subscription fee is the same for every month.&lt;br /&gt;
* Scenario: Recurring payment&lt;br /&gt;
* Explanation: The amount of the subsequent payments will not exceed the initial payment and the charge is regularly monthly-based.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bookclub with &amp;quot;free first month&amp;quot; bonus&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to a book renting service. he authorizes the book club to charge her card for a selection of books each month. The subscription fee is the same for every month however, the first month is free. To ensure the subscription the service requires her to register her card details.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, and the fee will stay the same, the initial payment is zero. So the amount of the next payment will exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Online food delivery service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The food delivery company wants to provide a quick and easy experience for its customer. They decide that the order will be quicker if the customers don&#039;t leave the website to pay for the goods.&lt;br /&gt;
* Scenario: OneClick payment&lt;br /&gt;
* Explanation: The customer will always be there so the other two scenarios are not available.&lt;br /&gt;
&lt;br /&gt;
== How to decide ==&lt;br /&gt;
&lt;br /&gt;
To help you decide on a suitable scenario, please use the decision graph below:&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurrencetype-decision.png|520px]]&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
To be able to integrate your webshop with the Barion Payment Gateway: &lt;br /&gt;
* You must [[Creating_an_account|register a Barion wallet]] at the Barion website or in the Sandbox environment. Learn more about the Sandbox environment [[Sandbox|here]].&lt;br /&gt;
* For this wallet you have to [[Creating_a_shop|create a shop]] which should be approved by Barion.&lt;br /&gt;
* For every currency you plan to conduct payments in you have to make sure there is an account created in your Barion wallet. This means that if you plan to have USD payments then there should be a USD account created in your wallet.&lt;br /&gt;
* To make sure every corner case scenario works for your webshop it is best to top up that account with a small amount (approx. 5-10EUR or your choice of currency around the same value).&lt;br /&gt;
* For the technical communication guide please read this: [[Calling_the_API|Calling the API]]&lt;br /&gt;
&lt;br /&gt;
= The payment process =&lt;br /&gt;
&lt;br /&gt;
The process is divided into two major steps:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 1:  Creating the funding source token|Creating the token]] that represents one of the customer&#039;s funding sources (credit card or e-money wallet)&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Preparing the payment via the Barion API&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Redirecting the customer to the Barion Smart Gateway to select a funding source&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Processing the callback and requesting information about the result of the payment&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 2: Using the token|Using the registered token]] to charge the customer&amp;lt;/li&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1:  Creating the funding source token ==&lt;br /&gt;
To be able to use a token payment scenario first the merchant has to register the token with Barion. The merchant has to make sure that the customer is well aware of the fact that they are giving consent to a tokenized payment. The Barion Smart Gateway UI does not indicate in any way that the payment is a token payment.&lt;br /&gt;
&lt;br /&gt;
The token is registered to the shop and not to the merchant&#039;s Barion account. So if the merchant has multiple shops in its Barion account, the registered tokens can not be shared among them even if the customer is the same. If you want to use tokens in multiple shops, please contact Barion in the Customer center.&lt;br /&gt;
&lt;br /&gt;
=== 1.1 Preparing the payment===&lt;br /&gt;
&lt;br /&gt;
The token registration is basically a [[Responsive_web_payment|normal payment]] with three extra properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* InitiateRecurrence&lt;br /&gt;
* RecurrenceId&lt;br /&gt;
* RecurrenceType&lt;br /&gt;
&lt;br /&gt;
==== InitiateRecurrence====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; is a bool property. If you set it to &#039;&#039;&#039;true&#039;&#039;&#039; then the payment gateway will consider the payment as a token registration. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This happens even if the customer is already has a registered token, so you are able to re-register a funding source or even a customer. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceId ====&lt;br /&gt;
The next required property for a token registration is the token itself. This is generated by the shop and has to be unique for every registration. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property of the [[Payment-Start-v2|Payment/Start]] request. This token must be saved in the webshops database. A &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; token represents the funding source (bank card or Barion balance) of a customer. Since a customer can have multiple cards and accounts as a funding source make sure that in the webshop&#039;s system multiple tokens can belong to a single customer.&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceType ====&lt;br /&gt;
The third required property is the [[RecurrenceType|Recurrence Type]]. This specifies the scenario. In case of Recurring Payment &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; must also be set.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Merchant Initiated Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The response will be the same as to a [[Responsive_web_payment#Processing_the_successful_response|basic &#039;&#039;&#039;Immediate&#039;&#039;&#039; scenario]]. The &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; property at this point is &#039;&#039;&#039;None&#039;&#039;&#039; since the token is not registered to a funding source yet.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Recurring Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Recurring Payment&#039;&#039;&#039; scenario has some extra restrictions. The merchant has to specify two additional properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt;: The date after subsequent charges should not be accepted.&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt;: The minimum days the merchant has to wait between payments.&lt;br /&gt;
&lt;br /&gt;
Both properties are located in the [[PurchaseInformation]] property and must be specified if this scenario is selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7, 30-33&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;PurchaseInformation&amp;quot;:{&lt;br /&gt;
        &amp;quot;RecurringFrequency&amp;quot;: 10,&lt;br /&gt;
        &amp;quot;RecurringExpiry&amp;quot;: &amp;quot;2022-10-01&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Possible error responses ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentNotAllowed || The token payment is not allowed for the shop identified by the &#039;&#039;&#039;POSKey&#039;&#039;&#039;. Contact Barion to request this feature.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 1.2 Redirecting the customer to the Barion Smart Gateway to select a funding source ===&lt;br /&gt;
&lt;br /&gt;
After a successful payment preparation, the customer is redirected to the secure Barion Smart Gateway to choose a funding source. The funding source the customer selects will be registered to the token. The funding source can either be a Barion e-money balance or a bank card. This means that even though the customer may own multiple cards only the one that was registered to the token can be used for future token payments. To change the funding source attached to the token a new registration should be requested.&lt;br /&gt;
&lt;br /&gt;
=== 1.3 Processing the callback and requesting information about the result of the payment ===&lt;br /&gt;
&lt;br /&gt;
When the payment is completed (either successfully or unsuccessfully) a callback message is sent to the merchant&#039;s system. Once received a [[Payment-GetPaymentState-v2|GetPaymentState]] request must be sent to the Barion API. On how to implement this please read the article about the  [[Callback_mechanism|Callback mechanism]].&lt;br /&gt;
&lt;br /&gt;
The full response of the GetPaymentState request depends on the payment scenario and the structure of the payment. When it comes to token payment there are several properties to look out for. &lt;br /&gt;
* In case the &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; is &#039;&#039;&#039;Succeeded&#039;&#039;&#039; the funding source token is registered and ready to use.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; contains the ID of the token process. This specifies the nature of the token payment. &lt;br /&gt;
&lt;br /&gt;
==== TraceId ====&lt;br /&gt;
&lt;br /&gt;
In case of Recurring payment or Merchant initiated payment scenarios the [[Payment-GetPaymentState-v2|GetPaymentState]] response returns an additional field called &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. The value of this property is generated by the card issuer. The merchant has to save it and submit it in all subsequent Recurring or Merchant initiated payments of the same type, otherwise, the payments can be declined by the issuer. The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; represents the first, customer-present payment and helps the issuer to connect subsequent payments to this initial payment.&lt;br /&gt;
&lt;br /&gt;
====Example GetPaymentState response====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;8, 11-12&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;OrderNumber&amp;quot;: null,&lt;br /&gt;
    &amp;quot;POSId&amp;quot;: &amp;quot;[[SHOPS_PUBLIC_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSName&amp;quot;: &amp;quot;[[MERCHANTS_BARION_SHOPNAME]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSOwnerEmail&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSource&amp;quot;: &amp;quot;BankCard&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;AllowedFundingSources&amp;quot;: [&lt;br /&gt;
        &amp;quot;All&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;GuestCheckout&amp;quot;: true,&lt;br /&gt;
    &amp;quot;CreatedAt&amp;quot;: &amp;quot;2020-11-26T07:52:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ValidUntil&amp;quot;: &amp;quot;2020-11-26T08:22:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;CompletedAt&amp;quot;: &amp;quot;2020-11-26T08:11:54.118Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ReservedUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;DelayedCaptureUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
           ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;Total&amp;quot;: 25.20,&lt;br /&gt;
    &amp;quot;SuggestedLocale&amp;quot;: &amp;quot;hu-HU&amp;quot;,&lt;br /&gt;
    &amp;quot;FraudRiskScore&amp;quot;: null,&lt;br /&gt;
    &amp;quot;RedirectUrl&amp;quot;: &amp;quot;https://merchanturl/Redirect?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;CallbackUrl&amp;quot;: &amp;quot;https://merchanturl/Callback?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Displaying the funding source in a GUI ====&lt;br /&gt;
We strongly advise saving the complete response for future reference. The &amp;lt;code&amp;gt;FundingSource&amp;lt;/code&amp;gt; field tells if the funding source is a Barion balance or a card. If it is a card, it is useful to save [[FundingInformation]] for displaying it for the user, when requesting future payments. The usual way to display funding sources is to show the last 4 digits of the card, with 4 stars, eg: *** 1234. The card used can be obtained from FundingInformation&#039;s [[BankCard]] field. The [[CardType]] field can be used to display the appropriate card logo. You can even show, if the card is expired, and offer to register another one.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; FundingInformation part of the GetPaymentState response &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=json&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be displayed for example as &amp;lt;code&amp;gt;VISA **** 0425 (12/20)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a request-response diagram of the token registration process:&lt;br /&gt;
 &lt;br /&gt;
[[File:Token_payment_initiation.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Step 2: Using the token =&lt;br /&gt;
&lt;br /&gt;
To use an already registered token for a payment, you have to use the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property. To be able to use a token, the initial payment must be in a successful state.&lt;br /&gt;
&lt;br /&gt;
At this point, the merchant has to decide whether this subsequent payment is used for the same token payment scenario or something changed. This is important because the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used for the same scenario, otherwise, the card issuer will decline the charge.&lt;br /&gt;
A &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used again if:&lt;br /&gt;
* the funding source is the same (technically the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* the token payment scenario is the same (technically the &amp;lt;code&amp;gt;RecurrenceType&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* this subsequent request complies with the scenario restrictions (eg: in case of recurring payment the amount of the subsequent payment does not exceed the initial amount)&lt;br /&gt;
&lt;br /&gt;
If the funding source changes, new &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the funding source|described in detail here]]. If the funding source stays the same but the scenario changes or the restrictions are no longer met new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the token payment scenario with an existing token|described here]].&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Recurring payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this case, three extra conditions must be met:&lt;br /&gt;
* the amount of the subsequent payment must not be higher than the initial amount&lt;br /&gt;
* at least that much days must be spent as defined in the initial &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; property&lt;br /&gt;
* the date of the payment must not exceed the day specified in the initial &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; property&lt;br /&gt;
&lt;br /&gt;
Please be aware that in case any of these are no longer valid the merchant has to request a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; as [[#Changing the token payment scenario with an existing token|described here]]. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=These conditions are not enforced by the Barion system so the violation of them will result in a declined charge.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
Payment/start must not include the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; properties (since they are already fixed during the initial payment).&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Recurring payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Merchant Initiated Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario there are no restrictions.&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Merchant Initiated Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 75,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Phone bill&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of OneClick Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario, the merchant has to prepare to perform the [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]] of the payer. 3DS authentication is not required in the following cases:&lt;br /&gt;
* the token (&amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;) was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is not used in this scenario since the payer is present during the transaction. &lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent OneClick Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 17,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Book: How to shop online&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;How to shop online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Book about shopping online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;piece&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
In this scenario, the response contains the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; property that is used to perform an [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8-9&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: &amp;quot;ewoJIkNhcmRQdWJs...WZXJzaW9uIjogIjIuMS4wIgp9Cg==&amp;quot;,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Possible error responses for the subsequent payment requests ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| InvalidRecurrenceId|| The token specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is invalid. Check if the token registration was successful.&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentDenied|| Something happened to the user since the token registration, either deleted, suspended, or blocked. The payment s not allowed in these cases.&lt;br /&gt;
|-&lt;br /&gt;
| InsufficientFunds|| If the original payment was with an e-money wallet and the customer doesn&#039;t have enough money to fulfill this charge this error happens.&lt;br /&gt;
|-&lt;br /&gt;
| OriginalPaymentWasntSuccessful || This means that the token belongs to an originally unsuccessful payment so this token can not be used anymore. This could only happen if the original payment was financed with a credit card.&lt;br /&gt;
|-&lt;br /&gt;
|InvalidCurrency || If the original payment was paid with e-money and the current token payment is in a currency that the wallet does not have an account in this error happens.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is the request-response diagram of the subsequent payments:&lt;br /&gt;
&lt;br /&gt;
[[File:Token_payment_2.png]]&lt;br /&gt;
&lt;br /&gt;
= Changing funding source or token scenarios =&lt;br /&gt;
&lt;br /&gt;
==Changing the funding source==&lt;br /&gt;
&lt;br /&gt;
This could happen if the funding source becomes invalid for some reason (card gets deleted or expires) or the merchant decides to use that token for another payer. In this case, the merchant has to register the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; again. &lt;br /&gt;
To do this a new payment must be started and in the [[Payment-Start-v2|Payment/Start]] request the following setup should be specified:&lt;br /&gt;
* the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; field has to be set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; &lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; has to be specified.&lt;br /&gt;
* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; should not be specified.&lt;br /&gt;
&lt;br /&gt;
[[File:Funding-source-change.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is bound to the payer and the process if the funding source changes new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be generated. This new ID must be saved to this payment and must be used from this moment on for subsequent payments.&lt;br /&gt;
&lt;br /&gt;
==Changing the token payment scenario with an existing token==&lt;br /&gt;
&lt;br /&gt;
This could occur when the merchant wants to get authorization from the payer to a new token scenario for the already registered funding source. To be able to do this the merchant has to have a valid and registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
Let&#039;s see some examples when this may be necessary:&lt;br /&gt;
* The payer subscribed to the merchant&#039;s service beforehand and the merchant decided to use the recurring payment token scenario. The payer wants to subscribe to another service and this requires a different payment schedule. This means that the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; that was specified initially can not be maintained so it is required to acquire a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;&lt;br /&gt;
* The payer bought something on the merchant&#039;s website and uses the one-click feature for subsequent fast non-redirect payments. After a while, the payer decides to subscribe to a service provided by this same merchant. This means that the merchant has to create a new token scenario (not a one-click payment but a recurring payment). For this, the merchant has to acquire a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. This can be done without redirecting the payer to Barion using the existing &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; and performing a 3DS authentication on the merchant&#039;s website.&lt;br /&gt;
&lt;br /&gt;
To do these a new payment must be started and in the [[Payment-Start-v2|Payment/Start]] request the following setup should be specified:&lt;br /&gt;
* the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; field has to be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; &lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; has to be specified.&lt;br /&gt;
* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; should not be specified.&lt;br /&gt;
&lt;br /&gt;
After this, a 3DS authentication has to be completed to acquire a new trace ID. This can be done on the merchant&#039;s site if the merchant implements the barion.offsitegw.js for off-site 3DS authentication.&lt;br /&gt;
&lt;br /&gt;
This means that it can be achieved to acquire different Trace IDs for different scenarios with only one &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
This is basically categorizing the different token scenarios as opposed to using every subsequent payment as an unmarked charge.&lt;br /&gt;
&lt;br /&gt;
[[File:Mutiple-traceid.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
= Off-site 3DS v2 authentication =&lt;br /&gt;
&lt;br /&gt;
In certain scenarios, the payer has to be authenticated to lower the risk of the card transaction. This can be either performed &lt;br /&gt;
* on the Barion Smart Gateway (on-site) by redirecting the customer to Barion &lt;br /&gt;
* or on the merchant&#039;s website (off-site) by integrating the Barion Off-site client library.&lt;br /&gt;
&lt;br /&gt;
This section describes how to integrate the Barion off-site authentication library into the merchant&#039;s site.&lt;br /&gt;
&lt;br /&gt;
== Step 1 : Initialize the off-site authentication library  ==&lt;br /&gt;
You have to include the following css and javascript files in the code of your site. &lt;br /&gt;
&amp;lt;source lang=html&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source &amp;gt;&lt;br /&gt;
These files include all the necessary javascript code and styling to handle the 3DS authentication and display the challenge if necessary.&lt;br /&gt;
&lt;br /&gt;
Then you have to initialize the Barion javascript client. To do that, you have to define a configuration object that specifies your functions that handle the off-site authentication events. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; Authentication events&#039;&#039;&#039;&lt;br /&gt;
* &amp;lt;code&amp;gt;onAuthenticationSucceeded&amp;lt;/code&amp;gt;: the 3DS v2 authentication successfully completed&lt;br /&gt;
* &amp;lt;code&amp;gt;onAuthenticationFailed&amp;lt;/code&amp;gt;:  the 3DS v2 authentication failed&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const configuration = {&lt;br /&gt;
    onAuthenticationSucceeded: function () {&lt;br /&gt;
        // handle successful authentication by calling the Barion API via merchant&#039;s backend&lt;br /&gt;
        // Call the v2/payment/complete endpoint&lt;br /&gt;
    },&lt;br /&gt;
    onAuthenticationFailed: function () {&lt;br /&gt;
        // Handle unsuccessful authentication result, no charge was made.&lt;br /&gt;
        // The payment might be still valid only the authentication failed&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to pass this config object to the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const gw = new Barion.OffsiteGw(configuration);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once the DOM is loaded you have to initialize the library:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
document.addEventListener(&amp;quot;DOMContentLoaded&amp;quot;, function () {&lt;br /&gt;
    // Initiate the Barion Offiste GW library&lt;br /&gt;
    gw.init();&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2: Start the authentication process ==&lt;br /&gt;
Once the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; is acquired from the payment/start you can start the authentication process by calling the &amp;lt;code&amp;gt;authenticate()&amp;lt;/code&amp;gt; method of the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
gw.authenticate(threeDsClientData);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will start the authentication process and present the challenge if needed. Visually this will create a modal window over the merchant&#039;s site and show the payer every necessary information.&lt;br /&gt;
Once the authentication process finished (either with or without a challenge) the appropriate event will be fired.&lt;br /&gt;
&lt;br /&gt;
== Step 3: Completing the payment ==&lt;br /&gt;
&lt;br /&gt;
In case of successful authentication, you have to call our [[Payment-Complete-v3|/Payment/Complete]] endpoint, where the actual charge will happen.&lt;br /&gt;
&lt;br /&gt;
=== Possible error responses for the subsequent payment requests ===&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
== Suggested implementation flow for off-site authentication ==&lt;br /&gt;
&lt;br /&gt;
Ideally, an off-site authentication should be part of a client-side experience without any postbacks or page reloads. This is our recommendation to achieve this:&lt;br /&gt;
&lt;br /&gt;
# After the customer clicks on the &amp;quot;Pay&amp;quot; button make an AJAX call from your client-side code to your back-end. &lt;br /&gt;
# Have your backend make a request to our payment/start endpoint (with the appropriate settings for the desired token scenario)&lt;br /&gt;
# Have your backend process the response and pass the value of the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; property to your client-side code.&lt;br /&gt;
# Use the Barion off-site library to perform the authentication&lt;br /&gt;
# Once the authentication succeeds send another AJAX request from your client-side code to your back-end.&lt;br /&gt;
# Have your back-end code call our [[Payment-Complete-v3|/Payment/Complete]]&lt;br /&gt;
# Have your backend process the response and pass the result to your client-side code.&lt;br /&gt;
# Display the result for the customer&lt;br /&gt;
&lt;br /&gt;
= Testing the integration =&lt;br /&gt;
&lt;br /&gt;
3D Secure has no environment for end-to-end testing, therefore merchants have to split their testings into two parts: Testing the payment flow with and without challenge. Getting a challenge is only possible with real-life cards, merchants have to use their own (there will be no real charging at the end on the Sandbox of the Payment Gateway, but using a real card will result initiating a real 3DS authentication).&lt;br /&gt;
&lt;br /&gt;
== Testing the whole payment flow, without challenge ==&lt;br /&gt;
&lt;br /&gt;
Use the [[https://docs.barion.com/Sandbox#Test_cards Barion test cards]], they will always get a &amp;quot;frictionless&amp;quot; flow, where the 3DS process is presented on the UI, but you will never see a challenge screen. &lt;br /&gt;
&lt;br /&gt;
This is good for testing your integration itself because it will lead to a successful charge, and you will get a TraceId as well.&lt;br /&gt;
&lt;br /&gt;
== Testing the challenge itself ==&lt;br /&gt;
&lt;br /&gt;
Use your own card, and let the card issuer decide whether your payment will get a challenge or not during the 3DS authentication procedure. Your payment will fail at the end, and you won&#039;t get the TraceId. &lt;br /&gt;
&lt;br /&gt;
This is good to test, how the challenge screens look like in your shop - especially when you integrated OneClick payment directly to your shop. You might also check how your customers see your checkout flow on popular devices.&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Payment-GetPaymentState-v2&amp;diff=2895</id>
		<title>Payment-GetPaymentState-v2</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Payment-GetPaymentState-v2&amp;diff=2895"/>
		<updated>2020-12-10T17:22:54Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* Output properties */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Barion API: Request the current state of a payment}}&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;margin-left:2em;&amp;quot; align=&amp;quot;right&amp;quot;&lt;br /&gt;
| __TOC__&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{api_callmethod&lt;br /&gt;
|method=GET&lt;br /&gt;
|uri=/v2/Payment/GetPaymentState&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;/payment/getpaymentstate&amp;lt;/code&amp;gt; API endpoint is used to query the details and current state of a given payment.&lt;br /&gt;
&lt;br /&gt;
Prerequisites before use:&lt;br /&gt;
* [[Creating_an_account|Creating an account in Barion]]&lt;br /&gt;
* [[Creating_a_shop|Creating a shop in Barion]]&lt;br /&gt;
* [[Calling_the_API|Calling the Barion API]]&lt;br /&gt;
* API: [[Payment-Start-v2 | /Payment/Start]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;api-ver&amp;quot;&amp;gt;v2&amp;lt;/span&amp;gt; This API endpoint is available in &#039;&#039;&#039;API v2&#039;&#039;&#039; only.&lt;br /&gt;
&lt;br /&gt;
== Use cases ==&lt;br /&gt;
&lt;br /&gt;
This API endpoint is designed to be used in the following scenarios:&lt;br /&gt;
* [[Responsive_web_payment|Responsive Web Payment]]&lt;br /&gt;
&lt;br /&gt;
== Input properties ==&lt;br /&gt;
&lt;br /&gt;
{{api_input_table_header}}&lt;br /&gt;
|-&lt;br /&gt;
| POSKey || Guid || &lt;br /&gt;
* Required&lt;br /&gt;
|| The secret API key of the shop, generated by Barion. This lets the shop to authenticate through the Barion API, but does not provide access to the account owning the shop itself.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| PaymentId || Guid || &lt;br /&gt;
* Required&lt;br /&gt;
|| The identifier of the payment in the Barion system.&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Output properties ==&lt;br /&gt;
&lt;br /&gt;
{{api_output_table_header}}&lt;br /&gt;
|-&lt;br /&gt;
| PaymentId || Guid || The identifier of the payment in the Barion system.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| PaymentRequestId || string || The identifier of the payment in the shop&#039;s system.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| POSId || Guid || The public identifier of the shop that created the payment.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| POSName || string || The name of the shop that created the payment.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| POSOwnerEmail || string || The e-mail address of the owner of the shop that created the payment.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Status || [[PaymentStatus]] || The current status of the payment in the Barion system.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| PaymentType || string || The type of the payment. Can be &amp;lt;code&amp;gt;Immediate&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;Reservation&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| AllowedFundingSources || string[] || The allowed funding sources that were defined when creating the payment.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| FundingSource || string || The funding source that was used to complete the payment. If the payment is not yet completed, this is empty. Can be &amp;lt;code&amp;gt;Balance&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;BankCard&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;BankTransfer&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| FundingInformation || [[FundingInformation]] || Detailed information about the funding source that was used to complete the payment. If the payment is not yet completed, this is empty.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| RecurrenceType || [[RecurrenceType]] || The RecurrenceType that was defined in the payment/start request for the recurring scenario.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| TraceId || string || The Trace Id that identifies that recurring scenario. Read more about this [[Token_payment_3D_Secure|here]]&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| GuestCheckout || bool || Indicates whether the payment allows guest checkout.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| CreatedAt || DateTime || The timestamp showing when the payment was created.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| StartedAt || DateTime || The timestamp showing when a reservation payment was started. If the payment type is not reservation, this is empty.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| CompletedAt || DateTime || The timestamp showing when the payment was completed. If the payment is not yet completed, this is empty.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| ValidUntil || DateTime || Timestamp showing the expiration time of the payment time window. The payment must be completed before this elapses.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| ReservedUntil || DateTime || Timestamp showing the expiration time of the reservation time window. The reserved payment must be finished before this elapses. If the payment type is not reservation, this is empty.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| DelayedCaptureUntil || DateTime || Timestamp showing the expiration time of the authorization time window. The authorized payment must be finished before this elapses. If the payment type is not DelayedCapture, this is empty.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Transactions || [[DetailedPaymentTransaction]][] || An array containing a detailed structure of all transactions associated with the payment.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Total || decimal || The total amount of the payment &amp;lt;u&amp;gt;at the time of the request&amp;lt;/u&amp;gt;. If a reservation was finished with a lower amount, or a previously completed payment was refunded, this can be less than at the time of creation.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| Currency || string || The 3 character ISO 4217 currency code of the payment.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| SuggestedLocale || string || Indicates in which language the Barion Smart Gateway should be shown for the payer.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| FraudRiskScore || int || A risk score computed by the anti-fraud analysis, between a range of 0 (completely legit) to 100 (certain fraud). Transactions under 10 are usually safe. Transactions with 10 an more, but less than 30 are risky, caution is advised. Transactions with 30 and over are blocked automatically for being almost certainly fraudulent.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| CallbackUrl || string || The URL (including the payment identifier) where the Barion system will send (or already sent) a request to whenever there is a change in the state of the payment.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| RedirectUrl || string|| The URL (including the payment identifier) where the payer gets (or already got) redirected to after the payment is or was completed or cancelled.&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_upgrade_to_3DS&amp;diff=2894</id>
		<title>Token payment upgrade to 3DS</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_upgrade_to_3DS&amp;diff=2894"/>
		<updated>2020-12-10T15:14:29Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* What happens if the merchant doesn&amp;#039;t upgrade its implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Upgrading token payment implementation to comply with 3DS}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=NOTE|text=This tutorial was created to help merchants that already have token payment integration with Barion. First, please read through the detailed description of the new [[Token_payment_3D_Secure|token payment with 3DS]]!|color=#1993c7}}&lt;br /&gt;
= Background =&lt;br /&gt;
[[Token_payment|Token payment]] is a solution that enables the merchant to charge the payer without the presence of them. It is a powerful tool to conduct subscription-like or payer-not-present scenarios. This scenario requires the merchant to create a token that would act as an identifier for the payer&#039;s funding source. To attach that token to a valid funding source the merchant had to do several things:&lt;br /&gt;
# Create an alphanumeric token&lt;br /&gt;
# Conduct an initial payment in which this token gets registered in the Barion system &lt;br /&gt;
# Refer to this token in a subsequent payment attempt&lt;br /&gt;
&lt;br /&gt;
[[File:Recurring-pre3ds.png|1280px]]&lt;br /&gt;
&lt;br /&gt;
This meant that as far as this token referenced a valid (and still available) funding source the merchant could create payments without any limitations. Basically, this token symbolized the funding source. It was up to the merchant to decide what it is used for, neither Barion nor the card issuer was aware of the nature of the subsequent payments. &lt;br /&gt;
&lt;br /&gt;
This funding source can be either a card or an e-money wallet and this is up to the payer to choose. In case the payer chooses to fund the payment from their e-money wallet there is no further need for extra security. On the other hand, when it comes to card payment the authentication process changed with the new Strong Customer Authentication directive and the 3DS v2 protocol.&lt;br /&gt;
&lt;br /&gt;
= Changes =&lt;br /&gt;
To make sure that the payer has more control over these token scenarios and the card issuer knows more about the payment scenarios several things need to be changed. &lt;br /&gt;
&lt;br /&gt;
== Token payment scenarios ==&lt;br /&gt;
&lt;br /&gt;
First of all the merchant has to decide what kind of token payment scenario is suitable. These scenarios are the following:&lt;br /&gt;
* &#039;&#039;&#039;One-click payment&#039;&#039;&#039;: The payer clicks on the &amp;quot;Purchase&amp;quot; button but the charge happens in the background without the payer leaving the merchant&#039;s site.&lt;br /&gt;
* &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: The payer authorizes the merchant (at the initial payment) to charge their card periodically without being present.&lt;br /&gt;
* &#039;&#039;&#039;Merchant initiated payment&#039;&#039;&#039;: The payer authorizes the merchant to charge their card without restrictions.&lt;br /&gt;
&lt;br /&gt;
To decide on a suitable scenario, please [[Token_payment_3D_Secure#Token_payment_scenarios|read this detailed description]]&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=CHANGE|text=The intended scenario must be specified in the new [[RecurrenceType|ReccurenceType]] property (located in the [[Payment-Start-v2|Payment/Start]] request)|color=#20c400}}&lt;br /&gt;
&lt;br /&gt;
== Usage of TraceId ==&lt;br /&gt;
&lt;br /&gt;
3DS authentication requires another identifier. This new identifier is used to differentiate these token payment scenarios and help the issuer control what is a non-fraudulent transaction.&lt;br /&gt;
&lt;br /&gt;
So from now on, there will be two IDs for every payer-not-present scenario:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; for the funding source: this identifies the source of the money (could be card or wallet)&lt;br /&gt;
* &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; (new) for the &#039;&#039;nature of the charge:&#039;&#039; this identifies the type of token payment scenario the merchant is conducting.&lt;br /&gt;
&lt;br /&gt;
This new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is generated and stored by the card issuer. The Id is available in the [[Payment-GetPaymentState-v2|GetPaymentState]] response once the charge is successfully completed.&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=CHANGE|text=The TraceId must processed from the [[Payment-GetPaymentState-v2|GetPaymentState]] response and must be attached to the payment in merchant&#039;s system. |color=#20c400}}&lt;br /&gt;
&lt;br /&gt;
Once the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is acquired it must be sent in the [[Payment-Start-v2|Payment/Start]] request to identify the scenario. This is crucial for the card transactions otherwise they could be declined. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=CHANGE|text=The TraceId must specified in the [[Payment-Start-v2|Payment/Start]] for the subsequent token charges. |color=#20c400}}&lt;br /&gt;
&lt;br /&gt;
== 3DS v2 authentication ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be conducted for every online card payment. These token payment scenarios also need to use these new secure way of authentication. &lt;br /&gt;
The initial payment must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Technical changes required =&lt;br /&gt;
The technical changes depend on what type of token scenario is needed for the business. It is important to notice that these scenarios can be implemented beside each other, a merchant is not required to choose only one type of token payment. The main goal is to appropriately use each scenario.&lt;br /&gt;
&lt;br /&gt;
== Technical changes for Recurring payments ==&lt;br /&gt;
&lt;br /&gt;
#&#039;&#039;&#039; For the token registration&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request the new properties have to be specified:&lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;RecurringPayment&amp;quot;&amp;lt;/code&amp;gt; to indicate the scenario&lt;br /&gt;
#* &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; for the limitations &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt; &lt;br /&gt;
#Once the callback is received get the response of [[Payment-GetPaymentState-v2|GetPaymentState]]. In case the charge was successful, there will be a &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; property for the payment. The value of it must be saved and attached to the payment.  &lt;br /&gt;
#&#039;&#039;&#039;For subsequent payments&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request specify the &lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;RecurringPayment&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
#* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; you received for the initial payment.&lt;br /&gt;
&lt;br /&gt;
== Technical changes for Merchant initiated payments ==&lt;br /&gt;
&lt;br /&gt;
#&#039;&#039;&#039; For the token registration&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request the new property has to be specified:&lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;MerchantInitiatedPayment&amp;quot;&amp;lt;/code&amp;gt; to indicate the scenario&lt;br /&gt;
#Once the callback is received get the response of [[Payment-GetPaymentState-v2|GetPaymentState]]. In case the charge was successful, there will be a &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; property for the payment. The value of it must be saved and attached to the payment.  &lt;br /&gt;
#&#039;&#039;&#039;For subsequent payments&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request specify the &lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;MerchantInitiatedPayment&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
#* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; you received for the initial payment.&lt;br /&gt;
&lt;br /&gt;
== Technical changes for One-click payments ==&lt;br /&gt;
&lt;br /&gt;
This modification needs the most attention since the merchant has to implement client-side functionality and add a new step at the end of the flow.&lt;br /&gt;
&lt;br /&gt;
#&#039;&#039;&#039; For the token registration&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request the new property has to be specified:&lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;OneClickPayment&amp;quot;&amp;lt;/code&amp;gt; to indicate the scenario&lt;br /&gt;
#&#039;&#039;&#039;For subsequent payments&#039;&#039;&#039; the merchant has to integrate the barion.offsitegw.js to be able to authenticate the payer via 3DS v2 on the merchant&#039;s site. To do this read the tutorial on [[Token_payment_3D_Secure#OneClick payment|how to integrate this]].&lt;br /&gt;
# After a successful authentication a new Barion API endpoint ([[Payment-Complete-v2|/Payment/Complete]]) must be called to finalize the process and charge the card&lt;br /&gt;
&lt;br /&gt;
Please notice that in case this scenario is used there is no need to use the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; since the 3DS authentication will be performed every time.&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=CHANGE|text=In case of one-click token scenario the merchant has to authenticate every card payment with 3DS v2|color=#20c400}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What happens if the merchant doesn&#039;t upgrade its implementation ==&lt;br /&gt;
&lt;br /&gt;
There will be a two-phase ramp-up period to make sure that integrations can be upgraded.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Until December 31, 2020&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In this period the integrations that are not up-to-date and are not capable to handle 3DS v2 transactions &#039;&#039;&#039;will work&#039;&#039;&#039;. &lt;br /&gt;
* New tokens can be initiated (without RecurrenceType and TraceId) and the 3DSv2 authentication will be performed by the Barion Smart Gateway.&lt;br /&gt;
* Subsequent payments can use existing tokens (RecurrenceId) without specifying the TraceId.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Between January 1 and January 31, 2021 &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In this period the integrations that are not up-to-date and are not capable to handle 3DS v2 transactions &#039;&#039;&#039;will work&#039;&#039;&#039;. However, to comply with the card scheme mandates Barion has to substitute the missing information.&lt;br /&gt;
* New tokens can be initiated (without RecurrenceType and TraceId) and the 3DSv2 authentication will be performed by the Barion Smart Gateway. The payment will be marked as an initial MIT transaction. The MerchantInitiatedPayment RecurrenceType will be used as a fallback.&lt;br /&gt;
* Subsequent payments can use existing tokens (RecurrenceId) without specifying the TraceId. They will be handled as the subsequent MIT payment of the initial transaction. The TraceId will be filled in by Barion.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;From February 1, 2021&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Until this date, all integrations must be upgraded. &lt;br /&gt;
* New tokens can only be initiated with the appropriate 3DSv2 information (RecurrenceType set). Otherwise, the payment/start will result in a validation error.&lt;br /&gt;
* Subsequent payments can use existing tokens (RecurrenceId) without specifying the TraceId. They will be handled as the subsequent MIT payment of the initial transaction. The TraceId will be filled in by Barion. This can be used until the card schemes allow this kind of TraceId substitution.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=SUPPORT|text=In case you have difficulties with the upgrade please contact our developers at devsupport@barion.com |color=#1993c7}}&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_upgrade_to_3DS&amp;diff=2893</id>
		<title>Token payment upgrade to 3DS</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_upgrade_to_3DS&amp;diff=2893"/>
		<updated>2020-12-10T13:41:17Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* What happens if the merchant doesn&amp;#039;t upgrade its implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Upgrading token payment implementation to comply with 3DS}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=NOTE|text=This tutorial was created to help merchants that already have token payment integration with Barion. First, please read through the detailed description of the new [[Token_payment_3D_Secure|token payment with 3DS]]!|color=#1993c7}}&lt;br /&gt;
= Background =&lt;br /&gt;
[[Token_payment|Token payment]] is a solution that enables the merchant to charge the payer without the presence of them. It is a powerful tool to conduct subscription-like or payer-not-present scenarios. This scenario requires the merchant to create a token that would act as an identifier for the payer&#039;s funding source. To attach that token to a valid funding source the merchant had to do several things:&lt;br /&gt;
# Create an alphanumeric token&lt;br /&gt;
# Conduct an initial payment in which this token gets registered in the Barion system &lt;br /&gt;
# Refer to this token in a subsequent payment attempt&lt;br /&gt;
&lt;br /&gt;
[[File:Recurring-pre3ds.png|1280px]]&lt;br /&gt;
&lt;br /&gt;
This meant that as far as this token referenced a valid (and still available) funding source the merchant could create payments without any limitations. Basically, this token symbolized the funding source. It was up to the merchant to decide what it is used for, neither Barion nor the card issuer was aware of the nature of the subsequent payments. &lt;br /&gt;
&lt;br /&gt;
This funding source can be either a card or an e-money wallet and this is up to the payer to choose. In case the payer chooses to fund the payment from their e-money wallet there is no further need for extra security. On the other hand, when it comes to card payment the authentication process changed with the new Strong Customer Authentication directive and the 3DS v2 protocol.&lt;br /&gt;
&lt;br /&gt;
= Changes =&lt;br /&gt;
To make sure that the payer has more control over these token scenarios and the card issuer knows more about the payment scenarios several things need to be changed. &lt;br /&gt;
&lt;br /&gt;
== Token payment scenarios ==&lt;br /&gt;
&lt;br /&gt;
First of all the merchant has to decide what kind of token payment scenario is suitable. These scenarios are the following:&lt;br /&gt;
* &#039;&#039;&#039;One-click payment&#039;&#039;&#039;: The payer clicks on the &amp;quot;Purchase&amp;quot; button but the charge happens in the background without the payer leaving the merchant&#039;s site.&lt;br /&gt;
* &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: The payer authorizes the merchant (at the initial payment) to charge their card periodically without being present.&lt;br /&gt;
* &#039;&#039;&#039;Merchant initiated payment&#039;&#039;&#039;: The payer authorizes the merchant to charge their card without restrictions.&lt;br /&gt;
&lt;br /&gt;
To decide on a suitable scenario, please [[Token_payment_3D_Secure#Token_payment_scenarios|read this detailed description]]&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=CHANGE|text=The intended scenario must be specified in the new [[RecurrenceType|ReccurenceType]] property (located in the [[Payment-Start-v2|Payment/Start]] request)|color=#20c400}}&lt;br /&gt;
&lt;br /&gt;
== Usage of TraceId ==&lt;br /&gt;
&lt;br /&gt;
3DS authentication requires another identifier. This new identifier is used to differentiate these token payment scenarios and help the issuer control what is a non-fraudulent transaction.&lt;br /&gt;
&lt;br /&gt;
So from now on, there will be two IDs for every payer-not-present scenario:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; for the funding source: this identifies the source of the money (could be card or wallet)&lt;br /&gt;
* &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; (new) for the &#039;&#039;nature of the charge:&#039;&#039; this identifies the type of token payment scenario the merchant is conducting.&lt;br /&gt;
&lt;br /&gt;
This new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is generated and stored by the card issuer. The Id is available in the [[Payment-GetPaymentState-v2|GetPaymentState]] response once the charge is successfully completed.&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=CHANGE|text=The TraceId must processed from the [[Payment-GetPaymentState-v2|GetPaymentState]] response and must be attached to the payment in merchant&#039;s system. |color=#20c400}}&lt;br /&gt;
&lt;br /&gt;
Once the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is acquired it must be sent in the [[Payment-Start-v2|Payment/Start]] request to identify the scenario. This is crucial for the card transactions otherwise they could be declined. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=CHANGE|text=The TraceId must specified in the [[Payment-Start-v2|Payment/Start]] for the subsequent token charges. |color=#20c400}}&lt;br /&gt;
&lt;br /&gt;
== 3DS v2 authentication ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be conducted for every online card payment. These token payment scenarios also need to use these new secure way of authentication. &lt;br /&gt;
The initial payment must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Technical changes required =&lt;br /&gt;
The technical changes depend on what type of token scenario is needed for the business. It is important to notice that these scenarios can be implemented beside each other, a merchant is not required to choose only one type of token payment. The main goal is to appropriately use each scenario.&lt;br /&gt;
&lt;br /&gt;
== Technical changes for Recurring payments ==&lt;br /&gt;
&lt;br /&gt;
#&#039;&#039;&#039; For the token registration&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request the new properties have to be specified:&lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;RecurringPayment&amp;quot;&amp;lt;/code&amp;gt; to indicate the scenario&lt;br /&gt;
#* &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; for the limitations &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt; &lt;br /&gt;
#Once the callback is received get the response of [[Payment-GetPaymentState-v2|GetPaymentState]]. In case the charge was successful, there will be a &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; property for the payment. The value of it must be saved and attached to the payment.  &lt;br /&gt;
#&#039;&#039;&#039;For subsequent payments&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request specify the &lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;RecurringPayment&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
#* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; you received for the initial payment.&lt;br /&gt;
&lt;br /&gt;
== Technical changes for Merchant initiated payments ==&lt;br /&gt;
&lt;br /&gt;
#&#039;&#039;&#039; For the token registration&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request the new property has to be specified:&lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;MerchantInitiatedPayment&amp;quot;&amp;lt;/code&amp;gt; to indicate the scenario&lt;br /&gt;
#Once the callback is received get the response of [[Payment-GetPaymentState-v2|GetPaymentState]]. In case the charge was successful, there will be a &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; property for the payment. The value of it must be saved and attached to the payment.  &lt;br /&gt;
#&#039;&#039;&#039;For subsequent payments&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request specify the &lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;MerchantInitiatedPayment&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
#* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; you received for the initial payment.&lt;br /&gt;
&lt;br /&gt;
== Technical changes for One-click payments ==&lt;br /&gt;
&lt;br /&gt;
This modification needs the most attention since the merchant has to implement client-side functionality and add a new step at the end of the flow.&lt;br /&gt;
&lt;br /&gt;
#&#039;&#039;&#039; For the token registration&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request the new property has to be specified:&lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;OneClickPayment&amp;quot;&amp;lt;/code&amp;gt; to indicate the scenario&lt;br /&gt;
#&#039;&#039;&#039;For subsequent payments&#039;&#039;&#039; the merchant has to integrate the barion.offsitegw.js to be able to authenticate the payer via 3DS v2 on the merchant&#039;s site. To do this read the tutorial on [[Token_payment_3D_Secure#OneClick payment|how to integrate this]].&lt;br /&gt;
# After a successful authentication a new Barion API endpoint ([[Payment-Complete-v2|/Payment/Complete]]) must be called to finalize the process and charge the card&lt;br /&gt;
&lt;br /&gt;
Please notice that in case this scenario is used there is no need to use the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; since the 3DS authentication will be performed every time.&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=CHANGE|text=In case of one-click token scenario the merchant has to authenticate every card payment with 3DS v2|color=#20c400}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What happens if the merchant doesn&#039;t upgrade its implementation ==&lt;br /&gt;
&lt;br /&gt;
There will be a two-phase ramp-up period to make sure that integrations can be upgraded.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Until December 31, 2020&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In this period the integrations that are not up-to-date and are not capable to handle 3DS v2 transactions &#039;&#039;&#039;will work&#039;&#039;&#039;. &lt;br /&gt;
* New tokens can be initiated (without 3DSv2 information) and the 3DSv2 authentication will be performed by the Barion Smart Gateway.&lt;br /&gt;
* Subsequent payments can use existing tokens (RecurrenceId) without specifying the TraceId.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Between January 1 and January 31, 2021 &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In this period the integrations that are not up-to-date and are not capable to handle 3DS v2 transactions &#039;&#039;&#039;will work&#039;&#039;&#039;. However, to comply with the card scheme mandates Barion has to substitute the missing information.&lt;br /&gt;
* New tokens can be initiated (without 3DSv2 information) and the 3DSv2 authentication will be performed by the Barion Smart Gateway. The payment will be marked as an initial MIT transaction. The MerchantInitiatedPayment RecurrenceType will be used as a fallback.&lt;br /&gt;
* Subsequent payments can use existing tokens (RecurrenceId) without specifying the TraceId. They will be handled as the subsequent MIT payment of the initial transaction. The TraceId will be filled in by Barion.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;From February 1, 2021&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Until this date, all integrations must be upgraded. &lt;br /&gt;
* New tokens can only be initiated with the appropriate 3DSv2 information (RecurrenceType set). Otherwise, the payment/start will result in a validation error.&lt;br /&gt;
* Subsequent payments can use existing tokens (RecurrenceId) without specifying the TraceId. They will be handled as the subsequent MIT payment of the initial transaction. The TraceId will be filled in by Barion. This can be used until the card schemes allow this kind of TraceId substitution.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=SUPPORT|text=In case you have difficulties with the upgrade please contact our developers at devsupport@barion.com |color=#1993c7}}&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_upgrade_to_3DS&amp;diff=2892</id>
		<title>Token payment upgrade to 3DS</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_upgrade_to_3DS&amp;diff=2892"/>
		<updated>2020-12-10T13:13:43Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* What happens if the merchant doesn&amp;#039;t upgrade its implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Upgrading token payment implementation to comply with 3DS}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=NOTE|text=This tutorial was created to help merchants that already have token payment integration with Barion. First, please read through the detailed description of the new [[Token_payment_3D_Secure|token payment with 3DS]]!|color=#1993c7}}&lt;br /&gt;
= Background =&lt;br /&gt;
[[Token_payment|Token payment]] is a solution that enables the merchant to charge the payer without the presence of them. It is a powerful tool to conduct subscription-like or payer-not-present scenarios. This scenario requires the merchant to create a token that would act as an identifier for the payer&#039;s funding source. To attach that token to a valid funding source the merchant had to do several things:&lt;br /&gt;
# Create an alphanumeric token&lt;br /&gt;
# Conduct an initial payment in which this token gets registered in the Barion system &lt;br /&gt;
# Refer to this token in a subsequent payment attempt&lt;br /&gt;
&lt;br /&gt;
[[File:Recurring-pre3ds.png|1280px]]&lt;br /&gt;
&lt;br /&gt;
This meant that as far as this token referenced a valid (and still available) funding source the merchant could create payments without any limitations. Basically, this token symbolized the funding source. It was up to the merchant to decide what it is used for, neither Barion nor the card issuer was aware of the nature of the subsequent payments. &lt;br /&gt;
&lt;br /&gt;
This funding source can be either a card or an e-money wallet and this is up to the payer to choose. In case the payer chooses to fund the payment from their e-money wallet there is no further need for extra security. On the other hand, when it comes to card payment the authentication process changed with the new Strong Customer Authentication directive and the 3DS v2 protocol.&lt;br /&gt;
&lt;br /&gt;
= Changes =&lt;br /&gt;
To make sure that the payer has more control over these token scenarios and the card issuer knows more about the payment scenarios several things need to be changed. &lt;br /&gt;
&lt;br /&gt;
== Token payment scenarios ==&lt;br /&gt;
&lt;br /&gt;
First of all the merchant has to decide what kind of token payment scenario is suitable. These scenarios are the following:&lt;br /&gt;
* &#039;&#039;&#039;One-click payment&#039;&#039;&#039;: The payer clicks on the &amp;quot;Purchase&amp;quot; button but the charge happens in the background without the payer leaving the merchant&#039;s site.&lt;br /&gt;
* &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: The payer authorizes the merchant (at the initial payment) to charge their card periodically without being present.&lt;br /&gt;
* &#039;&#039;&#039;Merchant initiated payment&#039;&#039;&#039;: The payer authorizes the merchant to charge their card without restrictions.&lt;br /&gt;
&lt;br /&gt;
To decide on a suitable scenario, please [[Token_payment_3D_Secure#Token_payment_scenarios|read this detailed description]]&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=CHANGE|text=The intended scenario must be specified in the new [[RecurrenceType|ReccurenceType]] property (located in the [[Payment-Start-v2|Payment/Start]] request)|color=#20c400}}&lt;br /&gt;
&lt;br /&gt;
== Usage of TraceId ==&lt;br /&gt;
&lt;br /&gt;
3DS authentication requires another identifier. This new identifier is used to differentiate these token payment scenarios and help the issuer control what is a non-fraudulent transaction.&lt;br /&gt;
&lt;br /&gt;
So from now on, there will be two IDs for every payer-not-present scenario:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; for the funding source: this identifies the source of the money (could be card or wallet)&lt;br /&gt;
* &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; (new) for the &#039;&#039;nature of the charge:&#039;&#039; this identifies the type of token payment scenario the merchant is conducting.&lt;br /&gt;
&lt;br /&gt;
This new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is generated and stored by the card issuer. The Id is available in the [[Payment-GetPaymentState-v2|GetPaymentState]] response once the charge is successfully completed.&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=CHANGE|text=The TraceId must processed from the [[Payment-GetPaymentState-v2|GetPaymentState]] response and must be attached to the payment in merchant&#039;s system. |color=#20c400}}&lt;br /&gt;
&lt;br /&gt;
Once the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is acquired it must be sent in the [[Payment-Start-v2|Payment/Start]] request to identify the scenario. This is crucial for the card transactions otherwise they could be declined. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=CHANGE|text=The TraceId must specified in the [[Payment-Start-v2|Payment/Start]] for the subsequent token charges. |color=#20c400}}&lt;br /&gt;
&lt;br /&gt;
== 3DS v2 authentication ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be conducted for every online card payment. These token payment scenarios also need to use these new secure way of authentication. &lt;br /&gt;
The initial payment must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Technical changes required =&lt;br /&gt;
The technical changes depend on what type of token scenario is needed for the business. It is important to notice that these scenarios can be implemented beside each other, a merchant is not required to choose only one type of token payment. The main goal is to appropriately use each scenario.&lt;br /&gt;
&lt;br /&gt;
== Technical changes for Recurring payments ==&lt;br /&gt;
&lt;br /&gt;
#&#039;&#039;&#039; For the token registration&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request the new properties have to be specified:&lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;RecurringPayment&amp;quot;&amp;lt;/code&amp;gt; to indicate the scenario&lt;br /&gt;
#* &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; for the limitations &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt; &lt;br /&gt;
#Once the callback is received get the response of [[Payment-GetPaymentState-v2|GetPaymentState]]. In case the charge was successful, there will be a &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; property for the payment. The value of it must be saved and attached to the payment.  &lt;br /&gt;
#&#039;&#039;&#039;For subsequent payments&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request specify the &lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;RecurringPayment&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
#* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; you received for the initial payment.&lt;br /&gt;
&lt;br /&gt;
== Technical changes for Merchant initiated payments ==&lt;br /&gt;
&lt;br /&gt;
#&#039;&#039;&#039; For the token registration&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request the new property has to be specified:&lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;MerchantInitiatedPayment&amp;quot;&amp;lt;/code&amp;gt; to indicate the scenario&lt;br /&gt;
#Once the callback is received get the response of [[Payment-GetPaymentState-v2|GetPaymentState]]. In case the charge was successful, there will be a &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; property for the payment. The value of it must be saved and attached to the payment.  &lt;br /&gt;
#&#039;&#039;&#039;For subsequent payments&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request specify the &lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;MerchantInitiatedPayment&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
#* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; you received for the initial payment.&lt;br /&gt;
&lt;br /&gt;
== Technical changes for One-click payments ==&lt;br /&gt;
&lt;br /&gt;
This modification needs the most attention since the merchant has to implement client-side functionality and add a new step at the end of the flow.&lt;br /&gt;
&lt;br /&gt;
#&#039;&#039;&#039; For the token registration&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request the new property has to be specified:&lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;OneClickPayment&amp;quot;&amp;lt;/code&amp;gt; to indicate the scenario&lt;br /&gt;
#&#039;&#039;&#039;For subsequent payments&#039;&#039;&#039; the merchant has to integrate the barion.offsitegw.js to be able to authenticate the payer via 3DS v2 on the merchant&#039;s site. To do this read the tutorial on [[Token_payment_3D_Secure#OneClick payment|how to integrate this]].&lt;br /&gt;
# After a successful authentication a new Barion API endpoint ([[Payment-Complete-v2|/Payment/Complete]]) must be called to finalize the process and charge the card&lt;br /&gt;
&lt;br /&gt;
Please notice that in case this scenario is used there is no need to use the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; since the 3DS authentication will be performed every time.&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=CHANGE|text=In case of one-click token scenario the merchant has to authenticate every card payment with 3DS v2|color=#20c400}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What happens if the merchant doesn&#039;t upgrade its implementation ==&lt;br /&gt;
&lt;br /&gt;
There will be a two-phase ramp-up period to make sure that integrations can be upgraded.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Until December 31, 2020&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In this period the integrations that are not up-to-date and are not capable to handle 3DS v2 transactions &#039;&#039;&#039;will work&#039;&#039;&#039;. &lt;br /&gt;
* New tokens can be initiated (without 3DSv2 information) and the 3DSv2 authentication will be performed by the Barion Smart Gateway.&lt;br /&gt;
* Subsequent payments can use existing tokens (RecurrenceId) without specifying the TraceId.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Between January 1 and January 31, 2021 &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In this period the integrations that are not up-to-date and are not capable to handle 3DS v2 transactions &#039;&#039;&#039;will work&#039;&#039;&#039;. However, to comply with the card scheme mandates Barion has to substitute the missing information.&lt;br /&gt;
* New tokens can be initiated (without 3DSv2 information) and the 3DSv2 authentication will be performed by the Barion Smart Gateway. The payment will be marked as an initial MIT transaction. The MerchantInitiatedPayment RecurrenceType will be used as a fallback.&lt;br /&gt;
* Subsequent payments can use existing tokens (RecurrenceId) without specifying the TraceId. They will be handled as the subsequent MIT payment of the initial transaction. The TraceId of the last successful payment will be filled in by Barion.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;From February 1, 2021&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Until this date, all integrations must be upgraded. &lt;br /&gt;
* New tokens can only be initiated with the appropriate 3DSv2 information (RecurrenceType set). Otherwise, the payment/start will result in a validation error.&lt;br /&gt;
* Subsequent payments can use existing tokens (RecurrenceId) without specifying the TraceId. They will be handled as the subsequent MIT payment of the initial transaction. The TraceId of the last successful payment will be filled in by Barion. This can be used until the card schemes allow this kind of TraceId substitution.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=SUPPORT|text=In case you have difficulties with the upgrade please contact our developers at devsupport@barion.com |color=#1993c7}}&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_upgrade_to_3DS&amp;diff=2891</id>
		<title>Token payment upgrade to 3DS</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_upgrade_to_3DS&amp;diff=2891"/>
		<updated>2020-12-10T12:57:52Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* What happens if the merchant doesn&amp;#039;t upgrade its implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Upgrading token payment implementation to comply with 3DS}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=NOTE|text=This tutorial was created to help merchants that already have token payment integration with Barion. First, please read through the detailed description of the new [[Token_payment_3D_Secure|token payment with 3DS]]!|color=#1993c7}}&lt;br /&gt;
= Background =&lt;br /&gt;
[[Token_payment|Token payment]] is a solution that enables the merchant to charge the payer without the presence of them. It is a powerful tool to conduct subscription-like or payer-not-present scenarios. This scenario requires the merchant to create a token that would act as an identifier for the payer&#039;s funding source. To attach that token to a valid funding source the merchant had to do several things:&lt;br /&gt;
# Create an alphanumeric token&lt;br /&gt;
# Conduct an initial payment in which this token gets registered in the Barion system &lt;br /&gt;
# Refer to this token in a subsequent payment attempt&lt;br /&gt;
&lt;br /&gt;
[[File:Recurring-pre3ds.png|1280px]]&lt;br /&gt;
&lt;br /&gt;
This meant that as far as this token referenced a valid (and still available) funding source the merchant could create payments without any limitations. Basically, this token symbolized the funding source. It was up to the merchant to decide what it is used for, neither Barion nor the card issuer was aware of the nature of the subsequent payments. &lt;br /&gt;
&lt;br /&gt;
This funding source can be either a card or an e-money wallet and this is up to the payer to choose. In case the payer chooses to fund the payment from their e-money wallet there is no further need for extra security. On the other hand, when it comes to card payment the authentication process changed with the new Strong Customer Authentication directive and the 3DS v2 protocol.&lt;br /&gt;
&lt;br /&gt;
= Changes =&lt;br /&gt;
To make sure that the payer has more control over these token scenarios and the card issuer knows more about the payment scenarios several things need to be changed. &lt;br /&gt;
&lt;br /&gt;
== Token payment scenarios ==&lt;br /&gt;
&lt;br /&gt;
First of all the merchant has to decide what kind of token payment scenario is suitable. These scenarios are the following:&lt;br /&gt;
* &#039;&#039;&#039;One-click payment&#039;&#039;&#039;: The payer clicks on the &amp;quot;Purchase&amp;quot; button but the charge happens in the background without the payer leaving the merchant&#039;s site.&lt;br /&gt;
* &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: The payer authorizes the merchant (at the initial payment) to charge their card periodically without being present.&lt;br /&gt;
* &#039;&#039;&#039;Merchant initiated payment&#039;&#039;&#039;: The payer authorizes the merchant to charge their card without restrictions.&lt;br /&gt;
&lt;br /&gt;
To decide on a suitable scenario, please [[Token_payment_3D_Secure#Token_payment_scenarios|read this detailed description]]&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=CHANGE|text=The intended scenario must be specified in the new [[RecurrenceType|ReccurenceType]] property (located in the [[Payment-Start-v2|Payment/Start]] request)|color=#20c400}}&lt;br /&gt;
&lt;br /&gt;
== Usage of TraceId ==&lt;br /&gt;
&lt;br /&gt;
3DS authentication requires another identifier. This new identifier is used to differentiate these token payment scenarios and help the issuer control what is a non-fraudulent transaction.&lt;br /&gt;
&lt;br /&gt;
So from now on, there will be two IDs for every payer-not-present scenario:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; for the funding source: this identifies the source of the money (could be card or wallet)&lt;br /&gt;
* &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; (new) for the &#039;&#039;nature of the charge:&#039;&#039; this identifies the type of token payment scenario the merchant is conducting.&lt;br /&gt;
&lt;br /&gt;
This new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is generated and stored by the card issuer. The Id is available in the [[Payment-GetPaymentState-v2|GetPaymentState]] response once the charge is successfully completed.&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=CHANGE|text=The TraceId must processed from the [[Payment-GetPaymentState-v2|GetPaymentState]] response and must be attached to the payment in merchant&#039;s system. |color=#20c400}}&lt;br /&gt;
&lt;br /&gt;
Once the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is acquired it must be sent in the [[Payment-Start-v2|Payment/Start]] request to identify the scenario. This is crucial for the card transactions otherwise they could be declined. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=CHANGE|text=The TraceId must specified in the [[Payment-Start-v2|Payment/Start]] for the subsequent token charges. |color=#20c400}}&lt;br /&gt;
&lt;br /&gt;
== 3DS v2 authentication ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be conducted for every online card payment. These token payment scenarios also need to use these new secure way of authentication. &lt;br /&gt;
The initial payment must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Technical changes required =&lt;br /&gt;
The technical changes depend on what type of token scenario is needed for the business. It is important to notice that these scenarios can be implemented beside each other, a merchant is not required to choose only one type of token payment. The main goal is to appropriately use each scenario.&lt;br /&gt;
&lt;br /&gt;
== Technical changes for Recurring payments ==&lt;br /&gt;
&lt;br /&gt;
#&#039;&#039;&#039; For the token registration&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request the new properties have to be specified:&lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;RecurringPayment&amp;quot;&amp;lt;/code&amp;gt; to indicate the scenario&lt;br /&gt;
#* &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; for the limitations &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt; &lt;br /&gt;
#Once the callback is received get the response of [[Payment-GetPaymentState-v2|GetPaymentState]]. In case the charge was successful, there will be a &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; property for the payment. The value of it must be saved and attached to the payment.  &lt;br /&gt;
#&#039;&#039;&#039;For subsequent payments&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request specify the &lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;RecurringPayment&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
#* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; you received for the initial payment.&lt;br /&gt;
&lt;br /&gt;
== Technical changes for Merchant initiated payments ==&lt;br /&gt;
&lt;br /&gt;
#&#039;&#039;&#039; For the token registration&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request the new property has to be specified:&lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;MerchantInitiatedPayment&amp;quot;&amp;lt;/code&amp;gt; to indicate the scenario&lt;br /&gt;
#Once the callback is received get the response of [[Payment-GetPaymentState-v2|GetPaymentState]]. In case the charge was successful, there will be a &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; property for the payment. The value of it must be saved and attached to the payment.  &lt;br /&gt;
#&#039;&#039;&#039;For subsequent payments&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request specify the &lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;MerchantInitiatedPayment&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
#* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; you received for the initial payment.&lt;br /&gt;
&lt;br /&gt;
== Technical changes for One-click payments ==&lt;br /&gt;
&lt;br /&gt;
This modification needs the most attention since the merchant has to implement client-side functionality and add a new step at the end of the flow.&lt;br /&gt;
&lt;br /&gt;
#&#039;&#039;&#039; For the token registration&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request the new property has to be specified:&lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;OneClickPayment&amp;quot;&amp;lt;/code&amp;gt; to indicate the scenario&lt;br /&gt;
#&#039;&#039;&#039;For subsequent payments&#039;&#039;&#039; the merchant has to integrate the barion.offsitegw.js to be able to authenticate the payer via 3DS v2 on the merchant&#039;s site. To do this read the tutorial on [[Token_payment_3D_Secure#OneClick payment|how to integrate this]].&lt;br /&gt;
# After a successful authentication a new Barion API endpoint ([[Payment-Complete-v2|/Payment/Complete]]) must be called to finalize the process and charge the card&lt;br /&gt;
&lt;br /&gt;
Please notice that in case this scenario is used there is no need to use the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; since the 3DS authentication will be performed every time.&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=CHANGE|text=In case of one-click token scenario the merchant has to authenticate every card payment with 3DS v2|color=#20c400}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What happens if the merchant doesn&#039;t upgrade its implementation ==&lt;br /&gt;
&lt;br /&gt;
There will be a two-phase ramp-up period to make sure that integrations can be upgraded.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Until December 31, 2020&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In this period the integrations that are not up-to-date and are not capable to handle 3DS v2 transactions &#039;&#039;&#039;will work&#039;&#039;&#039;. &lt;br /&gt;
* New tokens can be initiated (without 3DSv2 information) and the 3DSv2 authentication will be performed by the Barion Smart Gateway.&lt;br /&gt;
* Subsequent payments can use existing tokens (RecurrenceId) without specifying the TraceId.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Between January 1 and January 31, 2021 &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In this period the integrations that are not up-to-date and are not capable to handle 3DS v2 transactions &#039;&#039;&#039;will work&#039;&#039;&#039;. However, to comply with the card scheme mandates Barion has to substitute the missing information.&lt;br /&gt;
* New tokens can be initiated (without 3DSv2 information) and the 3DSv2 authentication will be performed by the Barion Smart Gateway. The payment will be marked as an initial MIT transaction. The MerchantInitiatedPayment RecurrenceType will be used as a fallback.&lt;br /&gt;
* Subsequent payments can use existing tokens (RecurrenceId) without specifying the TraceId. They will be handled as the subsequent MIT payment of the initial transaction. The TraceId of the last successful payment will be filled in by Barion.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;After February 1, 2021&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Until this date, all integrations must be upgraded. &lt;br /&gt;
* New tokens can only be initiated with the appropriate 3DSv2 information (RecurrenceType set). Otherwise, the payment/start will result in a validation error.&lt;br /&gt;
* Subsequent payments can use existing tokens (RecurrenceId) without specifying the TraceId. They will be handled as the subsequent MIT payment of the initial transaction. The TraceId of the last successful payment will be filled in by Barion.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;After November 1, 2021&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Only tokens initiated with proper 3DS v2 authentication can be used.&lt;br /&gt;
* New tokens can only be initiated with the appropriate 3DSv2 information (RecurrenceType set). Otherwise, the payment/start will result in a validation error.&lt;br /&gt;
* Subsequent payments can only be performed with the appropriate TraceId or the merchant has to perform off-site authentication to acquire a new TraceId.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=SUPPORT|text=In case you have difficulties with the upgrade please contact our developers at devsupport@barion.com |color=#1993c7}}&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2881</id>
		<title>Token payment 3D Secure</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2881"/>
		<updated>2020-11-26T20:24:38Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* Example JSON request for a Recurring Payment scenario */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Token Payment with 3D Secure}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{IncompletePage}}&lt;br /&gt;
&lt;br /&gt;
This payment scenario allows the integrator shop to register a token for a customer (and a funding source) in the Barion system and then, later on, using this token, charge the customer without redirecting her to the Barion Smart Gateway UI. The user may be present at the site of the merchant or she can be off-session as well, so the merchant can charge her e.g. for subscriptions. This means that the customer authorizes the shop to charge her card or Barion balance without typing in the card information or Barion login again.&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurring.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=Premium feature|text=This scenario is not allowed automatically for every approved shop and should be requested from Barion!|color=#1993c7}}&lt;br /&gt;
&lt;br /&gt;
= Token payment scenarios =&lt;br /&gt;
Token payment can be used in three use cases: &lt;br /&gt;
* &#039;&#039;&#039;Customer Initiated Payments&#039;&#039;&#039;: when the user is present on the website of the merchant and she decides to pay :&lt;br /&gt;
** &#039;&#039;&#039;OneClick payment&#039;&#039;&#039;: the user is charged upon her request initiated on the website of the merchant. Subsequent payments are subject to PSD2 SCA and as the user is present, she has to go through the authentication process.&lt;br /&gt;
* &#039;&#039;&#039;Merchant Initiated Payments&#039;&#039;&#039;: when the merchant initiates the payment without the user being present. It has two subtypes:&lt;br /&gt;
** &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: the user is charged with the same amount on a regular basis, typically in case of subscriptions. Subsequent payments are exempted from PSD2 SCA, but liability still shifts to the card issuer.&lt;br /&gt;
** &#039;&#039;&#039;MIT (merchant initiated transaction)&#039;&#039;&#039;: the user is charged on an irregular basis and/or with a different amount. Subsequent payments of this type are excluded from PSD2 SCA, the liability is on the merchant.&lt;br /&gt;
&lt;br /&gt;
== Customer participation ==&lt;br /&gt;
&lt;br /&gt;
Since the token scenario is suitable for both customer and merchant initiated payments here is a comparison about who starts the payment. This includes the regular, non-tokenized payment scenario as well:&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot; | Scenario&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Initial payment&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW &lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW&lt;br /&gt;
|-&lt;br /&gt;
| Non token (regular) payment || YES || YES || YES || YES &lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || YES || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| MIT || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #aaa; background-color:#eee; font-size: 0.8em; padding:5px 10px; display:inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; Token payment scenarios can be initiated with already registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; as well, in this case the customer may remain on the merchant&#039;s site. &lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements for the scenarios ==&lt;br /&gt;
&lt;br /&gt;
These token payment scenarios have different requirements, this table below summarizes the key differences.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Payment amount&lt;br /&gt;
! Payment frequency&lt;br /&gt;
! Liability in case of fraud&lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || Various || Various || Card issuer&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || Subsequent amounts must be equal or less than the initial amount  || Initial payment must define a minimum amount of days to wait between charges || Card issuer &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || Various  || Various || Merchant&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 3DS authentication of the payer ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be performed for every online card payment. These token payment scenarios also have to use this new secure way of authentication. &lt;br /&gt;
The initial payment of a token scenario must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
Here is a table to compare the 3DS authentication requirements:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Initial payment&lt;br /&gt;
! Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
| One-click payment || ✔️ || ✔️&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Real life examples ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phone bill&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Payer has a usage-based phone subscription that wants to pay without being present for every charge. She authorizes the phone company to charge her card every month.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, the amount of the subsequent payments may exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TV subscription&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to online streaming of a television channel. She authorizes the tv company to charge her card every month. The subscription fee is the same for every month.&lt;br /&gt;
* Scenario: Recurring payment&lt;br /&gt;
* Explanation: The amount of the subsequent payments will not exceed the initial payment and the charge is regularly monthly-based.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bookclub with &amp;quot;free first month&amp;quot; bonus&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to a book renting service. he authorizes the book club to charge her card for a selection of books each month. The subscription fee is the same for every month however, the first month is free. To ensure the subscription the service requires her to register her card details.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, and the fee will stay the same, the initial payment is zero. So the amount of the next payment will exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Online food delivery service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The food delivery company wants to provide a quick and easy experience for its customer. They decide that the order will be quicker if the customers don&#039;t leave the website to pay for the goods.&lt;br /&gt;
* Scenario: OneClick payment&lt;br /&gt;
* Explanation: The customer will always be there so the other two scenarios are not available.&lt;br /&gt;
&lt;br /&gt;
== How to decide ==&lt;br /&gt;
&lt;br /&gt;
To help you decide on a suitable scenario, please use the decision graph below:&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurrencetype-decision.png|520px]]&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
To be able to integrate your webshop with the Barion Payment Gateway: &lt;br /&gt;
* You must [[Creating_an_account|register a Barion wallet]] at the Barion website or in the Sandbox environment. Learn more about the Sandbox environment [[Sandbox|here]].&lt;br /&gt;
* For this wallet you have to [[Creating_a_shop|create a shop]] which should be approved by Barion.&lt;br /&gt;
* For every currency you plan to conduct payments in you have to make sure there is an account created in your Barion wallet. This means that if you plan to have USD payments then there should be a USD account created in your wallet.&lt;br /&gt;
* To make sure every corner case scenario works for your webshop it is best to top up that account with a small amount (approx. 5-10EUR or your choice of currency around the same value).&lt;br /&gt;
* For the technical communication guide please read this: [[Calling_the_API|Calling the API]]&lt;br /&gt;
&lt;br /&gt;
= The payment process =&lt;br /&gt;
&lt;br /&gt;
The process is divided into two major steps:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 1:  Creating the funding source token|Creating the token]] that represents one of the customer&#039;s funding sources (credit card or e-money wallet)&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Preparing the payment via the Barion API&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Redirecting the customer to the Barion Smart Gateway to select a funding source&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Processing the callback and requesting information about the result of the payment&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 2: Using the token|Using the registered token]] to charge the customer&amp;lt;/li&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1:  Creating the funding source token ==&lt;br /&gt;
To be able to use a token payment scenario first the merchant has to register the token with Barion. The merchant has to make sure that the customer is well aware of the fact that they are giving consent to a tokenized payment. The Barion Smart Gateway UI does not indicate in any way that the payment is a token payment.&lt;br /&gt;
&lt;br /&gt;
The token is registered to the shop and not to the merchant&#039;s Barion account. So if the merchant has multiple shops in its Barion account, the registered tokens can not be shared among them even if the customer is the same. If you want to use tokens in multiple shops, please contact Barion in the Customer center.&lt;br /&gt;
&lt;br /&gt;
=== 1.1 Preparing the payment===&lt;br /&gt;
&lt;br /&gt;
The token registration is basically a [[Responsive_web_payment|normal payment]] with three extra properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* InitiateRecurrence&lt;br /&gt;
* RecurrenceId&lt;br /&gt;
* RecurrenceType&lt;br /&gt;
&lt;br /&gt;
==== InitiateRecurrence====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; is a bool property. If you set it to &#039;&#039;&#039;true&#039;&#039;&#039; then the payment gateway will consider the payment as a token registration. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This happens even if the customer is already has a registered token, so you are able to re-register a funding source or even a customer. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceId ====&lt;br /&gt;
The next required property for a token registration is the token itself. This is generated by the shop and has to be unique for every registration. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property of the [[Payment-Start-v2|Payment/Start]] request. This token must be saved in the webshops database. A &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; token represents the funding source (bank card or Barion balance) of a customer. Since a customer can have multiple cards and accounts as a funding source make sure that in the webshop&#039;s system multiple tokens can belong to a single customer.&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceType ====&lt;br /&gt;
The third required property is the [[RecurrenceType|Recurrence Type]]. This specifies the scenario. In case of Recurring Payment &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; must also be set.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Merchant Initiated Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The response will be the same as to a [[Responsive_web_payment#Processing_the_successful_response|basic &#039;&#039;&#039;Immediate&#039;&#039;&#039; scenario]]. The &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; property at this point is &#039;&#039;&#039;None&#039;&#039;&#039; since the token is not registered to a funding source yet.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Recurring Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Recurring Payment&#039;&#039;&#039; scenario has some extra restrictions. The merchant has to specify two additional properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt;: The date after subsequent charges should not be accepted.&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt;: The minimum days the merchant has to wait between payments.&lt;br /&gt;
&lt;br /&gt;
Both properties are located in the [[PurchaseInformation]] property and must be specified if this scenario is selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7, 30-33&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;PurchaseInformation&amp;quot;:{&lt;br /&gt;
        &amp;quot;RecurringFrequency&amp;quot;: 10,&lt;br /&gt;
        &amp;quot;RecurringExpiry&amp;quot;: &amp;quot;2022-10-01&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Possible error responses ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentNotAllowed || The token payment is not allowed for the shop identified by the &#039;&#039;&#039;POSKey&#039;&#039;&#039;. Contact Barion to request this feature.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 1.2 Redirecting the customer to the Barion Smart Gateway to select a funding source ===&lt;br /&gt;
&lt;br /&gt;
After a successful payment preparation, the customer is redirected to the secure Barion Smart Gateway to choose a funding source. The funding source the customer selects will be registered to the token. The funding source can either be a Barion e-money balance or a bank card. This means that even though the customer may own multiple cards only the one that was registered to the token can be used for future token payments. To change the funding source attached to the token a new registration should be requested.&lt;br /&gt;
&lt;br /&gt;
=== 1.3 Processing the callback and requesting information about the result of the payment ===&lt;br /&gt;
&lt;br /&gt;
When the payment is completed (either successfully or unsuccessfully) a callback message is sent to the merchant&#039;s system. Once received a [[Payment-GetPaymentState-v2|GetPaymentState]] request must be sent to the Barion API. On how to implement this please read the article about the  [[Callback_mechanism|Callback mechanism]].&lt;br /&gt;
&lt;br /&gt;
The full response of the GetPaymentState request depends on the payment scenario and the structure of the payment. When it comes to token payment there are several properties to look out for. &lt;br /&gt;
* In case the &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; is &#039;&#039;&#039;Succeeded&#039;&#039;&#039; the funding source token is registered and ready to use.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; contains the ID of the token process. This specifies the nature of the token payment. &lt;br /&gt;
&lt;br /&gt;
==== TraceId ====&lt;br /&gt;
&lt;br /&gt;
In case of Recurring payment or Merchant initiated payment scenarios the [[Payment-GetPaymentState-v2|GetPaymentState]] response returns an additional field called &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. The value of this property is generated by the card issuer. The merchant has to save it and submit it in all subsequent Recurring or Merchant initiated payments of the same type, otherwise, the payments can be declined by the issuer. The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; represents the first, customer-present payment and helps the issuer to connect subsequent payments to this initial payment.&lt;br /&gt;
&lt;br /&gt;
====Example GetPaymentState response====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;8, 11-12&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;OrderNumber&amp;quot;: null,&lt;br /&gt;
    &amp;quot;POSId&amp;quot;: &amp;quot;[[SHOPS_PUBLIC_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSName&amp;quot;: &amp;quot;[[MERCHANTS_BARION_SHOPNAME]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSOwnerEmail&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSource&amp;quot;: &amp;quot;BankCard&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;AllowedFundingSources&amp;quot;: [&lt;br /&gt;
        &amp;quot;All&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;GuestCheckout&amp;quot;: true,&lt;br /&gt;
    &amp;quot;CreatedAt&amp;quot;: &amp;quot;2020-11-26T07:52:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ValidUntil&amp;quot;: &amp;quot;2020-11-26T08:22:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;CompletedAt&amp;quot;: &amp;quot;2020-11-26T08:11:54.118Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ReservedUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;DelayedCaptureUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
           ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;Total&amp;quot;: 25.20,&lt;br /&gt;
    &amp;quot;SuggestedLocale&amp;quot;: &amp;quot;hu-HU&amp;quot;,&lt;br /&gt;
    &amp;quot;FraudRiskScore&amp;quot;: null,&lt;br /&gt;
    &amp;quot;RedirectUrl&amp;quot;: &amp;quot;https://merchanturl/Redirect?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;CallbackUrl&amp;quot;: &amp;quot;https://merchanturl/Callback?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Displaying the funding source in a GUI ====&lt;br /&gt;
We strongly advise saving the complete response for future reference. The &amp;lt;code&amp;gt;FundingSource&amp;lt;/code&amp;gt; field tells if the funding source is a Barion balance or a card. If it is a card, it is useful to save [[FundingInformation]] for displaying it for the user, when requesting future payments. The usual way to display funding sources is to show the last 4 digits of the card, with 4 stars, eg: *** 1234. The card used can be obtained from FundingInformation&#039;s [[BankCard]] field. The [[CardType]] field can be used to display the appropriate card logo. You can even show, if the card is expired, and offer to register another one.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; FundingInformation part of the GetPaymentState response &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=json&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be displayed for example as &amp;lt;code&amp;gt;VISA **** 0425 (12/20)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a request-response diagram of the token registration process:&lt;br /&gt;
 &lt;br /&gt;
[[File:Token_payment_initiation.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Step 2: Using the token =&lt;br /&gt;
&lt;br /&gt;
To use an already registered token for a payment, you have to use the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property. To be able to use a token, the initial payment must be in a successful state.&lt;br /&gt;
&lt;br /&gt;
At this point, the merchant has to decide whether this subsequent payment is used for the same token payment scenario or something changed. This is important because the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used for the same scenario, otherwise, the card issuer will decline the charge.&lt;br /&gt;
A &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used again if:&lt;br /&gt;
* the funding source is the same (technically the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* the token payment scenario is the same (technically the &amp;lt;code&amp;gt;RecurrenceType&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* this subsequent request complies with the scenario restrictions (eg: in case of recurring payment the amount of the subsequent payment does not exceed the initial amount)&lt;br /&gt;
&lt;br /&gt;
If the funding source changes, new &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the funding source|described in detail here]]. If the funding source stays the same but the scenario changes or the restrictions are no longer met new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the token payment scenario with an existing token|described here]].&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Recurring payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this case, three extra conditions must be met:&lt;br /&gt;
* the amount of the subsequent payment must not be higher than the initial amount&lt;br /&gt;
* at least that much days must be spent as defined in the initial &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; property&lt;br /&gt;
* the date of the payment must not exceed the day specified in the initial &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; property&lt;br /&gt;
&lt;br /&gt;
Please be aware that in case any of these are no longer valid the merchant has to request a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; as [[#Changing the token payment scenario with an existing token|described here]]. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=These conditions are not enforced by the Barion system so the violation of them will result in a declined charge.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
Payment/start must not include the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; properties (since they are already fixed during the initial payment).&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Recurring payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Merchant Initiated Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario there are no restrictions.&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Merchant Initiated Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 75,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Phone bill&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of OneClick Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario, the merchant has to prepare to perform the [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]] of the payer. 3DS authentication is not required in the following cases:&lt;br /&gt;
* the token (&amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;) was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is not used in this scenario since the payer is present during the transaction. &lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent OneClick Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 17,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Book: How to shop online&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;How to shop online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Book about shopping online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;piece&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
In this scenario, the response contains the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; property that is used to perform an [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8-9&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: &amp;quot;ewoJIkNhcmRQdWJs...WZXJzaW9uIjogIjIuMS4wIgp9Cg==&amp;quot;,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Possible error responses for the subsequent payment requests ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| InvalidRecurrenceId|| The token specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is invalid. Check if the token registration was successful.&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentDenied|| Something happened to the user since the token registration, either deleted, suspended, or blocked. The payment s not allowed in these cases.&lt;br /&gt;
|-&lt;br /&gt;
| InsufficientFunds|| If the original payment was with an e-money wallet and the customer doesn&#039;t have enough money to fulfill this charge this error happens.&lt;br /&gt;
|-&lt;br /&gt;
| OriginalPaymentWasntSuccessful || This means that the token belongs to an originally unsuccessful payment so this token can not be used anymore. This could only happen if the original payment was financed with a credit card.&lt;br /&gt;
|-&lt;br /&gt;
|InvalidCurrency || If the original payment was paid with e-money and the current token payment is in a currency that the wallet does not have an account in this error happens.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is the request-response diagram of the subsequent payments:&lt;br /&gt;
&lt;br /&gt;
[[File:Token_payment_2.png]]&lt;br /&gt;
&lt;br /&gt;
= Changing funding source or token scenarios =&lt;br /&gt;
&lt;br /&gt;
==Changing the funding source==&lt;br /&gt;
&lt;br /&gt;
This could happen if the funding source becomes invalid for some reason (card gets deleted or expires) or the merchant decides to use that token for another payer. In this case, the merchant has to register the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; again. &lt;br /&gt;
To do this a new payment must be started and in the [[Payment-Start-v2|Payment/Start]] request the following setup should be specified:&lt;br /&gt;
* the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; field has to be set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; &lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; has to be specified.&lt;br /&gt;
* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; should not be specified.&lt;br /&gt;
&lt;br /&gt;
[[File:Funding-source-change.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is bound to the payer and the process if the funding source changes new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be generated. This new ID must be saved to this payment and must be used from this moment on for subsequent payments.&lt;br /&gt;
&lt;br /&gt;
==Changing the token payment scenario with an existing token==&lt;br /&gt;
&lt;br /&gt;
This could occur when the merchant wants to get authorization from the payer to a new token scenario for the already registered funding source. To be able to do this the merchant has to have a valid and registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
Let&#039;s see some examples when this may be necessary:&lt;br /&gt;
* The payer subscribed to the merchant&#039;s service beforehand and the merchant decided to use the recurring payment token scenario. The payer wants to subscribe to another service and this requires a different payment schedule. This means that the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; that was specified initially can not be maintained so it is required to acquire a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;&lt;br /&gt;
* The payer bought something on the merchant&#039;s website and uses the one-click feature for subsequent fast non-redirect payments. After a while, the payer decides to subscribe to a service provided by this same merchant. This means that the merchant has to create a new token scenario (not a one-click payment but a recurring payment). For this, the merchant has to acquire a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. This can be done without redirecting the payer to Barion using the existing &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; and performing a 3DS authentication on the merchant&#039;s website.&lt;br /&gt;
&lt;br /&gt;
To do these a new payment must be started and in the [[Payment-Start-v2|Payment/Start]] request the following setup should be specified:&lt;br /&gt;
* the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; field has to be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; &lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; has to be specified.&lt;br /&gt;
* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; should not be specified.&lt;br /&gt;
&lt;br /&gt;
After this, a 3DS authentication has to be completed to acquire a new trace ID. This can be done on the merchant&#039;s site if the merchant implements the barion.offsitegw.js for off-site 3DS authentication.&lt;br /&gt;
&lt;br /&gt;
This means that it can be achieved to acquire different Trace IDs for different scenarios with only one &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
This is basically categorizing the different token scenarios as opposed to using every subsequent payment as an unmarked charge.&lt;br /&gt;
&lt;br /&gt;
[[File:Mutiple-traceid.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
= Off-site 3DS v2 authentication =&lt;br /&gt;
&lt;br /&gt;
In certain scenarios, the payer has to be authenticated to lower the risk of the card transaction. This can be either performed &lt;br /&gt;
* on the Barion Smart Gateway (on-site) by redirecting the customer to Barion &lt;br /&gt;
* or on the merchant&#039;s website (off-site) by integrating the Barion Off-site client library.&lt;br /&gt;
&lt;br /&gt;
This section describes how to integrate the Barion off-site authentication library into the merchant&#039;s site.&lt;br /&gt;
&lt;br /&gt;
== Step 1 : Initialize the off-site authentication library  ==&lt;br /&gt;
You have to include the following css and javascript files in the code of your site. &lt;br /&gt;
&amp;lt;source lang=html&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source &amp;gt;&lt;br /&gt;
These files include all the necessary javascript code and styling to handle the 3DS authentication and display the challenge if necessary.&lt;br /&gt;
&lt;br /&gt;
Then you have to initialize the Barion javascript client. To do that, you have to define a configuration object that specifies your functions that handle the off-site authentication events. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; Authentication events&#039;&#039;&#039;&lt;br /&gt;
* &amp;lt;code&amp;gt;onAuthenticationSucceeded&amp;lt;/code&amp;gt;: the 3DS v2 authentication successfully completed&lt;br /&gt;
* &amp;lt;code&amp;gt;onAuthenticationFailed&amp;lt;/code&amp;gt;:  the 3DS v2 authentication failed&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const configuration = {&lt;br /&gt;
    onAuthenticationSucceeded: function () {&lt;br /&gt;
        // handle successful authentication by calling the Barion API via merchant&#039;s backend&lt;br /&gt;
        // Call the v2/payment/complete endpoint&lt;br /&gt;
    },&lt;br /&gt;
    onAuthenticationFailed: function () {&lt;br /&gt;
        // Handle unsuccessful authentication result, no charge was made.&lt;br /&gt;
        // The payment might be still valid only the authentication failed&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to pass this config object to the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const gw = new Barion.OffsiteGw(configuration);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Step 2: Start the authentication process ===&lt;br /&gt;
Once the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; is acquired from the payment/start you can start the authentication process by calling the &amp;lt;code&amp;gt;authenticate()&amp;lt;/code&amp;gt; method of the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
gw.authenticate(threeDsClientData);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will start the authentication process and present the challenge if needed. Visually this will create a modal window over the merchant&#039;s site and show the payer every necessary information.&lt;br /&gt;
Once the authentication process finished (either with or without a challenge) the appropriate event will be fired. &lt;br /&gt;
&lt;br /&gt;
== Step 3: Completing the payment ==&lt;br /&gt;
&lt;br /&gt;
In case of successful authentication, you have to call our [[Payment-Complete-v3|/Payment/Complete]] endpoint, where the actual charge will happen.&lt;br /&gt;
&lt;br /&gt;
=== Possible error responses for the subsequent payment requests ===&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
== Suggested implementation flow for off-site authentication ==&lt;br /&gt;
&lt;br /&gt;
Ideally, an off-site authentication should be part of a client-side experience without any postbacks or page reloads. This is our recommendation to achieve this:&lt;br /&gt;
&lt;br /&gt;
# After the customer clicks on the &amp;quot;Pay&amp;quot; button make an AJAX call from your client-side code to your back-end. &lt;br /&gt;
# Have your backend make a request to our payment/start endpoint (with the appropriate settings for the desired token scenario)&lt;br /&gt;
# Have your backend process the response and pass the value of the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; property to your client-side code.&lt;br /&gt;
# Use the Barion off-site library to perform the authentication&lt;br /&gt;
# Once the authentication succeeds send another AJAX request from your client-side code to your back-end.&lt;br /&gt;
# Have your back-end code call our [[Payment-Complete-v3|/Payment/Complete]]&lt;br /&gt;
# Have your backend process the response and pass the result to your client-side code.&lt;br /&gt;
# Display the result for the customer&lt;br /&gt;
&lt;br /&gt;
= Testing the integration =&lt;br /&gt;
&lt;br /&gt;
3D Secure has no environment for end-to-end testing, therefore merchants have to split their testings into two parts: Testing the payment flow with and without challenge. Getting a challenge is only possible with real-life cards, merchants have to use their own (there will be no real charging at the end on the Sandbox of the Payment Gateway, but using a real card will result initiating a real 3DS authentication).&lt;br /&gt;
&lt;br /&gt;
== Testing the whole payment flow, without challenge ==&lt;br /&gt;
&lt;br /&gt;
Use the OTP test cards (to-be-defined), they will always get a &amp;quot;frictionless&amp;quot; flow, where the 3DS process is presented on the UI, but you will never see a challenge screen. &lt;br /&gt;
&lt;br /&gt;
This is good for testing your integration itself because it will lead to a successful charge, and you will get a TraceId as well.&lt;br /&gt;
&lt;br /&gt;
== Testing the challenge itself ==&lt;br /&gt;
&lt;br /&gt;
Use your own card, and let the card issuer decide whether your payment will get a challenge or not during the 3DS authentication procedure. Your payment will fail at the end, and you won&#039;t get the TraceId. &lt;br /&gt;
&lt;br /&gt;
This is good to test, how the challenge screens look like in your shop - especially when you integrated OneClick payment directly to your shop. You might also check how your customers see your checkout flow on popular devices.&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2880</id>
		<title>Token payment 3D Secure</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2880"/>
		<updated>2020-11-26T20:22:55Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* InitiateRecurrence */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Token Payment with 3D Secure}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{IncompletePage}}&lt;br /&gt;
&lt;br /&gt;
This payment scenario allows the integrator shop to register a token for a customer (and a funding source) in the Barion system and then, later on, using this token, charge the customer without redirecting her to the Barion Smart Gateway UI. The user may be present at the site of the merchant or she can be off-session as well, so the merchant can charge her e.g. for subscriptions. This means that the customer authorizes the shop to charge her card or Barion balance without typing in the card information or Barion login again.&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurring.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=Premium feature|text=This scenario is not allowed automatically for every approved shop and should be requested from Barion!|color=#1993c7}}&lt;br /&gt;
&lt;br /&gt;
= Token payment scenarios =&lt;br /&gt;
Token payment can be used in three use cases: &lt;br /&gt;
* &#039;&#039;&#039;Customer Initiated Payments&#039;&#039;&#039;: when the user is present on the website of the merchant and she decides to pay :&lt;br /&gt;
** &#039;&#039;&#039;OneClick payment&#039;&#039;&#039;: the user is charged upon her request initiated on the website of the merchant. Subsequent payments are subject to PSD2 SCA and as the user is present, she has to go through the authentication process.&lt;br /&gt;
* &#039;&#039;&#039;Merchant Initiated Payments&#039;&#039;&#039;: when the merchant initiates the payment without the user being present. It has two subtypes:&lt;br /&gt;
** &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: the user is charged with the same amount on a regular basis, typically in case of subscriptions. Subsequent payments are exempted from PSD2 SCA, but liability still shifts to the card issuer.&lt;br /&gt;
** &#039;&#039;&#039;MIT (merchant initiated transaction)&#039;&#039;&#039;: the user is charged on an irregular basis and/or with a different amount. Subsequent payments of this type are excluded from PSD2 SCA, the liability is on the merchant.&lt;br /&gt;
&lt;br /&gt;
== Customer participation ==&lt;br /&gt;
&lt;br /&gt;
Since the token scenario is suitable for both customer and merchant initiated payments here is a comparison about who starts the payment. This includes the regular, non-tokenized payment scenario as well:&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot; | Scenario&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Initial payment&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW &lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW&lt;br /&gt;
|-&lt;br /&gt;
| Non token (regular) payment || YES || YES || YES || YES &lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || YES || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| MIT || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #aaa; background-color:#eee; font-size: 0.8em; padding:5px 10px; display:inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; Token payment scenarios can be initiated with already registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; as well, in this case the customer may remain on the merchant&#039;s site. &lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements for the scenarios ==&lt;br /&gt;
&lt;br /&gt;
These token payment scenarios have different requirements, this table below summarizes the key differences.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Payment amount&lt;br /&gt;
! Payment frequency&lt;br /&gt;
! Liability in case of fraud&lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || Various || Various || Card issuer&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || Subsequent amounts must be equal or less than the initial amount  || Initial payment must define a minimum amount of days to wait between charges || Card issuer &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || Various  || Various || Merchant&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 3DS authentication of the payer ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be performed for every online card payment. These token payment scenarios also have to use this new secure way of authentication. &lt;br /&gt;
The initial payment of a token scenario must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
Here is a table to compare the 3DS authentication requirements:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Initial payment&lt;br /&gt;
! Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
| One-click payment || ✔️ || ✔️&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Real life examples ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phone bill&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Payer has a usage-based phone subscription that wants to pay without being present for every charge. She authorizes the phone company to charge her card every month.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, the amount of the subsequent payments may exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TV subscription&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to online streaming of a television channel. She authorizes the tv company to charge her card every month. The subscription fee is the same for every month.&lt;br /&gt;
* Scenario: Recurring payment&lt;br /&gt;
* Explanation: The amount of the subsequent payments will not exceed the initial payment and the charge is regularly monthly-based.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bookclub with &amp;quot;free first month&amp;quot; bonus&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to a book renting service. he authorizes the book club to charge her card for a selection of books each month. The subscription fee is the same for every month however, the first month is free. To ensure the subscription the service requires her to register her card details.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, and the fee will stay the same, the initial payment is zero. So the amount of the next payment will exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Online food delivery service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The food delivery company wants to provide a quick and easy experience for its customer. They decide that the order will be quicker if the customers don&#039;t leave the website to pay for the goods.&lt;br /&gt;
* Scenario: OneClick payment&lt;br /&gt;
* Explanation: The customer will always be there so the other two scenarios are not available.&lt;br /&gt;
&lt;br /&gt;
== How to decide ==&lt;br /&gt;
&lt;br /&gt;
To help you decide on a suitable scenario, please use the decision graph below:&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurrencetype-decision.png|520px]]&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
To be able to integrate your webshop with the Barion Payment Gateway: &lt;br /&gt;
* You must [[Creating_an_account|register a Barion wallet]] at the Barion website or in the Sandbox environment. Learn more about the Sandbox environment [[Sandbox|here]].&lt;br /&gt;
* For this wallet you have to [[Creating_a_shop|create a shop]] which should be approved by Barion.&lt;br /&gt;
* For every currency you plan to conduct payments in you have to make sure there is an account created in your Barion wallet. This means that if you plan to have USD payments then there should be a USD account created in your wallet.&lt;br /&gt;
* To make sure every corner case scenario works for your webshop it is best to top up that account with a small amount (approx. 5-10EUR or your choice of currency around the same value).&lt;br /&gt;
* For the technical communication guide please read this: [[Calling_the_API|Calling the API]]&lt;br /&gt;
&lt;br /&gt;
= The payment process =&lt;br /&gt;
&lt;br /&gt;
The process is divided into two major steps:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 1:  Creating the funding source token|Creating the token]] that represents one of the customer&#039;s funding sources (credit card or e-money wallet)&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Preparing the payment via the Barion API&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Redirecting the customer to the Barion Smart Gateway to select a funding source&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Processing the callback and requesting information about the result of the payment&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 2: Using the token|Using the registered token]] to charge the customer&amp;lt;/li&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1:  Creating the funding source token ==&lt;br /&gt;
To be able to use a token payment scenario first the merchant has to register the token with Barion. The merchant has to make sure that the customer is well aware of the fact that they are giving consent to a tokenized payment. The Barion Smart Gateway UI does not indicate in any way that the payment is a token payment.&lt;br /&gt;
&lt;br /&gt;
The token is registered to the shop and not to the merchant&#039;s Barion account. So if the merchant has multiple shops in its Barion account, the registered tokens can not be shared among them even if the customer is the same. If you want to use tokens in multiple shops, please contact Barion in the Customer center.&lt;br /&gt;
&lt;br /&gt;
=== 1.1 Preparing the payment===&lt;br /&gt;
&lt;br /&gt;
The token registration is basically a [[Responsive_web_payment|normal payment]] with three extra properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* InitiateRecurrence&lt;br /&gt;
* RecurrenceId&lt;br /&gt;
* RecurrenceType&lt;br /&gt;
&lt;br /&gt;
==== InitiateRecurrence====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; is a bool property. If you set it to &#039;&#039;&#039;true&#039;&#039;&#039; then the payment gateway will consider the payment as a token registration. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This happens even if the customer is already has a registered token, so you are able to re-register a funding source or even a customer. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceId ====&lt;br /&gt;
The next required property for a token registration is the token itself. This is generated by the shop and has to be unique for every registration. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property of the [[Payment-Start-v2|Payment/Start]] request. This token must be saved in the webshops database. A &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; token represents the funding source (bank card or Barion balance) of a customer. Since a customer can have multiple cards and accounts as a funding source make sure that in the webshop&#039;s system multiple tokens can belong to a single customer.&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceType ====&lt;br /&gt;
The third required property is the [[RecurrenceType|Recurrence Type]]. This specifies the scenario. In case of Recurring Payment &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; must also be set.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Merchant Initiated Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The response will be the same as to a [[Responsive_web_payment#Processing_the_successful_response|basic &#039;&#039;&#039;Immediate&#039;&#039;&#039; scenario]]. The &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; property at this point is &#039;&#039;&#039;None&#039;&#039;&#039; since the token is not registered to a funding source yet.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Recurring Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Recurring Payment&#039;&#039;&#039; scenario has some extra restrictions. The merchant has to specify two additional properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt;: The date after the subsequent charges should not accepted.&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt;: The minimum days the merchant has to wait between payments.&lt;br /&gt;
&lt;br /&gt;
Both properties are located in the [[PurchaseInformation]] property and must be specified if this scenario is selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7, 30-33&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;PurchaseInformation&amp;quot;:{&lt;br /&gt;
        &amp;quot;RecurringFrequency&amp;quot;: 10,&lt;br /&gt;
        &amp;quot;RecurringExpiry&amp;quot;: &amp;quot;2022-10-01&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Possible error responses ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentNotAllowed || The token payment is not allowed for the shop identified by the &#039;&#039;&#039;POSKey&#039;&#039;&#039;. Contact Barion to request this feature.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 1.2 Redirecting the customer to the Barion Smart Gateway to select a funding source ===&lt;br /&gt;
&lt;br /&gt;
After a successful payment preparation, the customer is redirected to the secure Barion Smart Gateway to choose a funding source. The funding source the customer selects will be registered to the token. The funding source can either be a Barion e-money balance or a bank card. This means that even though the customer may own multiple cards only the one that was registered to the token can be used for future token payments. To change the funding source attached to the token a new registration should be requested.&lt;br /&gt;
&lt;br /&gt;
=== 1.3 Processing the callback and requesting information about the result of the payment ===&lt;br /&gt;
&lt;br /&gt;
When the payment is completed (either successfully or unsuccessfully) a callback message is sent to the merchant&#039;s system. Once received a [[Payment-GetPaymentState-v2|GetPaymentState]] request must be sent to the Barion API. On how to implement this please read the article about the  [[Callback_mechanism|Callback mechanism]].&lt;br /&gt;
&lt;br /&gt;
The full response of the GetPaymentState request depends on the payment scenario and the structure of the payment. When it comes to token payment there are several properties to look out for. &lt;br /&gt;
* In case the &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; is &#039;&#039;&#039;Succeeded&#039;&#039;&#039; the funding source token is registered and ready to use.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; contains the ID of the token process. This specifies the nature of the token payment. &lt;br /&gt;
&lt;br /&gt;
==== TraceId ====&lt;br /&gt;
&lt;br /&gt;
In case of Recurring payment or Merchant initiated payment scenarios the [[Payment-GetPaymentState-v2|GetPaymentState]] response returns an additional field called &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. The value of this property is generated by the card issuer. The merchant has to save it and submit it in all subsequent Recurring or Merchant initiated payments of the same type, otherwise, the payments can be declined by the issuer. The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; represents the first, customer-present payment and helps the issuer to connect subsequent payments to this initial payment.&lt;br /&gt;
&lt;br /&gt;
====Example GetPaymentState response====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;8, 11-12&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;OrderNumber&amp;quot;: null,&lt;br /&gt;
    &amp;quot;POSId&amp;quot;: &amp;quot;[[SHOPS_PUBLIC_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSName&amp;quot;: &amp;quot;[[MERCHANTS_BARION_SHOPNAME]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSOwnerEmail&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSource&amp;quot;: &amp;quot;BankCard&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;AllowedFundingSources&amp;quot;: [&lt;br /&gt;
        &amp;quot;All&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;GuestCheckout&amp;quot;: true,&lt;br /&gt;
    &amp;quot;CreatedAt&amp;quot;: &amp;quot;2020-11-26T07:52:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ValidUntil&amp;quot;: &amp;quot;2020-11-26T08:22:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;CompletedAt&amp;quot;: &amp;quot;2020-11-26T08:11:54.118Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ReservedUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;DelayedCaptureUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
           ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;Total&amp;quot;: 25.20,&lt;br /&gt;
    &amp;quot;SuggestedLocale&amp;quot;: &amp;quot;hu-HU&amp;quot;,&lt;br /&gt;
    &amp;quot;FraudRiskScore&amp;quot;: null,&lt;br /&gt;
    &amp;quot;RedirectUrl&amp;quot;: &amp;quot;https://merchanturl/Redirect?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;CallbackUrl&amp;quot;: &amp;quot;https://merchanturl/Callback?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Displaying the funding source in a GUI ====&lt;br /&gt;
We strongly advise saving the complete response for future reference. The &amp;lt;code&amp;gt;FundingSource&amp;lt;/code&amp;gt; field tells if the funding source is a Barion balance or a card. If it is a card, it is useful to save [[FundingInformation]] for displaying it for the user, when requesting future payments. The usual way to display funding sources is to show the last 4 digits of the card, with 4 stars, eg: *** 1234. The card used can be obtained from FundingInformation&#039;s [[BankCard]] field. The [[CardType]] field can be used to display the appropriate card logo. You can even show, if the card is expired, and offer to register another one.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; FundingInformation part of the GetPaymentState response &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=json&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be displayed for example as &amp;lt;code&amp;gt;VISA **** 0425 (12/20)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a request-response diagram of the token registration process:&lt;br /&gt;
 &lt;br /&gt;
[[File:Token_payment_initiation.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Step 2: Using the token =&lt;br /&gt;
&lt;br /&gt;
To use an already registered token for a payment, you have to use the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property. To be able to use a token, the initial payment must be in a successful state.&lt;br /&gt;
&lt;br /&gt;
At this point, the merchant has to decide whether this subsequent payment is used for the same token payment scenario or something changed. This is important because the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used for the same scenario, otherwise, the card issuer will decline the charge.&lt;br /&gt;
A &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used again if:&lt;br /&gt;
* the funding source is the same (technically the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* the token payment scenario is the same (technically the &amp;lt;code&amp;gt;RecurrenceType&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* this subsequent request complies with the scenario restrictions (eg: in case of recurring payment the amount of the subsequent payment does not exceed the initial amount)&lt;br /&gt;
&lt;br /&gt;
If the funding source changes, new &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the funding source|described in detail here]]. If the funding source stays the same but the scenario changes or the restrictions are no longer met new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the token payment scenario with an existing token|described here]].&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Recurring payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this case, three extra conditions must be met:&lt;br /&gt;
* the amount of the subsequent payment must not be higher than the initial amount&lt;br /&gt;
* at least that much days must be spent as defined in the initial &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; property&lt;br /&gt;
* the date of the payment must not exceed the day specified in the initial &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; property&lt;br /&gt;
&lt;br /&gt;
Please be aware that in case any of these are no longer valid the merchant has to request a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; as [[#Changing the token payment scenario with an existing token|described here]]. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=These conditions are not enforced by the Barion system so the violation of them will result in a declined charge.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
Payment/start must not include the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; properties (since they are already fixed during the initial payment).&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Recurring payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Merchant Initiated Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario there are no restrictions.&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Merchant Initiated Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 75,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Phone bill&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of OneClick Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario, the merchant has to prepare to perform the [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]] of the payer. 3DS authentication is not required in the following cases:&lt;br /&gt;
* the token (&amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;) was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is not used in this scenario since the payer is present during the transaction. &lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent OneClick Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 17,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Book: How to shop online&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;How to shop online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Book about shopping online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;piece&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
In this scenario, the response contains the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; property that is used to perform an [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8-9&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: &amp;quot;ewoJIkNhcmRQdWJs...WZXJzaW9uIjogIjIuMS4wIgp9Cg==&amp;quot;,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Possible error responses for the subsequent payment requests ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| InvalidRecurrenceId|| The token specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is invalid. Check if the token registration was successful.&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentDenied|| Something happened to the user since the token registration, either deleted, suspended, or blocked. The payment s not allowed in these cases.&lt;br /&gt;
|-&lt;br /&gt;
| InsufficientFunds|| If the original payment was with an e-money wallet and the customer doesn&#039;t have enough money to fulfill this charge this error happens.&lt;br /&gt;
|-&lt;br /&gt;
| OriginalPaymentWasntSuccessful || This means that the token belongs to an originally unsuccessful payment so this token can not be used anymore. This could only happen if the original payment was financed with a credit card.&lt;br /&gt;
|-&lt;br /&gt;
|InvalidCurrency || If the original payment was paid with e-money and the current token payment is in a currency that the wallet does not have an account in this error happens.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is the request-response diagram of the subsequent payments:&lt;br /&gt;
&lt;br /&gt;
[[File:Token_payment_2.png]]&lt;br /&gt;
&lt;br /&gt;
= Changing funding source or token scenarios =&lt;br /&gt;
&lt;br /&gt;
==Changing the funding source==&lt;br /&gt;
&lt;br /&gt;
This could happen if the funding source becomes invalid for some reason (card gets deleted or expires) or the merchant decides to use that token for another payer. In this case, the merchant has to register the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; again. &lt;br /&gt;
To do this a new payment must be started and in the [[Payment-Start-v2|Payment/Start]] request the following setup should be specified:&lt;br /&gt;
* the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; field has to be set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; &lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; has to be specified.&lt;br /&gt;
* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; should not be specified.&lt;br /&gt;
&lt;br /&gt;
[[File:Funding-source-change.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is bound to the payer and the process if the funding source changes new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be generated. This new ID must be saved to this payment and must be used from this moment on for subsequent payments.&lt;br /&gt;
&lt;br /&gt;
==Changing the token payment scenario with an existing token==&lt;br /&gt;
&lt;br /&gt;
This could occur when the merchant wants to get authorization from the payer to a new token scenario for the already registered funding source. To be able to do this the merchant has to have a valid and registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
Let&#039;s see some examples when this may be necessary:&lt;br /&gt;
* The payer subscribed to the merchant&#039;s service beforehand and the merchant decided to use the recurring payment token scenario. The payer wants to subscribe to another service and this requires a different payment schedule. This means that the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; that was specified initially can not be maintained so it is required to acquire a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;&lt;br /&gt;
* The payer bought something on the merchant&#039;s website and uses the one-click feature for subsequent fast non-redirect payments. After a while, the payer decides to subscribe to a service provided by this same merchant. This means that the merchant has to create a new token scenario (not a one-click payment but a recurring payment). For this, the merchant has to acquire a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. This can be done without redirecting the payer to Barion using the existing &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; and performing a 3DS authentication on the merchant&#039;s website.&lt;br /&gt;
&lt;br /&gt;
To do these a new payment must be started and in the [[Payment-Start-v2|Payment/Start]] request the following setup should be specified:&lt;br /&gt;
* the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; field has to be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; &lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; has to be specified.&lt;br /&gt;
* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; should not be specified.&lt;br /&gt;
&lt;br /&gt;
After this, a 3DS authentication has to be completed to acquire a new trace ID. This can be done on the merchant&#039;s site if the merchant implements the barion.offsitegw.js for off-site 3DS authentication.&lt;br /&gt;
&lt;br /&gt;
This means that it can be achieved to acquire different Trace IDs for different scenarios with only one &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
This is basically categorizing the different token scenarios as opposed to using every subsequent payment as an unmarked charge.&lt;br /&gt;
&lt;br /&gt;
[[File:Mutiple-traceid.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
= Off-site 3DS v2 authentication =&lt;br /&gt;
&lt;br /&gt;
In certain scenarios, the payer has to be authenticated to lower the risk of the card transaction. This can be either performed &lt;br /&gt;
* on the Barion Smart Gateway (on-site) by redirecting the customer to Barion &lt;br /&gt;
* or on the merchant&#039;s website (off-site) by integrating the Barion Off-site client library.&lt;br /&gt;
&lt;br /&gt;
This section describes how to integrate the Barion off-site authentication library into the merchant&#039;s site.&lt;br /&gt;
&lt;br /&gt;
== Step 1 : Initialize the off-site authentication library  ==&lt;br /&gt;
You have to include the following css and javascript files in the code of your site. &lt;br /&gt;
&amp;lt;source lang=html&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source &amp;gt;&lt;br /&gt;
These files include all the necessary javascript code and styling to handle the 3DS authentication and display the challenge if necessary.&lt;br /&gt;
&lt;br /&gt;
Then you have to initialize the Barion javascript client. To do that, you have to define a configuration object that specifies your functions that handle the off-site authentication events. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; Authentication events&#039;&#039;&#039;&lt;br /&gt;
* &amp;lt;code&amp;gt;onAuthenticationSucceeded&amp;lt;/code&amp;gt;: the 3DS v2 authentication successfully completed&lt;br /&gt;
* &amp;lt;code&amp;gt;onAuthenticationFailed&amp;lt;/code&amp;gt;:  the 3DS v2 authentication failed&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const configuration = {&lt;br /&gt;
    onAuthenticationSucceeded: function () {&lt;br /&gt;
        // handle successful authentication by calling the Barion API via merchant&#039;s backend&lt;br /&gt;
        // Call the v2/payment/complete endpoint&lt;br /&gt;
    },&lt;br /&gt;
    onAuthenticationFailed: function () {&lt;br /&gt;
        // Handle unsuccessful authentication result, no charge was made.&lt;br /&gt;
        // The payment might be still valid only the authentication failed&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to pass this config object to the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const gw = new Barion.OffsiteGw(configuration);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Step 2: Start the authentication process ===&lt;br /&gt;
Once the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; is acquired from the payment/start you can start the authentication process by calling the &amp;lt;code&amp;gt;authenticate()&amp;lt;/code&amp;gt; method of the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
gw.authenticate(threeDsClientData);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will start the authentication process and present the challenge if needed. Visually this will create a modal window over the merchant&#039;s site and show the payer every necessary information.&lt;br /&gt;
Once the authentication process finished (either with or without a challenge) the appropriate event will be fired. &lt;br /&gt;
&lt;br /&gt;
== Step 3: Completing the payment ==&lt;br /&gt;
&lt;br /&gt;
In case of successful authentication, you have to call our [[Payment-Complete-v3|/Payment/Complete]] endpoint, where the actual charge will happen.&lt;br /&gt;
&lt;br /&gt;
=== Possible error responses for the subsequent payment requests ===&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
== Suggested implementation flow for off-site authentication ==&lt;br /&gt;
&lt;br /&gt;
Ideally, an off-site authentication should be part of a client-side experience without any postbacks or page reloads. This is our recommendation to achieve this:&lt;br /&gt;
&lt;br /&gt;
# After the customer clicks on the &amp;quot;Pay&amp;quot; button make an AJAX call from your client-side code to your back-end. &lt;br /&gt;
# Have your backend make a request to our payment/start endpoint (with the appropriate settings for the desired token scenario)&lt;br /&gt;
# Have your backend process the response and pass the value of the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; property to your client-side code.&lt;br /&gt;
# Use the Barion off-site library to perform the authentication&lt;br /&gt;
# Once the authentication succeeds send another AJAX request from your client-side code to your back-end.&lt;br /&gt;
# Have your back-end code call our [[Payment-Complete-v3|/Payment/Complete]]&lt;br /&gt;
# Have your backend process the response and pass the result to your client-side code.&lt;br /&gt;
# Display the result for the customer&lt;br /&gt;
&lt;br /&gt;
= Testing the integration =&lt;br /&gt;
&lt;br /&gt;
3D Secure has no environment for end-to-end testing, therefore merchants have to split their testings into two parts: Testing the payment flow with and without challenge. Getting a challenge is only possible with real-life cards, merchants have to use their own (there will be no real charging at the end on the Sandbox of the Payment Gateway, but using a real card will result initiating a real 3DS authentication).&lt;br /&gt;
&lt;br /&gt;
== Testing the whole payment flow, without challenge ==&lt;br /&gt;
&lt;br /&gt;
Use the OTP test cards (to-be-defined), they will always get a &amp;quot;frictionless&amp;quot; flow, where the 3DS process is presented on the UI, but you will never see a challenge screen. &lt;br /&gt;
&lt;br /&gt;
This is good for testing your integration itself because it will lead to a successful charge, and you will get a TraceId as well.&lt;br /&gt;
&lt;br /&gt;
== Testing the challenge itself ==&lt;br /&gt;
&lt;br /&gt;
Use your own card, and let the card issuer decide whether your payment will get a challenge or not during the 3DS authentication procedure. Your payment will fail at the end, and you won&#039;t get the TraceId. &lt;br /&gt;
&lt;br /&gt;
This is good to test, how the challenge screens look like in your shop - especially when you integrated OneClick payment directly to your shop. You might also check how your customers see your checkout flow on popular devices.&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2879</id>
		<title>Token payment 3D Secure</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2879"/>
		<updated>2020-11-26T15:44:13Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* Real life examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Token Payment with 3D Secure}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{IncompletePage}}&lt;br /&gt;
&lt;br /&gt;
This payment scenario allows the integrator shop to register a token for a customer (and a funding source) in the Barion system and then, later on, using this token, charge the customer without redirecting her to the Barion Smart Gateway UI. The user may be present at the site of the merchant or she can be off-session as well, so the merchant can charge her e.g. for subscriptions. This means that the customer authorizes the shop to charge her card or Barion balance without typing in the card information or Barion login again.&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurring.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=Premium feature|text=This scenario is not allowed automatically for every approved shop and should be requested from Barion!|color=#1993c7}}&lt;br /&gt;
&lt;br /&gt;
= Token payment scenarios =&lt;br /&gt;
Token payment can be used in three use cases: &lt;br /&gt;
* &#039;&#039;&#039;Customer Initiated Payments&#039;&#039;&#039;: when the user is present on the website of the merchant and she decides to pay :&lt;br /&gt;
** &#039;&#039;&#039;OneClick payment&#039;&#039;&#039;: the user is charged upon her request initiated on the website of the merchant. Subsequent payments are subject to PSD2 SCA and as the user is present, she has to go through the authentication process.&lt;br /&gt;
* &#039;&#039;&#039;Merchant Initiated Payments&#039;&#039;&#039;: when the merchant initiates the payment without the user being present. It has two subtypes:&lt;br /&gt;
** &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: the user is charged with the same amount on a regular basis, typically in case of subscriptions. Subsequent payments are exempted from PSD2 SCA, but liability still shifts to the card issuer.&lt;br /&gt;
** &#039;&#039;&#039;MIT (merchant initiated transaction)&#039;&#039;&#039;: the user is charged on an irregular basis and/or with a different amount. Subsequent payments of this type are excluded from PSD2 SCA, the liability is on the merchant.&lt;br /&gt;
&lt;br /&gt;
== Customer participation ==&lt;br /&gt;
&lt;br /&gt;
Since the token scenario is suitable for both customer and merchant initiated payments here is a comparison about who starts the payment. This includes the regular, non-tokenized payment scenario as well:&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot; | Scenario&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Initial payment&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW &lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW&lt;br /&gt;
|-&lt;br /&gt;
| Non token (regular) payment || YES || YES || YES || YES &lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || YES || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| MIT || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #aaa; background-color:#eee; font-size: 0.8em; padding:5px 10px; display:inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; Token payment scenarios can be initiated with already registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; as well, in this case the customer may remain on the merchant&#039;s site. &lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements for the scenarios ==&lt;br /&gt;
&lt;br /&gt;
These token payment scenarios have different requirements, this table below summarizes the key differences.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Payment amount&lt;br /&gt;
! Payment frequency&lt;br /&gt;
! Liability in case of fraud&lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || Various || Various || Card issuer&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || Subsequent amounts must be equal or less than the initial amount  || Initial payment must define a minimum amount of days to wait between charges || Card issuer &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || Various  || Various || Merchant&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 3DS authentication of the payer ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be performed for every online card payment. These token payment scenarios also have to use this new secure way of authentication. &lt;br /&gt;
The initial payment of a token scenario must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
Here is a table to compare the 3DS authentication requirements:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Initial payment&lt;br /&gt;
! Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
| One-click payment || ✔️ || ✔️&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Real life examples ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phone bill&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Payer has a usage-based phone subscription that wants to pay without being present for every charge. She authorizes the phone company to charge her card every month.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, the amount of the subsequent payments may exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TV subscription&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to online streaming of a television channel. She authorizes the tv company to charge her card every month. The subscription fee is the same for every month.&lt;br /&gt;
* Scenario: Recurring payment&lt;br /&gt;
* Explanation: The amount of the subsequent payments will not exceed the initial payment and the charge is regularly monthly-based.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bookclub with &amp;quot;free first month&amp;quot; bonus&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to a book renting service. he authorizes the book club to charge her card for a selection of books each month. The subscription fee is the same for every month however, the first month is free. To ensure the subscription the service requires her to register her card details.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, and the fee will stay the same, the initial payment is zero. So the amount of the next payment will exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Online food delivery service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The food delivery company wants to provide a quick and easy experience for its customer. They decide that the order will be quicker if the customers don&#039;t leave the website to pay for the goods.&lt;br /&gt;
* Scenario: OneClick payment&lt;br /&gt;
* Explanation: The customer will always be there so the other two scenarios are not available.&lt;br /&gt;
&lt;br /&gt;
== How to decide ==&lt;br /&gt;
&lt;br /&gt;
To help you decide on a suitable scenario, please use the decision graph below:&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurrencetype-decision.png|520px]]&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
To be able to integrate your webshop with the Barion Payment Gateway: &lt;br /&gt;
* You must [[Creating_an_account|register a Barion wallet]] at the Barion website or in the Sandbox environment. Learn more about the Sandbox environment [[Sandbox|here]].&lt;br /&gt;
* For this wallet you have to [[Creating_a_shop|create a shop]] which should be approved by Barion.&lt;br /&gt;
* For every currency you plan to conduct payments in you have to make sure there is an account created in your Barion wallet. This means that if you plan to have USD payments then there should be a USD account created in your wallet.&lt;br /&gt;
* To make sure every corner case scenario works for your webshop it is best to top up that account with a small amount (approx. 5-10EUR or your choice of currency around the same value).&lt;br /&gt;
* For the technical communication guide please read this: [[Calling_the_API|Calling the API]]&lt;br /&gt;
&lt;br /&gt;
= The payment process =&lt;br /&gt;
&lt;br /&gt;
The process is divided into two major steps:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 1:  Creating the funding source token|Creating the token]] that represents one of the customer&#039;s funding sources (credit card or e-money wallet)&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Preparing the payment via the Barion API&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Redirecting the customer to the Barion Smart Gateway to select a funding source&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Processing the callback and requesting information about the result of the payment&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 2: Using the token|Using the registered token]] to charge the customer&amp;lt;/li&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1:  Creating the funding source token ==&lt;br /&gt;
To be able to use a token payment scenario first the merchant has to register the token with Barion. The merchant has to make sure that the customer is well aware of the fact that they are giving consent to a tokenized payment. The Barion Smart Gateway UI does not indicate in any way that the payment is a token payment.&lt;br /&gt;
&lt;br /&gt;
The token is registered to the shop and not to the merchant&#039;s Barion account. So if the merchant has multiple shops in its Barion account, the registered tokens can not be shared among them even if the customer is the same. If you want to use tokens in multiple shops, please contact Barion in the Customer center.&lt;br /&gt;
&lt;br /&gt;
=== 1.1 Preparing the payment===&lt;br /&gt;
&lt;br /&gt;
The token registration is basically a [[Responsive_web_payment|normal payment]] with three extra properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* InitiateRecurrence&lt;br /&gt;
* RecurrenceId&lt;br /&gt;
* RecurrenceType&lt;br /&gt;
&lt;br /&gt;
==== InitiateRecurrence====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; property is a bool property. If you set it to &#039;&#039;&#039;true&#039;&#039;&#039; then the payment gateway will consider the payment as a token registration. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This happens even if the customer is already has a registered token, so you are able to re-register a funding source or even a customer. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceId ====&lt;br /&gt;
The next required property for a token registration is the token itself. This is generated by the shop and has to be unique for every registration. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property of the [[Payment-Start-v2|Payment/Start]] request. This token must be saved in the webshops database. A &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; token represents the funding source (bank card or Barion balance) of a customer. Since a customer can have multiple cards and accounts as a funding source make sure that in the webshop&#039;s system multiple tokens can belong to a single customer.&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceType ====&lt;br /&gt;
The third required property is the [[RecurrenceType|Recurrence Type]]. This specifies the scenario. In case of Recurring Payment &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; must also be set.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Merchant Initiated Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The response will be the same as to a [[Responsive_web_payment#Processing_the_successful_response|basic &#039;&#039;&#039;Immediate&#039;&#039;&#039; scenario]]. The &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; property at this point is &#039;&#039;&#039;None&#039;&#039;&#039; since the token is not registered to a funding source yet.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Recurring Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Recurring Payment&#039;&#039;&#039; scenario has some extra restrictions. The merchant has to specify two additional properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt;: The date after the subsequent charges should not accepted.&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt;: The minimum days the merchant has to wait between payments.&lt;br /&gt;
&lt;br /&gt;
Both properties are located in the [[PurchaseInformation]] property and must be specified if this scenario is selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7, 30-33&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;PurchaseInformation&amp;quot;:{&lt;br /&gt;
        &amp;quot;RecurringFrequency&amp;quot;: 10,&lt;br /&gt;
        &amp;quot;RecurringExpiry&amp;quot;: &amp;quot;2022-10-01&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Possible error responses ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentNotAllowed || The token payment is not allowed for the shop identified by the &#039;&#039;&#039;POSKey&#039;&#039;&#039;. Contact Barion to request this feature.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 1.2 Redirecting the customer to the Barion Smart Gateway to select a funding source ===&lt;br /&gt;
&lt;br /&gt;
After a successful payment preparation, the customer is redirected to the secure Barion Smart Gateway to choose a funding source. The funding source the customer selects will be registered to the token. The funding source can either be a Barion e-money balance or a bank card. This means that even though the customer may own multiple cards only the one that was registered to the token can be used for future token payments. To change the funding source attached to the token a new registration should be requested.&lt;br /&gt;
&lt;br /&gt;
=== 1.3 Processing the callback and requesting information about the result of the payment ===&lt;br /&gt;
&lt;br /&gt;
When the payment is completed (either successfully or unsuccessfully) a callback message is sent to the merchant&#039;s system. Once received a [[Payment-GetPaymentState-v2|GetPaymentState]] request must be sent to the Barion API. On how to implement this please read the article about the  [[Callback_mechanism|Callback mechanism]].&lt;br /&gt;
&lt;br /&gt;
The full response of the GetPaymentState request depends on the payment scenario and the structure of the payment. When it comes to token payment there are several properties to look out for. &lt;br /&gt;
* In case the &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; is &#039;&#039;&#039;Succeeded&#039;&#039;&#039; the funding source token is registered and ready to use.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; contains the ID of the token process. This specifies the nature of the token payment. &lt;br /&gt;
&lt;br /&gt;
==== TraceId ====&lt;br /&gt;
&lt;br /&gt;
In case of Recurring payment or Merchant initiated payment scenarios the [[Payment-GetPaymentState-v2|GetPaymentState]] response returns an additional field called &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. The value of this property is generated by the card issuer. The merchant has to save it and submit it in all subsequent Recurring or Merchant initiated payments of the same type, otherwise, the payments can be declined by the issuer. The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; represents the first, customer-present payment and helps the issuer to connect subsequent payments to this initial payment.&lt;br /&gt;
&lt;br /&gt;
====Example GetPaymentState response====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;8, 11-12&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;OrderNumber&amp;quot;: null,&lt;br /&gt;
    &amp;quot;POSId&amp;quot;: &amp;quot;[[SHOPS_PUBLIC_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSName&amp;quot;: &amp;quot;[[MERCHANTS_BARION_SHOPNAME]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSOwnerEmail&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSource&amp;quot;: &amp;quot;BankCard&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;AllowedFundingSources&amp;quot;: [&lt;br /&gt;
        &amp;quot;All&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;GuestCheckout&amp;quot;: true,&lt;br /&gt;
    &amp;quot;CreatedAt&amp;quot;: &amp;quot;2020-11-26T07:52:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ValidUntil&amp;quot;: &amp;quot;2020-11-26T08:22:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;CompletedAt&amp;quot;: &amp;quot;2020-11-26T08:11:54.118Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ReservedUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;DelayedCaptureUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
           ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;Total&amp;quot;: 25.20,&lt;br /&gt;
    &amp;quot;SuggestedLocale&amp;quot;: &amp;quot;hu-HU&amp;quot;,&lt;br /&gt;
    &amp;quot;FraudRiskScore&amp;quot;: null,&lt;br /&gt;
    &amp;quot;RedirectUrl&amp;quot;: &amp;quot;https://merchanturl/Redirect?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;CallbackUrl&amp;quot;: &amp;quot;https://merchanturl/Callback?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Displaying the funding source in a GUI ====&lt;br /&gt;
We strongly advise saving the complete response for future reference. The &amp;lt;code&amp;gt;FundingSource&amp;lt;/code&amp;gt; field tells if the funding source is a Barion balance or a card. If it is a card, it is useful to save [[FundingInformation]] for displaying it for the user, when requesting future payments. The usual way to display funding sources is to show the last 4 digits of the card, with 4 stars, eg: *** 1234. The card used can be obtained from FundingInformation&#039;s [[BankCard]] field. The [[CardType]] field can be used to display the appropriate card logo. You can even show, if the card is expired, and offer to register another one.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; FundingInformation part of the GetPaymentState response &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=json&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be displayed for example as &amp;lt;code&amp;gt;VISA **** 0425 (12/20)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a request-response diagram of the token registration process:&lt;br /&gt;
 &lt;br /&gt;
[[File:Token_payment_initiation.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Step 2: Using the token =&lt;br /&gt;
&lt;br /&gt;
To use an already registered token for a payment, you have to use the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property. To be able to use a token, the initial payment must be in a successful state.&lt;br /&gt;
&lt;br /&gt;
At this point, the merchant has to decide whether this subsequent payment is used for the same token payment scenario or something changed. This is important because the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used for the same scenario, otherwise, the card issuer will decline the charge.&lt;br /&gt;
A &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used again if:&lt;br /&gt;
* the funding source is the same (technically the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* the token payment scenario is the same (technically the &amp;lt;code&amp;gt;RecurrenceType&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* this subsequent request complies with the scenario restrictions (eg: in case of recurring payment the amount of the subsequent payment does not exceed the initial amount)&lt;br /&gt;
&lt;br /&gt;
If the funding source changes, new &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the funding source|described in detail here]]. If the funding source stays the same but the scenario changes or the restrictions are no longer met new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the token payment scenario with an existing token|described here]].&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Recurring payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this case, three extra conditions must be met:&lt;br /&gt;
* the amount of the subsequent payment must not be higher than the initial amount&lt;br /&gt;
* at least that much days must be spent as defined in the initial &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; property&lt;br /&gt;
* the date of the payment must not exceed the day specified in the initial &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; property&lt;br /&gt;
&lt;br /&gt;
Please be aware that in case any of these are no longer valid the merchant has to request a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; as [[#Changing the token payment scenario with an existing token|described here]]. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=These conditions are not enforced by the Barion system so the violation of them will result in a declined charge.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
Payment/start must not include the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; properties (since they are already fixed during the initial payment).&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Recurring payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Merchant Initiated Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario there are no restrictions.&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Merchant Initiated Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 75,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Phone bill&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of OneClick Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario, the merchant has to prepare to perform the [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]] of the payer. 3DS authentication is not required in the following cases:&lt;br /&gt;
* the token (&amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;) was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is not used in this scenario since the payer is present during the transaction. &lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent OneClick Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 17,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Book: How to shop online&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;How to shop online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Book about shopping online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;piece&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
In this scenario, the response contains the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; property that is used to perform an [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8-9&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: &amp;quot;ewoJIkNhcmRQdWJs...WZXJzaW9uIjogIjIuMS4wIgp9Cg==&amp;quot;,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Possible error responses for the subsequent payment requests ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| InvalidRecurrenceId|| The token specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is invalid. Check if the token registration was successful.&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentDenied|| Something happened to the user since the token registration, either deleted, suspended, or blocked. The payment s not allowed in these cases.&lt;br /&gt;
|-&lt;br /&gt;
| InsufficientFunds|| If the original payment was with an e-money wallet and the customer doesn&#039;t have enough money to fulfill this charge this error happens.&lt;br /&gt;
|-&lt;br /&gt;
| OriginalPaymentWasntSuccessful || This means that the token belongs to an originally unsuccessful payment so this token can not be used anymore. This could only happen if the original payment was financed with a credit card.&lt;br /&gt;
|-&lt;br /&gt;
|InvalidCurrency || If the original payment was paid with e-money and the current token payment is in a currency that the wallet does not have an account in this error happens.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is the request-response diagram of the subsequent payments:&lt;br /&gt;
&lt;br /&gt;
[[File:Token_payment_2.png]]&lt;br /&gt;
&lt;br /&gt;
= Changing funding source or token scenarios =&lt;br /&gt;
&lt;br /&gt;
==Changing the funding source==&lt;br /&gt;
&lt;br /&gt;
This could happen if the funding source becomes invalid for some reason (card gets deleted or expires) or the merchant decides to use that token for another payer. In this case, the merchant has to register the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; again. &lt;br /&gt;
To do this a new payment must be started and in the [[Payment-Start-v2|Payment/Start]] request the following setup should be specified:&lt;br /&gt;
* the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; field has to be set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; &lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; has to be specified.&lt;br /&gt;
* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; should not be specified.&lt;br /&gt;
&lt;br /&gt;
[[File:Funding-source-change.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is bound to the payer and the process if the funding source changes new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be generated. This new ID must be saved to this payment and must be used from this moment on for subsequent payments.&lt;br /&gt;
&lt;br /&gt;
==Changing the token payment scenario with an existing token==&lt;br /&gt;
&lt;br /&gt;
This could occur when the merchant wants to get authorization from the payer to a new token scenario for the already registered funding source. To be able to do this the merchant has to have a valid and registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
Let&#039;s see some examples when this may be necessary:&lt;br /&gt;
* The payer subscribed to the merchant&#039;s service beforehand and the merchant decided to use the recurring payment token scenario. The payer wants to subscribe to another service and this requires a different payment schedule. This means that the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; that was specified initially can not be maintained so it is required to acquire a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;&lt;br /&gt;
* The payer bought something on the merchant&#039;s website and uses the one-click feature for subsequent fast non-redirect payments. After a while, the payer decides to subscribe to a service provided by this same merchant. This means that the merchant has to create a new token scenario (not a one-click payment but a recurring payment). For this, the merchant has to acquire a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. This can be done without redirecting the payer to Barion using the existing &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; and performing a 3DS authentication on the merchant&#039;s website.&lt;br /&gt;
&lt;br /&gt;
To do these a new payment must be started and in the [[Payment-Start-v2|Payment/Start]] request the following setup should be specified:&lt;br /&gt;
* the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; field has to be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; &lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; has to be specified.&lt;br /&gt;
* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; should not be specified.&lt;br /&gt;
&lt;br /&gt;
After this, a 3DS authentication has to be completed to acquire a new trace ID. This can be done on the merchant&#039;s site if the merchant implements the barion.offsitegw.js for off-site 3DS authentication.&lt;br /&gt;
&lt;br /&gt;
This means that it can be achieved to acquire different Trace IDs for different scenarios with only one &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
This is basically categorizing the different token scenarios as opposed to using every subsequent payment as an unmarked charge.&lt;br /&gt;
&lt;br /&gt;
[[File:Mutiple-traceid.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
= Off-site 3DS v2 authentication =&lt;br /&gt;
&lt;br /&gt;
In certain scenarios, the payer has to be authenticated to lower the risk of the card transaction. This can be either performed &lt;br /&gt;
* on the Barion Smart Gateway (on-site) by redirecting the customer to Barion &lt;br /&gt;
* or on the merchant&#039;s website (off-site) by integrating the Barion Off-site client library.&lt;br /&gt;
&lt;br /&gt;
This section describes how to integrate the Barion off-site authentication library into the merchant&#039;s site.&lt;br /&gt;
&lt;br /&gt;
== Step 1 : Initialize the off-site authentication library  ==&lt;br /&gt;
You have to include the following css and javascript files in the code of your site. &lt;br /&gt;
&amp;lt;source lang=html&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source &amp;gt;&lt;br /&gt;
These files include all the necessary javascript code and styling to handle the 3DS authentication and display the challenge if necessary.&lt;br /&gt;
&lt;br /&gt;
Then you have to initialize the Barion javascript client. To do that, you have to define a configuration object that specifies your functions that handle the off-site authentication events. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; Authentication events&#039;&#039;&#039;&lt;br /&gt;
* &amp;lt;code&amp;gt;onAuthenticationSucceeded&amp;lt;/code&amp;gt;: the 3DS v2 authentication successfully completed&lt;br /&gt;
* &amp;lt;code&amp;gt;onAuthenticationFailed&amp;lt;/code&amp;gt;:  the 3DS v2 authentication failed&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const configuration = {&lt;br /&gt;
    onAuthenticationSucceeded: function () {&lt;br /&gt;
        // handle successful authentication by calling the Barion API via merchant&#039;s backend&lt;br /&gt;
        // Call the v2/payment/complete endpoint&lt;br /&gt;
    },&lt;br /&gt;
    onAuthenticationFailed: function () {&lt;br /&gt;
        // Handle unsuccessful authentication result, no charge was made.&lt;br /&gt;
        // The payment might be still valid only the authentication failed&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to pass this config object to the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const gw = new Barion.OffsiteGw(configuration);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Step 2: Start the authentication process ===&lt;br /&gt;
Once the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; is acquired from the payment/start you can start the authentication process by calling the &amp;lt;code&amp;gt;authenticate()&amp;lt;/code&amp;gt; method of the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
gw.authenticate(threeDsClientData);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will start the authentication process and present the challenge if needed. Visually this will create a modal window over the merchant&#039;s site and show the payer every necessary information.&lt;br /&gt;
Once the authentication process finished (either with or without a challenge) the appropriate event will be fired. &lt;br /&gt;
&lt;br /&gt;
== Step 3: Completing the payment ==&lt;br /&gt;
&lt;br /&gt;
In case of successful authentication, you have to call our [[Payment-Complete-v3|/Payment/Complete]] endpoint, where the actual charge will happen.&lt;br /&gt;
&lt;br /&gt;
=== Possible error responses for the subsequent payment requests ===&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
== Suggested implementation flow for off-site authentication ==&lt;br /&gt;
&lt;br /&gt;
Ideally, an off-site authentication should be part of a client-side experience without any postbacks or page reloads. This is our recommendation to achieve this:&lt;br /&gt;
&lt;br /&gt;
# After the customer clicks on the &amp;quot;Pay&amp;quot; button make an AJAX call from your client-side code to your back-end. &lt;br /&gt;
# Have your backend make a request to our payment/start endpoint (with the appropriate settings for the desired token scenario)&lt;br /&gt;
# Have your backend process the response and pass the value of the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; property to your client-side code.&lt;br /&gt;
# Use the Barion off-site library to perform the authentication&lt;br /&gt;
# Once the authentication succeeds send another AJAX request from your client-side code to your back-end.&lt;br /&gt;
# Have your back-end code call our [[Payment-Complete-v3|/Payment/Complete]]&lt;br /&gt;
# Have your backend process the response and pass the result to your client-side code.&lt;br /&gt;
# Display the result for the customer&lt;br /&gt;
&lt;br /&gt;
= Testing the integration =&lt;br /&gt;
&lt;br /&gt;
3D Secure has no environment for end-to-end testing, therefore merchants have to split their testings into two parts: Testing the payment flow with and without challenge. Getting a challenge is only possible with real-life cards, merchants have to use their own (there will be no real charging at the end on the Sandbox of the Payment Gateway, but using a real card will result initiating a real 3DS authentication).&lt;br /&gt;
&lt;br /&gt;
== Testing the whole payment flow, without challenge ==&lt;br /&gt;
&lt;br /&gt;
Use the OTP test cards (to-be-defined), they will always get a &amp;quot;frictionless&amp;quot; flow, where the 3DS process is presented on the UI, but you will never see a challenge screen. &lt;br /&gt;
&lt;br /&gt;
This is good for testing your integration itself because it will lead to a successful charge, and you will get a TraceId as well.&lt;br /&gt;
&lt;br /&gt;
== Testing the challenge itself ==&lt;br /&gt;
&lt;br /&gt;
Use your own card, and let the card issuer decide whether your payment will get a challenge or not during the 3DS authentication procedure. Your payment will fail at the end, and you won&#039;t get the TraceId. &lt;br /&gt;
&lt;br /&gt;
This is good to test, how the challenge screens look like in your shop - especially when you integrated OneClick payment directly to your shop. You might also check how your customers see your checkout flow on popular devices.&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2876</id>
		<title>Token payment 3D Secure</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2876"/>
		<updated>2020-11-26T12:53:58Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* Suggested implementation flow for off-site authentication */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Token Payment with 3D Secure}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{IncompletePage}}&lt;br /&gt;
&lt;br /&gt;
This payment scenario allows the integrator shop to register a token for a customer (and a funding source) in the Barion system and then, later on, using this token, charge the customer without redirecting her to the Barion Smart Gateway UI. The user may be present at the site of the merchant or she can be off-session as well, so the merchant can charge her e.g. for subscriptions. This means that the customer authorizes the shop to charge her card or Barion balance without typing in the card information or Barion login again.&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurring.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=Premium feature|text=This scenario is not allowed automatically for every approved shop and should be requested from Barion!|color=#1993c7}}&lt;br /&gt;
&lt;br /&gt;
= Token payment scenarios =&lt;br /&gt;
Token payment can be used in three use cases: &lt;br /&gt;
* &#039;&#039;&#039;Customer Initiated Payments&#039;&#039;&#039;: when the user is present on the website of the merchant and she decides to pay :&lt;br /&gt;
** &#039;&#039;&#039;OneClick payment&#039;&#039;&#039;: the user is charged upon her request initiated on the website of the merchant. Subsequent payments are subject to PSD2 SCA and as the user is present, she has to go through the authentication process.&lt;br /&gt;
* &#039;&#039;&#039;Merchant Initiated Payments&#039;&#039;&#039;: when the merchant initiates the payment without the user being present. It has two subtypes:&lt;br /&gt;
** &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: the user is charged with the same amount on a regular basis, typically in case of subscriptions. Subsequent payments are exempted from PSD2 SCA, but liability still shifts to the card issuer.&lt;br /&gt;
** &#039;&#039;&#039;MIT (merchant initiated transaction)&#039;&#039;&#039;: the user is charged on an irregular basis and/or with a different amount. Subsequent payments of this type are excluded from PSD2 SCA, the liability is on the merchant.&lt;br /&gt;
&lt;br /&gt;
== Customer participation ==&lt;br /&gt;
&lt;br /&gt;
Since the token scenario is suitable for both customer and merchant initiated payments here is a comparison about who starts the payment. This includes the regular, non-tokenized payment scenario as well:&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot; | Scenario&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Initial payment&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW &lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW&lt;br /&gt;
|-&lt;br /&gt;
| Non token (regular) payment || YES || YES || YES || YES &lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || YES || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| MIT || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #aaa; background-color:#eee; font-size: 0.8em; padding:5px 10px; display:inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; Token payment scenarios can be initiated with already registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; as well, in this case the customer may remain on the merchant&#039;s site. &lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements for the scenarios ==&lt;br /&gt;
&lt;br /&gt;
These token payment scenarios have different requirements, this table below summarizes the key differences.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Payment amount&lt;br /&gt;
! Payment frequency&lt;br /&gt;
! Liability in case of fraud&lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || Various || Various || Card issuer&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || Subsequent amounts must be equal or less than the initial amount  || Initial payment must define a minimum amount of days to wait between charges || Card issuer &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || Various  || Various || Merchant&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 3DS authentication of the payer ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be performed for every online card payment. These token payment scenarios also have to use this new secure way of authentication. &lt;br /&gt;
The initial payment of a token scenario must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
Here is a table to compare the 3DS authentication requirements:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Initial payment&lt;br /&gt;
! Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
| One-click payment || ✔️ || ✔️&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Real life examples ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phone bill&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Payer has a usage-based phone subscription that wants to pay without being present for every charge. She authorizes the phone company to charge her card every month.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, the amount of the subsequent payments may exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TV subscription&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to online streaming of a television channel. She authorizes the phone company to charge her card every month. The subscription fee is the same for every month.&lt;br /&gt;
* Scenario: Recurring payment&lt;br /&gt;
* Explanation: The amount of the subsequent payments will not exceed the initial payment and the charge is regularly monthly-based.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bookclub with &amp;quot;free first month&amp;quot; bonus&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to a book renting service. She authorizes the book club to charge her card every month for a selection of books. The subscription fee is the same for every month however, the first month is free. To ensure the subscription the service requires her to register her card details.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, and the fee will stay the same, the initial payment is zero. So the amount of the next payment will exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Online food delivery service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The food delivery company wants to provide a quick and easy experience for its customer. They decide that the order will be quicker if the customers don&#039;t leave the website to pay for the goods.&lt;br /&gt;
* Scenario: OneClick payment&lt;br /&gt;
* Explanation: The customer will always be there so the other two scenarios are not available.&lt;br /&gt;
&lt;br /&gt;
== How to decide ==&lt;br /&gt;
&lt;br /&gt;
To help you decide on a suitable scenario, please use the decision graph below:&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurrencetype-decision.png|520px]]&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
To be able to integrate your webshop with the Barion Payment Gateway: &lt;br /&gt;
* You must [[Creating_an_account|register a Barion wallet]] at the Barion website or in the Sandbox environment. Learn more about the Sandbox environment [[Sandbox|here]].&lt;br /&gt;
* For this wallet you have to [[Creating_a_shop|create a shop]] which should be approved by Barion.&lt;br /&gt;
* For every currency you plan to conduct payments in you have to make sure there is an account created in your Barion wallet. This means that if you plan to have USD payments then there should be a USD account created in your wallet.&lt;br /&gt;
* To make sure every corner case scenario works for your webshop it is best to top up that account with a small amount (approx. 5-10EUR or your choice of currency around the same value).&lt;br /&gt;
* For the technical communication guide please read this: [[Calling_the_API|Calling the API]]&lt;br /&gt;
&lt;br /&gt;
= The payment process =&lt;br /&gt;
&lt;br /&gt;
The process is divided into two major steps:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 1:  Creating the funding source token|Creating the token]] that represents one of the customer&#039;s funding sources (credit card or e-money wallet)&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Preparing the payment via the Barion API&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Redirecting the customer to the Barion Smart Gateway to select a funding source&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Processing the callback and requesting information about the result of the payment&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 2: Using the token|Using the registered token]] to charge the customer&amp;lt;/li&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1:  Creating the funding source token ==&lt;br /&gt;
To be able to use a token payment scenario first the merchant has to register the token with Barion. The merchant has to make sure that the customer is well aware of the fact that they are giving consent to a tokenized payment. The Barion Smart Gateway UI does not indicate in any way that the payment is a token payment.&lt;br /&gt;
&lt;br /&gt;
The token is registered to the shop and not to the merchant&#039;s Barion account. So if the merchant has multiple shops in its Barion account, the registered tokens can not be shared among them even if the customer is the same. If you want to use tokens in multiple shops, please contact Barion in the Customer center.&lt;br /&gt;
&lt;br /&gt;
=== 1.1 Preparing the payment===&lt;br /&gt;
&lt;br /&gt;
The token registration is basically a [[Responsive_web_payment|normal payment]] with three extra properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* InitiateRecurrence&lt;br /&gt;
* RecurrenceId&lt;br /&gt;
* RecurrenceType&lt;br /&gt;
&lt;br /&gt;
==== InitiateRecurrence====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; property is a bool property. If you set it to &#039;&#039;&#039;true&#039;&#039;&#039; then the payment gateway will consider the payment as a token registration. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This happens even if the customer is already has a registered token, so you are able to re-register a funding source or even a customer. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceId ====&lt;br /&gt;
The next required property for a token registration is the token itself. This is generated by the shop and has to be unique for every registration. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property of the [[Payment-Start-v2|Payment/Start]] request. This token must be saved in the webshops database. A &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; token represents the funding source (bank card or Barion balance) of a customer. Since a customer can have multiple cards and accounts as a funding source make sure that in the webshop&#039;s system multiple tokens can belong to a single customer.&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceType ====&lt;br /&gt;
The third required property is the [[RecurrenceType|Recurrence Type]]. This specifies the scenario. In case of Recurring Payment &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; must also be set.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Merchant Initiated Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The response will be the same as to a [[Responsive_web_payment#Processing_the_successful_response|basic &#039;&#039;&#039;Immediate&#039;&#039;&#039; scenario]]. The &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; property at this point is &#039;&#039;&#039;None&#039;&#039;&#039; since the token is not registered to a funding source yet.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Recurring Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Recurring Payment&#039;&#039;&#039; scenario has some extra restrictions. The merchant has to specify two additional properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt;: The date after the subsequent charges should not accepted.&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt;: The minimum days the merchant has to wait between payments.&lt;br /&gt;
&lt;br /&gt;
Both properties are located in the [[PurchaseInformation]] property and must be specified if this scenario is selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7, 30-33&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;PurchaseInformation&amp;quot;:{&lt;br /&gt;
        &amp;quot;RecurringFrequency&amp;quot;: 10,&lt;br /&gt;
        &amp;quot;RecurringExpiry&amp;quot;: &amp;quot;2022-10-01&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Possible error responses ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentNotAllowed || The token payment is not allowed for the shop identified by the &#039;&#039;&#039;POSKey&#039;&#039;&#039;. Contact Barion to request this feature.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 1.2 Redirecting the customer to the Barion Smart Gateway to select a funding source ===&lt;br /&gt;
&lt;br /&gt;
After a successful payment preparation, the customer is redirected to the secure Barion Smart Gateway to choose a funding source. The funding source the customer selects will be registered to the token. The funding source can either be a Barion e-money balance or a bank card. This means that even though the customer may own multiple cards only the one that was registered to the token can be used for future token payments. To change the funding source attached to the token a new registration should be requested.&lt;br /&gt;
&lt;br /&gt;
=== 1.3 Processing the callback and requesting information about the result of the payment ===&lt;br /&gt;
&lt;br /&gt;
When the payment is completed (either successfully or unsuccessfully) a callback message is sent to the merchant&#039;s system. Once received a [[Payment-GetPaymentState-v2|GetPaymentState]] request must be sent to the Barion API. On how to implement this please read the article about the  [[Callback_mechanism|Callback mechanism]].&lt;br /&gt;
&lt;br /&gt;
The full response of the GetPaymentState request depends on the payment scenario and the structure of the payment. When it comes to token payment there are several properties to look out for. &lt;br /&gt;
* In case the &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; is &#039;&#039;&#039;Succeeded&#039;&#039;&#039; the funding source token is registered and ready to use.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; contains the ID of the token process. This specifies the nature of the token payment. &lt;br /&gt;
&lt;br /&gt;
==== TraceId ====&lt;br /&gt;
&lt;br /&gt;
In case of Recurring payment or Merchant initiated payment scenarios the [[Payment-GetPaymentState-v2|GetPaymentState]] response returns an additional field called &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. The value of this property is generated by the card issuer. The merchant has to save it and submit it in all subsequent Recurring or Merchant initiated payments of the same type, otherwise, the payments can be declined by the issuer. The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; represents the first, customer-present payment and helps the issuer to connect subsequent payments to this initial payment.&lt;br /&gt;
&lt;br /&gt;
====Example GetPaymentState response====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;8, 11-12&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;OrderNumber&amp;quot;: null,&lt;br /&gt;
    &amp;quot;POSId&amp;quot;: &amp;quot;[[SHOPS_PUBLIC_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSName&amp;quot;: &amp;quot;[[MERCHANTS_BARION_SHOPNAME]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSOwnerEmail&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSource&amp;quot;: &amp;quot;BankCard&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;AllowedFundingSources&amp;quot;: [&lt;br /&gt;
        &amp;quot;All&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;GuestCheckout&amp;quot;: true,&lt;br /&gt;
    &amp;quot;CreatedAt&amp;quot;: &amp;quot;2020-11-26T07:52:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ValidUntil&amp;quot;: &amp;quot;2020-11-26T08:22:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;CompletedAt&amp;quot;: &amp;quot;2020-11-26T08:11:54.118Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ReservedUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;DelayedCaptureUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
           ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;Total&amp;quot;: 25.20,&lt;br /&gt;
    &amp;quot;SuggestedLocale&amp;quot;: &amp;quot;hu-HU&amp;quot;,&lt;br /&gt;
    &amp;quot;FraudRiskScore&amp;quot;: null,&lt;br /&gt;
    &amp;quot;RedirectUrl&amp;quot;: &amp;quot;https://merchanturl/Redirect?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;CallbackUrl&amp;quot;: &amp;quot;https://merchanturl/Callback?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Displaying the funding source in a GUI ====&lt;br /&gt;
We strongly advise saving the complete response for future reference. The &amp;lt;code&amp;gt;FundingSource&amp;lt;/code&amp;gt; field tells if the funding source is a Barion balance or a card. If it is a card, it is useful to save [[FundingInformation]] for displaying it for the user, when requesting future payments. The usual way to display funding sources is to show the last 4 digits of the card, with 4 stars, eg: *** 1234. The card used can be obtained from FundingInformation&#039;s [[BankCard]] field. The [[CardType]] field can be used to display the appropriate card logo. You can even show, if the card is expired, and offer to register another one.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; FundingInformation part of the GetPaymentState response &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=json&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be displayed for example as &amp;lt;code&amp;gt;VISA **** 0425 (12/20)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a request-response diagram of the token registration process:&lt;br /&gt;
 &lt;br /&gt;
[[File:Token_payment_initiation.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Step 2: Using the token =&lt;br /&gt;
&lt;br /&gt;
To use an already registered token for a payment, you have to use the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property. To be able to use a token, the initial payment must be in a successful state.&lt;br /&gt;
&lt;br /&gt;
At this point, the merchant has to decide whether this subsequent payment is used for the same token payment scenario or something changed. This is important because the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used for the same scenario, otherwise, the card issuer will decline the charge.&lt;br /&gt;
A &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used again if:&lt;br /&gt;
* the funding source is the same (technically the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* the token payment scenario is the same (technically the &amp;lt;code&amp;gt;RecurrenceType&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* this subsequent request complies with the scenario restrictions (eg: in case of recurring payment the amount of the subsequent payment does not exceed the initial amount)&lt;br /&gt;
&lt;br /&gt;
If the funding source changes, new &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the funding source|described in detail here]]. If the funding source stays the same but the scenario changes or the restrictions are no longer met new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the token payment scenario with an existing token|described here]].&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Recurring payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this case, three extra conditions must be met:&lt;br /&gt;
* the amount of the subsequent payment must not be higher than the initial amount&lt;br /&gt;
* at least that much days must be spent as defined in the initial &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; property&lt;br /&gt;
* the date of the payment must not exceed the day specified in the initial &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; property&lt;br /&gt;
&lt;br /&gt;
Please be aware that in case any of these are no longer valid the merchant has to request a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; as [[#Changing the token payment scenario with an existing token|described here]]. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=These conditions are not enforced by the Barion system so the violation of them will result in a declined charge.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
Payment/start must not include the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; properties (since they are already fixed during the initial payment).&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Recurring payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Merchant Initiated Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario there are no restrictions.&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Merchant Initiated Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 75,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Phone bill&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of OneClick Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario, the merchant has to prepare to perform the [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]] of the payer. 3DS authentication is not required in the following cases:&lt;br /&gt;
* the token (&amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;) was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is not used in this scenario since the payer is present during the transaction. &lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent OneClick Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 17,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Book: How to shop online&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;How to shop online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Book about shopping online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;piece&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
In this scenario, the response contains the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; property that is used to perform an [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8-9&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: &amp;quot;ewoJIkNhcmRQdWJs...WZXJzaW9uIjogIjIuMS4wIgp9Cg==&amp;quot;,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Possible error responses for the subsequent payment requests ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| InvalidRecurrenceId|| The token specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is invalid. Check if the token registration was successful.&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentDenied|| Something happened to the user since the token registration, either deleted, suspended, or blocked. The payment s not allowed in these cases.&lt;br /&gt;
|-&lt;br /&gt;
| InsufficientFunds|| If the original payment was with an e-money wallet and the customer doesn&#039;t have enough money to fulfill this charge this error happens.&lt;br /&gt;
|-&lt;br /&gt;
| OriginalPaymentWasntSuccessful || This means that the token belongs to an originally unsuccessful payment so this token can not be used anymore. This could only happen if the original payment was financed with a credit card.&lt;br /&gt;
|-&lt;br /&gt;
|InvalidCurrency || If the original payment was paid with e-money and the current token payment is in a currency that the wallet does not have an account in this error happens.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is the request-response diagram of the subsequent payments:&lt;br /&gt;
&lt;br /&gt;
[[File:Token_payment_2.png]]&lt;br /&gt;
&lt;br /&gt;
= Changing funding source or token scenarios =&lt;br /&gt;
&lt;br /&gt;
==Changing the funding source==&lt;br /&gt;
&lt;br /&gt;
This could happen if the funding source becomes invalid for some reason (card gets deleted or expires) or the merchant decides to use that token for another payer. In this case, the merchant has to register the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; again. &lt;br /&gt;
To do this a new payment must be started and in the [[Payment-Start-v2|Payment/Start]] request the following setup should be specified:&lt;br /&gt;
* the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; field has to be set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; &lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; has to be specified.&lt;br /&gt;
* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; should not be specified.&lt;br /&gt;
&lt;br /&gt;
[[File:Funding-source-change.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is bound to the payer and the process if the funding source changes new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be generated. This new ID must be saved to this payment and must be used from this moment on for subsequent payments.&lt;br /&gt;
&lt;br /&gt;
==Changing the token payment scenario with an existing token==&lt;br /&gt;
&lt;br /&gt;
This could occur when the merchant wants to get authorization from the payer to a new token scenario for the already registered funding source. To be able to do this the merchant has to have a valid and registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
Let&#039;s see some examples when this may be necessary:&lt;br /&gt;
* The payer subscribed to the merchant&#039;s service beforehand and the merchant decided to use the recurring payment token scenario. The payer wants to subscribe to another service and this requires a different payment schedule. This means that the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; that was specified initially can not be maintained so it is required to acquire a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;&lt;br /&gt;
* The payer bought something on the merchant&#039;s website and uses the one-click feature for subsequent fast non-redirect payments. After a while, the payer decides to subscribe to a service provided by this same merchant. This means that the merchant has to create a new token scenario (not a one-click payment but a recurring payment). For this, the merchant has to acquire a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. This can be done without redirecting the payer to Barion using the existing &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; and performing a 3DS authentication on the merchant&#039;s website.&lt;br /&gt;
&lt;br /&gt;
To do these a new payment must be started and in the [[Payment-Start-v2|Payment/Start]] request the following setup should be specified:&lt;br /&gt;
* the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; field has to be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; &lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; has to be specified.&lt;br /&gt;
* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; should not be specified.&lt;br /&gt;
&lt;br /&gt;
After this, a 3DS authentication has to be completed to acquire a new trace ID. This can be done on the merchant&#039;s site if the merchant implements the barion.offsitegw.js for off-site 3DS authentication.&lt;br /&gt;
&lt;br /&gt;
This means that it can be achieved to acquire different Trace IDs for different scenarios with only one &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
This is basically categorizing the different token scenarios as opposed to using every subsequent payment as an unmarked charge.&lt;br /&gt;
&lt;br /&gt;
[[File:Mutiple-traceid.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
= Off-site 3DS v2 authentication =&lt;br /&gt;
&lt;br /&gt;
In certain scenarios, the payer has to be authenticated to lower the risk of the card transaction. This can be either performed &lt;br /&gt;
* on the Barion Smart Gateway (on-site) by redirecting the customer to Barion &lt;br /&gt;
* or on the merchant&#039;s website (off-site) by integrating the Barion Off-site client library.&lt;br /&gt;
&lt;br /&gt;
This section describes how to integrate the Barion off-site authentication library into the merchant&#039;s site.&lt;br /&gt;
&lt;br /&gt;
== Step 1 : Initialize the off-site authentication library  ==&lt;br /&gt;
You have to include the following css and javascript files in the code of your site. &lt;br /&gt;
&amp;lt;source lang=html&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source &amp;gt;&lt;br /&gt;
These files include all the necessary javascript code and styling to handle the 3DS authentication and display the challenge if necessary.&lt;br /&gt;
&lt;br /&gt;
Then you have to initialize the Barion javascript client. To do that, you have to define a configuration object that specifies your functions that handle the off-site authentication events. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; Authentication events&#039;&#039;&#039;&lt;br /&gt;
* &amp;lt;code&amp;gt;onAuthenticationSucceeded&amp;lt;/code&amp;gt;: the 3DS v2 authentication successfully completed&lt;br /&gt;
* &amp;lt;code&amp;gt;onAuthenticationFailed&amp;lt;/code&amp;gt;:  the 3DS v2 authentication failed&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const configuration = {&lt;br /&gt;
    onAuthenticationSucceeded: function () {&lt;br /&gt;
        // handle successful authentication by calling the Barion API via merchant&#039;s backend&lt;br /&gt;
        // Call the v2/payment/complete endpoint&lt;br /&gt;
    },&lt;br /&gt;
    onAuthenticationFailed: function () {&lt;br /&gt;
        // Handle unsuccessful authentication result, no charge was made.&lt;br /&gt;
        // The payment might be still valid only the authentication failed&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to pass this config object to the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const gw = new Barion.OffsiteGw(configuration);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Step 2: Start the authentication process ===&lt;br /&gt;
Once the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; is acquired from the payment/start you can start the authentication process by calling the &amp;lt;code&amp;gt;authenticate()&amp;lt;/code&amp;gt; method of the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
gw.authenticate(threeDsClientData);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will start the authentication process and present the challenge if needed. Visually this will create a modal window over the merchant&#039;s site and show the payer every necessary information.&lt;br /&gt;
Once the authentication process finished (either with or without a challenge) the appropriate event will be fired. &lt;br /&gt;
&lt;br /&gt;
== Step 3: Completing the payment ==&lt;br /&gt;
&lt;br /&gt;
In case of successful authentication, you have to call our [[Payment-Complete-v3|/Payment/Complete]] endpoint, where the actual charge will happen.&lt;br /&gt;
&lt;br /&gt;
=== Possible error responses for the subsequent payment requests ===&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
== Suggested implementation flow for off-site authentication ==&lt;br /&gt;
&lt;br /&gt;
Ideally, an off-site authentication should be part of a client-side experience without any postbacks or page reloads. This is our recommendation to achieve this:&lt;br /&gt;
&lt;br /&gt;
# After the customer clicks on the &amp;quot;Pay&amp;quot; button make an AJAX call from your client-side code to your back-end. &lt;br /&gt;
# Have your backend make a request to our payment/start endpoint (with the appropriate settings for the desired token scenario)&lt;br /&gt;
# Have your backend process the response and pass the value of the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; property to your client-side code.&lt;br /&gt;
# Use the Barion off-site library to perform the authentication&lt;br /&gt;
# Once the authentication succeeds send another AJAX request from your client-side code to your back-end.&lt;br /&gt;
# Have your back-end code call our [[Payment-Complete-v3|/Payment/Complete]]&lt;br /&gt;
# Have your backend process the response and pass the result to your client-side code.&lt;br /&gt;
# Display the result for the customer&lt;br /&gt;
&lt;br /&gt;
= Testing the integration =&lt;br /&gt;
&lt;br /&gt;
TODO&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_upgrade_to_3DS&amp;diff=2875</id>
		<title>Token payment upgrade to 3DS</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_upgrade_to_3DS&amp;diff=2875"/>
		<updated>2020-11-26T12:51:23Z</updated>

		<summary type="html">&lt;p&gt;Botza: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Upgrading token payment implementation to comply with 3DS}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=NOTE|text=This tutorial was created to help merchants that already have token payment integration with Barion. First, please read through the detailed description of the new [[Token_payment_3D_Secure|token payment with 3DS]]!|color=#1993c7}}&lt;br /&gt;
= Background =&lt;br /&gt;
[[Token_payment|Token payment]] is a solution that enables the merchant to charge the payer without the presence of them. It is a powerful tool to conduct subscription-like or payer-not-present scenarios. This scenario requires the merchant to create a token that would act as an identifier for the payer&#039;s funding source. To attach that token to a valid funding source the merchant had to do several things:&lt;br /&gt;
# Create an alphanumeric token&lt;br /&gt;
# Conduct an initial payment in which this token gets registered in the Barion system &lt;br /&gt;
# Refer to this token in a subsequent payment attempt&lt;br /&gt;
&lt;br /&gt;
[[File:Recurring-pre3ds.png|1280px]]&lt;br /&gt;
&lt;br /&gt;
This meant that as far as this token referenced a valid (and still available) funding source the merchant could create payments without any limitations. Basically, this token symbolized the funding source. It was up to the merchant to decide what it is used for, neither Barion nor the card issuer was aware of the nature of the subsequent payments. &lt;br /&gt;
&lt;br /&gt;
This funding source can be either a card or an e-money wallet and this is up to the payer to choose. In case the payer chooses to fund the payment from their e-money wallet there is no further need for extra security. On the other hand, when it comes to card payment the authentication process changed with the new Strong Customer Authentication directive and the 3DS v2 protocol.&lt;br /&gt;
&lt;br /&gt;
= Changes =&lt;br /&gt;
To make sure that the payer has more control over these token scenarios and the card issuer knows more about the payment scenarios several things need to be changed. &lt;br /&gt;
&lt;br /&gt;
== Token payment scenarios ==&lt;br /&gt;
&lt;br /&gt;
First of all the merchant has to decide what kind of token payment scenario is suitable. These scenarios are the following:&lt;br /&gt;
* &#039;&#039;&#039;One-click payment&#039;&#039;&#039;: The payer clicks on the &amp;quot;Purchase&amp;quot; button but the charge happens in the background without the payer leaving the merchant&#039;s site.&lt;br /&gt;
* &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: The payer authorizes the merchant (at the initial payment) to charge their card periodically without being present.&lt;br /&gt;
* &#039;&#039;&#039;Merchant initiated payment&#039;&#039;&#039;: The payer authorizes the merchant to charge their card without restrictions.&lt;br /&gt;
&lt;br /&gt;
To decide on a suitable scenario, please [[Token_payment_3D_Secure#Token_payment_scenarios|read this detailed description]]&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=CHANGE|text=The intended scenario must be specified in the new [[RecurrenceType|ReccurenceType]] property (located in the [[Payment-Start-v2|Payment/Start]] request)|color=#20c400}}&lt;br /&gt;
&lt;br /&gt;
== Usage of TraceId ==&lt;br /&gt;
&lt;br /&gt;
3DS authentication requires another identifier. This new identifier is used to differentiate these token payment scenarios and help the issuer control what is a non-fraudulent transaction.&lt;br /&gt;
&lt;br /&gt;
So from now on, there will be two IDs for every payer-not-present scenario:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; for the funding source: this identifies the source of the money (could be card or wallet)&lt;br /&gt;
* &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; (new) for the &#039;&#039;nature of the charge:&#039;&#039; this identifies the type of token payment scenario the merchant is conducting.&lt;br /&gt;
&lt;br /&gt;
This new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is generated and stored by the card issuer. The Id is available in the [[Payment-GetPaymentState-v2|GetPaymentState]] response once the charge is successfully completed.&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=CHANGE|text=The TraceId must processed from the [[Payment-GetPaymentState-v2|GetPaymentState]] response and must be attached to the payment in merchant&#039;s system. |color=#20c400}}&lt;br /&gt;
&lt;br /&gt;
Once the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is acquired it must be sent in the [[Payment-Start-v2|Payment/Start]] request to identify the scenario. This is crucial for the card transactions otherwise they could be declined. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=CHANGE|text=The TraceId must specified in the [[Payment-Start-v2|Payment/Start]] for the subsequent token charges. |color=#20c400}}&lt;br /&gt;
&lt;br /&gt;
== 3DS v2 authentication ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be conducted for every online card payment. These token payment scenarios also need to use these new secure way of authentication. &lt;br /&gt;
The initial payment must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Technical changes required =&lt;br /&gt;
The technical changes depend on what type of token scenario is needed for the business. It is important to notice that these scenarios can be implemented beside each other, a merchant is not required to choose only one type of token payment. The main goal is to appropriately use each scenario.&lt;br /&gt;
&lt;br /&gt;
== Technical changes for Recurring payments ==&lt;br /&gt;
&lt;br /&gt;
#&#039;&#039;&#039; For the token registration&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request the new properties have to be specified:&lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;RecurringPayment&amp;quot;&amp;lt;/code&amp;gt; to indicate the scenario&lt;br /&gt;
#* &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; for the limitations &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt; &lt;br /&gt;
#Once the callback is received get the response of [[Payment-GetPaymentState-v2|GetPaymentState]]. In case the charge was successful, there will be a &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; property for the payment. The value of it must be saved and attached to the payment.  &lt;br /&gt;
#&#039;&#039;&#039;For subsequent payments&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request specify the &lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;RecurringPayment&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
#* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; you received for the initial payment.&lt;br /&gt;
&lt;br /&gt;
== Technical changes for Merchant initiated payments ==&lt;br /&gt;
&lt;br /&gt;
#&#039;&#039;&#039; For the token registration&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request the new property has to be specified:&lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;MerchantInitiatedPayment&amp;quot;&amp;lt;/code&amp;gt; to indicate the scenario&lt;br /&gt;
#Once the callback is received get the response of [[Payment-GetPaymentState-v2|GetPaymentState]]. In case the charge was successful, there will be a &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; property for the payment. The value of it must be saved and attached to the payment.  &lt;br /&gt;
#&#039;&#039;&#039;For subsequent payments&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request specify the &lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;MerchantInitiatedPayment&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
#* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; you received for the initial payment.&lt;br /&gt;
&lt;br /&gt;
== Technical changes for One-click payments ==&lt;br /&gt;
&lt;br /&gt;
This modification needs the most attention since the merchant has to implement client-side functionality and add a new step at the end of the flow.&lt;br /&gt;
&lt;br /&gt;
#&#039;&#039;&#039; For the token registration&#039;&#039;&#039; in the [[Payment-Start-v2|Payment/Start]] request the new property has to be specified:&lt;br /&gt;
#* &amp;lt;code&amp;gt;&amp;quot;RecurrenceType&amp;quot; : &amp;quot;OneClickPayment&amp;quot;&amp;lt;/code&amp;gt; to indicate the scenario&lt;br /&gt;
#&#039;&#039;&#039;For subsequent payments&#039;&#039;&#039; the merchant has to integrate the barion.offsitegw.js to be able to authenticate the payer via 3DS v2 on the merchant&#039;s site. To do this read the tutorial on [[Token_payment_3D_Secure#OneClick payment|how to integrate this]].&lt;br /&gt;
# After a successful authentication a new Barion API endpoint ([[Payment-Complete-v2|/Payment/Complete]]) must be called to finalize the process and charge the card&lt;br /&gt;
&lt;br /&gt;
Please notice that in case this scenario is used there is no need to use the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; since the 3DS authentication will be performed every time.&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=CHANGE|text=In case of one-click token scenario the merchant has to authenticate every card payment with 3DS v2|color=#20c400}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What happens if the merchant doesn&#039;t upgrade its implementation ==&lt;br /&gt;
&lt;br /&gt;
There is a transition period for the integrators to upgrade their system. In this period both of these integrations will work. Once the period is over not the initial payments nor the subsequent payments will succeed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=SUPPORT|text=In case you have difficulties with the upgrade please contact our developers at devsupport@barion.com |color=#1993c7}}&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2874</id>
		<title>Token payment 3D Secure</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2874"/>
		<updated>2020-11-26T12:44:35Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* Step 3: Completing the payment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Token Payment with 3D Secure}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{IncompletePage}}&lt;br /&gt;
&lt;br /&gt;
This payment scenario allows the integrator shop to register a token for a customer (and a funding source) in the Barion system and then, later on, using this token, charge the customer without redirecting her to the Barion Smart Gateway UI. The user may be present at the site of the merchant or she can be off-session as well, so the merchant can charge her e.g. for subscriptions. This means that the customer authorizes the shop to charge her card or Barion balance without typing in the card information or Barion login again.&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurring.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=Premium feature|text=This scenario is not allowed automatically for every approved shop and should be requested from Barion!|color=#1993c7}}&lt;br /&gt;
&lt;br /&gt;
= Token payment scenarios =&lt;br /&gt;
Token payment can be used in three use cases: &lt;br /&gt;
* &#039;&#039;&#039;Customer Initiated Payments&#039;&#039;&#039;: when the user is present on the website of the merchant and she decides to pay :&lt;br /&gt;
** &#039;&#039;&#039;OneClick payment&#039;&#039;&#039;: the user is charged upon her request initiated on the website of the merchant. Subsequent payments are subject to PSD2 SCA and as the user is present, she has to go through the authentication process.&lt;br /&gt;
* &#039;&#039;&#039;Merchant Initiated Payments&#039;&#039;&#039;: when the merchant initiates the payment without the user being present. It has two subtypes:&lt;br /&gt;
** &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: the user is charged with the same amount on a regular basis, typically in case of subscriptions. Subsequent payments are exempted from PSD2 SCA, but liability still shifts to the card issuer.&lt;br /&gt;
** &#039;&#039;&#039;MIT (merchant initiated transaction)&#039;&#039;&#039;: the user is charged on an irregular basis and/or with a different amount. Subsequent payments of this type are excluded from PSD2 SCA, the liability is on the merchant.&lt;br /&gt;
&lt;br /&gt;
== Customer participation ==&lt;br /&gt;
&lt;br /&gt;
Since the token scenario is suitable for both customer and merchant initiated payments here is a comparison about who starts the payment. This includes the regular, non-tokenized payment scenario as well:&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot; | Scenario&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Initial payment&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW &lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW&lt;br /&gt;
|-&lt;br /&gt;
| Non token (regular) payment || YES || YES || YES || YES &lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || YES || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| MIT || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #aaa; background-color:#eee; font-size: 0.8em; padding:5px 10px; display:inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; Token payment scenarios can be initiated with already registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; as well, in this case the customer may remain on the merchant&#039;s site. &lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements for the scenarios ==&lt;br /&gt;
&lt;br /&gt;
These token payment scenarios have different requirements, this table below summarizes the key differences.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Payment amount&lt;br /&gt;
! Payment frequency&lt;br /&gt;
! Liability in case of fraud&lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || Various || Various || Card issuer&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || Subsequent amounts must be equal or less than the initial amount  || Initial payment must define a minimum amount of days to wait between charges || Card issuer &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || Various  || Various || Merchant&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 3DS authentication of the payer ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be performed for every online card payment. These token payment scenarios also have to use this new secure way of authentication. &lt;br /&gt;
The initial payment of a token scenario must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
Here is a table to compare the 3DS authentication requirements:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Initial payment&lt;br /&gt;
! Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
| One-click payment || ✔️ || ✔️&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Real life examples ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phone bill&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Payer has a usage-based phone subscription that wants to pay without being present for every charge. She authorizes the phone company to charge her card every month.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, the amount of the subsequent payments may exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TV subscription&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to online streaming of a television channel. She authorizes the phone company to charge her card every month. The subscription fee is the same for every month.&lt;br /&gt;
* Scenario: Recurring payment&lt;br /&gt;
* Explanation: The amount of the subsequent payments will not exceed the initial payment and the charge is regularly monthly-based.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bookclub with &amp;quot;free first month&amp;quot; bonus&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to a book renting service. She authorizes the book club to charge her card every month for a selection of books. The subscription fee is the same for every month however, the first month is free. To ensure the subscription the service requires her to register her card details.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, and the fee will stay the same, the initial payment is zero. So the amount of the next payment will exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Online food delivery service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The food delivery company wants to provide a quick and easy experience for its customer. They decide that the order will be quicker if the customers don&#039;t leave the website to pay for the goods.&lt;br /&gt;
* Scenario: OneClick payment&lt;br /&gt;
* Explanation: The customer will always be there so the other two scenarios are not available.&lt;br /&gt;
&lt;br /&gt;
== How to decide ==&lt;br /&gt;
&lt;br /&gt;
To help you decide on a suitable scenario, please use the decision graph below:&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurrencetype-decision.png|520px]]&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
To be able to integrate your webshop with the Barion Payment Gateway: &lt;br /&gt;
* You must [[Creating_an_account|register a Barion wallet]] at the Barion website or in the Sandbox environment. Learn more about the Sandbox environment [[Sandbox|here]].&lt;br /&gt;
* For this wallet you have to [[Creating_a_shop|create a shop]] which should be approved by Barion.&lt;br /&gt;
* For every currency you plan to conduct payments in you have to make sure there is an account created in your Barion wallet. This means that if you plan to have USD payments then there should be a USD account created in your wallet.&lt;br /&gt;
* To make sure every corner case scenario works for your webshop it is best to top up that account with a small amount (approx. 5-10EUR or your choice of currency around the same value).&lt;br /&gt;
* For the technical communication guide please read this: [[Calling_the_API|Calling the API]]&lt;br /&gt;
&lt;br /&gt;
= The payment process =&lt;br /&gt;
&lt;br /&gt;
The process is divided into two major steps:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 1:  Creating the funding source token|Creating the token]] that represents one of the customer&#039;s funding sources (credit card or e-money wallet)&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Preparing the payment via the Barion API&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Redirecting the customer to the Barion Smart Gateway to select a funding source&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Processing the callback and requesting information about the result of the payment&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 2: Using the token|Using the registered token]] to charge the customer&amp;lt;/li&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1:  Creating the funding source token ==&lt;br /&gt;
To be able to use a token payment scenario first the merchant has to register the token with Barion. The merchant has to make sure that the customer is well aware of the fact that they are giving consent to a tokenized payment. The Barion Smart Gateway UI does not indicate in any way that the payment is a token payment.&lt;br /&gt;
&lt;br /&gt;
The token is registered to the shop and not to the merchant&#039;s Barion account. So if the merchant has multiple shops in its Barion account, the registered tokens can not be shared among them even if the customer is the same. If you want to use tokens in multiple shops, please contact Barion in the Customer center.&lt;br /&gt;
&lt;br /&gt;
=== 1.1 Preparing the payment===&lt;br /&gt;
&lt;br /&gt;
The token registration is basically a [[Responsive_web_payment|normal payment]] with three extra properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* InitiateRecurrence&lt;br /&gt;
* RecurrenceId&lt;br /&gt;
* RecurrenceType&lt;br /&gt;
&lt;br /&gt;
==== InitiateRecurrence====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; property is a bool property. If you set it to &#039;&#039;&#039;true&#039;&#039;&#039; then the payment gateway will consider the payment as a token registration. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This happens even if the customer is already has a registered token, so you are able to re-register a funding source or even a customer. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceId ====&lt;br /&gt;
The next required property for a token registration is the token itself. This is generated by the shop and has to be unique for every registration. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property of the [[Payment-Start-v2|Payment/Start]] request. This token must be saved in the webshops database. A &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; token represents the funding source (bank card or Barion balance) of a customer. Since a customer can have multiple cards and accounts as a funding source make sure that in the webshop&#039;s system multiple tokens can belong to a single customer.&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceType ====&lt;br /&gt;
The third required property is the [[RecurrenceType|Recurrence Type]]. This specifies the scenario. In case of Recurring Payment &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; must also be set.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Merchant Initiated Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The response will be the same as to a [[Responsive_web_payment#Processing_the_successful_response|basic &#039;&#039;&#039;Immediate&#039;&#039;&#039; scenario]]. The &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; property at this point is &#039;&#039;&#039;None&#039;&#039;&#039; since the token is not registered to a funding source yet.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Recurring Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Recurring Payment&#039;&#039;&#039; scenario has some extra restrictions. The merchant has to specify two additional properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt;: The date after the subsequent charges should not accepted.&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt;: The minimum days the merchant has to wait between payments.&lt;br /&gt;
&lt;br /&gt;
Both properties are located in the [[PurchaseInformation]] property and must be specified if this scenario is selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7, 30-33&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;PurchaseInformation&amp;quot;:{&lt;br /&gt;
        &amp;quot;RecurringFrequency&amp;quot;: 10,&lt;br /&gt;
        &amp;quot;RecurringExpiry&amp;quot;: &amp;quot;2022-10-01&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Possible error responses ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentNotAllowed || The token payment is not allowed for the shop identified by the &#039;&#039;&#039;POSKey&#039;&#039;&#039;. Contact Barion to request this feature.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 1.2 Redirecting the customer to the Barion Smart Gateway to select a funding source ===&lt;br /&gt;
&lt;br /&gt;
After a successful payment preparation, the customer is redirected to the secure Barion Smart Gateway to choose a funding source. The funding source the customer selects will be registered to the token. The funding source can either be a Barion e-money balance or a bank card. This means that even though the customer may own multiple cards only the one that was registered to the token can be used for future token payments. To change the funding source attached to the token a new registration should be requested.&lt;br /&gt;
&lt;br /&gt;
=== 1.3 Processing the callback and requesting information about the result of the payment ===&lt;br /&gt;
&lt;br /&gt;
When the payment is completed (either successfully or unsuccessfully) a callback message is sent to the merchant&#039;s system. Once received a [[Payment-GetPaymentState-v2|GetPaymentState]] request must be sent to the Barion API. On how to implement this please read the article about the  [[Callback_mechanism|Callback mechanism]].&lt;br /&gt;
&lt;br /&gt;
The full response of the GetPaymentState request depends on the payment scenario and the structure of the payment. When it comes to token payment there are several properties to look out for. &lt;br /&gt;
* In case the &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; is &#039;&#039;&#039;Succeeded&#039;&#039;&#039; the funding source token is registered and ready to use.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; contains the ID of the token process. This specifies the nature of the token payment. &lt;br /&gt;
&lt;br /&gt;
==== TraceId ====&lt;br /&gt;
&lt;br /&gt;
In case of Recurring payment or Merchant initiated payment scenarios the [[Payment-GetPaymentState-v2|GetPaymentState]] response returns an additional field called &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. The value of this property is generated by the card issuer. The merchant has to save it and submit it in all subsequent Recurring or Merchant initiated payments of the same type, otherwise, the payments can be declined by the issuer. The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; represents the first, customer-present payment and helps the issuer to connect subsequent payments to this initial payment.&lt;br /&gt;
&lt;br /&gt;
====Example GetPaymentState response====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;8, 11-12&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;OrderNumber&amp;quot;: null,&lt;br /&gt;
    &amp;quot;POSId&amp;quot;: &amp;quot;[[SHOPS_PUBLIC_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSName&amp;quot;: &amp;quot;[[MERCHANTS_BARION_SHOPNAME]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSOwnerEmail&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSource&amp;quot;: &amp;quot;BankCard&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;AllowedFundingSources&amp;quot;: [&lt;br /&gt;
        &amp;quot;All&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;GuestCheckout&amp;quot;: true,&lt;br /&gt;
    &amp;quot;CreatedAt&amp;quot;: &amp;quot;2020-11-26T07:52:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ValidUntil&amp;quot;: &amp;quot;2020-11-26T08:22:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;CompletedAt&amp;quot;: &amp;quot;2020-11-26T08:11:54.118Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ReservedUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;DelayedCaptureUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
           ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;Total&amp;quot;: 25.20,&lt;br /&gt;
    &amp;quot;SuggestedLocale&amp;quot;: &amp;quot;hu-HU&amp;quot;,&lt;br /&gt;
    &amp;quot;FraudRiskScore&amp;quot;: null,&lt;br /&gt;
    &amp;quot;RedirectUrl&amp;quot;: &amp;quot;https://merchanturl/Redirect?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;CallbackUrl&amp;quot;: &amp;quot;https://merchanturl/Callback?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Displaying the funding source in a GUI ====&lt;br /&gt;
We strongly advise saving the complete response for future reference. The &amp;lt;code&amp;gt;FundingSource&amp;lt;/code&amp;gt; field tells if the funding source is a Barion balance or a card. If it is a card, it is useful to save [[FundingInformation]] for displaying it for the user, when requesting future payments. The usual way to display funding sources is to show the last 4 digits of the card, with 4 stars, eg: *** 1234. The card used can be obtained from FundingInformation&#039;s [[BankCard]] field. The [[CardType]] field can be used to display the appropriate card logo. You can even show, if the card is expired, and offer to register another one.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; FundingInformation part of the GetPaymentState response &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=json&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be displayed for example as &amp;lt;code&amp;gt;VISA **** 0425 (12/20)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a request-response diagram of the token registration process:&lt;br /&gt;
 &lt;br /&gt;
[[File:Token_payment_initiation.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Step 2: Using the token =&lt;br /&gt;
&lt;br /&gt;
To use an already registered token for a payment, you have to use the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property. To be able to use a token, the initial payment must be in a successful state.&lt;br /&gt;
&lt;br /&gt;
At this point, the merchant has to decide whether this subsequent payment is used for the same token payment scenario or something changed. This is important because the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used for the same scenario, otherwise, the card issuer will decline the charge.&lt;br /&gt;
A &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used again if:&lt;br /&gt;
* the funding source is the same (technically the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* the token payment scenario is the same (technically the &amp;lt;code&amp;gt;RecurrenceType&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* this subsequent request complies with the scenario restrictions (eg: in case of recurring payment the amount of the subsequent payment does not exceed the initial amount)&lt;br /&gt;
&lt;br /&gt;
If the funding source changes, new &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the funding source|described in detail here]]. If the funding source stays the same but the scenario changes or the restrictions are no longer met new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the token payment scenario with an existing token|described here]].&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Recurring payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this case, three extra conditions must be met:&lt;br /&gt;
* the amount of the subsequent payment must not be higher than the initial amount&lt;br /&gt;
* at least that much days must be spent as defined in the initial &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; property&lt;br /&gt;
* the date of the payment must not exceed the day specified in the initial &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; property&lt;br /&gt;
&lt;br /&gt;
Please be aware that in case any of these are no longer valid the merchant has to request a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; as [[#Changing the token payment scenario with an existing token|described here]]. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=These conditions are not enforced by the Barion system so the violation of them will result in a declined charge.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
Payment/start must not include the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; properties (since they are already fixed during the initial payment).&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Recurring payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Merchant Initiated Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario there are no restrictions.&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Merchant Initiated Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 75,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Phone bill&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of OneClick Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario, the merchant has to prepare to perform the [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]] of the payer. 3DS authentication is not required in the following cases:&lt;br /&gt;
* the token (&amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;) was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is not used in this scenario since the payer is present during the transaction. &lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent OneClick Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 17,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Book: How to shop online&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;How to shop online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Book about shopping online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;piece&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
In this scenario, the response contains the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; property that is used to perform an [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8-9&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: &amp;quot;ewoJIkNhcmRQdWJs...WZXJzaW9uIjogIjIuMS4wIgp9Cg==&amp;quot;,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Possible error responses for the subsequent payment requests ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| InvalidRecurrenceId|| The token specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is invalid. Check if the token registration was successful.&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentDenied|| Something happened to the user since the token registration, either deleted, suspended, or blocked. The payment s not allowed in these cases.&lt;br /&gt;
|-&lt;br /&gt;
| InsufficientFunds|| If the original payment was with an e-money wallet and the customer doesn&#039;t have enough money to fulfill this charge this error happens.&lt;br /&gt;
|-&lt;br /&gt;
| OriginalPaymentWasntSuccessful || This means that the token belongs to an originally unsuccessful payment so this token can not be used anymore. This could only happen if the original payment was financed with a credit card.&lt;br /&gt;
|-&lt;br /&gt;
|InvalidCurrency || If the original payment was paid with e-money and the current token payment is in a currency that the wallet does not have an account in this error happens.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is the request-response diagram of the subsequent payments:&lt;br /&gt;
&lt;br /&gt;
[[File:Token_payment_2.png]]&lt;br /&gt;
&lt;br /&gt;
= Changing funding source or token scenarios =&lt;br /&gt;
&lt;br /&gt;
==Changing the funding source==&lt;br /&gt;
&lt;br /&gt;
This could happen if the funding source becomes invalid for some reason (card gets deleted or expires) or the merchant decides to use that token for another payer. In this case, the merchant has to register the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; again. &lt;br /&gt;
To do this a new payment must be started and in the [[Payment-Start-v2|Payment/Start]] request the following setup should be specified:&lt;br /&gt;
* the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; field has to be set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; &lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; has to be specified.&lt;br /&gt;
* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; should not be specified.&lt;br /&gt;
&lt;br /&gt;
[[File:Funding-source-change.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is bound to the payer and the process if the funding source changes new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be generated. This new ID must be saved to this payment and must be used from this moment on for subsequent payments.&lt;br /&gt;
&lt;br /&gt;
==Changing the token payment scenario with an existing token==&lt;br /&gt;
&lt;br /&gt;
This could occur when the merchant wants to get authorization from the payer to a new token scenario for the already registered funding source. To be able to do this the merchant has to have a valid and registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
Let&#039;s see some examples when this may be necessary:&lt;br /&gt;
* The payer subscribed to the merchant&#039;s service beforehand and the merchant decided to use the recurring payment token scenario. The payer wants to subscribe to another service and this requires a different payment schedule. This means that the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; that was specified initially can not be maintained so it is required to acquire a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;&lt;br /&gt;
* The payer bought something on the merchant&#039;s website and uses the one-click feature for subsequent fast non-redirect payments. After a while, the payer decides to subscribe to a service provided by this same merchant. This means that the merchant has to create a new token scenario (not a one-click payment but a recurring payment). For this, the merchant has to acquire a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. This can be done without redirecting the payer to Barion using the existing &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; and performing a 3DS authentication on the merchant&#039;s website.&lt;br /&gt;
&lt;br /&gt;
To do these a new payment must be started and in the [[Payment-Start-v2|Payment/Start]] request the following setup should be specified:&lt;br /&gt;
* the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; field has to be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; &lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; has to be specified.&lt;br /&gt;
* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; should not be specified.&lt;br /&gt;
&lt;br /&gt;
After this, a 3DS authentication has to be completed to acquire a new trace ID. This can be done on the merchant&#039;s site if the merchant implements the barion.offsitegw.js for off-site 3DS authentication.&lt;br /&gt;
&lt;br /&gt;
This means that it can be achieved to acquire different Trace IDs for different scenarios with only one &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
This is basically categorizing the different token scenarios as opposed to using every subsequent payment as an unmarked charge.&lt;br /&gt;
&lt;br /&gt;
[[File:Mutiple-traceid.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
= Off-site 3DS v2 authentication =&lt;br /&gt;
&lt;br /&gt;
In certain scenarios, the payer has to be authenticated to lower the risk of the card transaction. This can be either performed &lt;br /&gt;
* on the Barion Smart Gateway (on-site) by redirecting the customer to Barion &lt;br /&gt;
* or on the merchant&#039;s website (off-site) by integrating the Barion Off-site client library.&lt;br /&gt;
&lt;br /&gt;
This section describes how to integrate the Barion off-site authentication library into the merchant&#039;s site.&lt;br /&gt;
&lt;br /&gt;
== Step 1 : Initialize the off-site authentication library  ==&lt;br /&gt;
You have to include the following css and javascript files in the code of your site. &lt;br /&gt;
&amp;lt;source lang=html&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source &amp;gt;&lt;br /&gt;
These files include all the necessary javascript code and styling to handle the 3DS authentication and display the challenge if necessary.&lt;br /&gt;
&lt;br /&gt;
Then you have to initialize the Barion javascript client. To do that, you have to define a configuration object that specifies your functions that handle the off-site authentication events. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; Authentication events&#039;&#039;&#039;&lt;br /&gt;
* &amp;lt;code&amp;gt;onAuthenticationSucceeded&amp;lt;/code&amp;gt;: the 3DS v2 authentication successfully completed&lt;br /&gt;
* &amp;lt;code&amp;gt;onAuthenticationFailed&amp;lt;/code&amp;gt;:  the 3DS v2 authentication failed&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const configuration = {&lt;br /&gt;
    onAuthenticationSucceeded: function () {&lt;br /&gt;
        // handle successful authentication by calling the Barion API via merchant&#039;s backend&lt;br /&gt;
        // Call the v2/payment/complete endpoint&lt;br /&gt;
    },&lt;br /&gt;
    onAuthenticationFailed: function () {&lt;br /&gt;
        // Handle unsuccessful authentication result, no charge was made.&lt;br /&gt;
        // The payment might be still valid only the authentication failed&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to pass this config object to the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const gw = new Barion.OffsiteGw(configuration);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Step 2: Start the authentication process ===&lt;br /&gt;
Once the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; is acquired from the payment/start you can start the authentication process by calling the &amp;lt;code&amp;gt;authenticate()&amp;lt;/code&amp;gt; method of the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
gw.authenticate(threeDsClientData);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will start the authentication process and present the challenge if needed. Visually this will create a modal window over the merchant&#039;s site and show the payer every necessary information.&lt;br /&gt;
Once the authentication process finished (either with or without a challenge) the appropriate event will be fired. &lt;br /&gt;
&lt;br /&gt;
== Step 3: Completing the payment ==&lt;br /&gt;
&lt;br /&gt;
In case of successful authentication, you have to call our [[Payment-Complete-v3|/Payment/Complete]] endpoint, where the actual charge will happen.&lt;br /&gt;
&lt;br /&gt;
=== Possible error responses for the subsequent payment requests ===&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
== Suggested implementation flow for off-site authentication ==&lt;br /&gt;
&lt;br /&gt;
Ideally, an off-site authentication should be part of a client-side experience without any postbacks or page reloads. This is our recommendation to achieve this:&lt;br /&gt;
&lt;br /&gt;
# After the customer clicks on the &amp;quot;Pay&amp;quot; button make an AJAX call from your client-side code to your back-end. &lt;br /&gt;
# Have your backend make a request to our payment/start endpoint (with the appropriate settings for the desired token scenario)&lt;br /&gt;
# Have your backend process the response and pass the value of the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; property to your client-side code.&lt;br /&gt;
# Use the Barion off-site library to perform the authentication&lt;br /&gt;
# Once the authentication succeeds send another AJAX request from your client-side code to your back-end.&lt;br /&gt;
# Have your back-end code call our [[Payment-Complete-v3|/Payment/Complete]]&lt;br /&gt;
# Have your backend process the response and pass the result to your client-side code.&lt;br /&gt;
# Display the result for the customer&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2873</id>
		<title>Token payment 3D Secure</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2873"/>
		<updated>2020-11-26T12:43:57Z</updated>

		<summary type="html">&lt;p&gt;Botza: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Token Payment with 3D Secure}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{IncompletePage}}&lt;br /&gt;
&lt;br /&gt;
This payment scenario allows the integrator shop to register a token for a customer (and a funding source) in the Barion system and then, later on, using this token, charge the customer without redirecting her to the Barion Smart Gateway UI. The user may be present at the site of the merchant or she can be off-session as well, so the merchant can charge her e.g. for subscriptions. This means that the customer authorizes the shop to charge her card or Barion balance without typing in the card information or Barion login again.&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurring.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=Premium feature|text=This scenario is not allowed automatically for every approved shop and should be requested from Barion!|color=#1993c7}}&lt;br /&gt;
&lt;br /&gt;
= Token payment scenarios =&lt;br /&gt;
Token payment can be used in three use cases: &lt;br /&gt;
* &#039;&#039;&#039;Customer Initiated Payments&#039;&#039;&#039;: when the user is present on the website of the merchant and she decides to pay :&lt;br /&gt;
** &#039;&#039;&#039;OneClick payment&#039;&#039;&#039;: the user is charged upon her request initiated on the website of the merchant. Subsequent payments are subject to PSD2 SCA and as the user is present, she has to go through the authentication process.&lt;br /&gt;
* &#039;&#039;&#039;Merchant Initiated Payments&#039;&#039;&#039;: when the merchant initiates the payment without the user being present. It has two subtypes:&lt;br /&gt;
** &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: the user is charged with the same amount on a regular basis, typically in case of subscriptions. Subsequent payments are exempted from PSD2 SCA, but liability still shifts to the card issuer.&lt;br /&gt;
** &#039;&#039;&#039;MIT (merchant initiated transaction)&#039;&#039;&#039;: the user is charged on an irregular basis and/or with a different amount. Subsequent payments of this type are excluded from PSD2 SCA, the liability is on the merchant.&lt;br /&gt;
&lt;br /&gt;
== Customer participation ==&lt;br /&gt;
&lt;br /&gt;
Since the token scenario is suitable for both customer and merchant initiated payments here is a comparison about who starts the payment. This includes the regular, non-tokenized payment scenario as well:&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot; | Scenario&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Initial payment&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW &lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW&lt;br /&gt;
|-&lt;br /&gt;
| Non token (regular) payment || YES || YES || YES || YES &lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || YES || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| MIT || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #aaa; background-color:#eee; font-size: 0.8em; padding:5px 10px; display:inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; Token payment scenarios can be initiated with already registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; as well, in this case the customer may remain on the merchant&#039;s site. &lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements for the scenarios ==&lt;br /&gt;
&lt;br /&gt;
These token payment scenarios have different requirements, this table below summarizes the key differences.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Payment amount&lt;br /&gt;
! Payment frequency&lt;br /&gt;
! Liability in case of fraud&lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || Various || Various || Card issuer&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || Subsequent amounts must be equal or less than the initial amount  || Initial payment must define a minimum amount of days to wait between charges || Card issuer &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || Various  || Various || Merchant&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 3DS authentication of the payer ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be performed for every online card payment. These token payment scenarios also have to use this new secure way of authentication. &lt;br /&gt;
The initial payment of a token scenario must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
Here is a table to compare the 3DS authentication requirements:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Initial payment&lt;br /&gt;
! Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
| One-click payment || ✔️ || ✔️&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Real life examples ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phone bill&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Payer has a usage-based phone subscription that wants to pay without being present for every charge. She authorizes the phone company to charge her card every month.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, the amount of the subsequent payments may exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TV subscription&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to online streaming of a television channel. She authorizes the phone company to charge her card every month. The subscription fee is the same for every month.&lt;br /&gt;
* Scenario: Recurring payment&lt;br /&gt;
* Explanation: The amount of the subsequent payments will not exceed the initial payment and the charge is regularly monthly-based.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bookclub with &amp;quot;free first month&amp;quot; bonus&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to a book renting service. She authorizes the book club to charge her card every month for a selection of books. The subscription fee is the same for every month however, the first month is free. To ensure the subscription the service requires her to register her card details.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, and the fee will stay the same, the initial payment is zero. So the amount of the next payment will exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Online food delivery service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The food delivery company wants to provide a quick and easy experience for its customer. They decide that the order will be quicker if the customers don&#039;t leave the website to pay for the goods.&lt;br /&gt;
* Scenario: OneClick payment&lt;br /&gt;
* Explanation: The customer will always be there so the other two scenarios are not available.&lt;br /&gt;
&lt;br /&gt;
== How to decide ==&lt;br /&gt;
&lt;br /&gt;
To help you decide on a suitable scenario, please use the decision graph below:&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurrencetype-decision.png|520px]]&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
To be able to integrate your webshop with the Barion Payment Gateway: &lt;br /&gt;
* You must [[Creating_an_account|register a Barion wallet]] at the Barion website or in the Sandbox environment. Learn more about the Sandbox environment [[Sandbox|here]].&lt;br /&gt;
* For this wallet you have to [[Creating_a_shop|create a shop]] which should be approved by Barion.&lt;br /&gt;
* For every currency you plan to conduct payments in you have to make sure there is an account created in your Barion wallet. This means that if you plan to have USD payments then there should be a USD account created in your wallet.&lt;br /&gt;
* To make sure every corner case scenario works for your webshop it is best to top up that account with a small amount (approx. 5-10EUR or your choice of currency around the same value).&lt;br /&gt;
* For the technical communication guide please read this: [[Calling_the_API|Calling the API]]&lt;br /&gt;
&lt;br /&gt;
= The payment process =&lt;br /&gt;
&lt;br /&gt;
The process is divided into two major steps:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 1:  Creating the funding source token|Creating the token]] that represents one of the customer&#039;s funding sources (credit card or e-money wallet)&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Preparing the payment via the Barion API&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Redirecting the customer to the Barion Smart Gateway to select a funding source&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Processing the callback and requesting information about the result of the payment&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 2: Using the token|Using the registered token]] to charge the customer&amp;lt;/li&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1:  Creating the funding source token ==&lt;br /&gt;
To be able to use a token payment scenario first the merchant has to register the token with Barion. The merchant has to make sure that the customer is well aware of the fact that they are giving consent to a tokenized payment. The Barion Smart Gateway UI does not indicate in any way that the payment is a token payment.&lt;br /&gt;
&lt;br /&gt;
The token is registered to the shop and not to the merchant&#039;s Barion account. So if the merchant has multiple shops in its Barion account, the registered tokens can not be shared among them even if the customer is the same. If you want to use tokens in multiple shops, please contact Barion in the Customer center.&lt;br /&gt;
&lt;br /&gt;
=== 1.1 Preparing the payment===&lt;br /&gt;
&lt;br /&gt;
The token registration is basically a [[Responsive_web_payment|normal payment]] with three extra properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* InitiateRecurrence&lt;br /&gt;
* RecurrenceId&lt;br /&gt;
* RecurrenceType&lt;br /&gt;
&lt;br /&gt;
==== InitiateRecurrence====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; property is a bool property. If you set it to &#039;&#039;&#039;true&#039;&#039;&#039; then the payment gateway will consider the payment as a token registration. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This happens even if the customer is already has a registered token, so you are able to re-register a funding source or even a customer. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceId ====&lt;br /&gt;
The next required property for a token registration is the token itself. This is generated by the shop and has to be unique for every registration. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property of the [[Payment-Start-v2|Payment/Start]] request. This token must be saved in the webshops database. A &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; token represents the funding source (bank card or Barion balance) of a customer. Since a customer can have multiple cards and accounts as a funding source make sure that in the webshop&#039;s system multiple tokens can belong to a single customer.&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceType ====&lt;br /&gt;
The third required property is the [[RecurrenceType|Recurrence Type]]. This specifies the scenario. In case of Recurring Payment &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; must also be set.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Merchant Initiated Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The response will be the same as to a [[Responsive_web_payment#Processing_the_successful_response|basic &#039;&#039;&#039;Immediate&#039;&#039;&#039; scenario]]. The &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; property at this point is &#039;&#039;&#039;None&#039;&#039;&#039; since the token is not registered to a funding source yet.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Recurring Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Recurring Payment&#039;&#039;&#039; scenario has some extra restrictions. The merchant has to specify two additional properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt;: The date after the subsequent charges should not accepted.&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt;: The minimum days the merchant has to wait between payments.&lt;br /&gt;
&lt;br /&gt;
Both properties are located in the [[PurchaseInformation]] property and must be specified if this scenario is selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7, 30-33&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;PurchaseInformation&amp;quot;:{&lt;br /&gt;
        &amp;quot;RecurringFrequency&amp;quot;: 10,&lt;br /&gt;
        &amp;quot;RecurringExpiry&amp;quot;: &amp;quot;2022-10-01&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Possible error responses ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentNotAllowed || The token payment is not allowed for the shop identified by the &#039;&#039;&#039;POSKey&#039;&#039;&#039;. Contact Barion to request this feature.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 1.2 Redirecting the customer to the Barion Smart Gateway to select a funding source ===&lt;br /&gt;
&lt;br /&gt;
After a successful payment preparation, the customer is redirected to the secure Barion Smart Gateway to choose a funding source. The funding source the customer selects will be registered to the token. The funding source can either be a Barion e-money balance or a bank card. This means that even though the customer may own multiple cards only the one that was registered to the token can be used for future token payments. To change the funding source attached to the token a new registration should be requested.&lt;br /&gt;
&lt;br /&gt;
=== 1.3 Processing the callback and requesting information about the result of the payment ===&lt;br /&gt;
&lt;br /&gt;
When the payment is completed (either successfully or unsuccessfully) a callback message is sent to the merchant&#039;s system. Once received a [[Payment-GetPaymentState-v2|GetPaymentState]] request must be sent to the Barion API. On how to implement this please read the article about the  [[Callback_mechanism|Callback mechanism]].&lt;br /&gt;
&lt;br /&gt;
The full response of the GetPaymentState request depends on the payment scenario and the structure of the payment. When it comes to token payment there are several properties to look out for. &lt;br /&gt;
* In case the &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; is &#039;&#039;&#039;Succeeded&#039;&#039;&#039; the funding source token is registered and ready to use.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; contains the ID of the token process. This specifies the nature of the token payment. &lt;br /&gt;
&lt;br /&gt;
==== TraceId ====&lt;br /&gt;
&lt;br /&gt;
In case of Recurring payment or Merchant initiated payment scenarios the [[Payment-GetPaymentState-v2|GetPaymentState]] response returns an additional field called &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. The value of this property is generated by the card issuer. The merchant has to save it and submit it in all subsequent Recurring or Merchant initiated payments of the same type, otherwise, the payments can be declined by the issuer. The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; represents the first, customer-present payment and helps the issuer to connect subsequent payments to this initial payment.&lt;br /&gt;
&lt;br /&gt;
====Example GetPaymentState response====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;8, 11-12&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;OrderNumber&amp;quot;: null,&lt;br /&gt;
    &amp;quot;POSId&amp;quot;: &amp;quot;[[SHOPS_PUBLIC_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSName&amp;quot;: &amp;quot;[[MERCHANTS_BARION_SHOPNAME]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSOwnerEmail&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSource&amp;quot;: &amp;quot;BankCard&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;AllowedFundingSources&amp;quot;: [&lt;br /&gt;
        &amp;quot;All&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;GuestCheckout&amp;quot;: true,&lt;br /&gt;
    &amp;quot;CreatedAt&amp;quot;: &amp;quot;2020-11-26T07:52:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ValidUntil&amp;quot;: &amp;quot;2020-11-26T08:22:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;CompletedAt&amp;quot;: &amp;quot;2020-11-26T08:11:54.118Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ReservedUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;DelayedCaptureUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
           ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;Total&amp;quot;: 25.20,&lt;br /&gt;
    &amp;quot;SuggestedLocale&amp;quot;: &amp;quot;hu-HU&amp;quot;,&lt;br /&gt;
    &amp;quot;FraudRiskScore&amp;quot;: null,&lt;br /&gt;
    &amp;quot;RedirectUrl&amp;quot;: &amp;quot;https://merchanturl/Redirect?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;CallbackUrl&amp;quot;: &amp;quot;https://merchanturl/Callback?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Displaying the funding source in a GUI ====&lt;br /&gt;
We strongly advise saving the complete response for future reference. The &amp;lt;code&amp;gt;FundingSource&amp;lt;/code&amp;gt; field tells if the funding source is a Barion balance or a card. If it is a card, it is useful to save [[FundingInformation]] for displaying it for the user, when requesting future payments. The usual way to display funding sources is to show the last 4 digits of the card, with 4 stars, eg: *** 1234. The card used can be obtained from FundingInformation&#039;s [[BankCard]] field. The [[CardType]] field can be used to display the appropriate card logo. You can even show, if the card is expired, and offer to register another one.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; FundingInformation part of the GetPaymentState response &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=json&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be displayed for example as &amp;lt;code&amp;gt;VISA **** 0425 (12/20)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a request-response diagram of the token registration process:&lt;br /&gt;
 &lt;br /&gt;
[[File:Token_payment_initiation.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Step 2: Using the token =&lt;br /&gt;
&lt;br /&gt;
To use an already registered token for a payment, you have to use the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property. To be able to use a token, the initial payment must be in a successful state.&lt;br /&gt;
&lt;br /&gt;
At this point, the merchant has to decide whether this subsequent payment is used for the same token payment scenario or something changed. This is important because the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used for the same scenario, otherwise, the card issuer will decline the charge.&lt;br /&gt;
A &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used again if:&lt;br /&gt;
* the funding source is the same (technically the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* the token payment scenario is the same (technically the &amp;lt;code&amp;gt;RecurrenceType&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* this subsequent request complies with the scenario restrictions (eg: in case of recurring payment the amount of the subsequent payment does not exceed the initial amount)&lt;br /&gt;
&lt;br /&gt;
If the funding source changes, new &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the funding source|described in detail here]]. If the funding source stays the same but the scenario changes or the restrictions are no longer met new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the token payment scenario with an existing token|described here]].&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Recurring payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this case, three extra conditions must be met:&lt;br /&gt;
* the amount of the subsequent payment must not be higher than the initial amount&lt;br /&gt;
* at least that much days must be spent as defined in the initial &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; property&lt;br /&gt;
* the date of the payment must not exceed the day specified in the initial &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; property&lt;br /&gt;
&lt;br /&gt;
Please be aware that in case any of these are no longer valid the merchant has to request a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; as [[#Changing the token payment scenario with an existing token|described here]]. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=These conditions are not enforced by the Barion system so the violation of them will result in a declined charge.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
Payment/start must not include the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; properties (since they are already fixed during the initial payment).&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Recurring payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Merchant Initiated Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario there are no restrictions.&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Merchant Initiated Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 75,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Phone bill&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of OneClick Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario, the merchant has to prepare to perform the [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]] of the payer. 3DS authentication is not required in the following cases:&lt;br /&gt;
* the token (&amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;) was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is not used in this scenario since the payer is present during the transaction. &lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent OneClick Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 17,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Book: How to shop online&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;How to shop online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Book about shopping online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;piece&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
In this scenario, the response contains the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; property that is used to perform an [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8-9&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: &amp;quot;ewoJIkNhcmRQdWJs...WZXJzaW9uIjogIjIuMS4wIgp9Cg==&amp;quot;,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Possible error responses for the subsequent payment requests ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| InvalidRecurrenceId|| The token specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is invalid. Check if the token registration was successful.&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentDenied|| Something happened to the user since the token registration, either deleted, suspended, or blocked. The payment s not allowed in these cases.&lt;br /&gt;
|-&lt;br /&gt;
| InsufficientFunds|| If the original payment was with an e-money wallet and the customer doesn&#039;t have enough money to fulfill this charge this error happens.&lt;br /&gt;
|-&lt;br /&gt;
| OriginalPaymentWasntSuccessful || This means that the token belongs to an originally unsuccessful payment so this token can not be used anymore. This could only happen if the original payment was financed with a credit card.&lt;br /&gt;
|-&lt;br /&gt;
|InvalidCurrency || If the original payment was paid with e-money and the current token payment is in a currency that the wallet does not have an account in this error happens.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is the request-response diagram of the subsequent payments:&lt;br /&gt;
&lt;br /&gt;
[[File:Token_payment_2.png]]&lt;br /&gt;
&lt;br /&gt;
= Changing funding source or token scenarios =&lt;br /&gt;
&lt;br /&gt;
==Changing the funding source==&lt;br /&gt;
&lt;br /&gt;
This could happen if the funding source becomes invalid for some reason (card gets deleted or expires) or the merchant decides to use that token for another payer. In this case, the merchant has to register the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; again. &lt;br /&gt;
To do this a new payment must be started and in the [[Payment-Start-v2|Payment/Start]] request the following setup should be specified:&lt;br /&gt;
* the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; field has to be set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; &lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; has to be specified.&lt;br /&gt;
* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; should not be specified.&lt;br /&gt;
&lt;br /&gt;
[[File:Funding-source-change.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is bound to the payer and the process if the funding source changes new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be generated. This new ID must be saved to this payment and must be used from this moment on for subsequent payments.&lt;br /&gt;
&lt;br /&gt;
==Changing the token payment scenario with an existing token==&lt;br /&gt;
&lt;br /&gt;
This could occur when the merchant wants to get authorization from the payer to a new token scenario for the already registered funding source. To be able to do this the merchant has to have a valid and registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
Let&#039;s see some examples when this may be necessary:&lt;br /&gt;
* The payer subscribed to the merchant&#039;s service beforehand and the merchant decided to use the recurring payment token scenario. The payer wants to subscribe to another service and this requires a different payment schedule. This means that the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; that was specified initially can not be maintained so it is required to acquire a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;&lt;br /&gt;
* The payer bought something on the merchant&#039;s website and uses the one-click feature for subsequent fast non-redirect payments. After a while, the payer decides to subscribe to a service provided by this same merchant. This means that the merchant has to create a new token scenario (not a one-click payment but a recurring payment). For this, the merchant has to acquire a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. This can be done without redirecting the payer to Barion using the existing &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; and performing a 3DS authentication on the merchant&#039;s website.&lt;br /&gt;
&lt;br /&gt;
To do these a new payment must be started and in the [[Payment-Start-v2|Payment/Start]] request the following setup should be specified:&lt;br /&gt;
* the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; field has to be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; &lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; has to be specified.&lt;br /&gt;
* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; should not be specified.&lt;br /&gt;
&lt;br /&gt;
After this, a 3DS authentication has to be completed to acquire a new trace ID. This can be done on the merchant&#039;s site if the merchant implements the barion.offsitegw.js for off-site 3DS authentication.&lt;br /&gt;
&lt;br /&gt;
This means that it can be achieved to acquire different Trace IDs for different scenarios with only one &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
This is basically categorizing the different token scenarios as opposed to using every subsequent payment as an unmarked charge.&lt;br /&gt;
&lt;br /&gt;
[[File:Mutiple-traceid.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
= Off-site 3DS v2 authentication =&lt;br /&gt;
&lt;br /&gt;
In certain scenarios, the payer has to be authenticated to lower the risk of the card transaction. This can be either performed &lt;br /&gt;
* on the Barion Smart Gateway (on-site) by redirecting the customer to Barion &lt;br /&gt;
* or on the merchant&#039;s website (off-site) by integrating the Barion Off-site client library.&lt;br /&gt;
&lt;br /&gt;
This section describes how to integrate the Barion off-site authentication library into the merchant&#039;s site.&lt;br /&gt;
&lt;br /&gt;
== Step 1 : Initialize the off-site authentication library  ==&lt;br /&gt;
You have to include the following css and javascript files in the code of your site. &lt;br /&gt;
&amp;lt;source lang=html&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source &amp;gt;&lt;br /&gt;
These files include all the necessary javascript code and styling to handle the 3DS authentication and display the challenge if necessary.&lt;br /&gt;
&lt;br /&gt;
Then you have to initialize the Barion javascript client. To do that, you have to define a configuration object that specifies your functions that handle the off-site authentication events. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; Authentication events&#039;&#039;&#039;&lt;br /&gt;
* &amp;lt;code&amp;gt;onAuthenticationSucceeded&amp;lt;/code&amp;gt;: the 3DS v2 authentication successfully completed&lt;br /&gt;
* &amp;lt;code&amp;gt;onAuthenticationFailed&amp;lt;/code&amp;gt;:  the 3DS v2 authentication failed&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const configuration = {&lt;br /&gt;
    onAuthenticationSucceeded: function () {&lt;br /&gt;
        // handle successful authentication by calling the Barion API via merchant&#039;s backend&lt;br /&gt;
        // Call the v2/payment/complete endpoint&lt;br /&gt;
    },&lt;br /&gt;
    onAuthenticationFailed: function () {&lt;br /&gt;
        // Handle unsuccessful authentication result, no charge was made.&lt;br /&gt;
        // The payment might be still valid only the authentication failed&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to pass this config object to the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const gw = new Barion.OffsiteGw(configuration);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Step 2: Start the authentication process ===&lt;br /&gt;
Once the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; is acquired from the payment/start you can start the authentication process by calling the &amp;lt;code&amp;gt;authenticate()&amp;lt;/code&amp;gt; method of the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
gw.authenticate(threeDsClientData);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will start the authentication process and present the challenge if needed. Visually this will create a modal window over the merchant&#039;s site and show the payer every necessary information.&lt;br /&gt;
Once the authentication process finished (either with or without a challenge) the appropriate event will be fired. &lt;br /&gt;
&lt;br /&gt;
== Step 3: Completing the payment ==&lt;br /&gt;
&lt;br /&gt;
In case of successful authentication, you have to call our [[Payment-Complete-v3|/Payment/Complete]] endpoint, where the actual charge will happen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Suggested implementation flow for off-site authentication ==&lt;br /&gt;
&lt;br /&gt;
Ideally, an off-site authentication should be part of a client-side experience without any postbacks or page reloads. This is our recommendation to achieve this:&lt;br /&gt;
&lt;br /&gt;
# After the customer clicks on the &amp;quot;Pay&amp;quot; button make an AJAX call from your client-side code to your back-end. &lt;br /&gt;
# Have your backend make a request to our payment/start endpoint (with the appropriate settings for the desired token scenario)&lt;br /&gt;
# Have your backend process the response and pass the value of the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; property to your client-side code.&lt;br /&gt;
# Use the Barion off-site library to perform the authentication&lt;br /&gt;
# Once the authentication succeeds send another AJAX request from your client-side code to your back-end.&lt;br /&gt;
# Have your back-end code call our [[Payment-Complete-v3|/Payment/Complete]]&lt;br /&gt;
# Have your backend process the response and pass the result to your client-side code.&lt;br /&gt;
# Display the result for the customer&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=File:Mutiple-traceid.png&amp;diff=2872</id>
		<title>File:Mutiple-traceid.png</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=File:Mutiple-traceid.png&amp;diff=2872"/>
		<updated>2020-11-26T12:43:37Z</updated>

		<summary type="html">&lt;p&gt;Botza: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=File:Funding-source-change.png&amp;diff=2871</id>
		<title>File:Funding-source-change.png</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=File:Funding-source-change.png&amp;diff=2871"/>
		<updated>2020-11-26T12:42:30Z</updated>

		<summary type="html">&lt;p&gt;Botza: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2870</id>
		<title>Token payment 3D Secure</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2870"/>
		<updated>2020-11-26T12:39:30Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* Off-site 3DS v2 authentication */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Token Payment with 3D Secure}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{IncompletePage}}&lt;br /&gt;
&lt;br /&gt;
This payment scenario allows the integrator shop to register a token for a customer (and a funding source) in the Barion system and then, later on, using this token, charge the customer without redirecting her to the Barion Smart Gateway UI. The user may be present at the site of the merchant or she can be off-session as well, so the merchant can charge her e.g. for subscriptions. This means that the customer authorizes the shop to charge her card or Barion balance without typing in the card information or Barion login again.&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurring.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=Premium feature|text=This scenario is not allowed automatically for every approved shop and should be requested from Barion!|color=#1993c7}}&lt;br /&gt;
&lt;br /&gt;
= Token payment scenarios =&lt;br /&gt;
Token payment can be used in three use cases: &lt;br /&gt;
* &#039;&#039;&#039;Customer Initiated Payments&#039;&#039;&#039;: when the user is present on the website of the merchant and she decides to pay :&lt;br /&gt;
** &#039;&#039;&#039;OneClick payment&#039;&#039;&#039;: the user is charged upon her request initiated on the website of the merchant. Subsequent payments are subject to PSD2 SCA and as the user is present, she has to go through the authentication process.&lt;br /&gt;
* &#039;&#039;&#039;Merchant Initiated Payments&#039;&#039;&#039;: when the merchant initiates the payment without the user being present. It has two subtypes:&lt;br /&gt;
** &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: the user is charged with the same amount on a regular basis, typically in case of subscriptions. Subsequent payments are exempted from PSD2 SCA, but liability still shifts to the card issuer.&lt;br /&gt;
** &#039;&#039;&#039;MIT (merchant initiated transaction)&#039;&#039;&#039;: the user is charged on an irregular basis and/or with a different amount. Subsequent payments of this type are excluded from PSD2 SCA, the liability is on the merchant.&lt;br /&gt;
&lt;br /&gt;
== Customer participation ==&lt;br /&gt;
&lt;br /&gt;
Since the token scenario is suitable for both customer and merchant initiated payments here is a comparison about who starts the payment. This includes the regular, non-tokenized payment scenario as well:&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot; | Scenario&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Initial payment&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW &lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW&lt;br /&gt;
|-&lt;br /&gt;
| Non token (regular) payment || YES || YES || YES || YES &lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || YES || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| MIT || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #aaa; background-color:#eee; font-size: 0.8em; padding:5px 10px; display:inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; Token payment scenarios can be initiated with already registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; as well, in this case the customer may remain on the merchant&#039;s site. &lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements for the scenarios ==&lt;br /&gt;
&lt;br /&gt;
These token payment scenarios have different requirements, this table below summarizes the key differences.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Payment amount&lt;br /&gt;
! Payment frequency&lt;br /&gt;
! Liability in case of fraud&lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || Various || Various || Card issuer&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || Subsequent amounts must be equal or less than the initial amount  || Initial payment must define a minimum amount of days to wait between charges || Card issuer &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || Various  || Various || Merchant&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 3DS authentication of the payer ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be performed for every online card payment. These token payment scenarios also have to use this new secure way of authentication. &lt;br /&gt;
The initial payment of a token scenario must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
Here is a table to compare the 3DS authentication requirements:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Initial payment&lt;br /&gt;
! Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
| One-click payment || ✔️ || ✔️&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Real life examples ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phone bill&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Payer has a usage-based phone subscription that wants to pay without being present for every charge. She authorizes the phone company to charge her card every month.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, the amount of the subsequent payments may exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TV subscription&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to online streaming of a television channel. She authorizes the phone company to charge her card every month. The subscription fee is the same for every month.&lt;br /&gt;
* Scenario: Recurring payment&lt;br /&gt;
* Explanation: The amount of the subsequent payments will not exceed the initial payment and the charge is regularly monthly-based.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bookclub with &amp;quot;free first month&amp;quot; bonus&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to a book renting service. She authorizes the book club to charge her card every month for a selection of books. The subscription fee is the same for every month however, the first month is free. To ensure the subscription the service requires her to register her card details.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, and the fee will stay the same, the initial payment is zero. So the amount of the next payment will exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Online food delivery service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The food delivery company wants to provide a quick and easy experience for its customer. They decide that the order will be quicker if the customers don&#039;t leave the website to pay for the goods.&lt;br /&gt;
* Scenario: OneClick payment&lt;br /&gt;
* Explanation: The customer will always be there so the other two scenarios are not available.&lt;br /&gt;
&lt;br /&gt;
== How to decide ==&lt;br /&gt;
&lt;br /&gt;
To help you decide on a suitable scenario, please use the decision graph below:&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurrencetype-decision.png|520px]]&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
To be able to integrate your webshop with the Barion Payment Gateway: &lt;br /&gt;
* You must [[Creating_an_account|register a Barion wallet]] at the Barion website or in the Sandbox environment. Learn more about the Sandbox environment [[Sandbox|here]].&lt;br /&gt;
* For this wallet you have to [[Creating_a_shop|create a shop]] which should be approved by Barion.&lt;br /&gt;
* For every currency you plan to conduct payments in you have to make sure there is an account created in your Barion wallet. This means that if you plan to have USD payments then there should be a USD account created in your wallet.&lt;br /&gt;
* To make sure every corner case scenario works for your webshop it is best to top up that account with a small amount (approx. 5-10EUR or your choice of currency around the same value).&lt;br /&gt;
* For the technical communication guide please read this: [[Calling_the_API|Calling the API]]&lt;br /&gt;
&lt;br /&gt;
= The payment process =&lt;br /&gt;
&lt;br /&gt;
The process is divided into two major steps:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 1:  Creating the funding source token|Creating the token]] that represents one of the customer&#039;s funding sources (credit card or e-money wallet)&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Preparing the payment via the Barion API&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Redirecting the customer to the Barion Smart Gateway to select a funding source&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Processing the callback and requesting information about the result of the payment&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 2: Using the token|Using the registered token]] to charge the customer&amp;lt;/li&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1:  Creating the funding source token ==&lt;br /&gt;
To be able to use a token payment scenario first the merchant has to register the token with Barion. The merchant has to make sure that the customer is well aware of the fact that they are giving consent to a tokenized payment. The Barion Smart Gateway UI does not indicate in any way that the payment is a token payment.&lt;br /&gt;
&lt;br /&gt;
The token is registered to the shop and not to the merchant&#039;s Barion account. So if the merchant has multiple shops in its Barion account, the registered tokens can not be shared among them even if the customer is the same. If you want to use tokens in multiple shops, please contact Barion in the Customer center.&lt;br /&gt;
&lt;br /&gt;
=== 1.1 Preparing the payment===&lt;br /&gt;
&lt;br /&gt;
The token registration is basically a [[Responsive_web_payment|normal payment]] with three extra properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* InitiateRecurrence&lt;br /&gt;
* RecurrenceId&lt;br /&gt;
* RecurrenceType&lt;br /&gt;
&lt;br /&gt;
==== InitiateRecurrence====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; property is a bool property. If you set it to &#039;&#039;&#039;true&#039;&#039;&#039; then the payment gateway will consider the payment as a token registration. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This happens even if the customer is already has a registered token, so you are able to re-register a funding source or even a customer. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceId ====&lt;br /&gt;
The next required property for a token registration is the token itself. This is generated by the shop and has to be unique for every registration. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property of the [[Payment-Start-v2|Payment/Start]] request. This token must be saved in the webshops database. A &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; token represents the funding source (bank card or Barion balance) of a customer. Since a customer can have multiple cards and accounts as a funding source make sure that in the webshop&#039;s system multiple tokens can belong to a single customer.&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceType ====&lt;br /&gt;
The third required property is the [[RecurrenceType|Recurrence Type]]. This specifies the scenario. In case of Recurring Payment &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; must also be set.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Merchant Initiated Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The response will be the same as to a [[Responsive_web_payment#Processing_the_successful_response|basic &#039;&#039;&#039;Immediate&#039;&#039;&#039; scenario]]. The &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; property at this point is &#039;&#039;&#039;None&#039;&#039;&#039; since the token is not registered to a funding source yet.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Recurring Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Recurring Payment&#039;&#039;&#039; scenario has some extra restrictions. The merchant has to specify two additional properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt;: The date after the subsequent charges should not accepted.&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt;: The minimum days the merchant has to wait between payments.&lt;br /&gt;
&lt;br /&gt;
Both properties are located in the [[PurchaseInformation]] property and must be specified if this scenario is selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7, 30-33&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;PurchaseInformation&amp;quot;:{&lt;br /&gt;
        &amp;quot;RecurringFrequency&amp;quot;: 10,&lt;br /&gt;
        &amp;quot;RecurringExpiry&amp;quot;: &amp;quot;2022-10-01&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Possible error responses ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentNotAllowed || The token payment is not allowed for the shop identified by the &#039;&#039;&#039;POSKey&#039;&#039;&#039;. Contact Barion to request this feature.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 1.2 Redirecting the customer to the Barion Smart Gateway to select a funding source ===&lt;br /&gt;
&lt;br /&gt;
After a successful payment preparation, the customer is redirected to the secure Barion Smart Gateway to choose a funding source. The funding source the customer selects will be registered to the token. The funding source can either be a Barion e-money balance or a bank card. This means that even though the customer may own multiple cards only the one that was registered to the token can be used for future token payments. To change the funding source attached to the token a new registration should be requested.&lt;br /&gt;
&lt;br /&gt;
=== 1.3 Processing the callback and requesting information about the result of the payment ===&lt;br /&gt;
&lt;br /&gt;
When the payment is completed (either successfully or unsuccessfully) a callback message is sent to the merchant&#039;s system. Once received a [[Payment-GetPaymentState-v2|GetPaymentState]] request must be sent to the Barion API. On how to implement this please read the article about the  [[Callback_mechanism|Callback mechanism]].&lt;br /&gt;
&lt;br /&gt;
The full response of the GetPaymentState request depends on the payment scenario and the structure of the payment. When it comes to token payment there are several properties to look out for. &lt;br /&gt;
* In case the &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; is &#039;&#039;&#039;Succeeded&#039;&#039;&#039; the funding source token is registered and ready to use.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; contains the ID of the token process. This specifies the nature of the token payment. &lt;br /&gt;
&lt;br /&gt;
==== TraceId ====&lt;br /&gt;
&lt;br /&gt;
In case of Recurring payment or Merchant initiated payment scenarios the [[Payment-GetPaymentState-v2|GetPaymentState]] response returns an additional field called &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. The value of this property is generated by the card issuer. The merchant has to save it and submit it in all subsequent Recurring or Merchant initiated payments of the same type, otherwise, the payments can be declined by the issuer. The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; represents the first, customer-present payment and helps the issuer to connect subsequent payments to this initial payment.&lt;br /&gt;
&lt;br /&gt;
====Example GetPaymentState response====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;8, 11-12&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;OrderNumber&amp;quot;: null,&lt;br /&gt;
    &amp;quot;POSId&amp;quot;: &amp;quot;[[SHOPS_PUBLIC_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSName&amp;quot;: &amp;quot;[[MERCHANTS_BARION_SHOPNAME]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSOwnerEmail&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSource&amp;quot;: &amp;quot;BankCard&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;AllowedFundingSources&amp;quot;: [&lt;br /&gt;
        &amp;quot;All&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;GuestCheckout&amp;quot;: true,&lt;br /&gt;
    &amp;quot;CreatedAt&amp;quot;: &amp;quot;2020-11-26T07:52:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ValidUntil&amp;quot;: &amp;quot;2020-11-26T08:22:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;CompletedAt&amp;quot;: &amp;quot;2020-11-26T08:11:54.118Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ReservedUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;DelayedCaptureUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
           ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;Total&amp;quot;: 25.20,&lt;br /&gt;
    &amp;quot;SuggestedLocale&amp;quot;: &amp;quot;hu-HU&amp;quot;,&lt;br /&gt;
    &amp;quot;FraudRiskScore&amp;quot;: null,&lt;br /&gt;
    &amp;quot;RedirectUrl&amp;quot;: &amp;quot;https://merchanturl/Redirect?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;CallbackUrl&amp;quot;: &amp;quot;https://merchanturl/Callback?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Displaying the funding source in a GUI ====&lt;br /&gt;
We strongly advise saving the complete response for future reference. The &amp;lt;code&amp;gt;FundingSource&amp;lt;/code&amp;gt; field tells if the funding source is a Barion balance or a card. If it is a card, it is useful to save [[FundingInformation]] for displaying it for the user, when requesting future payments. The usual way to display funding sources is to show the last 4 digits of the card, with 4 stars, eg: *** 1234. The card used can be obtained from FundingInformation&#039;s [[BankCard]] field. The [[CardType]] field can be used to display the appropriate card logo. You can even show, if the card is expired, and offer to register another one.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; FundingInformation part of the GetPaymentState response &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=json&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be displayed for example as &amp;lt;code&amp;gt;VISA **** 0425 (12/20)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a request-response diagram of the token registration process:&lt;br /&gt;
 &lt;br /&gt;
[[File:Token_payment_initiation.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Step 2: Using the token =&lt;br /&gt;
&lt;br /&gt;
To use an already registered token for a payment, you have to use the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property. To be able to use a token, the initial payment must be in a successful state.&lt;br /&gt;
&lt;br /&gt;
At this point, the merchant has to decide whether this subsequent payment is used for the same token payment scenario or something changed. This is important because the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used for the same scenario, otherwise, the card issuer will decline the charge.&lt;br /&gt;
A &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used again if:&lt;br /&gt;
* the funding source is the same (technically the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* the token payment scenario is the same (technically the &amp;lt;code&amp;gt;RecurrenceType&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* this subsequent request complies with the scenario restrictions (eg: in case of recurring payment the amount of the subsequent payment does not exceed the initial amount)&lt;br /&gt;
&lt;br /&gt;
If the funding source changes, new &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the funding source|described in detail here]]. If the funding source stays the same but the scenario changes or the restrictions are no longer met new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the token payment scenario with an existing token|described here]].&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Recurring payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this case, three extra conditions must be met:&lt;br /&gt;
* the amount of the subsequent payment must not be higher than the initial amount&lt;br /&gt;
* at least that much days must be spent as defined in the initial &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; property&lt;br /&gt;
* the date of the payment must not exceed the day specified in the initial &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; property&lt;br /&gt;
&lt;br /&gt;
Please be aware that in case any of these are no longer valid the merchant has to request a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; as [[#Changing the token payment scenario with an existing token|described here]]. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=These conditions are not enforced by the Barion system so the violation of them will result in a declined charge.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
Payment/start must not include the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; properties (since they are already fixed during the initial payment).&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Recurring payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Merchant Initiated Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario there are no restrictions.&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Merchant Initiated Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 75,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Phone bill&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of OneClick Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario, the merchant has to prepare to perform the [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]] of the payer. 3DS authentication is not required in the following cases:&lt;br /&gt;
* the token (&amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;) was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is not used in this scenario since the payer is present during the transaction. &lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent OneClick Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 17,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Book: How to shop online&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;How to shop online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Book about shopping online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;piece&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
In this scenario, the response contains the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; property that is used to perform an [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8-9&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: &amp;quot;ewoJIkNhcmRQdWJs...WZXJzaW9uIjogIjIuMS4wIgp9Cg==&amp;quot;,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Possible error responses for the subsequent payment requests ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| InvalidRecurrenceId|| The token specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is invalid. Check if the token registration was successful.&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentDenied|| Something happened to the user since the token registration, either deleted, suspended, or blocked. The payment s not allowed in these cases.&lt;br /&gt;
|-&lt;br /&gt;
| InsufficientFunds|| If the original payment was with an e-money wallet and the customer doesn&#039;t have enough money to fulfill this charge this error happens.&lt;br /&gt;
|-&lt;br /&gt;
| OriginalPaymentWasntSuccessful || This means that the token belongs to an originally unsuccessful payment so this token can not be used anymore. This could only happen if the original payment was financed with a credit card.&lt;br /&gt;
|-&lt;br /&gt;
|InvalidCurrency || If the original payment was paid with e-money and the current token payment is in a currency that the wallet does not have an account in this error happens.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is the request-response diagram of the subsequent payments:&lt;br /&gt;
&lt;br /&gt;
[[File:Token_payment_2.png]]&lt;br /&gt;
&lt;br /&gt;
= todo =&lt;br /&gt;
&lt;br /&gt;
==Changing the funding source==&lt;br /&gt;
&lt;br /&gt;
This could happen if the funding source becomes invalid for some reason (card gets deleted or expires) or the merchant decides to use that token for another payer. In this case, the merchant has to register the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; again. &lt;br /&gt;
To do this a new payment must be started and in the [[Payment-Start-v2|Payment/Start]] request the following setup should be specified:&lt;br /&gt;
* the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; field has to be set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; &lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; has to be specified.&lt;br /&gt;
* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; should not be specified.&lt;br /&gt;
&lt;br /&gt;
Since the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is bound to the payer and the process if the funding source changes new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be generated. This new ID must be saved to this payment and must be used from this moment on for subsequent payments.&lt;br /&gt;
&lt;br /&gt;
==Changing the token payment scenario==&lt;br /&gt;
&lt;br /&gt;
This could occur when the merchant wants to get authorization from the payer to a new token scenario for the already registered funding source. To be able to do this the merchant has to have a valid and registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
Let&#039;s see some examples when this may be necessary:&lt;br /&gt;
* The payer subscribed to the merchant&#039;s service beforehand and the merchant decided to use the recurring payment token scenario. The payer wants to subscribe to another service and this requires a different payment schedule. This means that the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; that was specified initially can not be maintained so it is required to acquire a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;&lt;br /&gt;
* The payer bought something on the merchant&#039;s website and uses the one-click feature for subsequent fast non-redirect payments. After a while, the payer decides to subscribe to a service provided by this same merchant. This means that the merchant has to create a new token scenario (not a one-click payment but a recurring payment). For this, the merchant has to acquire a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. This can be done without redirecting the payer to Barion using the existing &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; and performing a 3DS authentication on the merchant&#039;s website.&lt;br /&gt;
&lt;br /&gt;
To do these a new payment must be started and in the [[Payment-Start-v2|Payment/Start]] request the following setup should be specified:&lt;br /&gt;
* the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; field has to be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; &lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; has to be specified.&lt;br /&gt;
* and the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; should not be specified.&lt;br /&gt;
&lt;br /&gt;
After this, a 3DS authentication has to be completed to acquire a new trace ID. This can be done on the merchant&#039;s site if the merchant implements the barion.offsitegw.js for off-site 3DS authentication.&lt;br /&gt;
&lt;br /&gt;
This means that it can be achieved to acquire different Trace IDs for different scenarios with only one RecurrenceId.&lt;br /&gt;
This is basically categorizing the different token scenarios as opposed to using every subsequent payment as an unmarked charge.&lt;br /&gt;
&lt;br /&gt;
= Off-site 3DS v2 authentication =&lt;br /&gt;
&lt;br /&gt;
In certain scenarios, the payer has to be authenticated to lower the risk of the card transaction. This can be either performed &lt;br /&gt;
* on the Barion Smart Gateway (on-site) by redirecting the customer to Barion &lt;br /&gt;
* or on the merchant&#039;s website (off-site) by integrating the Barion Off-site client library.&lt;br /&gt;
&lt;br /&gt;
This section describes how to integrate the Barion off-site authentication library into the merchant&#039;s site.&lt;br /&gt;
&lt;br /&gt;
== Step 1 : Initialize the off-site authentication library  ==&lt;br /&gt;
You have to include the following css and javascript files in the code of your site. &lt;br /&gt;
&amp;lt;source lang=html&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source &amp;gt;&lt;br /&gt;
These files include all the necessary javascript code and styling to handle the 3DS authentication and display the challenge if necessary.&lt;br /&gt;
&lt;br /&gt;
Then you have to initialize the Barion javascript client. To do that, you have to define a configuration object that specifies your functions that handle the off-site authentication events. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; Authentication events&#039;&#039;&#039;&lt;br /&gt;
* &amp;lt;code&amp;gt;onAuthenticationSucceeded&amp;lt;/code&amp;gt;: the 3DS v2 authentication successfully completed&lt;br /&gt;
* &amp;lt;code&amp;gt;onAuthenticationFailed&amp;lt;/code&amp;gt;:  the 3DS v2 authentication failed&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const configuration = {&lt;br /&gt;
    onAuthenticationSucceeded: function () {&lt;br /&gt;
        // handle successful authentication by calling the Barion API via merchant&#039;s backend&lt;br /&gt;
        // Call the v2/payment/complete endpoint&lt;br /&gt;
    },&lt;br /&gt;
    onAuthenticationFailed: function () {&lt;br /&gt;
        // Handle unsuccessful authentication result, no charge was made.&lt;br /&gt;
        // The payment might be still valid only the authentication failed&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to pass this config object to the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const gw = new Barion.OffsiteGw(configuration);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Step 2: Start the authentication process ===&lt;br /&gt;
Once the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; is acquired from the payment/start you can start the authentication process by calling the &amp;lt;code&amp;gt;authenticate()&amp;lt;/code&amp;gt; method of the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
gw.authenticate(threeDsClientData);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will start the authentication process and present the challenge if needed. Visually this will create a modal window over the merchant&#039;s site and show the payer every necessary information.&lt;br /&gt;
Once the authentication process finished (either with or without a challenge) the appropriate event will be fired. &lt;br /&gt;
&lt;br /&gt;
== Step 3: Completing the payment ==&lt;br /&gt;
&lt;br /&gt;
In case of successful authentication, you have to call our [[Payment-Complete-v3|/Payment/Complete]] endpoint, where the actual charge will happen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Suggested implementation flow for off-site authentication ==&lt;br /&gt;
&lt;br /&gt;
Ideally, an off-site authentication should be part of a client-side experience without any postbacks or page reloads. This is our recommendation to achieve this:&lt;br /&gt;
&lt;br /&gt;
# After the customer clicks on the &amp;quot;Pay&amp;quot; button make an AJAX call from your client-side code to your back-end. &lt;br /&gt;
# Have your backend make a request to our payment/start endpoint (with the appropriate settings for the desired token scenario)&lt;br /&gt;
# Have your backend process the response and pass the value of the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; property to your client-side code.&lt;br /&gt;
# Use the Barion off-site library to perform the authentication&lt;br /&gt;
# Once the authentication succeeds send another AJAX request from your client-side code to your back-end.&lt;br /&gt;
# Have your back-end code call our [[Payment-Complete-v3|/Payment/Complete]]&lt;br /&gt;
# Have your backend process the response and pass the result to your client-side code.&lt;br /&gt;
# Display the result for the customer&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2869</id>
		<title>Token payment 3D Secure</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2869"/>
		<updated>2020-11-26T12:38:12Z</updated>

		<summary type="html">&lt;p&gt;Botza: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Token Payment with 3D Secure}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{IncompletePage}}&lt;br /&gt;
&lt;br /&gt;
This payment scenario allows the integrator shop to register a token for a customer (and a funding source) in the Barion system and then, later on, using this token, charge the customer without redirecting her to the Barion Smart Gateway UI. The user may be present at the site of the merchant or she can be off-session as well, so the merchant can charge her e.g. for subscriptions. This means that the customer authorizes the shop to charge her card or Barion balance without typing in the card information or Barion login again.&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurring.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=Premium feature|text=This scenario is not allowed automatically for every approved shop and should be requested from Barion!|color=#1993c7}}&lt;br /&gt;
&lt;br /&gt;
= Token payment scenarios =&lt;br /&gt;
Token payment can be used in three use cases: &lt;br /&gt;
* &#039;&#039;&#039;Customer Initiated Payments&#039;&#039;&#039;: when the user is present on the website of the merchant and she decides to pay :&lt;br /&gt;
** &#039;&#039;&#039;OneClick payment&#039;&#039;&#039;: the user is charged upon her request initiated on the website of the merchant. Subsequent payments are subject to PSD2 SCA and as the user is present, she has to go through the authentication process.&lt;br /&gt;
* &#039;&#039;&#039;Merchant Initiated Payments&#039;&#039;&#039;: when the merchant initiates the payment without the user being present. It has two subtypes:&lt;br /&gt;
** &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: the user is charged with the same amount on a regular basis, typically in case of subscriptions. Subsequent payments are exempted from PSD2 SCA, but liability still shifts to the card issuer.&lt;br /&gt;
** &#039;&#039;&#039;MIT (merchant initiated transaction)&#039;&#039;&#039;: the user is charged on an irregular basis and/or with a different amount. Subsequent payments of this type are excluded from PSD2 SCA, the liability is on the merchant.&lt;br /&gt;
&lt;br /&gt;
== Customer participation ==&lt;br /&gt;
&lt;br /&gt;
Since the token scenario is suitable for both customer and merchant initiated payments here is a comparison about who starts the payment. This includes the regular, non-tokenized payment scenario as well:&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot; | Scenario&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Initial payment&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW &lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW&lt;br /&gt;
|-&lt;br /&gt;
| Non token (regular) payment || YES || YES || YES || YES &lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || YES || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| MIT || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #aaa; background-color:#eee; font-size: 0.8em; padding:5px 10px; display:inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; Token payment scenarios can be initiated with already registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; as well, in this case the customer may remain on the merchant&#039;s site. &lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements for the scenarios ==&lt;br /&gt;
&lt;br /&gt;
These token payment scenarios have different requirements, this table below summarizes the key differences.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Payment amount&lt;br /&gt;
! Payment frequency&lt;br /&gt;
! Liability in case of fraud&lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || Various || Various || Card issuer&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || Subsequent amounts must be equal or less than the initial amount  || Initial payment must define a minimum amount of days to wait between charges || Card issuer &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || Various  || Various || Merchant&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 3DS authentication of the payer ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be performed for every online card payment. These token payment scenarios also have to use this new secure way of authentication. &lt;br /&gt;
The initial payment of a token scenario must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
Here is a table to compare the 3DS authentication requirements:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Initial payment&lt;br /&gt;
! Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
| One-click payment || ✔️ || ✔️&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Real life examples ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phone bill&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Payer has a usage-based phone subscription that wants to pay without being present for every charge. She authorizes the phone company to charge her card every month.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, the amount of the subsequent payments may exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TV subscription&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to online streaming of a television channel. She authorizes the phone company to charge her card every month. The subscription fee is the same for every month.&lt;br /&gt;
* Scenario: Recurring payment&lt;br /&gt;
* Explanation: The amount of the subsequent payments will not exceed the initial payment and the charge is regularly monthly-based.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bookclub with &amp;quot;free first month&amp;quot; bonus&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to a book renting service. She authorizes the book club to charge her card every month for a selection of books. The subscription fee is the same for every month however, the first month is free. To ensure the subscription the service requires her to register her card details.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, and the fee will stay the same, the initial payment is zero. So the amount of the next payment will exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Online food delivery service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The food delivery company wants to provide a quick and easy experience for its customer. They decide that the order will be quicker if the customers don&#039;t leave the website to pay for the goods.&lt;br /&gt;
* Scenario: OneClick payment&lt;br /&gt;
* Explanation: The customer will always be there so the other two scenarios are not available.&lt;br /&gt;
&lt;br /&gt;
== How to decide ==&lt;br /&gt;
&lt;br /&gt;
To help you decide on a suitable scenario, please use the decision graph below:&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurrencetype-decision.png|520px]]&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
To be able to integrate your webshop with the Barion Payment Gateway: &lt;br /&gt;
* You must [[Creating_an_account|register a Barion wallet]] at the Barion website or in the Sandbox environment. Learn more about the Sandbox environment [[Sandbox|here]].&lt;br /&gt;
* For this wallet you have to [[Creating_a_shop|create a shop]] which should be approved by Barion.&lt;br /&gt;
* For every currency you plan to conduct payments in you have to make sure there is an account created in your Barion wallet. This means that if you plan to have USD payments then there should be a USD account created in your wallet.&lt;br /&gt;
* To make sure every corner case scenario works for your webshop it is best to top up that account with a small amount (approx. 5-10EUR or your choice of currency around the same value).&lt;br /&gt;
* For the technical communication guide please read this: [[Calling_the_API|Calling the API]]&lt;br /&gt;
&lt;br /&gt;
= The payment process =&lt;br /&gt;
&lt;br /&gt;
The process is divided into two major steps:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 1:  Creating the funding source token|Creating the token]] that represents one of the customer&#039;s funding sources (credit card or e-money wallet)&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Preparing the payment via the Barion API&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Redirecting the customer to the Barion Smart Gateway to select a funding source&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Processing the callback and requesting information about the result of the payment&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 2: Using the token|Using the registered token]] to charge the customer&amp;lt;/li&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1:  Creating the funding source token ==&lt;br /&gt;
To be able to use a token payment scenario first the merchant has to register the token with Barion. The merchant has to make sure that the customer is well aware of the fact that they are giving consent to a tokenized payment. The Barion Smart Gateway UI does not indicate in any way that the payment is a token payment.&lt;br /&gt;
&lt;br /&gt;
The token is registered to the shop and not to the merchant&#039;s Barion account. So if the merchant has multiple shops in its Barion account, the registered tokens can not be shared among them even if the customer is the same. If you want to use tokens in multiple shops, please contact Barion in the Customer center.&lt;br /&gt;
&lt;br /&gt;
=== 1.1 Preparing the payment===&lt;br /&gt;
&lt;br /&gt;
The token registration is basically a [[Responsive_web_payment|normal payment]] with three extra properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* InitiateRecurrence&lt;br /&gt;
* RecurrenceId&lt;br /&gt;
* RecurrenceType&lt;br /&gt;
&lt;br /&gt;
==== InitiateRecurrence====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; property is a bool property. If you set it to &#039;&#039;&#039;true&#039;&#039;&#039; then the payment gateway will consider the payment as a token registration. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This happens even if the customer is already has a registered token, so you are able to re-register a funding source or even a customer. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceId ====&lt;br /&gt;
The next required property for a token registration is the token itself. This is generated by the shop and has to be unique for every registration. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property of the [[Payment-Start-v2|Payment/Start]] request. This token must be saved in the webshops database. A &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; token represents the funding source (bank card or Barion balance) of a customer. Since a customer can have multiple cards and accounts as a funding source make sure that in the webshop&#039;s system multiple tokens can belong to a single customer.&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceType ====&lt;br /&gt;
The third required property is the [[RecurrenceType|Recurrence Type]]. This specifies the scenario. In case of Recurring Payment &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; must also be set.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Merchant Initiated Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The response will be the same as to a [[Responsive_web_payment#Processing_the_successful_response|basic &#039;&#039;&#039;Immediate&#039;&#039;&#039; scenario]]. The &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; property at this point is &#039;&#039;&#039;None&#039;&#039;&#039; since the token is not registered to a funding source yet.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Recurring Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Recurring Payment&#039;&#039;&#039; scenario has some extra restrictions. The merchant has to specify two additional properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt;: The date after the subsequent charges should not accepted.&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt;: The minimum days the merchant has to wait between payments.&lt;br /&gt;
&lt;br /&gt;
Both properties are located in the [[PurchaseInformation]] property and must be specified if this scenario is selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7, 30-33&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;PurchaseInformation&amp;quot;:{&lt;br /&gt;
        &amp;quot;RecurringFrequency&amp;quot;: 10,&lt;br /&gt;
        &amp;quot;RecurringExpiry&amp;quot;: &amp;quot;2022-10-01&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Possible error responses ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentNotAllowed || The token payment is not allowed for the shop identified by the &#039;&#039;&#039;POSKey&#039;&#039;&#039;. Contact Barion to request this feature.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 1.2 Redirecting the customer to the Barion Smart Gateway to select a funding source ===&lt;br /&gt;
&lt;br /&gt;
After a successful payment preparation, the customer is redirected to the secure Barion Smart Gateway to choose a funding source. The funding source the customer selects will be registered to the token. The funding source can either be a Barion e-money balance or a bank card. This means that even though the customer may own multiple cards only the one that was registered to the token can be used for future token payments. To change the funding source attached to the token a new registration should be requested.&lt;br /&gt;
&lt;br /&gt;
=== 1.3 Processing the callback and requesting information about the result of the payment ===&lt;br /&gt;
&lt;br /&gt;
When the payment is completed (either successfully or unsuccessfully) a callback message is sent to the merchant&#039;s system. Once received a [[Payment-GetPaymentState-v2|GetPaymentState]] request must be sent to the Barion API. On how to implement this please read the article about the  [[Callback_mechanism|Callback mechanism]].&lt;br /&gt;
&lt;br /&gt;
The full response of the GetPaymentState request depends on the payment scenario and the structure of the payment. When it comes to token payment there are several properties to look out for. &lt;br /&gt;
* In case the &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; is &#039;&#039;&#039;Succeeded&#039;&#039;&#039; the funding source token is registered and ready to use.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; contains the ID of the token process. This specifies the nature of the token payment. &lt;br /&gt;
&lt;br /&gt;
==== TraceId ====&lt;br /&gt;
&lt;br /&gt;
In case of Recurring payment or Merchant initiated payment scenarios the [[Payment-GetPaymentState-v2|GetPaymentState]] response returns an additional field called &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. The value of this property is generated by the card issuer. The merchant has to save it and submit it in all subsequent Recurring or Merchant initiated payments of the same type, otherwise, the payments can be declined by the issuer. The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; represents the first, customer-present payment and helps the issuer to connect subsequent payments to this initial payment.&lt;br /&gt;
&lt;br /&gt;
====Example GetPaymentState response====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;8, 11-12&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;OrderNumber&amp;quot;: null,&lt;br /&gt;
    &amp;quot;POSId&amp;quot;: &amp;quot;[[SHOPS_PUBLIC_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSName&amp;quot;: &amp;quot;[[MERCHANTS_BARION_SHOPNAME]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSOwnerEmail&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSource&amp;quot;: &amp;quot;BankCard&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;AllowedFundingSources&amp;quot;: [&lt;br /&gt;
        &amp;quot;All&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;GuestCheckout&amp;quot;: true,&lt;br /&gt;
    &amp;quot;CreatedAt&amp;quot;: &amp;quot;2020-11-26T07:52:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ValidUntil&amp;quot;: &amp;quot;2020-11-26T08:22:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;CompletedAt&amp;quot;: &amp;quot;2020-11-26T08:11:54.118Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ReservedUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;DelayedCaptureUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
           ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;Total&amp;quot;: 25.20,&lt;br /&gt;
    &amp;quot;SuggestedLocale&amp;quot;: &amp;quot;hu-HU&amp;quot;,&lt;br /&gt;
    &amp;quot;FraudRiskScore&amp;quot;: null,&lt;br /&gt;
    &amp;quot;RedirectUrl&amp;quot;: &amp;quot;https://merchanturl/Redirect?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;CallbackUrl&amp;quot;: &amp;quot;https://merchanturl/Callback?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Displaying the funding source in a GUI ====&lt;br /&gt;
We strongly advise saving the complete response for future reference. The &amp;lt;code&amp;gt;FundingSource&amp;lt;/code&amp;gt; field tells if the funding source is a Barion balance or a card. If it is a card, it is useful to save [[FundingInformation]] for displaying it for the user, when requesting future payments. The usual way to display funding sources is to show the last 4 digits of the card, with 4 stars, eg: *** 1234. The card used can be obtained from FundingInformation&#039;s [[BankCard]] field. The [[CardType]] field can be used to display the appropriate card logo. You can even show, if the card is expired, and offer to register another one.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; FundingInformation part of the GetPaymentState response &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=json&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be displayed for example as &amp;lt;code&amp;gt;VISA **** 0425 (12/20)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a request-response diagram of the token registration process:&lt;br /&gt;
 &lt;br /&gt;
[[File:Token_payment_initiation.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Step 2: Using the token =&lt;br /&gt;
&lt;br /&gt;
To use an already registered token for a payment, you have to use the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property. To be able to use a token, the initial payment must be in a successful state.&lt;br /&gt;
&lt;br /&gt;
At this point, the merchant has to decide whether this subsequent payment is used for the same token payment scenario or something changed. This is important because the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used for the same scenario, otherwise, the card issuer will decline the charge.&lt;br /&gt;
A &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used again if:&lt;br /&gt;
* the funding source is the same (technically the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* the token payment scenario is the same (technically the &amp;lt;code&amp;gt;RecurrenceType&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* this subsequent request complies with the scenario restrictions (eg: in case of recurring payment the amount of the subsequent payment does not exceed the initial amount)&lt;br /&gt;
&lt;br /&gt;
If the funding source changes, new &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the funding source|described in detail here]]. If the funding source stays the same but the scenario changes or the restrictions are no longer met new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the token payment scenario with an existing token|described here]].&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Recurring payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this case, three extra conditions must be met:&lt;br /&gt;
* the amount of the subsequent payment must not be higher than the initial amount&lt;br /&gt;
* at least that much days must be spent as defined in the initial &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; property&lt;br /&gt;
* the date of the payment must not exceed the day specified in the initial &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; property&lt;br /&gt;
&lt;br /&gt;
Please be aware that in case any of these are no longer valid the merchant has to request a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; as [[#Changing the token payment scenario with an existing token|described here]]. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=These conditions are not enforced by the Barion system so the violation of them will result in a declined charge.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
Payment/start must not include the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; properties (since they are already fixed during the initial payment).&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Recurring payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Merchant Initiated Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario there are no restrictions.&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Merchant Initiated Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 75,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Phone bill&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of OneClick Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario, the merchant has to prepare to perform the [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]] of the payer. 3DS authentication is not required in the following cases:&lt;br /&gt;
* the token (&amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;) was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is not used in this scenario since the payer is present during the transaction. &lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent OneClick Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 17,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Book: How to shop online&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;How to shop online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Book about shopping online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;piece&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
In this scenario, the response contains the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; property that is used to perform an [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8-9&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: &amp;quot;ewoJIkNhcmRQdWJs...WZXJzaW9uIjogIjIuMS4wIgp9Cg==&amp;quot;,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Possible error responses for the subsequent payment requests ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| InvalidRecurrenceId|| The token specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is invalid. Check if the token registration was successful.&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentDenied|| Something happened to the user since the token registration, either deleted, suspended, or blocked. The payment s not allowed in these cases.&lt;br /&gt;
|-&lt;br /&gt;
| InsufficientFunds|| If the original payment was with an e-money wallet and the customer doesn&#039;t have enough money to fulfill this charge this error happens.&lt;br /&gt;
|-&lt;br /&gt;
| OriginalPaymentWasntSuccessful || This means that the token belongs to an originally unsuccessful payment so this token can not be used anymore. This could only happen if the original payment was financed with a credit card.&lt;br /&gt;
|-&lt;br /&gt;
|InvalidCurrency || If the original payment was paid with e-money and the current token payment is in a currency that the wallet does not have an account in this error happens.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is the request-response diagram of the subsequent payments:&lt;br /&gt;
&lt;br /&gt;
[[File:Token_payment_2.png]]&lt;br /&gt;
&lt;br /&gt;
= Off-site 3DS v2 authentication =&lt;br /&gt;
&lt;br /&gt;
In certain scenarios, the payer has to be authenticated to lower the risk of the card transaction. This can be either performed &lt;br /&gt;
* on the Barion Smart Gateway (on-site) by redirecting the customer to Barion &lt;br /&gt;
* or on the merchant&#039;s website (off-site) by integrating the Barion Off-site client library.&lt;br /&gt;
&lt;br /&gt;
This section describes how to integrate the Barion off-site authentication library into the merchant&#039;s site.&lt;br /&gt;
&lt;br /&gt;
== Step 1 : Initialize the off-site authentication library  ==&lt;br /&gt;
You have to include the following css and javascript files in the code of your site. &lt;br /&gt;
&amp;lt;source lang=html&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source &amp;gt;&lt;br /&gt;
These files include all the necessary javascript code and styling to handle the 3DS authentication and display the challenge if necessary.&lt;br /&gt;
&lt;br /&gt;
Then you have to initialize the Barion javascript client. To do that, you have to define a configuration object that specifies your functions that handle the off-site authentication events. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; Authentication events&#039;&#039;&#039;&lt;br /&gt;
* &amp;lt;code&amp;gt;onAuthenticationSucceeded&amp;lt;/code&amp;gt;: the 3DS v2 authentication successfully completed&lt;br /&gt;
* &amp;lt;code&amp;gt;onAuthenticationFailed&amp;lt;/code&amp;gt;:  the 3DS v2 authentication failed&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const configuration = {&lt;br /&gt;
    onAuthenticationSucceeded: function () {&lt;br /&gt;
        // handle successful authentication by calling the Barion API via merchant&#039;s backend&lt;br /&gt;
        // Call the v2/payment/complete endpoint&lt;br /&gt;
    },&lt;br /&gt;
    onAuthenticationFailed: function () {&lt;br /&gt;
        // Handle unsuccessful authentication result, no charge was made.&lt;br /&gt;
        // The payment might be still valid only the authentication failed&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to pass this config object to the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const gw = new Barion.OffsiteGw(configuration);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Step 2: Start the authentication process ===&lt;br /&gt;
Once the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; is acquired from the payment/start you can start the authentication process by calling the &amp;lt;code&amp;gt;authenticate()&amp;lt;/code&amp;gt; method of the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
gw.authenticate(threeDsClientData);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will start the authentication process and present the challenge if needed. Visually this will create a modal window over the merchant&#039;s site and show the payer every necessary information.&lt;br /&gt;
Once the authentication process finished (either with or without a challenge) the appropriate event will be fired. &lt;br /&gt;
&lt;br /&gt;
== Step 3: Completing the payment ==&lt;br /&gt;
&lt;br /&gt;
In case of successful authentication, you have to call our [[Payment-Complete-v3|/Payment/Complete]] endpoint, where the actual charge will happen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Suggested implementation flow for off-site authentication ==&lt;br /&gt;
&lt;br /&gt;
Ideally, an off-site authentication should be part of a client-side experience without any postbacks or page reloads. This is our recommendation to achieve this:&lt;br /&gt;
&lt;br /&gt;
# After the customer clicks on the &amp;quot;Pay&amp;quot; button make an AJAX call from your client-side code to your back-end. &lt;br /&gt;
# Have your backend make a request to our payment/start endpoint (with the appropriate settings for the desired token scenario)&lt;br /&gt;
# Have your backend process the response and pass the value of the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; property to your client-side code.&lt;br /&gt;
# Use the Barion off-site library to perform the authentication&lt;br /&gt;
# Once the authentication succeeds send another AJAX request from your client-side code to your back-end.&lt;br /&gt;
# Have your back-end code call our [[Payment-Complete-v3|/Payment/Complete]]&lt;br /&gt;
# Have your backend process the response and pass the result to your client-side code.&lt;br /&gt;
# Display the result for the customer&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2868</id>
		<title>Token payment 3D Secure</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2868"/>
		<updated>2020-11-26T12:36:53Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* Off-site 3DS v2 authentication */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Token Payment with 3D Secure}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{IncompletePage}}&lt;br /&gt;
&lt;br /&gt;
This payment scenario allows the integrator shop to register a token for a customer (and a funding source) in the Barion system and then, later on, using this token, charge the customer without redirecting her to the Barion Smart Gateway UI. The user may be present at the site of the merchant or she can be off-session as well, so the merchant can charge her e.g. for subscriptions. This means that the customer authorizes the shop to charge her card or Barion balance without typing in the card information or Barion login again.&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurring.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=Premium feature|text=This scenario is not allowed automatically for every approved shop and should be requested from Barion!|color=#1993c7}}&lt;br /&gt;
&lt;br /&gt;
= Token payment scenarios =&lt;br /&gt;
Token payment can be used in three use cases: &lt;br /&gt;
* &#039;&#039;&#039;Customer Initiated Payments&#039;&#039;&#039;: when the user is present on the website of the merchant and she decides to pay :&lt;br /&gt;
** &#039;&#039;&#039;OneClick payment&#039;&#039;&#039;: the user is charged upon her request initiated on the website of the merchant. Subsequent payments are subject to PSD2 SCA and as the user is present, she has to go through the authentication process.&lt;br /&gt;
* &#039;&#039;&#039;Merchant Initiated Payments&#039;&#039;&#039;: when the merchant initiates the payment without the user being present. It has two subtypes:&lt;br /&gt;
** &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: the user is charged with the same amount on a regular basis, typically in case of subscriptions. Subsequent payments are exempted from PSD2 SCA, but liability still shifts to the card issuer.&lt;br /&gt;
** &#039;&#039;&#039;MIT (merchant initiated transaction)&#039;&#039;&#039;: the user is charged on an irregular basis and/or with a different amount. Subsequent payments of this type are excluded from PSD2 SCA, the liability is on the merchant.&lt;br /&gt;
&lt;br /&gt;
== Customer participation ==&lt;br /&gt;
&lt;br /&gt;
Since the token scenario is suitable for both customer and merchant initiated payments here is a comparison about who starts the payment. This includes the regular, non-tokenized payment scenario as well:&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot; | Scenario&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Initial payment&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW &lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW&lt;br /&gt;
|-&lt;br /&gt;
| Non token (regular) payment || YES || YES || YES || YES &lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || YES || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| MIT || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #aaa; background-color:#eee; font-size: 0.8em; padding:5px 10px; display:inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; Token payment scenarios can be initiated with already registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; as well, in this case the customer may remain on the merchant&#039;s site. &lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements for the scenarios ==&lt;br /&gt;
&lt;br /&gt;
These token payment scenarios have different requirements, this table below summarizes the key differences.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Payment amount&lt;br /&gt;
! Payment frequency&lt;br /&gt;
! Liability in case of fraud&lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || Various || Various || Card issuer&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || Subsequent amounts must be equal or less than the initial amount  || Initial payment must define a minimum amount of days to wait between charges || Card issuer &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || Various  || Various || Merchant&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 3DS authentication of the payer ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be performed for every online card payment. These token payment scenarios also have to use this new secure way of authentication. &lt;br /&gt;
The initial payment of a token scenario must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
Here is a table to compare the 3DS authentication requirements:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Initial payment&lt;br /&gt;
! Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
| One-click payment || ✔️ || ✔️&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Real life examples ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phone bill&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Payer has a usage-based phone subscription that wants to pay without being present for every charge. She authorizes the phone company to charge her card every month.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, the amount of the subsequent payments may exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TV subscription&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to online streaming of a television channel. She authorizes the phone company to charge her card every month. The subscription fee is the same for every month.&lt;br /&gt;
* Scenario: Recurring payment&lt;br /&gt;
* Explanation: The amount of the subsequent payments will not exceed the initial payment and the charge is regularly monthly-based.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bookclub with &amp;quot;free first month&amp;quot; bonus&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to a book renting service. She authorizes the book club to charge her card every month for a selection of books. The subscription fee is the same for every month however, the first month is free. To ensure the subscription the service requires her to register her card details.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, and the fee will stay the same, the initial payment is zero. So the amount of the next payment will exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Online food delivery service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The food delivery company wants to provide a quick and easy experience for its customer. They decide that the order will be quicker if the customers don&#039;t leave the website to pay for the goods.&lt;br /&gt;
* Scenario: OneClick payment&lt;br /&gt;
* Explanation: The customer will always be there so the other two scenarios are not available.&lt;br /&gt;
&lt;br /&gt;
== How to decide ==&lt;br /&gt;
&lt;br /&gt;
To help you decide on a suitable scenario, please use the decision graph below:&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurrencetype-decision.png|520px]]&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
To be able to integrate your webshop with the Barion Payment Gateway: &lt;br /&gt;
* You must [[Creating_an_account|register a Barion wallet]] at the Barion website or in the Sandbox environment. Learn more about the Sandbox environment [[Sandbox|here]].&lt;br /&gt;
* For this wallet you have to [[Creating_a_shop|create a shop]] which should be approved by Barion.&lt;br /&gt;
* For every currency you plan to conduct payments in you have to make sure there is an account created in your Barion wallet. This means that if you plan to have USD payments then there should be a USD account created in your wallet.&lt;br /&gt;
* To make sure every corner case scenario works for your webshop it is best to top up that account with a small amount (approx. 5-10EUR or your choice of currency around the same value).&lt;br /&gt;
* For the technical communication guide please read this: [[Calling_the_API|Calling the API]]&lt;br /&gt;
&lt;br /&gt;
= The payment process =&lt;br /&gt;
&lt;br /&gt;
The process is divided into two major steps:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 1:  Creating the funding source token|Creating the token]] that represents one of the customer&#039;s funding sources (credit card or e-money wallet)&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Preparing the payment via the Barion API&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Redirecting the customer to the Barion Smart Gateway to select a funding source&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Processing the callback and requesting information about the result of the payment&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 2: Using the token|Using the registered token]] to charge the customer&amp;lt;/li&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1:  Creating the funding source token ==&lt;br /&gt;
To be able to use a token payment scenario first the merchant has to register the token with Barion. The merchant has to make sure that the customer is well aware of the fact that they are giving consent to a tokenized payment. The Barion Smart Gateway UI does not indicate in any way that the payment is a token payment.&lt;br /&gt;
&lt;br /&gt;
The token is registered to the shop and not to the merchant&#039;s Barion account. So if the merchant has multiple shops in its Barion account, the registered tokens can not be shared among them even if the customer is the same. If you want to use tokens in multiple shops, please contact Barion in the Customer center.&lt;br /&gt;
&lt;br /&gt;
=== 1.1 Preparing the payment===&lt;br /&gt;
&lt;br /&gt;
The token registration is basically a [[Responsive_web_payment|normal payment]] with three extra properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* InitiateRecurrence&lt;br /&gt;
* RecurrenceId&lt;br /&gt;
* RecurrenceType&lt;br /&gt;
&lt;br /&gt;
==== InitiateRecurrence====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; property is a bool property. If you set it to &#039;&#039;&#039;true&#039;&#039;&#039; then the payment gateway will consider the payment as a token registration. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This happens even if the customer is already has a registered token, so you are able to re-register a funding source or even a customer. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceId ====&lt;br /&gt;
The next required property for a token registration is the token itself. This is generated by the shop and has to be unique for every registration. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property of the [[Payment-Start-v2|Payment/Start]] request. This token must be saved in the webshops database. A &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; token represents the funding source (bank card or Barion balance) of a customer. Since a customer can have multiple cards and accounts as a funding source make sure that in the webshop&#039;s system multiple tokens can belong to a single customer.&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceType ====&lt;br /&gt;
The third required property is the [[RecurrenceType|Recurrence Type]]. This specifies the scenario. In case of Recurring Payment &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; must also be set.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Merchant Initiated Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The response will be the same as to a [[Responsive_web_payment#Processing_the_successful_response|basic &#039;&#039;&#039;Immediate&#039;&#039;&#039; scenario]]. The &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; property at this point is &#039;&#039;&#039;None&#039;&#039;&#039; since the token is not registered to a funding source yet.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Recurring Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Recurring Payment&#039;&#039;&#039; scenario has some extra restrictions. The merchant has to specify two additional properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt;: The date after the subsequent charges should not accepted.&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt;: The minimum days the merchant has to wait between payments.&lt;br /&gt;
&lt;br /&gt;
Both properties are located in the [[PurchaseInformation]] property and must be specified if this scenario is selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7, 30-33&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;PurchaseInformation&amp;quot;:{&lt;br /&gt;
        &amp;quot;RecurringFrequency&amp;quot;: 10,&lt;br /&gt;
        &amp;quot;RecurringExpiry&amp;quot;: &amp;quot;2022-10-01&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Possible error responses ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentNotAllowed || The token payment is not allowed for the shop identified by the &#039;&#039;&#039;POSKey&#039;&#039;&#039;. Contact Barion to request this feature.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 1.2 Redirecting the customer to the Barion Smart Gateway to select a funding source ===&lt;br /&gt;
&lt;br /&gt;
After a successful payment preparation, the customer is redirected to the secure Barion Smart Gateway to choose a funding source. The funding source the customer selects will be registered to the token. The funding source can either be a Barion e-money balance or a bank card. This means that even though the customer may own multiple cards only the one that was registered to the token can be used for future token payments. To change the funding source attached to the token a new registration should be requested.&lt;br /&gt;
&lt;br /&gt;
=== 1.3 Processing the callback and requesting information about the result of the payment ===&lt;br /&gt;
&lt;br /&gt;
When the payment is completed (either successfully or unsuccessfully) a callback message is sent to the merchant&#039;s system. Once received a [[Payment-GetPaymentState-v2|GetPaymentState]] request must be sent to the Barion API. On how to implement this please read the article about the  [[Callback_mechanism|Callback mechanism]].&lt;br /&gt;
&lt;br /&gt;
The full response of the GetPaymentState request depends on the payment scenario and the structure of the payment. When it comes to token payment there are several properties to look out for. &lt;br /&gt;
* In case the &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; is &#039;&#039;&#039;Succeeded&#039;&#039;&#039; the funding source token is registered and ready to use.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; contains the ID of the token process. This specifies the nature of the token payment. &lt;br /&gt;
&lt;br /&gt;
==== TraceId ====&lt;br /&gt;
&lt;br /&gt;
In case of Recurring payment or Merchant initiated payment scenarios the [[Payment-GetPaymentState-v2|GetPaymentState]] response returns an additional field called &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. The value of this property is generated by the card issuer. The merchant has to save it and submit it in all subsequent Recurring or Merchant initiated payments of the same type, otherwise, the payments can be declined by the issuer. The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; represents the first, customer-present payment and helps the issuer to connect subsequent payments to this initial payment.&lt;br /&gt;
&lt;br /&gt;
====Example GetPaymentState response====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;8, 11-12&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;OrderNumber&amp;quot;: null,&lt;br /&gt;
    &amp;quot;POSId&amp;quot;: &amp;quot;[[SHOPS_PUBLIC_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSName&amp;quot;: &amp;quot;[[MERCHANTS_BARION_SHOPNAME]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSOwnerEmail&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSource&amp;quot;: &amp;quot;BankCard&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;AllowedFundingSources&amp;quot;: [&lt;br /&gt;
        &amp;quot;All&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;GuestCheckout&amp;quot;: true,&lt;br /&gt;
    &amp;quot;CreatedAt&amp;quot;: &amp;quot;2020-11-26T07:52:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ValidUntil&amp;quot;: &amp;quot;2020-11-26T08:22:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;CompletedAt&amp;quot;: &amp;quot;2020-11-26T08:11:54.118Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ReservedUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;DelayedCaptureUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
           ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;Total&amp;quot;: 25.20,&lt;br /&gt;
    &amp;quot;SuggestedLocale&amp;quot;: &amp;quot;hu-HU&amp;quot;,&lt;br /&gt;
    &amp;quot;FraudRiskScore&amp;quot;: null,&lt;br /&gt;
    &amp;quot;RedirectUrl&amp;quot;: &amp;quot;https://merchanturl/Redirect?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;CallbackUrl&amp;quot;: &amp;quot;https://merchanturl/Callback?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Displaying the funding source in a GUI ====&lt;br /&gt;
We strongly advise saving the complete response for future reference. The &amp;lt;code&amp;gt;FundingSource&amp;lt;/code&amp;gt; field tells if the funding source is a Barion balance or a card. If it is a card, it is useful to save [[FundingInformation]] for displaying it for the user, when requesting future payments. The usual way to display funding sources is to show the last 4 digits of the card, with 4 stars, eg: *** 1234. The card used can be obtained from FundingInformation&#039;s [[BankCard]] field. The [[CardType]] field can be used to display the appropriate card logo. You can even show, if the card is expired, and offer to register another one.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; FundingInformation part of the GetPaymentState response &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=json&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be displayed for example as &amp;lt;code&amp;gt;VISA **** 0425 (12/20)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a request-response diagram of the token registration process:&lt;br /&gt;
 &lt;br /&gt;
[[File:Token_payment_initiation.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Step 2: Using the token =&lt;br /&gt;
&lt;br /&gt;
To use an already registered token for a payment, you have to use the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property. To be able to use a token, the initial payment must be in a successful state.&lt;br /&gt;
&lt;br /&gt;
At this point, the merchant has to decide whether this subsequent payment is used for the same token payment scenario or something changed. This is important because the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used for the same scenario, otherwise, the card issuer will decline the charge.&lt;br /&gt;
A &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used again if:&lt;br /&gt;
* the funding source is the same (technically the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* the token payment scenario is the same (technically the &amp;lt;code&amp;gt;RecurrenceType&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* this subsequent request complies with the scenario restrictions (eg: in case of recurring payment the amount of the subsequent payment does not exceed the initial amount)&lt;br /&gt;
&lt;br /&gt;
If the funding source changes, new &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the funding source|described in detail here]]. If the funding source stays the same but the scenario changes or the restrictions are no longer met new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the token payment scenario with an existing token|described here]].&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Recurring payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this case, three extra conditions must be met:&lt;br /&gt;
* the amount of the subsequent payment must not be higher than the initial amount&lt;br /&gt;
* at least that much days must be spent as defined in the initial &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; property&lt;br /&gt;
* the date of the payment must not exceed the day specified in the initial &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; property&lt;br /&gt;
&lt;br /&gt;
Please be aware that in case any of these are no longer valid the merchant has to request a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; as [[#Changing the token payment scenario with an existing token|described here]]. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=These conditions are not enforced by the Barion system so the violation of them will result in a declined charge.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
Payment/start must not include the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; properties (since they are already fixed during the initial payment).&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Recurring payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Merchant Initiated Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario there are no restrictions.&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Merchant Initiated Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 75,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Phone bill&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of OneClick Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario, the merchant has to prepare to perform the [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]] of the payer. 3DS authentication is not required in the following cases:&lt;br /&gt;
* the token (&amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;) was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is not used in this scenario since the payer is present during the transaction. &lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent OneClick Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 17,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Book: How to shop online&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;How to shop online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Book about shopping online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;piece&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
In this scenario, the response contains the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; property that is used to perform an [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8-9&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: &amp;quot;ewoJIkNhcmRQdWJs...WZXJzaW9uIjogIjIuMS4wIgp9Cg==&amp;quot;,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is the request-response diagram of the subsequent payments:&lt;br /&gt;
&lt;br /&gt;
[[File:Token_payment_2.png]]&lt;br /&gt;
&lt;br /&gt;
= Off-site 3DS v2 authentication =&lt;br /&gt;
&lt;br /&gt;
In certain scenarios, the payer has to be authenticated to lower the risk of the card transaction. This can be either performed &lt;br /&gt;
* on the Barion Smart Gateway (on-site) by redirecting the customer to Barion &lt;br /&gt;
* or on the merchant&#039;s website (off-site) by integrating the Barion Off-site client library.&lt;br /&gt;
&lt;br /&gt;
This section describes how to integrate the Barion off-site authentication library into the merchant&#039;s site.&lt;br /&gt;
&lt;br /&gt;
== Step 1 : Initialize the off-site authentication library  ==&lt;br /&gt;
You have to include the following css and javascript files in the code of your site. &lt;br /&gt;
&amp;lt;source lang=html&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source &amp;gt;&lt;br /&gt;
These files include all the necessary javascript code and styling to handle the 3DS authentication and display the challenge if necessary.&lt;br /&gt;
&lt;br /&gt;
Then you have to initialize the Barion javascript client. To do that, you have to define a configuration object that specifies your functions that handle the off-site authentication events. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; Authentication events&#039;&#039;&#039;&lt;br /&gt;
* &amp;lt;code&amp;gt;onAuthenticationSucceeded&amp;lt;/code&amp;gt;: the 3DS v2 authentication successfully completed&lt;br /&gt;
* &amp;lt;code&amp;gt;onAuthenticationFailed&amp;lt;/code&amp;gt;:  the 3DS v2 authentication failed&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const configuration = {&lt;br /&gt;
    onAuthenticationSucceeded: function () {&lt;br /&gt;
        // handle successful authentication by calling the Barion API via merchant&#039;s backend&lt;br /&gt;
        // Call the v2/payment/complete endpoint&lt;br /&gt;
    },&lt;br /&gt;
    onAuthenticationFailed: function () {&lt;br /&gt;
        // Handle unsuccessful authentication result, no charge was made.&lt;br /&gt;
        // The payment might be still valid only the authentication failed&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to pass this config object to the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const gw = new Barion.OffsiteGw(configuration);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Step 2: Start the authentication process ===&lt;br /&gt;
Once the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; is acquired from the payment/start you can start the authentication process by calling the &amp;lt;code&amp;gt;authenticate()&amp;lt;/code&amp;gt; method of the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
gw.authenticate(threeDsClientData);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will start the authentication process and present the challenge if needed. Visually this will create a modal window over the merchant&#039;s site and show the payer every necessary information.&lt;br /&gt;
Once the authentication process finished (either with or without a challenge) the appropriate event will be fired. &lt;br /&gt;
&lt;br /&gt;
== Step 3: Completing the payment ==&lt;br /&gt;
&lt;br /&gt;
In case of successful authentication, you have to call our [[Payment-Complete-v3|/Payment/Complete]] endpoint, where the actual charge will happen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Suggested implementation flow for off-site authentication ==&lt;br /&gt;
&lt;br /&gt;
Ideally, an off-site authentication should be part of a client-side experience without any postbacks or page reloads. This is our recommendation to achieve this:&lt;br /&gt;
&lt;br /&gt;
# After the customer clicks on the &amp;quot;Pay&amp;quot; button make an AJAX call from your client-side code to your back-end. &lt;br /&gt;
# Have your backend make a request to our payment/start endpoint (with the appropriate settings for the desired token scenario)&lt;br /&gt;
# Have your backend process the response and pass the value of the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; property to your client-side code.&lt;br /&gt;
# Use the Barion off-site library to perform the authentication&lt;br /&gt;
# Once the authentication succeeds send another AJAX request from your client-side code to your back-end.&lt;br /&gt;
# Have your back-end code call our [[Payment-Complete-v3|/Payment/Complete]]&lt;br /&gt;
# Have your backend process the response and pass the result to your client-side code.&lt;br /&gt;
# Display the result for the customer &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Possible error responses ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| InvalidRecurrenceId|| The token specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is invalid. Check if the token registration was successful.&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentDenied|| Something happened to the user since the token registration, either deleted, suspended, or blocked. The payment s not allowed in these cases.&lt;br /&gt;
|-&lt;br /&gt;
| InsufficientFunds|| If the original payment was with an e-money wallet and the customer doesn&#039;t have enough money to fulfill this charge this error happens.&lt;br /&gt;
|-&lt;br /&gt;
| OriginalPaymentWasntSuccessful || This means that the token belongs to an originally unsuccessful payment so this token can not be used anymore. This could only happen if the original payment was financed with a credit card.&lt;br /&gt;
|-&lt;br /&gt;
|InvalidCurrency || If the original payment was paid with e-money and the current token payment is in a currency that the wallet does not have an account in this error happens.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2867</id>
		<title>Token payment 3D Secure</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2867"/>
		<updated>2020-11-26T12:07:31Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* Subsequent payments in case of OneClick Payment scenario */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Token Payment with 3D Secure}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{IncompletePage}}&lt;br /&gt;
&lt;br /&gt;
This payment scenario allows the integrator shop to register a token for a customer (and a funding source) in the Barion system and then, later on, using this token, charge the customer without redirecting her to the Barion Smart Gateway UI. The user may be present at the site of the merchant or she can be off-session as well, so the merchant can charge her e.g. for subscriptions. This means that the customer authorizes the shop to charge her card or Barion balance without typing in the card information or Barion login again.&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurring.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=Premium feature|text=This scenario is not allowed automatically for every approved shop and should be requested from Barion!|color=#1993c7}}&lt;br /&gt;
&lt;br /&gt;
= Token payment scenarios =&lt;br /&gt;
Token payment can be used in three use cases: &lt;br /&gt;
* &#039;&#039;&#039;Customer Initiated Payments&#039;&#039;&#039;: when the user is present on the website of the merchant and she decides to pay :&lt;br /&gt;
** &#039;&#039;&#039;OneClick payment&#039;&#039;&#039;: the user is charged upon her request initiated on the website of the merchant. Subsequent payments are subject to PSD2 SCA and as the user is present, she has to go through the authentication process.&lt;br /&gt;
* &#039;&#039;&#039;Merchant Initiated Payments&#039;&#039;&#039;: when the merchant initiates the payment without the user being present. It has two subtypes:&lt;br /&gt;
** &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: the user is charged with the same amount on a regular basis, typically in case of subscriptions. Subsequent payments are exempted from PSD2 SCA, but liability still shifts to the card issuer.&lt;br /&gt;
** &#039;&#039;&#039;MIT (merchant initiated transaction)&#039;&#039;&#039;: the user is charged on an irregular basis and/or with a different amount. Subsequent payments of this type are excluded from PSD2 SCA, the liability is on the merchant.&lt;br /&gt;
&lt;br /&gt;
== Customer participation ==&lt;br /&gt;
&lt;br /&gt;
Since the token scenario is suitable for both customer and merchant initiated payments here is a comparison about who starts the payment. This includes the regular, non-tokenized payment scenario as well:&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot; | Scenario&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Initial payment&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW &lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW&lt;br /&gt;
|-&lt;br /&gt;
| Non token (regular) payment || YES || YES || YES || YES &lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || YES || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| MIT || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #aaa; background-color:#eee; font-size: 0.8em; padding:5px 10px; display:inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; Token payment scenarios can be initiated with already registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; as well, in this case the customer may remain on the merchant&#039;s site. &lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements for the scenarios ==&lt;br /&gt;
&lt;br /&gt;
These token payment scenarios have different requirements, this table below summarizes the key differences.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Payment amount&lt;br /&gt;
! Payment frequency&lt;br /&gt;
! Liability in case of fraud&lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || Various || Various || Card issuer&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || Subsequent amounts must be equal or less than the initial amount  || Initial payment must define a minimum amount of days to wait between charges || Card issuer &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || Various  || Various || Merchant&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 3DS authentication of the payer ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be performed for every online card payment. These token payment scenarios also have to use this new secure way of authentication. &lt;br /&gt;
The initial payment of a token scenario must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
Here is a table to compare the 3DS authentication requirements:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Initial payment&lt;br /&gt;
! Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
| One-click payment || ✔️ || ✔️&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Real life examples ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phone bill&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Payer has a usage-based phone subscription that wants to pay without being present for every charge. She authorizes the phone company to charge her card every month.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, the amount of the subsequent payments may exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TV subscription&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to online streaming of a television channel. She authorizes the phone company to charge her card every month. The subscription fee is the same for every month.&lt;br /&gt;
* Scenario: Recurring payment&lt;br /&gt;
* Explanation: The amount of the subsequent payments will not exceed the initial payment and the charge is regularly monthly-based.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bookclub with &amp;quot;free first month&amp;quot; bonus&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to a book renting service. She authorizes the book club to charge her card every month for a selection of books. The subscription fee is the same for every month however, the first month is free. To ensure the subscription the service requires her to register her card details.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, and the fee will stay the same, the initial payment is zero. So the amount of the next payment will exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Online food delivery service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The food delivery company wants to provide a quick and easy experience for its customer. They decide that the order will be quicker if the customers don&#039;t leave the website to pay for the goods.&lt;br /&gt;
* Scenario: OneClick payment&lt;br /&gt;
* Explanation: The customer will always be there so the other two scenarios are not available.&lt;br /&gt;
&lt;br /&gt;
== How to decide ==&lt;br /&gt;
&lt;br /&gt;
To help you decide on a suitable scenario, please use the decision graph below:&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurrencetype-decision.png|520px]]&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
To be able to integrate your webshop with the Barion Payment Gateway: &lt;br /&gt;
* You must [[Creating_an_account|register a Barion wallet]] at the Barion website or in the Sandbox environment. Learn more about the Sandbox environment [[Sandbox|here]].&lt;br /&gt;
* For this wallet you have to [[Creating_a_shop|create a shop]] which should be approved by Barion.&lt;br /&gt;
* For every currency you plan to conduct payments in you have to make sure there is an account created in your Barion wallet. This means that if you plan to have USD payments then there should be a USD account created in your wallet.&lt;br /&gt;
* To make sure every corner case scenario works for your webshop it is best to top up that account with a small amount (approx. 5-10EUR or your choice of currency around the same value).&lt;br /&gt;
* For the technical communication guide please read this: [[Calling_the_API|Calling the API]]&lt;br /&gt;
&lt;br /&gt;
= The payment process =&lt;br /&gt;
&lt;br /&gt;
The process is divided into two major steps:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 1:  Creating the funding source token|Creating the token]] that represents one of the customer&#039;s funding sources (credit card or e-money wallet)&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Preparing the payment via the Barion API&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Redirecting the customer to the Barion Smart Gateway to select a funding source&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Processing the callback and requesting information about the result of the payment&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 2: Using the token|Using the registered token]] to charge the customer&amp;lt;/li&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1:  Creating the funding source token ==&lt;br /&gt;
To be able to use a token payment scenario first the merchant has to register the token with Barion. The merchant has to make sure that the customer is well aware of the fact that they are giving consent to a tokenized payment. The Barion Smart Gateway UI does not indicate in any way that the payment is a token payment.&lt;br /&gt;
&lt;br /&gt;
The token is registered to the shop and not to the merchant&#039;s Barion account. So if the merchant has multiple shops in its Barion account, the registered tokens can not be shared among them even if the customer is the same. If you want to use tokens in multiple shops, please contact Barion in the Customer center.&lt;br /&gt;
&lt;br /&gt;
=== 1.1 Preparing the payment===&lt;br /&gt;
&lt;br /&gt;
The token registration is basically a [[Responsive_web_payment|normal payment]] with three extra properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* InitiateRecurrence&lt;br /&gt;
* RecurrenceId&lt;br /&gt;
* RecurrenceType&lt;br /&gt;
&lt;br /&gt;
==== InitiateRecurrence====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; property is a bool property. If you set it to &#039;&#039;&#039;true&#039;&#039;&#039; then the payment gateway will consider the payment as a token registration. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This happens even if the customer is already has a registered token, so you are able to re-register a funding source or even a customer. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceId ====&lt;br /&gt;
The next required property for a token registration is the token itself. This is generated by the shop and has to be unique for every registration. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property of the [[Payment-Start-v2|Payment/Start]] request. This token must be saved in the webshops database. A &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; token represents the funding source (bank card or Barion balance) of a customer. Since a customer can have multiple cards and accounts as a funding source make sure that in the webshop&#039;s system multiple tokens can belong to a single customer.&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceType ====&lt;br /&gt;
The third required property is the [[RecurrenceType|Recurrence Type]]. This specifies the scenario. In case of Recurring Payment &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; must also be set.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Merchant Initiated Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The response will be the same as to a [[Responsive_web_payment#Processing_the_successful_response|basic &#039;&#039;&#039;Immediate&#039;&#039;&#039; scenario]]. The &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; property at this point is &#039;&#039;&#039;None&#039;&#039;&#039; since the token is not registered to a funding source yet.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Recurring Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Recurring Payment&#039;&#039;&#039; scenario has some extra restrictions. The merchant has to specify two additional properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt;: The date after the subsequent charges should not accepted.&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt;: The minimum days the merchant has to wait between payments.&lt;br /&gt;
&lt;br /&gt;
Both properties are located in the [[PurchaseInformation]] property and must be specified if this scenario is selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7, 30-33&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;PurchaseInformation&amp;quot;:{&lt;br /&gt;
        &amp;quot;RecurringFrequency&amp;quot;: 10,&lt;br /&gt;
        &amp;quot;RecurringExpiry&amp;quot;: &amp;quot;2022-10-01&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Possible error responses ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentNotAllowed || The token payment is not allowed for the shop identified by the &#039;&#039;&#039;POSKey&#039;&#039;&#039;. Contact Barion to request this feature.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 1.2 Redirecting the customer to the Barion Smart Gateway to select a funding source ===&lt;br /&gt;
&lt;br /&gt;
After a successful payment preparation, the customer is redirected to the secure Barion Smart Gateway to choose a funding source. The funding source the customer selects will be registered to the token. The funding source can either be a Barion e-money balance or a bank card. This means that even though the customer may own multiple cards only the one that was registered to the token can be used for future token payments. To change the funding source attached to the token a new registration should be requested.&lt;br /&gt;
&lt;br /&gt;
=== 1.3 Processing the callback and requesting information about the result of the payment ===&lt;br /&gt;
&lt;br /&gt;
When the payment is completed (either successfully or unsuccessfully) a callback message is sent to the merchant&#039;s system. Once received a [[Payment-GetPaymentState-v2|GetPaymentState]] request must be sent to the Barion API. On how to implement this please read the article about the  [[Callback_mechanism|Callback mechanism]].&lt;br /&gt;
&lt;br /&gt;
The full response of the GetPaymentState request depends on the payment scenario and the structure of the payment. When it comes to token payment there are several properties to look out for. &lt;br /&gt;
* In case the &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; is &#039;&#039;&#039;Succeeded&#039;&#039;&#039; the funding source token is registered and ready to use.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; contains the ID of the token process. This specifies the nature of the token payment. &lt;br /&gt;
&lt;br /&gt;
==== TraceId ====&lt;br /&gt;
&lt;br /&gt;
In case of Recurring payment or Merchant initiated payment scenarios the [[Payment-GetPaymentState-v2|GetPaymentState]] response returns an additional field called &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. The value of this property is generated by the card issuer. The merchant has to save it and submit it in all subsequent Recurring or Merchant initiated payments of the same type, otherwise, the payments can be declined by the issuer. The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; represents the first, customer-present payment and helps the issuer to connect subsequent payments to this initial payment.&lt;br /&gt;
&lt;br /&gt;
====Example GetPaymentState response====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;8, 11-12&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;OrderNumber&amp;quot;: null,&lt;br /&gt;
    &amp;quot;POSId&amp;quot;: &amp;quot;[[SHOPS_PUBLIC_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSName&amp;quot;: &amp;quot;[[MERCHANTS_BARION_SHOPNAME]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSOwnerEmail&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSource&amp;quot;: &amp;quot;BankCard&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;AllowedFundingSources&amp;quot;: [&lt;br /&gt;
        &amp;quot;All&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;GuestCheckout&amp;quot;: true,&lt;br /&gt;
    &amp;quot;CreatedAt&amp;quot;: &amp;quot;2020-11-26T07:52:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ValidUntil&amp;quot;: &amp;quot;2020-11-26T08:22:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;CompletedAt&amp;quot;: &amp;quot;2020-11-26T08:11:54.118Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ReservedUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;DelayedCaptureUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
           ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;Total&amp;quot;: 25.20,&lt;br /&gt;
    &amp;quot;SuggestedLocale&amp;quot;: &amp;quot;hu-HU&amp;quot;,&lt;br /&gt;
    &amp;quot;FraudRiskScore&amp;quot;: null,&lt;br /&gt;
    &amp;quot;RedirectUrl&amp;quot;: &amp;quot;https://merchanturl/Redirect?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;CallbackUrl&amp;quot;: &amp;quot;https://merchanturl/Callback?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Displaying the funding source in a GUI ====&lt;br /&gt;
We strongly advise saving the complete response for future reference. The &amp;lt;code&amp;gt;FundingSource&amp;lt;/code&amp;gt; field tells if the funding source is a Barion balance or a card. If it is a card, it is useful to save [[FundingInformation]] for displaying it for the user, when requesting future payments. The usual way to display funding sources is to show the last 4 digits of the card, with 4 stars, eg: *** 1234. The card used can be obtained from FundingInformation&#039;s [[BankCard]] field. The [[CardType]] field can be used to display the appropriate card logo. You can even show, if the card is expired, and offer to register another one.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; FundingInformation part of the GetPaymentState response &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=json&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be displayed for example as &amp;lt;code&amp;gt;VISA **** 0425 (12/20)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a request-response diagram of the token registration process:&lt;br /&gt;
 &lt;br /&gt;
[[File:Token_payment_initiation.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Step 2: Using the token =&lt;br /&gt;
&lt;br /&gt;
To use an already registered token for a payment, you have to use the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property. To be able to use a token, the initial payment must be in a successful state.&lt;br /&gt;
&lt;br /&gt;
At this point, the merchant has to decide whether this subsequent payment is used for the same token payment scenario or something changed. This is important because the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used for the same scenario, otherwise, the card issuer will decline the charge.&lt;br /&gt;
A &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used again if:&lt;br /&gt;
* the funding source is the same (technically the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* the token payment scenario is the same (technically the &amp;lt;code&amp;gt;RecurrenceType&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* this subsequent request complies with the scenario restrictions (eg: in case of recurring payment the amount of the subsequent payment does not exceed the initial amount)&lt;br /&gt;
&lt;br /&gt;
If the funding source changes, new &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the funding source|described in detail here]]. If the funding source stays the same but the scenario changes or the restrictions are no longer met new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the token payment scenario with an existing token|described here]].&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Recurring payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this case, three extra conditions must be met:&lt;br /&gt;
* the amount of the subsequent payment must not be higher than the initial amount&lt;br /&gt;
* at least that much days must be spent as defined in the initial &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; property&lt;br /&gt;
* the date of the payment must not exceed the day specified in the initial &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; property&lt;br /&gt;
&lt;br /&gt;
Please be aware that in case any of these are no longer valid the merchant has to request a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; as [[#Changing the token payment scenario with an existing token|described here]]. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=These conditions are not enforced by the Barion system so the violation of them will result in a declined charge.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
Payment/start must not include the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; properties (since they are already fixed during the initial payment).&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Recurring payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Merchant Initiated Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario there are no restrictions.&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Merchant Initiated Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 75,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Phone bill&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of OneClick Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario, the merchant has to prepare to perform the [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]] of the payer. 3DS authentication is not required in the following cases:&lt;br /&gt;
* the token (&amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;) was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is not used in this scenario since the payer is present during the transaction. &lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent OneClick Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 17,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Book: How to shop online&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;How to shop online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Book about shopping online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;piece&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
In this scenario, the response contains the &amp;lt;code&amp;gt;ThreeDSAuthClientData&amp;lt;/code&amp;gt; property that is used to perform an [[#Off-site 3DS v2 authentication|off-site 3DS v2 authentication]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8-9&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: &amp;quot;ewoJIkNhcmRQdWJs...WZXJzaW9uIjogIjIuMS4wIgp9Cg==&amp;quot;,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is the request-response diagram of the subsequent payments:&lt;br /&gt;
&lt;br /&gt;
[[File:Token_payment_2.png]]&lt;br /&gt;
&lt;br /&gt;
= Off-site 3DS v2 authentication =&lt;br /&gt;
&lt;br /&gt;
== Step 1 : Initialize the off-site authentication library  ==&lt;br /&gt;
You have to include the following css and javascript files in the code of your site. These files include all the necessary javascript code and styling to handle the 3DS authentication and display the challenge if necessary.&lt;br /&gt;
&amp;lt;source lang=html&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source &amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to initialize the Barion javascript client:&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const configuration = {&lt;br /&gt;
    onAuthenticationSucceeded: function () {&lt;br /&gt;
        // handle successful authentication by calling the Barion API via merchant&#039;s backend&lt;br /&gt;
        // Call the v2/payment/complete endpoint&lt;br /&gt;
    },&lt;br /&gt;
    onAuthenticationFailed: function () {&lt;br /&gt;
        // Handle unsuccessful authentication result, no charge was made.&lt;br /&gt;
        // The payment might be still valid only the authentication failed&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
const gw= new Barion.OffsiteGw(configuration);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Step 2 : Make a payment  ====&lt;br /&gt;
To use an already registered token for a payment, you have to call the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; and the appropriate [[RecurrenceType|Recurrence Type]] should be sent. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property along with the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Example Payment/Start json request =====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;E31EC263-01DC-40BD-BDF1-38FC7A332434&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot; : &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot; : false,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot; : &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot; : &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot; : &amp;quot;SHOP-XMLP-TRACEID-123&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR002&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;webshop@example.com&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subsription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Processing the Payment/Start response =====&lt;br /&gt;
To this request, the Barion API sends back the required data for the 3DS authentication for the specified paymentId.&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
! Field name&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| PaymentId&lt;br /&gt;
| Payment Identifier of the purchase in Barion&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| ThreeDSAuthClientData&lt;br /&gt;
| basae64 encoded 3DS client data&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Payment/Start response =====&lt;br /&gt;
&amp;lt;source lang=json line style=&amp;quot;word-break: break-all;&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot; : &amp;quot;dce46843-6266-4c1f-b82a-387e0fee9073&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot; : &amp;quot;ewoJIkNhcmRQdWJsaWNJZCI6ICIxYTE5M2E1NDQzNDI0YjJiOGJiMjMyOGRhNWY4NmYzYiIsCgkiUGF5bWVudElkIjogImRjZTQ2ODQzNjI2NjRjMWZiODJhMzg3ZTBmZWU5MDczIiwKCSJPbmVDbGlja0NvbnRlbnRVcmwiOiAiaHR0cDovL3NlY3VyZS5iYXJpb24uY29tL3RocmVlZHMvb25lY2xpY2twYXltZW50IiwKCSJBQ1NTdGFydFByb3RvY29sVmVyc2lvbiI6ICIyLjEuMCIsCgkiQUNTRW5kUHJvdG9jb2xWZXJzaW9uIjogIjIuMS4wIiwKCSJEU1N0YXJ0UHJvdG9jb2xWZXJzaW9uIjogIjIuMS4wIiwKCSJEU0VuZFByb3RvY29sVmVyc2lvbiI6ICIyLjIuMCIsCgkiVGhyZWVEU1NlcnZlclRyYW5zSUQiOiBudWxsLAoJIlRocmVlRFNNZXRob2RVUkwiOiBudWxsLAoJIlRocmVlRFNNZXRob2REYXRhRm9ybSI6ICJleUowYUhKbFpVUlRUV1YwYUc5a1RtOTBhV1pwWTJGMGFXOXVWVkpNSWpvaWFIUjBjSE02THk4elpITXVZbUZ5YVc5dUxtTnZiUzh6WkhNdmRqSXZNMlJ6TFcxbGRHaHZaQzF1YjNScFptbGpZWFJwYjI0aUxDSjBhSEpsWlVSVFUyVnlkbVZ5VkhKaGJuTkpSQ0k2SWpFNE5URTJPR0kxTFRKalkyUXROR0kxWlMxaVlqWm1MVFUzTW1VM00yVTNNemt3TnlKOSIsCgkiRXJyb3JEZXRhaWxzIjogbnVsbCwKCSJWZXJzaW9uIjogIjIuMS4wIgp9Cg==&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Step 3: 3DS authentication &amp;amp; challenge ====&lt;br /&gt;
This data then should be passed onto the &amp;lt;code&amp;gt;authenticate()&amp;lt;/code&amp;gt; method of the offsite gw manager, which will do all the magic to authenticate and display the challenge (if needed).&lt;br /&gt;
&amp;lt;source lang=javascript line highlight=&amp;quot;9&amp;quot;&amp;gt;&lt;br /&gt;
        // call Barion API via merchant&#039;s backend&lt;br /&gt;
        // once the result is returned continue with authentication&lt;br /&gt;
        $.ajax({&lt;br /&gt;
            url: &amp;quot;Url/Of/Your/Payment/Start&amp;quot;,&lt;br /&gt;
            method: &amp;quot;POST&amp;quot;,&lt;br /&gt;
            data: data,&lt;br /&gt;
            success: function (threeDsClientData) {&lt;br /&gt;
               // the threeDsClientData will be in the response of payment/start	&lt;br /&gt;
               gw.authenticate(threeDsClientData);&lt;br /&gt;
            }&lt;br /&gt;
         });&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the request is finished the appropriate callback is fired, the BarionClient was initialized with in [[#Step 1 : Initialize oneClick|Step 1]]. In case of successful authentication, you have to call our [[Payment-Complete-v3|/Payment/Complete]] endpoint, where the actual charge will happen.&lt;br /&gt;
&lt;br /&gt;
=== Recurring payment/Merchant Initiated payment ===&lt;br /&gt;
&lt;br /&gt;
For these types of payments, the subsequent payments are nearly identical to the process of [[#Creating_the_token|Creating the token]]. The only difference is that the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; received in the initial [[Payment-GetPaymentState-v2|GetPaymentState]] response must be sent in the &lt;br /&gt;
[[Payment-Start-v2|Payment/Start]] request. Also don&#039;t forget to set the appropriate [[RecurrenceType|Recurrence Type]].&lt;br /&gt;
&lt;br /&gt;
=== Possible error responses ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| InvalidRecurrenceId|| The token specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is invalid. Check if the token registration was successful.&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentDenied|| Something happened to the user since the token registration, either deleted, suspended, or blocked. The payment s not allowed in these cases.&lt;br /&gt;
|-&lt;br /&gt;
| InsufficientFunds|| If the original payment was with an e-money wallet and the customer doesn&#039;t have enough money to fulfill this charge this error happens.&lt;br /&gt;
|-&lt;br /&gt;
| OriginalPaymentWasntSuccessful || This means that the token belongs to an originally unsuccessful payment so this token can not be used anymore. This could only happen if the original payment was financed with a credit card.&lt;br /&gt;
|-&lt;br /&gt;
|InvalidCurrency || If the original payment was paid with e-money and the current token payment is in a currency that the wallet does not have an account in this error happens.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2866</id>
		<title>Token payment 3D Secure</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2866"/>
		<updated>2020-11-26T12:05:44Z</updated>

		<summary type="html">&lt;p&gt;Botza: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Token Payment with 3D Secure}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{IncompletePage}}&lt;br /&gt;
&lt;br /&gt;
This payment scenario allows the integrator shop to register a token for a customer (and a funding source) in the Barion system and then, later on, using this token, charge the customer without redirecting her to the Barion Smart Gateway UI. The user may be present at the site of the merchant or she can be off-session as well, so the merchant can charge her e.g. for subscriptions. This means that the customer authorizes the shop to charge her card or Barion balance without typing in the card information or Barion login again.&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurring.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=Premium feature|text=This scenario is not allowed automatically for every approved shop and should be requested from Barion!|color=#1993c7}}&lt;br /&gt;
&lt;br /&gt;
= Token payment scenarios =&lt;br /&gt;
Token payment can be used in three use cases: &lt;br /&gt;
* &#039;&#039;&#039;Customer Initiated Payments&#039;&#039;&#039;: when the user is present on the website of the merchant and she decides to pay :&lt;br /&gt;
** &#039;&#039;&#039;OneClick payment&#039;&#039;&#039;: the user is charged upon her request initiated on the website of the merchant. Subsequent payments are subject to PSD2 SCA and as the user is present, she has to go through the authentication process.&lt;br /&gt;
* &#039;&#039;&#039;Merchant Initiated Payments&#039;&#039;&#039;: when the merchant initiates the payment without the user being present. It has two subtypes:&lt;br /&gt;
** &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: the user is charged with the same amount on a regular basis, typically in case of subscriptions. Subsequent payments are exempted from PSD2 SCA, but liability still shifts to the card issuer.&lt;br /&gt;
** &#039;&#039;&#039;MIT (merchant initiated transaction)&#039;&#039;&#039;: the user is charged on an irregular basis and/or with a different amount. Subsequent payments of this type are excluded from PSD2 SCA, the liability is on the merchant.&lt;br /&gt;
&lt;br /&gt;
== Customer participation ==&lt;br /&gt;
&lt;br /&gt;
Since the token scenario is suitable for both customer and merchant initiated payments here is a comparison about who starts the payment. This includes the regular, non-tokenized payment scenario as well:&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot; | Scenario&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Initial payment&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW &lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW&lt;br /&gt;
|-&lt;br /&gt;
| Non token (regular) payment || YES || YES || YES || YES &lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || YES || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| MIT || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #aaa; background-color:#eee; font-size: 0.8em; padding:5px 10px; display:inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; Token payment scenarios can be initiated with already registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; as well, in this case the customer may remain on the merchant&#039;s site. &lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements for the scenarios ==&lt;br /&gt;
&lt;br /&gt;
These token payment scenarios have different requirements, this table below summarizes the key differences.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Payment amount&lt;br /&gt;
! Payment frequency&lt;br /&gt;
! Liability in case of fraud&lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || Various || Various || Card issuer&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || Subsequent amounts must be equal or less than the initial amount  || Initial payment must define a minimum amount of days to wait between charges || Card issuer &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || Various  || Various || Merchant&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 3DS authentication of the payer ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be performed for every online card payment. These token payment scenarios also have to use this new secure way of authentication. &lt;br /&gt;
The initial payment of a token scenario must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
Here is a table to compare the 3DS authentication requirements:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Initial payment&lt;br /&gt;
! Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
| One-click payment || ✔️ || ✔️&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Real life examples ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phone bill&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Payer has a usage-based phone subscription that wants to pay without being present for every charge. She authorizes the phone company to charge her card every month.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, the amount of the subsequent payments may exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TV subscription&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to online streaming of a television channel. She authorizes the phone company to charge her card every month. The subscription fee is the same for every month.&lt;br /&gt;
* Scenario: Recurring payment&lt;br /&gt;
* Explanation: The amount of the subsequent payments will not exceed the initial payment and the charge is regularly monthly-based.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bookclub with &amp;quot;free first month&amp;quot; bonus&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to a book renting service. She authorizes the book club to charge her card every month for a selection of books. The subscription fee is the same for every month however, the first month is free. To ensure the subscription the service requires her to register her card details.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, and the fee will stay the same, the initial payment is zero. So the amount of the next payment will exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Online food delivery service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The food delivery company wants to provide a quick and easy experience for its customer. They decide that the order will be quicker if the customers don&#039;t leave the website to pay for the goods.&lt;br /&gt;
* Scenario: OneClick payment&lt;br /&gt;
* Explanation: The customer will always be there so the other two scenarios are not available.&lt;br /&gt;
&lt;br /&gt;
== How to decide ==&lt;br /&gt;
&lt;br /&gt;
To help you decide on a suitable scenario, please use the decision graph below:&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurrencetype-decision.png|520px]]&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
To be able to integrate your webshop with the Barion Payment Gateway: &lt;br /&gt;
* You must [[Creating_an_account|register a Barion wallet]] at the Barion website or in the Sandbox environment. Learn more about the Sandbox environment [[Sandbox|here]].&lt;br /&gt;
* For this wallet you have to [[Creating_a_shop|create a shop]] which should be approved by Barion.&lt;br /&gt;
* For every currency you plan to conduct payments in you have to make sure there is an account created in your Barion wallet. This means that if you plan to have USD payments then there should be a USD account created in your wallet.&lt;br /&gt;
* To make sure every corner case scenario works for your webshop it is best to top up that account with a small amount (approx. 5-10EUR or your choice of currency around the same value).&lt;br /&gt;
* For the technical communication guide please read this: [[Calling_the_API|Calling the API]]&lt;br /&gt;
&lt;br /&gt;
= The payment process =&lt;br /&gt;
&lt;br /&gt;
The process is divided into two major steps:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 1:  Creating the funding source token|Creating the token]] that represents one of the customer&#039;s funding sources (credit card or e-money wallet)&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Preparing the payment via the Barion API&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Redirecting the customer to the Barion Smart Gateway to select a funding source&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Processing the callback and requesting information about the result of the payment&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 2: Using the token|Using the registered token]] to charge the customer&amp;lt;/li&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1:  Creating the funding source token ==&lt;br /&gt;
To be able to use a token payment scenario first the merchant has to register the token with Barion. The merchant has to make sure that the customer is well aware of the fact that they are giving consent to a tokenized payment. The Barion Smart Gateway UI does not indicate in any way that the payment is a token payment.&lt;br /&gt;
&lt;br /&gt;
The token is registered to the shop and not to the merchant&#039;s Barion account. So if the merchant has multiple shops in its Barion account, the registered tokens can not be shared among them even if the customer is the same. If you want to use tokens in multiple shops, please contact Barion in the Customer center.&lt;br /&gt;
&lt;br /&gt;
=== 1.1 Preparing the payment===&lt;br /&gt;
&lt;br /&gt;
The token registration is basically a [[Responsive_web_payment|normal payment]] with three extra properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* InitiateRecurrence&lt;br /&gt;
* RecurrenceId&lt;br /&gt;
* RecurrenceType&lt;br /&gt;
&lt;br /&gt;
==== InitiateRecurrence====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; property is a bool property. If you set it to &#039;&#039;&#039;true&#039;&#039;&#039; then the payment gateway will consider the payment as a token registration. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This happens even if the customer is already has a registered token, so you are able to re-register a funding source or even a customer. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceId ====&lt;br /&gt;
The next required property for a token registration is the token itself. This is generated by the shop and has to be unique for every registration. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property of the [[Payment-Start-v2|Payment/Start]] request. This token must be saved in the webshops database. A &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; token represents the funding source (bank card or Barion balance) of a customer. Since a customer can have multiple cards and accounts as a funding source make sure that in the webshop&#039;s system multiple tokens can belong to a single customer.&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceType ====&lt;br /&gt;
The third required property is the [[RecurrenceType|Recurrence Type]]. This specifies the scenario. In case of Recurring Payment &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; must also be set.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Merchant Initiated Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The response will be the same as to a [[Responsive_web_payment#Processing_the_successful_response|basic &#039;&#039;&#039;Immediate&#039;&#039;&#039; scenario]]. The &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; property at this point is &#039;&#039;&#039;None&#039;&#039;&#039; since the token is not registered to a funding source yet.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Recurring Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Recurring Payment&#039;&#039;&#039; scenario has some extra restrictions. The merchant has to specify two additional properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt;: The date after the subsequent charges should not accepted.&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt;: The minimum days the merchant has to wait between payments.&lt;br /&gt;
&lt;br /&gt;
Both properties are located in the [[PurchaseInformation]] property and must be specified if this scenario is selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7, 30-33&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;PurchaseInformation&amp;quot;:{&lt;br /&gt;
        &amp;quot;RecurringFrequency&amp;quot;: 10,&lt;br /&gt;
        &amp;quot;RecurringExpiry&amp;quot;: &amp;quot;2022-10-01&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Possible error responses ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentNotAllowed || The token payment is not allowed for the shop identified by the &#039;&#039;&#039;POSKey&#039;&#039;&#039;. Contact Barion to request this feature.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 1.2 Redirecting the customer to the Barion Smart Gateway to select a funding source ===&lt;br /&gt;
&lt;br /&gt;
After a successful payment preparation, the customer is redirected to the secure Barion Smart Gateway to choose a funding source. The funding source the customer selects will be registered to the token. The funding source can either be a Barion e-money balance or a bank card. This means that even though the customer may own multiple cards only the one that was registered to the token can be used for future token payments. To change the funding source attached to the token a new registration should be requested.&lt;br /&gt;
&lt;br /&gt;
=== 1.3 Processing the callback and requesting information about the result of the payment ===&lt;br /&gt;
&lt;br /&gt;
When the payment is completed (either successfully or unsuccessfully) a callback message is sent to the merchant&#039;s system. Once received a [[Payment-GetPaymentState-v2|GetPaymentState]] request must be sent to the Barion API. On how to implement this please read the article about the  [[Callback_mechanism|Callback mechanism]].&lt;br /&gt;
&lt;br /&gt;
The full response of the GetPaymentState request depends on the payment scenario and the structure of the payment. When it comes to token payment there are several properties to look out for. &lt;br /&gt;
* In case the &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; is &#039;&#039;&#039;Succeeded&#039;&#039;&#039; the funding source token is registered and ready to use.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; contains the ID of the token process. This specifies the nature of the token payment. &lt;br /&gt;
&lt;br /&gt;
==== TraceId ====&lt;br /&gt;
&lt;br /&gt;
In case of Recurring payment or Merchant initiated payment scenarios the [[Payment-GetPaymentState-v2|GetPaymentState]] response returns an additional field called &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. The value of this property is generated by the card issuer. The merchant has to save it and submit it in all subsequent Recurring or Merchant initiated payments of the same type, otherwise, the payments can be declined by the issuer. The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; represents the first, customer-present payment and helps the issuer to connect subsequent payments to this initial payment.&lt;br /&gt;
&lt;br /&gt;
====Example GetPaymentState response====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;8, 11-12&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;OrderNumber&amp;quot;: null,&lt;br /&gt;
    &amp;quot;POSId&amp;quot;: &amp;quot;[[SHOPS_PUBLIC_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSName&amp;quot;: &amp;quot;[[MERCHANTS_BARION_SHOPNAME]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSOwnerEmail&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSource&amp;quot;: &amp;quot;BankCard&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;AllowedFundingSources&amp;quot;: [&lt;br /&gt;
        &amp;quot;All&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;GuestCheckout&amp;quot;: true,&lt;br /&gt;
    &amp;quot;CreatedAt&amp;quot;: &amp;quot;2020-11-26T07:52:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ValidUntil&amp;quot;: &amp;quot;2020-11-26T08:22:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;CompletedAt&amp;quot;: &amp;quot;2020-11-26T08:11:54.118Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ReservedUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;DelayedCaptureUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
           ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;Total&amp;quot;: 25.20,&lt;br /&gt;
    &amp;quot;SuggestedLocale&amp;quot;: &amp;quot;hu-HU&amp;quot;,&lt;br /&gt;
    &amp;quot;FraudRiskScore&amp;quot;: null,&lt;br /&gt;
    &amp;quot;RedirectUrl&amp;quot;: &amp;quot;https://merchanturl/Redirect?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;CallbackUrl&amp;quot;: &amp;quot;https://merchanturl/Callback?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Displaying the funding source in a GUI ====&lt;br /&gt;
We strongly advise saving the complete response for future reference. The &amp;lt;code&amp;gt;FundingSource&amp;lt;/code&amp;gt; field tells if the funding source is a Barion balance or a card. If it is a card, it is useful to save [[FundingInformation]] for displaying it for the user, when requesting future payments. The usual way to display funding sources is to show the last 4 digits of the card, with 4 stars, eg: *** 1234. The card used can be obtained from FundingInformation&#039;s [[BankCard]] field. The [[CardType]] field can be used to display the appropriate card logo. You can even show, if the card is expired, and offer to register another one.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; FundingInformation part of the GetPaymentState response &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=json&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be displayed for example as &amp;lt;code&amp;gt;VISA **** 0425 (12/20)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a request-response diagram of the token registration process:&lt;br /&gt;
 &lt;br /&gt;
[[File:Token_payment_initiation.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Step 2: Using the token =&lt;br /&gt;
&lt;br /&gt;
To use an already registered token for a payment, you have to use the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property. To be able to use a token, the initial payment must be in a successful state.&lt;br /&gt;
&lt;br /&gt;
At this point, the merchant has to decide whether this subsequent payment is used for the same token payment scenario or something changed. This is important because the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used for the same scenario, otherwise, the card issuer will decline the charge.&lt;br /&gt;
A &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used again if:&lt;br /&gt;
* the funding source is the same (technically the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* the token payment scenario is the same (technically the &amp;lt;code&amp;gt;RecurrenceType&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* this subsequent request complies with the scenario restrictions (eg: in case of recurring payment the amount of the subsequent payment does not exceed the initial amount)&lt;br /&gt;
&lt;br /&gt;
If the funding source changes, new &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the funding source|described in detail here]]. If the funding source stays the same but the scenario changes or the restrictions are no longer met new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the token payment scenario with an existing token|described here]].&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Recurring payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this case, three extra conditions must be met:&lt;br /&gt;
* the amount of the subsequent payment must not be higher than the initial amount&lt;br /&gt;
* at least that much days must be spent as defined in the initial &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; property&lt;br /&gt;
* the date of the payment must not exceed the day specified in the initial &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; property&lt;br /&gt;
&lt;br /&gt;
Please be aware that in case any of these are no longer valid the merchant has to request a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; as [[#Changing the token payment scenario with an existing token|described here]]. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=These conditions are not enforced by the Barion system so the violation of them will result in a declined charge.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
Payment/start must not include the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; properties (since they are already fixed during the initial payment).&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Recurring payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Merchant Initiated Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario there are no restrictions.&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Merchant Initiated Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 75,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Phone bill&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of OneClick Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario, the merchant has to prepare to perform the [[#Off-site 3DS v2 authentication]] of the payer. 3DS authentication is not required in the following cases:&lt;br /&gt;
* the token (&amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;) was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is not used in this scenario since the payer is present during the transaction. &lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent OneClick Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 17,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Book: How to shop online&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;How to shop online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Book about shopping online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;piece&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8-9&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: &amp;quot;ewoJIkNhcmRQdWJs...WZXJzaW9uIjogIjIuMS4wIgp9Cg==&amp;quot;,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is the request-response diagram of the subsequent payments:&lt;br /&gt;
&lt;br /&gt;
[[File:Token_payment_2.png]]&lt;br /&gt;
&lt;br /&gt;
= Off-site 3DS v2 authentication =&lt;br /&gt;
&lt;br /&gt;
== Step 1 : Initialize the off-site authentication library  ==&lt;br /&gt;
You have to include the following css and javascript files in the code of your site. These files include all the necessary javascript code and styling to handle the 3DS authentication and display the challenge if necessary.&lt;br /&gt;
&amp;lt;source lang=html&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source &amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to initialize the Barion javascript client:&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const configuration = {&lt;br /&gt;
    onAuthenticationSucceeded: function () {&lt;br /&gt;
        // handle successful authentication by calling the Barion API via merchant&#039;s backend&lt;br /&gt;
        // Call the v2/payment/complete endpoint&lt;br /&gt;
    },&lt;br /&gt;
    onAuthenticationFailed: function () {&lt;br /&gt;
        // Handle unsuccessful authentication result, no charge was made.&lt;br /&gt;
        // The payment might be still valid only the authentication failed&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
const gw= new Barion.OffsiteGw(configuration);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Step 2 : Make a payment  ====&lt;br /&gt;
To use an already registered token for a payment, you have to call the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; and the appropriate [[RecurrenceType|Recurrence Type]] should be sent. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property along with the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Example Payment/Start json request =====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;E31EC263-01DC-40BD-BDF1-38FC7A332434&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot; : &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot; : false,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot; : &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot; : &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot; : &amp;quot;SHOP-XMLP-TRACEID-123&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR002&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;webshop@example.com&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subsription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Processing the Payment/Start response =====&lt;br /&gt;
To this request, the Barion API sends back the required data for the 3DS authentication for the specified paymentId.&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
! Field name&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| PaymentId&lt;br /&gt;
| Payment Identifier of the purchase in Barion&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| ThreeDSAuthClientData&lt;br /&gt;
| basae64 encoded 3DS client data&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Payment/Start response =====&lt;br /&gt;
&amp;lt;source lang=json line style=&amp;quot;word-break: break-all;&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot; : &amp;quot;dce46843-6266-4c1f-b82a-387e0fee9073&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot; : &amp;quot;ewoJIkNhcmRQdWJsaWNJZCI6ICIxYTE5M2E1NDQzNDI0YjJiOGJiMjMyOGRhNWY4NmYzYiIsCgkiUGF5bWVudElkIjogImRjZTQ2ODQzNjI2NjRjMWZiODJhMzg3ZTBmZWU5MDczIiwKCSJPbmVDbGlja0NvbnRlbnRVcmwiOiAiaHR0cDovL3NlY3VyZS5iYXJpb24uY29tL3RocmVlZHMvb25lY2xpY2twYXltZW50IiwKCSJBQ1NTdGFydFByb3RvY29sVmVyc2lvbiI6ICIyLjEuMCIsCgkiQUNTRW5kUHJvdG9jb2xWZXJzaW9uIjogIjIuMS4wIiwKCSJEU1N0YXJ0UHJvdG9jb2xWZXJzaW9uIjogIjIuMS4wIiwKCSJEU0VuZFByb3RvY29sVmVyc2lvbiI6ICIyLjIuMCIsCgkiVGhyZWVEU1NlcnZlclRyYW5zSUQiOiBudWxsLAoJIlRocmVlRFNNZXRob2RVUkwiOiBudWxsLAoJIlRocmVlRFNNZXRob2REYXRhRm9ybSI6ICJleUowYUhKbFpVUlRUV1YwYUc5a1RtOTBhV1pwWTJGMGFXOXVWVkpNSWpvaWFIUjBjSE02THk4elpITXVZbUZ5YVc5dUxtTnZiUzh6WkhNdmRqSXZNMlJ6TFcxbGRHaHZaQzF1YjNScFptbGpZWFJwYjI0aUxDSjBhSEpsWlVSVFUyVnlkbVZ5VkhKaGJuTkpSQ0k2SWpFNE5URTJPR0kxTFRKalkyUXROR0kxWlMxaVlqWm1MVFUzTW1VM00yVTNNemt3TnlKOSIsCgkiRXJyb3JEZXRhaWxzIjogbnVsbCwKCSJWZXJzaW9uIjogIjIuMS4wIgp9Cg==&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Step 3: 3DS authentication &amp;amp; challenge ====&lt;br /&gt;
This data then should be passed onto the &amp;lt;code&amp;gt;authenticate()&amp;lt;/code&amp;gt; method of the offsite gw manager, which will do all the magic to authenticate and display the challenge (if needed).&lt;br /&gt;
&amp;lt;source lang=javascript line highlight=&amp;quot;9&amp;quot;&amp;gt;&lt;br /&gt;
        // call Barion API via merchant&#039;s backend&lt;br /&gt;
        // once the result is returned continue with authentication&lt;br /&gt;
        $.ajax({&lt;br /&gt;
            url: &amp;quot;Url/Of/Your/Payment/Start&amp;quot;,&lt;br /&gt;
            method: &amp;quot;POST&amp;quot;,&lt;br /&gt;
            data: data,&lt;br /&gt;
            success: function (threeDsClientData) {&lt;br /&gt;
               // the threeDsClientData will be in the response of payment/start	&lt;br /&gt;
               gw.authenticate(threeDsClientData);&lt;br /&gt;
            }&lt;br /&gt;
         });&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the request is finished the appropriate callback is fired, the BarionClient was initialized with in [[#Step 1 : Initialize oneClick|Step 1]]. In case of successful authentication, you have to call our [[Payment-Complete-v3|/Payment/Complete]] endpoint, where the actual charge will happen.&lt;br /&gt;
&lt;br /&gt;
=== Recurring payment/Merchant Initiated payment ===&lt;br /&gt;
&lt;br /&gt;
For these types of payments, the subsequent payments are nearly identical to the process of [[#Creating_the_token|Creating the token]]. The only difference is that the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; received in the initial [[Payment-GetPaymentState-v2|GetPaymentState]] response must be sent in the &lt;br /&gt;
[[Payment-Start-v2|Payment/Start]] request. Also don&#039;t forget to set the appropriate [[RecurrenceType|Recurrence Type]].&lt;br /&gt;
&lt;br /&gt;
=== Possible error responses ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| InvalidRecurrenceId|| The token specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is invalid. Check if the token registration was successful.&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentDenied|| Something happened to the user since the token registration, either deleted, suspended, or blocked. The payment s not allowed in these cases.&lt;br /&gt;
|-&lt;br /&gt;
| InsufficientFunds|| If the original payment was with an e-money wallet and the customer doesn&#039;t have enough money to fulfill this charge this error happens.&lt;br /&gt;
|-&lt;br /&gt;
| OriginalPaymentWasntSuccessful || This means that the token belongs to an originally unsuccessful payment so this token can not be used anymore. This could only happen if the original payment was financed with a credit card.&lt;br /&gt;
|-&lt;br /&gt;
|InvalidCurrency || If the original payment was paid with e-money and the current token payment is in a currency that the wallet does not have an account in this error happens.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2865</id>
		<title>Token payment 3D Secure</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2865"/>
		<updated>2020-11-26T11:54:16Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* Subsequent payments in case of Recurring payment scenario */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Token Payment with 3D Secure}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{IncompletePage}}&lt;br /&gt;
&lt;br /&gt;
This payment scenario allows the integrator shop to register a token for a customer (and a funding source) in the Barion system and then, later on, using this token, charge the customer without redirecting her to the Barion Smart Gateway UI. The user may be present at the site of the merchant or she can be off-session as well, so the merchant can charge her e.g. for subscriptions. This means that the customer authorizes the shop to charge her card or Barion balance without typing in the card information or Barion login again.&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurring.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=Premium feature|text=This scenario is not allowed automatically for every approved shop and should be requested from Barion!|color=#1993c7}}&lt;br /&gt;
&lt;br /&gt;
= Token payment scenarios =&lt;br /&gt;
Token payment can be used in three use cases: &lt;br /&gt;
* &#039;&#039;&#039;Customer Initiated Payments&#039;&#039;&#039;: when the user is present on the website of the merchant and she decides to pay :&lt;br /&gt;
** &#039;&#039;&#039;OneClick payment&#039;&#039;&#039;: the user is charged upon her request initiated on the website of the merchant. Subsequent payments are subject to PSD2 SCA and as the user is present, she has to go through the authentication process.&lt;br /&gt;
* &#039;&#039;&#039;Merchant Initiated Payments&#039;&#039;&#039;: when the merchant initiates the payment without the user being present. It has two subtypes:&lt;br /&gt;
** &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: the user is charged with the same amount on a regular basis, typically in case of subscriptions. Subsequent payments are exempted from PSD2 SCA, but liability still shifts to the card issuer.&lt;br /&gt;
** &#039;&#039;&#039;MIT (merchant initiated transaction)&#039;&#039;&#039;: the user is charged on an irregular basis and/or with a different amount. Subsequent payments of this type are excluded from PSD2 SCA, the liability is on the merchant.&lt;br /&gt;
&lt;br /&gt;
== Customer participation ==&lt;br /&gt;
&lt;br /&gt;
Since the token scenario is suitable for both customer and merchant initiated payments here is a comparison about who starts the payment. This includes the regular, non-tokenized payment scenario as well:&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot; | Scenario&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Initial payment&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW &lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW&lt;br /&gt;
|-&lt;br /&gt;
| Non token (regular) payment || YES || YES || YES || YES &lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || YES || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| MIT || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #aaa; background-color:#eee; font-size: 0.8em; padding:5px 10px; display:inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; Token payment scenarios can be initiated with already registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; as well, in this case the customer may remain on the merchant&#039;s site. &lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements for the scenarios ==&lt;br /&gt;
&lt;br /&gt;
These token payment scenarios have different requirements, this table below summarizes the key differences.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Payment amount&lt;br /&gt;
! Payment frequency&lt;br /&gt;
! Liability in case of fraud&lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || Various || Various || Card issuer&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || Subsequent amounts must be equal or less than the initial amount  || Initial payment must define a minimum amount of days to wait between charges || Card issuer &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || Various  || Various || Merchant&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 3DS authentication of the payer ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be performed for every online card payment. These token payment scenarios also have to use this new secure way of authentication. &lt;br /&gt;
The initial payment of a token scenario must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
Here is a table to compare the 3DS authentication requirements:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Initial payment&lt;br /&gt;
! Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
| One-click payment || ✔️ || ✔️&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Real life examples ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phone bill&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Payer has a usage-based phone subscription that wants to pay without being present for every charge. She authorizes the phone company to charge her card every month.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, the amount of the subsequent payments may exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TV subscription&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to online streaming of a television channel. She authorizes the phone company to charge her card every month. The subscription fee is the same for every month.&lt;br /&gt;
* Scenario: Recurring payment&lt;br /&gt;
* Explanation: The amount of the subsequent payments will not exceed the initial payment and the charge is regularly monthly-based.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bookclub with &amp;quot;free first month&amp;quot; bonus&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to a book renting service. She authorizes the book club to charge her card every month for a selection of books. The subscription fee is the same for every month however, the first month is free. To ensure the subscription the service requires her to register her card details.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, and the fee will stay the same, the initial payment is zero. So the amount of the next payment will exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Online food delivery service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The food delivery company wants to provide a quick and easy experience for its customer. They decide that the order will be quicker if the customers don&#039;t leave the website to pay for the goods.&lt;br /&gt;
* Scenario: OneClick payment&lt;br /&gt;
* Explanation: The customer will always be there so the other two scenarios are not available.&lt;br /&gt;
&lt;br /&gt;
== How to decide ==&lt;br /&gt;
&lt;br /&gt;
To help you decide on a suitable scenario, please use the decision graph below:&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurrencetype-decision.png|520px]]&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
To be able to integrate your webshop with the Barion Payment Gateway: &lt;br /&gt;
* You must [[Creating_an_account|register a Barion wallet]] at the Barion website or in the Sandbox environment. Learn more about the Sandbox environment [[Sandbox|here]].&lt;br /&gt;
* For this wallet you have to [[Creating_a_shop|create a shop]] which should be approved by Barion.&lt;br /&gt;
* For every currency you plan to conduct payments in you have to make sure there is an account created in your Barion wallet. This means that if you plan to have USD payments then there should be a USD account created in your wallet.&lt;br /&gt;
* To make sure every corner case scenario works for your webshop it is best to top up that account with a small amount (approx. 5-10EUR or your choice of currency around the same value).&lt;br /&gt;
* For the technical communication guide please read this: [[Calling_the_API|Calling the API]]&lt;br /&gt;
&lt;br /&gt;
= The payment process =&lt;br /&gt;
&lt;br /&gt;
The process is divided into two major steps:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 1:  Creating the funding source token|Creating the token]] that represents one of the customer&#039;s funding sources (credit card or e-money wallet)&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Preparing the payment via the Barion API&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Redirecting the customer to the Barion Smart Gateway to select a funding source&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Processing the callback and requesting information about the result of the payment&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 2: Using the token|Using the registered token]] to charge the customer&amp;lt;/li&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1:  Creating the funding source token ==&lt;br /&gt;
To be able to use a token payment scenario first the merchant has to register the token with Barion. The merchant has to make sure that the customer is well aware of the fact that they are giving consent to a tokenized payment. The Barion Smart Gateway UI does not indicate in any way that the payment is a token payment.&lt;br /&gt;
&lt;br /&gt;
The token is registered to the shop and not to the merchant&#039;s Barion account. So if the merchant has multiple shops in its Barion account, the registered tokens can not be shared among them even if the customer is the same. If you want to use tokens in multiple shops, please contact Barion in the Customer center.&lt;br /&gt;
&lt;br /&gt;
=== 1.1 Preparing the payment===&lt;br /&gt;
&lt;br /&gt;
The token registration is basically a [[Responsive_web_payment|normal payment]] with three extra properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* InitiateRecurrence&lt;br /&gt;
* RecurrenceId&lt;br /&gt;
* RecurrenceType&lt;br /&gt;
&lt;br /&gt;
==== InitiateRecurrence====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; property is a bool property. If you set it to &#039;&#039;&#039;true&#039;&#039;&#039; then the payment gateway will consider the payment as a token registration. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This happens even if the customer is already has a registered token, so you are able to re-register a funding source or even a customer. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceId ====&lt;br /&gt;
The next required property for a token registration is the token itself. This is generated by the shop and has to be unique for every registration. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property of the [[Payment-Start-v2|Payment/Start]] request. This token must be saved in the webshops database. A &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; token represents the funding source (bank card or Barion balance) of a customer. Since a customer can have multiple cards and accounts as a funding source make sure that in the webshop&#039;s system multiple tokens can belong to a single customer.&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceType ====&lt;br /&gt;
The third required property is the [[RecurrenceType|Recurrence Type]]. This specifies the scenario. In case of Recurring Payment &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; must also be set.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Merchant Initiated Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The response will be the same as to a [[Responsive_web_payment#Processing_the_successful_response|basic &#039;&#039;&#039;Immediate&#039;&#039;&#039; scenario]]. The &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; property at this point is &#039;&#039;&#039;None&#039;&#039;&#039; since the token is not registered to a funding source yet.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Recurring Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Recurring Payment&#039;&#039;&#039; scenario has some extra restrictions. The merchant has to specify two additional properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt;: The date after the subsequent charges should not accepted.&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt;: The minimum days the merchant has to wait between payments.&lt;br /&gt;
&lt;br /&gt;
Both properties are located in the [[PurchaseInformation]] property and must be specified if this scenario is selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7, 30-33&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;PurchaseInformation&amp;quot;:{&lt;br /&gt;
        &amp;quot;RecurringFrequency&amp;quot;: 10,&lt;br /&gt;
        &amp;quot;RecurringExpiry&amp;quot;: &amp;quot;2022-10-01&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Possible error responses ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentNotAllowed || The token payment is not allowed for the shop identified by the &#039;&#039;&#039;POSKey&#039;&#039;&#039;. Contact Barion to request this feature.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 1.2 Redirecting the customer to the Barion Smart Gateway to select a funding source ===&lt;br /&gt;
&lt;br /&gt;
After a successful payment preparation, the customer is redirected to the secure Barion Smart Gateway to choose a funding source. The funding source the customer selects will be registered to the token. The funding source can either be a Barion e-money balance or a bank card. This means that even though the customer may own multiple cards only the one that was registered to the token can be used for future token payments. To change the funding source attached to the token a new registration should be requested.&lt;br /&gt;
&lt;br /&gt;
=== 1.3 Processing the callback and requesting information about the result of the payment ===&lt;br /&gt;
&lt;br /&gt;
When the payment is completed (either successfully or unsuccessfully) a callback message is sent to the merchant&#039;s system. Once received a [[Payment-GetPaymentState-v2|GetPaymentState]] request must be sent to the Barion API. On how to implement this please read the article about the  [[Callback_mechanism|Callback mechanism]].&lt;br /&gt;
&lt;br /&gt;
The full response of the GetPaymentState request depends on the payment scenario and the structure of the payment. When it comes to token payment there are several properties to look out for. &lt;br /&gt;
* In case the &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; is &#039;&#039;&#039;Succeeded&#039;&#039;&#039; the funding source token is registered and ready to use.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; contains the ID of the token process. This specifies the nature of the token payment. &lt;br /&gt;
&lt;br /&gt;
==== TraceId ====&lt;br /&gt;
&lt;br /&gt;
In case of Recurring payment or Merchant initiated payment scenarios the [[Payment-GetPaymentState-v2|GetPaymentState]] response returns an additional field called &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. The value of this property is generated by the card issuer. The merchant has to save it and submit it in all subsequent Recurring or Merchant initiated payments of the same type, otherwise, the payments can be declined by the issuer. The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; represents the first, customer-present payment and helps the issuer to connect subsequent payments to this initial payment.&lt;br /&gt;
&lt;br /&gt;
====Example GetPaymentState response====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;8, 11-12&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;OrderNumber&amp;quot;: null,&lt;br /&gt;
    &amp;quot;POSId&amp;quot;: &amp;quot;[[SHOPS_PUBLIC_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSName&amp;quot;: &amp;quot;[[MERCHANTS_BARION_SHOPNAME]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSOwnerEmail&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSource&amp;quot;: &amp;quot;BankCard&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;AllowedFundingSources&amp;quot;: [&lt;br /&gt;
        &amp;quot;All&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;GuestCheckout&amp;quot;: true,&lt;br /&gt;
    &amp;quot;CreatedAt&amp;quot;: &amp;quot;2020-11-26T07:52:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ValidUntil&amp;quot;: &amp;quot;2020-11-26T08:22:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;CompletedAt&amp;quot;: &amp;quot;2020-11-26T08:11:54.118Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ReservedUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;DelayedCaptureUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
           ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;Total&amp;quot;: 25.20,&lt;br /&gt;
    &amp;quot;SuggestedLocale&amp;quot;: &amp;quot;hu-HU&amp;quot;,&lt;br /&gt;
    &amp;quot;FraudRiskScore&amp;quot;: null,&lt;br /&gt;
    &amp;quot;RedirectUrl&amp;quot;: &amp;quot;https://merchanturl/Redirect?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;CallbackUrl&amp;quot;: &amp;quot;https://merchanturl/Callback?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Displaying the funding source in a GUI ====&lt;br /&gt;
We strongly advise saving the complete response for future reference. The &amp;lt;code&amp;gt;FundingSource&amp;lt;/code&amp;gt; field tells if the funding source is a Barion balance or a card. If it is a card, it is useful to save [[FundingInformation]] for displaying it for the user, when requesting future payments. The usual way to display funding sources is to show the last 4 digits of the card, with 4 stars, eg: *** 1234. The card used can be obtained from FundingInformation&#039;s [[BankCard]] field. The [[CardType]] field can be used to display the appropriate card logo. You can even show, if the card is expired, and offer to register another one.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; FundingInformation part of the GetPaymentState response &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=json&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be displayed for example as &amp;lt;code&amp;gt;VISA **** 0425 (12/20)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a request-response diagram of the token registration process:&lt;br /&gt;
 &lt;br /&gt;
[[File:Token_payment_initiation.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Step 2: Using the token =&lt;br /&gt;
&lt;br /&gt;
To use an already registered token for a payment, you have to use the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property. To be able to use a token, the initial payment must be in a successful state.&lt;br /&gt;
&lt;br /&gt;
At this point, the merchant has to decide whether this subsequent payment is used for the same token payment scenario or something changed. This is important because the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used for the same scenario, otherwise, the card issuer will decline the charge.&lt;br /&gt;
A &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used again if:&lt;br /&gt;
* the funding source is the same (technically the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* the token payment scenario is the same (technically the &amp;lt;code&amp;gt;RecurrenceType&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* this subsequent request complies with the scenario restrictions (eg: in case of recurring payment the amount of the subsequent payment does not exceed the initial amount)&lt;br /&gt;
&lt;br /&gt;
If the funding source changes, new &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the funding source|described in detail here]]. If the funding source stays the same but the scenario changes or the restrictions are no longer met new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the token payment scenario with an existing token|described here]].&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Recurring payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this case, three extra conditions must be met:&lt;br /&gt;
* the amount of the subsequent payment must not be higher than the initial amount&lt;br /&gt;
* at least that much days must be spent as defined in the initial &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; property&lt;br /&gt;
* the date of the payment must not exceed the day specified in the initial &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; property&lt;br /&gt;
&lt;br /&gt;
Please be aware that in case any of these are no longer valid the merchant has to request a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; as [[#Changing the token payment scenario with an existing token|described here]]. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=These conditions are not enforced by the Barion system so the violation of them will result in a declined charge.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
Payment/start must not include the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; properties (since they are already fixed during the initial payment).&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Recurring payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Merchant Initiated Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario there are no restrictions.&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Merchant Initiated Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 75,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Phone bill&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of OneClick Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario, the merchant has to prepare to perform the 3DS v2 authentication of the payer. 3DS authentication is not required in the following cases:&lt;br /&gt;
* the token () was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
* the subsequent payment is a merchant initiated payment.&lt;br /&gt;
&lt;br /&gt;
To perform an off-site 3DS authentication of the payer the merchant has to integrate the client library of the Barion Smart Gateway. Read the detailed instructions here.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is not used in this scenario since the payer is present during the transaction. &lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent OneClick Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 17,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Book: How to shop online&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;How to shop online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Book about shopping online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;piece&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Depending on the type of the subsequent payment, 3DSecure authentication might be required for subsequent payments.&lt;br /&gt;
3DS authentication is not required in the following cases:&lt;br /&gt;
* the token (&amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;) was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
&lt;br /&gt;
=== Prerequisites ===&lt;br /&gt;
&lt;br /&gt;
[[File:Token_payment_2.png]]&lt;br /&gt;
&lt;br /&gt;
=== OneClick payment ===&lt;br /&gt;
==== Step 1 : Initialize oneClick ====&lt;br /&gt;
You have to include the following css and javascript files in the code of your site. These files include all the necessary javascript code and styling to handle the 3DS authentication and display the challenge if necessary.&lt;br /&gt;
&amp;lt;source lang=html&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source &amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to initialize the Barion javascript client:&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const configuration = {&lt;br /&gt;
    onAuthenticationSucceeded: function () {&lt;br /&gt;
        // handle successful authentication by calling the Barion API via merchant&#039;s backend&lt;br /&gt;
        // Call the v2/payment/complete endpoint&lt;br /&gt;
    },&lt;br /&gt;
    onAuthenticationFailed: function () {&lt;br /&gt;
        // Handle unsuccessful authentication result, no charge was made.&lt;br /&gt;
        // The payment might be still valid only the authentication failed&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
const gw= new Barion.OffsiteGw(configuration);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Step 2 : Make a payment  ====&lt;br /&gt;
To use an already registered token for a payment, you have to call the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; and the appropriate [[RecurrenceType|Recurrence Type]] should be sent. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property along with the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Example Payment/Start json request =====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;E31EC263-01DC-40BD-BDF1-38FC7A332434&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot; : &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot; : false,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot; : &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot; : &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot; : &amp;quot;SHOP-XMLP-TRACEID-123&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR002&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;webshop@example.com&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subsription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Processing the Payment/Start response =====&lt;br /&gt;
To this request, the Barion API sends back the required data for the 3DS authentication for the specified paymentId.&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
! Field name&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| PaymentId&lt;br /&gt;
| Payment Identifier of the purchase in Barion&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| ThreeDSAuthClientData&lt;br /&gt;
| basae64 encoded 3DS client data&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Payment/Start response =====&lt;br /&gt;
&amp;lt;source lang=json line style=&amp;quot;word-break: break-all;&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot; : &amp;quot;dce46843-6266-4c1f-b82a-387e0fee9073&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot; : &amp;quot;ewoJIkNhcmRQdWJsaWNJZCI6ICIxYTE5M2E1NDQzNDI0YjJiOGJiMjMyOGRhNWY4NmYzYiIsCgkiUGF5bWVudElkIjogImRjZTQ2ODQzNjI2NjRjMWZiODJhMzg3ZTBmZWU5MDczIiwKCSJPbmVDbGlja0NvbnRlbnRVcmwiOiAiaHR0cDovL3NlY3VyZS5iYXJpb24uY29tL3RocmVlZHMvb25lY2xpY2twYXltZW50IiwKCSJBQ1NTdGFydFByb3RvY29sVmVyc2lvbiI6ICIyLjEuMCIsCgkiQUNTRW5kUHJvdG9jb2xWZXJzaW9uIjogIjIuMS4wIiwKCSJEU1N0YXJ0UHJvdG9jb2xWZXJzaW9uIjogIjIuMS4wIiwKCSJEU0VuZFByb3RvY29sVmVyc2lvbiI6ICIyLjIuMCIsCgkiVGhyZWVEU1NlcnZlclRyYW5zSUQiOiBudWxsLAoJIlRocmVlRFNNZXRob2RVUkwiOiBudWxsLAoJIlRocmVlRFNNZXRob2REYXRhRm9ybSI6ICJleUowYUhKbFpVUlRUV1YwYUc5a1RtOTBhV1pwWTJGMGFXOXVWVkpNSWpvaWFIUjBjSE02THk4elpITXVZbUZ5YVc5dUxtTnZiUzh6WkhNdmRqSXZNMlJ6TFcxbGRHaHZaQzF1YjNScFptbGpZWFJwYjI0aUxDSjBhSEpsWlVSVFUyVnlkbVZ5VkhKaGJuTkpSQ0k2SWpFNE5URTJPR0kxTFRKalkyUXROR0kxWlMxaVlqWm1MVFUzTW1VM00yVTNNemt3TnlKOSIsCgkiRXJyb3JEZXRhaWxzIjogbnVsbCwKCSJWZXJzaW9uIjogIjIuMS4wIgp9Cg==&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Step 3: 3DS authentication &amp;amp; challenge ====&lt;br /&gt;
This data then should be passed onto the &amp;lt;code&amp;gt;authenticate()&amp;lt;/code&amp;gt; method of the offsite gw manager, which will do all the magic to authenticate and display the challenge (if needed).&lt;br /&gt;
&amp;lt;source lang=javascript line highlight=&amp;quot;9&amp;quot;&amp;gt;&lt;br /&gt;
        // call Barion API via merchant&#039;s backend&lt;br /&gt;
        // once the result is returned continue with authentication&lt;br /&gt;
        $.ajax({&lt;br /&gt;
            url: &amp;quot;Url/Of/Your/Payment/Start&amp;quot;,&lt;br /&gt;
            method: &amp;quot;POST&amp;quot;,&lt;br /&gt;
            data: data,&lt;br /&gt;
            success: function (threeDsClientData) {&lt;br /&gt;
               // the threeDsClientData will be in the response of payment/start	&lt;br /&gt;
               gw.authenticate(threeDsClientData);&lt;br /&gt;
            }&lt;br /&gt;
         });&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the request is finished the appropriate callback is fired, the BarionClient was initialized with in [[#Step 1 : Initialize oneClick|Step 1]]. In case of successful authentication, you have to call our [[Payment-Complete-v3|/Payment/Complete]] endpoint, where the actual charge will happen.&lt;br /&gt;
&lt;br /&gt;
=== Recurring payment/Merchant Initiated payment ===&lt;br /&gt;
&lt;br /&gt;
For these types of payments, the subsequent payments are nearly identical to the process of [[#Creating_the_token|Creating the token]]. The only difference is that the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; received in the initial [[Payment-GetPaymentState-v2|GetPaymentState]] response must be sent in the &lt;br /&gt;
[[Payment-Start-v2|Payment/Start]] request. Also don&#039;t forget to set the appropriate [[RecurrenceType|Recurrence Type]].&lt;br /&gt;
&lt;br /&gt;
=== Possible error responses ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| InvalidRecurrenceId|| The token specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is invalid. Check if the token registration was successful.&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentDenied|| Something happened to the user since the token registration, either deleted, suspended, or blocked. The payment s not allowed in these cases.&lt;br /&gt;
|-&lt;br /&gt;
| InsufficientFunds|| If the original payment was with an e-money wallet and the customer doesn&#039;t have enough money to fulfill this charge this error happens.&lt;br /&gt;
|-&lt;br /&gt;
| OriginalPaymentWasntSuccessful || This means that the token belongs to an originally unsuccessful payment so this token can not be used anymore. This could only happen if the original payment was financed with a credit card.&lt;br /&gt;
|-&lt;br /&gt;
|InvalidCurrency || If the original payment was paid with e-money and the current token payment is in a currency that the wallet does not have an account in this error happens.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2864</id>
		<title>Token payment 3D Secure</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2864"/>
		<updated>2020-11-26T11:52:36Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* Subsequent payments in case of Recurring payment scenario */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Token Payment with 3D Secure}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{IncompletePage}}&lt;br /&gt;
&lt;br /&gt;
This payment scenario allows the integrator shop to register a token for a customer (and a funding source) in the Barion system and then, later on, using this token, charge the customer without redirecting her to the Barion Smart Gateway UI. The user may be present at the site of the merchant or she can be off-session as well, so the merchant can charge her e.g. for subscriptions. This means that the customer authorizes the shop to charge her card or Barion balance without typing in the card information or Barion login again.&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurring.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=Premium feature|text=This scenario is not allowed automatically for every approved shop and should be requested from Barion!|color=#1993c7}}&lt;br /&gt;
&lt;br /&gt;
= Token payment scenarios =&lt;br /&gt;
Token payment can be used in three use cases: &lt;br /&gt;
* &#039;&#039;&#039;Customer Initiated Payments&#039;&#039;&#039;: when the user is present on the website of the merchant and she decides to pay :&lt;br /&gt;
** &#039;&#039;&#039;OneClick payment&#039;&#039;&#039;: the user is charged upon her request initiated on the website of the merchant. Subsequent payments are subject to PSD2 SCA and as the user is present, she has to go through the authentication process.&lt;br /&gt;
* &#039;&#039;&#039;Merchant Initiated Payments&#039;&#039;&#039;: when the merchant initiates the payment without the user being present. It has two subtypes:&lt;br /&gt;
** &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: the user is charged with the same amount on a regular basis, typically in case of subscriptions. Subsequent payments are exempted from PSD2 SCA, but liability still shifts to the card issuer.&lt;br /&gt;
** &#039;&#039;&#039;MIT (merchant initiated transaction)&#039;&#039;&#039;: the user is charged on an irregular basis and/or with a different amount. Subsequent payments of this type are excluded from PSD2 SCA, the liability is on the merchant.&lt;br /&gt;
&lt;br /&gt;
== Customer participation ==&lt;br /&gt;
&lt;br /&gt;
Since the token scenario is suitable for both customer and merchant initiated payments here is a comparison about who starts the payment. This includes the regular, non-tokenized payment scenario as well:&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot; | Scenario&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Initial payment&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW &lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW&lt;br /&gt;
|-&lt;br /&gt;
| Non token (regular) payment || YES || YES || YES || YES &lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || YES || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| MIT || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #aaa; background-color:#eee; font-size: 0.8em; padding:5px 10px; display:inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; Token payment scenarios can be initiated with already registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; as well, in this case the customer may remain on the merchant&#039;s site. &lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements for the scenarios ==&lt;br /&gt;
&lt;br /&gt;
These token payment scenarios have different requirements, this table below summarizes the key differences.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Payment amount&lt;br /&gt;
! Payment frequency&lt;br /&gt;
! Liability in case of fraud&lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || Various || Various || Card issuer&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || Subsequent amounts must be equal or less than the initial amount  || Initial payment must define a minimum amount of days to wait between charges || Card issuer &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || Various  || Various || Merchant&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 3DS authentication of the payer ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be performed for every online card payment. These token payment scenarios also have to use this new secure way of authentication. &lt;br /&gt;
The initial payment of a token scenario must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
Here is a table to compare the 3DS authentication requirements:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Initial payment&lt;br /&gt;
! Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
| One-click payment || ✔️ || ✔️&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Real life examples ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phone bill&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Payer has a usage-based phone subscription that wants to pay without being present for every charge. She authorizes the phone company to charge her card every month.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, the amount of the subsequent payments may exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TV subscription&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to online streaming of a television channel. She authorizes the phone company to charge her card every month. The subscription fee is the same for every month.&lt;br /&gt;
* Scenario: Recurring payment&lt;br /&gt;
* Explanation: The amount of the subsequent payments will not exceed the initial payment and the charge is regularly monthly-based.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bookclub with &amp;quot;free first month&amp;quot; bonus&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to a book renting service. She authorizes the book club to charge her card every month for a selection of books. The subscription fee is the same for every month however, the first month is free. To ensure the subscription the service requires her to register her card details.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, and the fee will stay the same, the initial payment is zero. So the amount of the next payment will exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Online food delivery service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The food delivery company wants to provide a quick and easy experience for its customer. They decide that the order will be quicker if the customers don&#039;t leave the website to pay for the goods.&lt;br /&gt;
* Scenario: OneClick payment&lt;br /&gt;
* Explanation: The customer will always be there so the other two scenarios are not available.&lt;br /&gt;
&lt;br /&gt;
== How to decide ==&lt;br /&gt;
&lt;br /&gt;
To help you decide on a suitable scenario, please use the decision graph below:&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurrencetype-decision.png|520px]]&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
To be able to integrate your webshop with the Barion Payment Gateway: &lt;br /&gt;
* You must [[Creating_an_account|register a Barion wallet]] at the Barion website or in the Sandbox environment. Learn more about the Sandbox environment [[Sandbox|here]].&lt;br /&gt;
* For this wallet you have to [[Creating_a_shop|create a shop]] which should be approved by Barion.&lt;br /&gt;
* For every currency you plan to conduct payments in you have to make sure there is an account created in your Barion wallet. This means that if you plan to have USD payments then there should be a USD account created in your wallet.&lt;br /&gt;
* To make sure every corner case scenario works for your webshop it is best to top up that account with a small amount (approx. 5-10EUR or your choice of currency around the same value).&lt;br /&gt;
* For the technical communication guide please read this: [[Calling_the_API|Calling the API]]&lt;br /&gt;
&lt;br /&gt;
= The payment process =&lt;br /&gt;
&lt;br /&gt;
The process is divided into two major steps:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 1:  Creating the funding source token|Creating the token]] that represents one of the customer&#039;s funding sources (credit card or e-money wallet)&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Preparing the payment via the Barion API&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Redirecting the customer to the Barion Smart Gateway to select a funding source&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Processing the callback and requesting information about the result of the payment&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 2: Using the token|Using the registered token]] to charge the customer&amp;lt;/li&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1:  Creating the funding source token ==&lt;br /&gt;
To be able to use a token payment scenario first the merchant has to register the token with Barion. The merchant has to make sure that the customer is well aware of the fact that they are giving consent to a tokenized payment. The Barion Smart Gateway UI does not indicate in any way that the payment is a token payment.&lt;br /&gt;
&lt;br /&gt;
The token is registered to the shop and not to the merchant&#039;s Barion account. So if the merchant has multiple shops in its Barion account, the registered tokens can not be shared among them even if the customer is the same. If you want to use tokens in multiple shops, please contact Barion in the Customer center.&lt;br /&gt;
&lt;br /&gt;
=== 1.1 Preparing the payment===&lt;br /&gt;
&lt;br /&gt;
The token registration is basically a [[Responsive_web_payment|normal payment]] with three extra properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* InitiateRecurrence&lt;br /&gt;
* RecurrenceId&lt;br /&gt;
* RecurrenceType&lt;br /&gt;
&lt;br /&gt;
==== InitiateRecurrence====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; property is a bool property. If you set it to &#039;&#039;&#039;true&#039;&#039;&#039; then the payment gateway will consider the payment as a token registration. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This happens even if the customer is already has a registered token, so you are able to re-register a funding source or even a customer. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceId ====&lt;br /&gt;
The next required property for a token registration is the token itself. This is generated by the shop and has to be unique for every registration. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property of the [[Payment-Start-v2|Payment/Start]] request. This token must be saved in the webshops database. A &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; token represents the funding source (bank card or Barion balance) of a customer. Since a customer can have multiple cards and accounts as a funding source make sure that in the webshop&#039;s system multiple tokens can belong to a single customer.&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceType ====&lt;br /&gt;
The third required property is the [[RecurrenceType|Recurrence Type]]. This specifies the scenario. In case of Recurring Payment &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; must also be set.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Merchant Initiated Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The response will be the same as to a [[Responsive_web_payment#Processing_the_successful_response|basic &#039;&#039;&#039;Immediate&#039;&#039;&#039; scenario]]. The &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; property at this point is &#039;&#039;&#039;None&#039;&#039;&#039; since the token is not registered to a funding source yet.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Recurring Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Recurring Payment&#039;&#039;&#039; scenario has some extra restrictions. The merchant has to specify two additional properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt;: The date after the subsequent charges should not accepted.&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt;: The minimum days the merchant has to wait between payments.&lt;br /&gt;
&lt;br /&gt;
Both properties are located in the [[PurchaseInformation]] property and must be specified if this scenario is selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7, 30-33&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;PurchaseInformation&amp;quot;:{&lt;br /&gt;
        &amp;quot;RecurringFrequency&amp;quot;: 10,&lt;br /&gt;
        &amp;quot;RecurringExpiry&amp;quot;: &amp;quot;2022-10-01&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Possible error responses ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentNotAllowed || The token payment is not allowed for the shop identified by the &#039;&#039;&#039;POSKey&#039;&#039;&#039;. Contact Barion to request this feature.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 1.2 Redirecting the customer to the Barion Smart Gateway to select a funding source ===&lt;br /&gt;
&lt;br /&gt;
After a successful payment preparation, the customer is redirected to the secure Barion Smart Gateway to choose a funding source. The funding source the customer selects will be registered to the token. The funding source can either be a Barion e-money balance or a bank card. This means that even though the customer may own multiple cards only the one that was registered to the token can be used for future token payments. To change the funding source attached to the token a new registration should be requested.&lt;br /&gt;
&lt;br /&gt;
=== 1.3 Processing the callback and requesting information about the result of the payment ===&lt;br /&gt;
&lt;br /&gt;
When the payment is completed (either successfully or unsuccessfully) a callback message is sent to the merchant&#039;s system. Once received a [[Payment-GetPaymentState-v2|GetPaymentState]] request must be sent to the Barion API. On how to implement this please read the article about the  [[Callback_mechanism|Callback mechanism]].&lt;br /&gt;
&lt;br /&gt;
The full response of the GetPaymentState request depends on the payment scenario and the structure of the payment. When it comes to token payment there are several properties to look out for. &lt;br /&gt;
* In case the &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; is &#039;&#039;&#039;Succeeded&#039;&#039;&#039; the funding source token is registered and ready to use.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; contains the ID of the token process. This specifies the nature of the token payment. &lt;br /&gt;
&lt;br /&gt;
==== TraceId ====&lt;br /&gt;
&lt;br /&gt;
In case of Recurring payment or Merchant initiated payment scenarios the [[Payment-GetPaymentState-v2|GetPaymentState]] response returns an additional field called &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. The value of this property is generated by the card issuer. The merchant has to save it and submit it in all subsequent Recurring or Merchant initiated payments of the same type, otherwise, the payments can be declined by the issuer. The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; represents the first, customer-present payment and helps the issuer to connect subsequent payments to this initial payment.&lt;br /&gt;
&lt;br /&gt;
====Example GetPaymentState response====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;8, 11-12&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;OrderNumber&amp;quot;: null,&lt;br /&gt;
    &amp;quot;POSId&amp;quot;: &amp;quot;[[SHOPS_PUBLIC_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSName&amp;quot;: &amp;quot;[[MERCHANTS_BARION_SHOPNAME]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSOwnerEmail&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSource&amp;quot;: &amp;quot;BankCard&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;AllowedFundingSources&amp;quot;: [&lt;br /&gt;
        &amp;quot;All&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;GuestCheckout&amp;quot;: true,&lt;br /&gt;
    &amp;quot;CreatedAt&amp;quot;: &amp;quot;2020-11-26T07:52:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ValidUntil&amp;quot;: &amp;quot;2020-11-26T08:22:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;CompletedAt&amp;quot;: &amp;quot;2020-11-26T08:11:54.118Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ReservedUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;DelayedCaptureUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
           ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;Total&amp;quot;: 25.20,&lt;br /&gt;
    &amp;quot;SuggestedLocale&amp;quot;: &amp;quot;hu-HU&amp;quot;,&lt;br /&gt;
    &amp;quot;FraudRiskScore&amp;quot;: null,&lt;br /&gt;
    &amp;quot;RedirectUrl&amp;quot;: &amp;quot;https://merchanturl/Redirect?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;CallbackUrl&amp;quot;: &amp;quot;https://merchanturl/Callback?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Displaying the funding source in a GUI ====&lt;br /&gt;
We strongly advise saving the complete response for future reference. The &amp;lt;code&amp;gt;FundingSource&amp;lt;/code&amp;gt; field tells if the funding source is a Barion balance or a card. If it is a card, it is useful to save [[FundingInformation]] for displaying it for the user, when requesting future payments. The usual way to display funding sources is to show the last 4 digits of the card, with 4 stars, eg: *** 1234. The card used can be obtained from FundingInformation&#039;s [[BankCard]] field. The [[CardType]] field can be used to display the appropriate card logo. You can even show, if the card is expired, and offer to register another one.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; FundingInformation part of the GetPaymentState response &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=json&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be displayed for example as &amp;lt;code&amp;gt;VISA **** 0425 (12/20)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a request-response diagram of the token registration process:&lt;br /&gt;
 &lt;br /&gt;
[[File:Token_payment_initiation.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Step 2: Using the token =&lt;br /&gt;
&lt;br /&gt;
To use an already registered token for a payment, you have to use the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property. To be able to use a token, the initial payment must be in a successful state.&lt;br /&gt;
&lt;br /&gt;
At this point, the merchant has to decide whether this subsequent payment is used for the same token payment scenario or something changed. This is important because the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used for the same scenario, otherwise, the card issuer will decline the charge.&lt;br /&gt;
A &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used again if:&lt;br /&gt;
* the funding source is the same (technically the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* the token payment scenario is the same (technically the &amp;lt;code&amp;gt;RecurrenceType&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* this subsequent request complies with the scenario restrictions (eg: in case of recurring payment the amount of the subsequent payment does not exceed the initial amount)&lt;br /&gt;
&lt;br /&gt;
If the funding source changes, new &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the funding source|described in detail here]]. If the funding source stays the same but the scenario changes or the restrictions are no longer met new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the token payment scenario with an existing token|described here]].&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Recurring payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this case, three extra conditions must be met:&lt;br /&gt;
* the amount of the subsequent payment must not be higher than the initial amount&lt;br /&gt;
* at least that much days must be spent as defined in the initial &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; property&lt;br /&gt;
* the date of the payment must not exceed the day specified in the initial &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; property&lt;br /&gt;
&lt;br /&gt;
Please be aware that in case any of these are no longer valid the merchant has to request a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; as [[#Changing the token payment scenario with an existing token|described here]]. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=These conditions are not enforced by the Barion system so the violation of them will result in a declined charge.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
Payment/start must not include the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; properties (since they are already fixed during the initial payment).&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Recurring payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Merchant Initiated Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario there are no restrictions.&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Merchant Initiated Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 75,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Phone bill&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of OneClick Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario, the merchant has to prepare to perform the 3DS v2 authentication of the payer. 3DS authentication is not required in the following cases:&lt;br /&gt;
* the token () was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
* the subsequent payment is a merchant initiated payment.&lt;br /&gt;
&lt;br /&gt;
To perform an off-site 3DS authentication of the payer the merchant has to integrate the client library of the Barion Smart Gateway. Read the detailed instructions here.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is not used in this scenario since the payer is present during the transaction. &lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent OneClick Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 17,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Book: How to shop online&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;How to shop online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Book about shopping online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;piece&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Depending on the type of the subsequent payment, 3DSecure authentication might be required for subsequent payments.&lt;br /&gt;
3DS authentication is not required in the following cases:&lt;br /&gt;
* the token (&amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;) was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
&lt;br /&gt;
=== Prerequisites ===&lt;br /&gt;
&lt;br /&gt;
[[File:Token_payment_2.png]]&lt;br /&gt;
&lt;br /&gt;
=== OneClick payment ===&lt;br /&gt;
==== Step 1 : Initialize oneClick ====&lt;br /&gt;
You have to include the following css and javascript files in the code of your site. These files include all the necessary javascript code and styling to handle the 3DS authentication and display the challenge if necessary.&lt;br /&gt;
&amp;lt;source lang=html&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source &amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to initialize the Barion javascript client:&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const configuration = {&lt;br /&gt;
    onAuthenticationSucceeded: function () {&lt;br /&gt;
        // handle successful authentication by calling the Barion API via merchant&#039;s backend&lt;br /&gt;
        // Call the v2/payment/complete endpoint&lt;br /&gt;
    },&lt;br /&gt;
    onAuthenticationFailed: function () {&lt;br /&gt;
        // Handle unsuccessful authentication result, no charge was made.&lt;br /&gt;
        // The payment might be still valid only the authentication failed&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
const gw= new Barion.OffsiteGw(configuration);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Step 2 : Make a payment  ====&lt;br /&gt;
To use an already registered token for a payment, you have to call the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; and the appropriate [[RecurrenceType|Recurrence Type]] should be sent. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property along with the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Example Payment/Start json request =====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;E31EC263-01DC-40BD-BDF1-38FC7A332434&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot; : &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot; : false,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot; : &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot; : &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot; : &amp;quot;SHOP-XMLP-TRACEID-123&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR002&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;webshop@example.com&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subsription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Processing the Payment/Start response =====&lt;br /&gt;
To this request, the Barion API sends back the required data for the 3DS authentication for the specified paymentId.&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
! Field name&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| PaymentId&lt;br /&gt;
| Payment Identifier of the purchase in Barion&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| ThreeDSAuthClientData&lt;br /&gt;
| basae64 encoded 3DS client data&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Payment/Start response =====&lt;br /&gt;
&amp;lt;source lang=json line style=&amp;quot;word-break: break-all;&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot; : &amp;quot;dce46843-6266-4c1f-b82a-387e0fee9073&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot; : &amp;quot;ewoJIkNhcmRQdWJsaWNJZCI6ICIxYTE5M2E1NDQzNDI0YjJiOGJiMjMyOGRhNWY4NmYzYiIsCgkiUGF5bWVudElkIjogImRjZTQ2ODQzNjI2NjRjMWZiODJhMzg3ZTBmZWU5MDczIiwKCSJPbmVDbGlja0NvbnRlbnRVcmwiOiAiaHR0cDovL3NlY3VyZS5iYXJpb24uY29tL3RocmVlZHMvb25lY2xpY2twYXltZW50IiwKCSJBQ1NTdGFydFByb3RvY29sVmVyc2lvbiI6ICIyLjEuMCIsCgkiQUNTRW5kUHJvdG9jb2xWZXJzaW9uIjogIjIuMS4wIiwKCSJEU1N0YXJ0UHJvdG9jb2xWZXJzaW9uIjogIjIuMS4wIiwKCSJEU0VuZFByb3RvY29sVmVyc2lvbiI6ICIyLjIuMCIsCgkiVGhyZWVEU1NlcnZlclRyYW5zSUQiOiBudWxsLAoJIlRocmVlRFNNZXRob2RVUkwiOiBudWxsLAoJIlRocmVlRFNNZXRob2REYXRhRm9ybSI6ICJleUowYUhKbFpVUlRUV1YwYUc5a1RtOTBhV1pwWTJGMGFXOXVWVkpNSWpvaWFIUjBjSE02THk4elpITXVZbUZ5YVc5dUxtTnZiUzh6WkhNdmRqSXZNMlJ6TFcxbGRHaHZaQzF1YjNScFptbGpZWFJwYjI0aUxDSjBhSEpsWlVSVFUyVnlkbVZ5VkhKaGJuTkpSQ0k2SWpFNE5URTJPR0kxTFRKalkyUXROR0kxWlMxaVlqWm1MVFUzTW1VM00yVTNNemt3TnlKOSIsCgkiRXJyb3JEZXRhaWxzIjogbnVsbCwKCSJWZXJzaW9uIjogIjIuMS4wIgp9Cg==&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Step 3: 3DS authentication &amp;amp; challenge ====&lt;br /&gt;
This data then should be passed onto the &amp;lt;code&amp;gt;authenticate()&amp;lt;/code&amp;gt; method of the offsite gw manager, which will do all the magic to authenticate and display the challenge (if needed).&lt;br /&gt;
&amp;lt;source lang=javascript line highlight=&amp;quot;9&amp;quot;&amp;gt;&lt;br /&gt;
        // call Barion API via merchant&#039;s backend&lt;br /&gt;
        // once the result is returned continue with authentication&lt;br /&gt;
        $.ajax({&lt;br /&gt;
            url: &amp;quot;Url/Of/Your/Payment/Start&amp;quot;,&lt;br /&gt;
            method: &amp;quot;POST&amp;quot;,&lt;br /&gt;
            data: data,&lt;br /&gt;
            success: function (threeDsClientData) {&lt;br /&gt;
               // the threeDsClientData will be in the response of payment/start	&lt;br /&gt;
               gw.authenticate(threeDsClientData);&lt;br /&gt;
            }&lt;br /&gt;
         });&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the request is finished the appropriate callback is fired, the BarionClient was initialized with in [[#Step 1 : Initialize oneClick|Step 1]]. In case of successful authentication, you have to call our [[Payment-Complete-v3|/Payment/Complete]] endpoint, where the actual charge will happen.&lt;br /&gt;
&lt;br /&gt;
=== Recurring payment/Merchant Initiated payment ===&lt;br /&gt;
&lt;br /&gt;
For these types of payments, the subsequent payments are nearly identical to the process of [[#Creating_the_token|Creating the token]]. The only difference is that the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; received in the initial [[Payment-GetPaymentState-v2|GetPaymentState]] response must be sent in the &lt;br /&gt;
[[Payment-Start-v2|Payment/Start]] request. Also don&#039;t forget to set the appropriate [[RecurrenceType|Recurrence Type]].&lt;br /&gt;
&lt;br /&gt;
=== Possible error responses ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| InvalidRecurrenceId|| The token specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is invalid. Check if the token registration was successful.&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentDenied|| Something happened to the user since the token registration, either deleted, suspended, or blocked. The payment s not allowed in these cases.&lt;br /&gt;
|-&lt;br /&gt;
| InsufficientFunds|| If the original payment was with an e-money wallet and the customer doesn&#039;t have enough money to fulfill this charge this error happens.&lt;br /&gt;
|-&lt;br /&gt;
| OriginalPaymentWasntSuccessful || This means that the token belongs to an originally unsuccessful payment so this token can not be used anymore. This could only happen if the original payment was financed with a credit card.&lt;br /&gt;
|-&lt;br /&gt;
|InvalidCurrency || If the original payment was paid with e-money and the current token payment is in a currency that the wallet does not have an account in this error happens.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2863</id>
		<title>Token payment 3D Secure</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2863"/>
		<updated>2020-11-26T11:51:17Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* Subsequent payments in case of Merchant Initiated Payment scenario */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Token Payment with 3D Secure}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{IncompletePage}}&lt;br /&gt;
&lt;br /&gt;
This payment scenario allows the integrator shop to register a token for a customer (and a funding source) in the Barion system and then, later on, using this token, charge the customer without redirecting her to the Barion Smart Gateway UI. The user may be present at the site of the merchant or she can be off-session as well, so the merchant can charge her e.g. for subscriptions. This means that the customer authorizes the shop to charge her card or Barion balance without typing in the card information or Barion login again.&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurring.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=Premium feature|text=This scenario is not allowed automatically for every approved shop and should be requested from Barion!|color=#1993c7}}&lt;br /&gt;
&lt;br /&gt;
= Token payment scenarios =&lt;br /&gt;
Token payment can be used in three use cases: &lt;br /&gt;
* &#039;&#039;&#039;Customer Initiated Payments&#039;&#039;&#039;: when the user is present on the website of the merchant and she decides to pay :&lt;br /&gt;
** &#039;&#039;&#039;OneClick payment&#039;&#039;&#039;: the user is charged upon her request initiated on the website of the merchant. Subsequent payments are subject to PSD2 SCA and as the user is present, she has to go through the authentication process.&lt;br /&gt;
* &#039;&#039;&#039;Merchant Initiated Payments&#039;&#039;&#039;: when the merchant initiates the payment without the user being present. It has two subtypes:&lt;br /&gt;
** &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: the user is charged with the same amount on a regular basis, typically in case of subscriptions. Subsequent payments are exempted from PSD2 SCA, but liability still shifts to the card issuer.&lt;br /&gt;
** &#039;&#039;&#039;MIT (merchant initiated transaction)&#039;&#039;&#039;: the user is charged on an irregular basis and/or with a different amount. Subsequent payments of this type are excluded from PSD2 SCA, the liability is on the merchant.&lt;br /&gt;
&lt;br /&gt;
== Customer participation ==&lt;br /&gt;
&lt;br /&gt;
Since the token scenario is suitable for both customer and merchant initiated payments here is a comparison about who starts the payment. This includes the regular, non-tokenized payment scenario as well:&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot; | Scenario&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Initial payment&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW &lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW&lt;br /&gt;
|-&lt;br /&gt;
| Non token (regular) payment || YES || YES || YES || YES &lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || YES || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| MIT || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #aaa; background-color:#eee; font-size: 0.8em; padding:5px 10px; display:inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; Token payment scenarios can be initiated with already registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; as well, in this case the customer may remain on the merchant&#039;s site. &lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements for the scenarios ==&lt;br /&gt;
&lt;br /&gt;
These token payment scenarios have different requirements, this table below summarizes the key differences.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Payment amount&lt;br /&gt;
! Payment frequency&lt;br /&gt;
! Liability in case of fraud&lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || Various || Various || Card issuer&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || Subsequent amounts must be equal or less than the initial amount  || Initial payment must define a minimum amount of days to wait between charges || Card issuer &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || Various  || Various || Merchant&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 3DS authentication of the payer ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be performed for every online card payment. These token payment scenarios also have to use this new secure way of authentication. &lt;br /&gt;
The initial payment of a token scenario must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
Here is a table to compare the 3DS authentication requirements:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Initial payment&lt;br /&gt;
! Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
| One-click payment || ✔️ || ✔️&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Real life examples ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phone bill&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Payer has a usage-based phone subscription that wants to pay without being present for every charge. She authorizes the phone company to charge her card every month.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, the amount of the subsequent payments may exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TV subscription&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to online streaming of a television channel. She authorizes the phone company to charge her card every month. The subscription fee is the same for every month.&lt;br /&gt;
* Scenario: Recurring payment&lt;br /&gt;
* Explanation: The amount of the subsequent payments will not exceed the initial payment and the charge is regularly monthly-based.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bookclub with &amp;quot;free first month&amp;quot; bonus&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to a book renting service. She authorizes the book club to charge her card every month for a selection of books. The subscription fee is the same for every month however, the first month is free. To ensure the subscription the service requires her to register her card details.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, and the fee will stay the same, the initial payment is zero. So the amount of the next payment will exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Online food delivery service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The food delivery company wants to provide a quick and easy experience for its customer. They decide that the order will be quicker if the customers don&#039;t leave the website to pay for the goods.&lt;br /&gt;
* Scenario: OneClick payment&lt;br /&gt;
* Explanation: The customer will always be there so the other two scenarios are not available.&lt;br /&gt;
&lt;br /&gt;
== How to decide ==&lt;br /&gt;
&lt;br /&gt;
To help you decide on a suitable scenario, please use the decision graph below:&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurrencetype-decision.png|520px]]&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
To be able to integrate your webshop with the Barion Payment Gateway: &lt;br /&gt;
* You must [[Creating_an_account|register a Barion wallet]] at the Barion website or in the Sandbox environment. Learn more about the Sandbox environment [[Sandbox|here]].&lt;br /&gt;
* For this wallet you have to [[Creating_a_shop|create a shop]] which should be approved by Barion.&lt;br /&gt;
* For every currency you plan to conduct payments in you have to make sure there is an account created in your Barion wallet. This means that if you plan to have USD payments then there should be a USD account created in your wallet.&lt;br /&gt;
* To make sure every corner case scenario works for your webshop it is best to top up that account with a small amount (approx. 5-10EUR or your choice of currency around the same value).&lt;br /&gt;
* For the technical communication guide please read this: [[Calling_the_API|Calling the API]]&lt;br /&gt;
&lt;br /&gt;
= The payment process =&lt;br /&gt;
&lt;br /&gt;
The process is divided into two major steps:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 1:  Creating the funding source token|Creating the token]] that represents one of the customer&#039;s funding sources (credit card or e-money wallet)&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Preparing the payment via the Barion API&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Redirecting the customer to the Barion Smart Gateway to select a funding source&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Processing the callback and requesting information about the result of the payment&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 2: Using the token|Using the registered token]] to charge the customer&amp;lt;/li&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1:  Creating the funding source token ==&lt;br /&gt;
To be able to use a token payment scenario first the merchant has to register the token with Barion. The merchant has to make sure that the customer is well aware of the fact that they are giving consent to a tokenized payment. The Barion Smart Gateway UI does not indicate in any way that the payment is a token payment.&lt;br /&gt;
&lt;br /&gt;
The token is registered to the shop and not to the merchant&#039;s Barion account. So if the merchant has multiple shops in its Barion account, the registered tokens can not be shared among them even if the customer is the same. If you want to use tokens in multiple shops, please contact Barion in the Customer center.&lt;br /&gt;
&lt;br /&gt;
=== 1.1 Preparing the payment===&lt;br /&gt;
&lt;br /&gt;
The token registration is basically a [[Responsive_web_payment|normal payment]] with three extra properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* InitiateRecurrence&lt;br /&gt;
* RecurrenceId&lt;br /&gt;
* RecurrenceType&lt;br /&gt;
&lt;br /&gt;
==== InitiateRecurrence====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; property is a bool property. If you set it to &#039;&#039;&#039;true&#039;&#039;&#039; then the payment gateway will consider the payment as a token registration. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This happens even if the customer is already has a registered token, so you are able to re-register a funding source or even a customer. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceId ====&lt;br /&gt;
The next required property for a token registration is the token itself. This is generated by the shop and has to be unique for every registration. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property of the [[Payment-Start-v2|Payment/Start]] request. This token must be saved in the webshops database. A &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; token represents the funding source (bank card or Barion balance) of a customer. Since a customer can have multiple cards and accounts as a funding source make sure that in the webshop&#039;s system multiple tokens can belong to a single customer.&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceType ====&lt;br /&gt;
The third required property is the [[RecurrenceType|Recurrence Type]]. This specifies the scenario. In case of Recurring Payment &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; must also be set.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Merchant Initiated Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The response will be the same as to a [[Responsive_web_payment#Processing_the_successful_response|basic &#039;&#039;&#039;Immediate&#039;&#039;&#039; scenario]]. The &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; property at this point is &#039;&#039;&#039;None&#039;&#039;&#039; since the token is not registered to a funding source yet.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Recurring Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Recurring Payment&#039;&#039;&#039; scenario has some extra restrictions. The merchant has to specify two additional properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt;: The date after the subsequent charges should not accepted.&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt;: The minimum days the merchant has to wait between payments.&lt;br /&gt;
&lt;br /&gt;
Both properties are located in the [[PurchaseInformation]] property and must be specified if this scenario is selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7, 30-33&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;PurchaseInformation&amp;quot;:{&lt;br /&gt;
        &amp;quot;RecurringFrequency&amp;quot;: 10,&lt;br /&gt;
        &amp;quot;RecurringExpiry&amp;quot;: &amp;quot;2022-10-01&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Possible error responses ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentNotAllowed || The token payment is not allowed for the shop identified by the &#039;&#039;&#039;POSKey&#039;&#039;&#039;. Contact Barion to request this feature.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 1.2 Redirecting the customer to the Barion Smart Gateway to select a funding source ===&lt;br /&gt;
&lt;br /&gt;
After a successful payment preparation, the customer is redirected to the secure Barion Smart Gateway to choose a funding source. The funding source the customer selects will be registered to the token. The funding source can either be a Barion e-money balance or a bank card. This means that even though the customer may own multiple cards only the one that was registered to the token can be used for future token payments. To change the funding source attached to the token a new registration should be requested.&lt;br /&gt;
&lt;br /&gt;
=== 1.3 Processing the callback and requesting information about the result of the payment ===&lt;br /&gt;
&lt;br /&gt;
When the payment is completed (either successfully or unsuccessfully) a callback message is sent to the merchant&#039;s system. Once received a [[Payment-GetPaymentState-v2|GetPaymentState]] request must be sent to the Barion API. On how to implement this please read the article about the  [[Callback_mechanism|Callback mechanism]].&lt;br /&gt;
&lt;br /&gt;
The full response of the GetPaymentState request depends on the payment scenario and the structure of the payment. When it comes to token payment there are several properties to look out for. &lt;br /&gt;
* In case the &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; is &#039;&#039;&#039;Succeeded&#039;&#039;&#039; the funding source token is registered and ready to use.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; contains the ID of the token process. This specifies the nature of the token payment. &lt;br /&gt;
&lt;br /&gt;
==== TraceId ====&lt;br /&gt;
&lt;br /&gt;
In case of Recurring payment or Merchant initiated payment scenarios the [[Payment-GetPaymentState-v2|GetPaymentState]] response returns an additional field called &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. The value of this property is generated by the card issuer. The merchant has to save it and submit it in all subsequent Recurring or Merchant initiated payments of the same type, otherwise, the payments can be declined by the issuer. The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; represents the first, customer-present payment and helps the issuer to connect subsequent payments to this initial payment.&lt;br /&gt;
&lt;br /&gt;
====Example GetPaymentState response====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;8, 11-12&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;OrderNumber&amp;quot;: null,&lt;br /&gt;
    &amp;quot;POSId&amp;quot;: &amp;quot;[[SHOPS_PUBLIC_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSName&amp;quot;: &amp;quot;[[MERCHANTS_BARION_SHOPNAME]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSOwnerEmail&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSource&amp;quot;: &amp;quot;BankCard&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;AllowedFundingSources&amp;quot;: [&lt;br /&gt;
        &amp;quot;All&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;GuestCheckout&amp;quot;: true,&lt;br /&gt;
    &amp;quot;CreatedAt&amp;quot;: &amp;quot;2020-11-26T07:52:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ValidUntil&amp;quot;: &amp;quot;2020-11-26T08:22:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;CompletedAt&amp;quot;: &amp;quot;2020-11-26T08:11:54.118Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ReservedUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;DelayedCaptureUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
           ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;Total&amp;quot;: 25.20,&lt;br /&gt;
    &amp;quot;SuggestedLocale&amp;quot;: &amp;quot;hu-HU&amp;quot;,&lt;br /&gt;
    &amp;quot;FraudRiskScore&amp;quot;: null,&lt;br /&gt;
    &amp;quot;RedirectUrl&amp;quot;: &amp;quot;https://merchanturl/Redirect?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;CallbackUrl&amp;quot;: &amp;quot;https://merchanturl/Callback?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Displaying the funding source in a GUI ====&lt;br /&gt;
We strongly advise saving the complete response for future reference. The &amp;lt;code&amp;gt;FundingSource&amp;lt;/code&amp;gt; field tells if the funding source is a Barion balance or a card. If it is a card, it is useful to save [[FundingInformation]] for displaying it for the user, when requesting future payments. The usual way to display funding sources is to show the last 4 digits of the card, with 4 stars, eg: *** 1234. The card used can be obtained from FundingInformation&#039;s [[BankCard]] field. The [[CardType]] field can be used to display the appropriate card logo. You can even show, if the card is expired, and offer to register another one.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; FundingInformation part of the GetPaymentState response &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=json&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be displayed for example as &amp;lt;code&amp;gt;VISA **** 0425 (12/20)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a request-response diagram of the token registration process:&lt;br /&gt;
 &lt;br /&gt;
[[File:Token_payment_initiation.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Step 2: Using the token =&lt;br /&gt;
&lt;br /&gt;
To use an already registered token for a payment, you have to use the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property. To be able to use a token, the initial payment must be in a successful state.&lt;br /&gt;
&lt;br /&gt;
At this point, the merchant has to decide whether this subsequent payment is used for the same token payment scenario or something changed. This is important because the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used for the same scenario, otherwise, the card issuer will decline the charge.&lt;br /&gt;
A &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used again if:&lt;br /&gt;
* the funding source is the same (technically the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* the token payment scenario is the same (technically the &amp;lt;code&amp;gt;RecurrenceType&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* this subsequent request complies with the scenario restrictions (eg: in case of recurring payment the amount of the subsequent payment does not exceed the initial amount)&lt;br /&gt;
&lt;br /&gt;
If the funding source changes, new &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the funding source|described in detail here]]. If the funding source stays the same but the scenario changes or the restrictions are no longer met new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the token payment scenario with an existing token|described here]].&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Recurring payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this case, three extra conditions must be met:&lt;br /&gt;
* the amount of the subsequent payment must not be higher than the initial amount&lt;br /&gt;
* at least that much days must be spent as defined in the initial &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; property&lt;br /&gt;
* the date of the payment must not exceed the day specified in the initial &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; property&lt;br /&gt;
&lt;br /&gt;
Please be aware that in case any of these are no longer valid the merchant has to request a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; as [[#Changing the token payment scenario with an existing token|described here]]. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=These conditions are not enforced by the Barion system so the violation of them will result in a declined charge.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
Payment/start must not include the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; properties (since they are already fixed during the initial payment).&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Recurring payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Merchant Initiated Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario there are no restrictions.&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Merchant Initiated Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 75,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Phone bill&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of OneClick Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario, the merchant has to prepare to perform the 3DS v2 authentication of the payer. 3DS authentication is not required in the following cases:&lt;br /&gt;
* the token () was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
* the subsequent payment is a merchant initiated payment.&lt;br /&gt;
&lt;br /&gt;
To perform an off-site 3DS authentication of the payer the merchant has to integrate the client library of the Barion Smart Gateway. Read the detailed instructions here.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is not used in this scenario since the payer is present during the transaction. &lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent OneClick Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 17,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Book: How to shop online&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;How to shop online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Book about shopping online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;piece&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Depending on the type of the subsequent payment, 3DSecure authentication might be required for subsequent payments.&lt;br /&gt;
3DS authentication is not required in the following cases:&lt;br /&gt;
* the token (&amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;) was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
&lt;br /&gt;
=== Prerequisites ===&lt;br /&gt;
&lt;br /&gt;
[[File:Token_payment_2.png]]&lt;br /&gt;
&lt;br /&gt;
=== OneClick payment ===&lt;br /&gt;
==== Step 1 : Initialize oneClick ====&lt;br /&gt;
You have to include the following css and javascript files in the code of your site. These files include all the necessary javascript code and styling to handle the 3DS authentication and display the challenge if necessary.&lt;br /&gt;
&amp;lt;source lang=html&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source &amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to initialize the Barion javascript client:&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const configuration = {&lt;br /&gt;
    onAuthenticationSucceeded: function () {&lt;br /&gt;
        // handle successful authentication by calling the Barion API via merchant&#039;s backend&lt;br /&gt;
        // Call the v2/payment/complete endpoint&lt;br /&gt;
    },&lt;br /&gt;
    onAuthenticationFailed: function () {&lt;br /&gt;
        // Handle unsuccessful authentication result, no charge was made.&lt;br /&gt;
        // The payment might be still valid only the authentication failed&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
const gw= new Barion.OffsiteGw(configuration);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Step 2 : Make a payment  ====&lt;br /&gt;
To use an already registered token for a payment, you have to call the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; and the appropriate [[RecurrenceType|Recurrence Type]] should be sent. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property along with the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Example Payment/Start json request =====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;E31EC263-01DC-40BD-BDF1-38FC7A332434&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot; : &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot; : false,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot; : &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot; : &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot; : &amp;quot;SHOP-XMLP-TRACEID-123&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR002&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;webshop@example.com&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subsription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Processing the Payment/Start response =====&lt;br /&gt;
To this request, the Barion API sends back the required data for the 3DS authentication for the specified paymentId.&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
! Field name&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| PaymentId&lt;br /&gt;
| Payment Identifier of the purchase in Barion&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| ThreeDSAuthClientData&lt;br /&gt;
| basae64 encoded 3DS client data&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Payment/Start response =====&lt;br /&gt;
&amp;lt;source lang=json line style=&amp;quot;word-break: break-all;&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot; : &amp;quot;dce46843-6266-4c1f-b82a-387e0fee9073&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot; : &amp;quot;ewoJIkNhcmRQdWJsaWNJZCI6ICIxYTE5M2E1NDQzNDI0YjJiOGJiMjMyOGRhNWY4NmYzYiIsCgkiUGF5bWVudElkIjogImRjZTQ2ODQzNjI2NjRjMWZiODJhMzg3ZTBmZWU5MDczIiwKCSJPbmVDbGlja0NvbnRlbnRVcmwiOiAiaHR0cDovL3NlY3VyZS5iYXJpb24uY29tL3RocmVlZHMvb25lY2xpY2twYXltZW50IiwKCSJBQ1NTdGFydFByb3RvY29sVmVyc2lvbiI6ICIyLjEuMCIsCgkiQUNTRW5kUHJvdG9jb2xWZXJzaW9uIjogIjIuMS4wIiwKCSJEU1N0YXJ0UHJvdG9jb2xWZXJzaW9uIjogIjIuMS4wIiwKCSJEU0VuZFByb3RvY29sVmVyc2lvbiI6ICIyLjIuMCIsCgkiVGhyZWVEU1NlcnZlclRyYW5zSUQiOiBudWxsLAoJIlRocmVlRFNNZXRob2RVUkwiOiBudWxsLAoJIlRocmVlRFNNZXRob2REYXRhRm9ybSI6ICJleUowYUhKbFpVUlRUV1YwYUc5a1RtOTBhV1pwWTJGMGFXOXVWVkpNSWpvaWFIUjBjSE02THk4elpITXVZbUZ5YVc5dUxtTnZiUzh6WkhNdmRqSXZNMlJ6TFcxbGRHaHZaQzF1YjNScFptbGpZWFJwYjI0aUxDSjBhSEpsWlVSVFUyVnlkbVZ5VkhKaGJuTkpSQ0k2SWpFNE5URTJPR0kxTFRKalkyUXROR0kxWlMxaVlqWm1MVFUzTW1VM00yVTNNemt3TnlKOSIsCgkiRXJyb3JEZXRhaWxzIjogbnVsbCwKCSJWZXJzaW9uIjogIjIuMS4wIgp9Cg==&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Step 3: 3DS authentication &amp;amp; challenge ====&lt;br /&gt;
This data then should be passed onto the &amp;lt;code&amp;gt;authenticate()&amp;lt;/code&amp;gt; method of the offsite gw manager, which will do all the magic to authenticate and display the challenge (if needed).&lt;br /&gt;
&amp;lt;source lang=javascript line highlight=&amp;quot;9&amp;quot;&amp;gt;&lt;br /&gt;
        // call Barion API via merchant&#039;s backend&lt;br /&gt;
        // once the result is returned continue with authentication&lt;br /&gt;
        $.ajax({&lt;br /&gt;
            url: &amp;quot;Url/Of/Your/Payment/Start&amp;quot;,&lt;br /&gt;
            method: &amp;quot;POST&amp;quot;,&lt;br /&gt;
            data: data,&lt;br /&gt;
            success: function (threeDsClientData) {&lt;br /&gt;
               // the threeDsClientData will be in the response of payment/start	&lt;br /&gt;
               gw.authenticate(threeDsClientData);&lt;br /&gt;
            }&lt;br /&gt;
         });&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the request is finished the appropriate callback is fired, the BarionClient was initialized with in [[#Step 1 : Initialize oneClick|Step 1]]. In case of successful authentication, you have to call our [[Payment-Complete-v3|/Payment/Complete]] endpoint, where the actual charge will happen.&lt;br /&gt;
&lt;br /&gt;
=== Recurring payment/Merchant Initiated payment ===&lt;br /&gt;
&lt;br /&gt;
For these types of payments, the subsequent payments are nearly identical to the process of [[#Creating_the_token|Creating the token]]. The only difference is that the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; received in the initial [[Payment-GetPaymentState-v2|GetPaymentState]] response must be sent in the &lt;br /&gt;
[[Payment-Start-v2|Payment/Start]] request. Also don&#039;t forget to set the appropriate [[RecurrenceType|Recurrence Type]].&lt;br /&gt;
&lt;br /&gt;
=== Possible error responses ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| InvalidRecurrenceId|| The token specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is invalid. Check if the token registration was successful.&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentDenied|| Something happened to the user since the token registration, either deleted, suspended, or blocked. The payment s not allowed in these cases.&lt;br /&gt;
|-&lt;br /&gt;
| InsufficientFunds|| If the original payment was with an e-money wallet and the customer doesn&#039;t have enough money to fulfill this charge this error happens.&lt;br /&gt;
|-&lt;br /&gt;
| OriginalPaymentWasntSuccessful || This means that the token belongs to an originally unsuccessful payment so this token can not be used anymore. This could only happen if the original payment was financed with a credit card.&lt;br /&gt;
|-&lt;br /&gt;
|InvalidCurrency || If the original payment was paid with e-money and the current token payment is in a currency that the wallet does not have an account in this error happens.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2862</id>
		<title>Token payment 3D Secure</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2862"/>
		<updated>2020-11-26T11:50:44Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* Subsequent payments in case of Merchant Initiated Payment scenario */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Token Payment with 3D Secure}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{IncompletePage}}&lt;br /&gt;
&lt;br /&gt;
This payment scenario allows the integrator shop to register a token for a customer (and a funding source) in the Barion system and then, later on, using this token, charge the customer without redirecting her to the Barion Smart Gateway UI. The user may be present at the site of the merchant or she can be off-session as well, so the merchant can charge her e.g. for subscriptions. This means that the customer authorizes the shop to charge her card or Barion balance without typing in the card information or Barion login again.&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurring.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=Premium feature|text=This scenario is not allowed automatically for every approved shop and should be requested from Barion!|color=#1993c7}}&lt;br /&gt;
&lt;br /&gt;
= Token payment scenarios =&lt;br /&gt;
Token payment can be used in three use cases: &lt;br /&gt;
* &#039;&#039;&#039;Customer Initiated Payments&#039;&#039;&#039;: when the user is present on the website of the merchant and she decides to pay :&lt;br /&gt;
** &#039;&#039;&#039;OneClick payment&#039;&#039;&#039;: the user is charged upon her request initiated on the website of the merchant. Subsequent payments are subject to PSD2 SCA and as the user is present, she has to go through the authentication process.&lt;br /&gt;
* &#039;&#039;&#039;Merchant Initiated Payments&#039;&#039;&#039;: when the merchant initiates the payment without the user being present. It has two subtypes:&lt;br /&gt;
** &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: the user is charged with the same amount on a regular basis, typically in case of subscriptions. Subsequent payments are exempted from PSD2 SCA, but liability still shifts to the card issuer.&lt;br /&gt;
** &#039;&#039;&#039;MIT (merchant initiated transaction)&#039;&#039;&#039;: the user is charged on an irregular basis and/or with a different amount. Subsequent payments of this type are excluded from PSD2 SCA, the liability is on the merchant.&lt;br /&gt;
&lt;br /&gt;
== Customer participation ==&lt;br /&gt;
&lt;br /&gt;
Since the token scenario is suitable for both customer and merchant initiated payments here is a comparison about who starts the payment. This includes the regular, non-tokenized payment scenario as well:&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot; | Scenario&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Initial payment&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW &lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW&lt;br /&gt;
|-&lt;br /&gt;
| Non token (regular) payment || YES || YES || YES || YES &lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || YES || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| MIT || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #aaa; background-color:#eee; font-size: 0.8em; padding:5px 10px; display:inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; Token payment scenarios can be initiated with already registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; as well, in this case the customer may remain on the merchant&#039;s site. &lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements for the scenarios ==&lt;br /&gt;
&lt;br /&gt;
These token payment scenarios have different requirements, this table below summarizes the key differences.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Payment amount&lt;br /&gt;
! Payment frequency&lt;br /&gt;
! Liability in case of fraud&lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || Various || Various || Card issuer&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || Subsequent amounts must be equal or less than the initial amount  || Initial payment must define a minimum amount of days to wait between charges || Card issuer &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || Various  || Various || Merchant&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 3DS authentication of the payer ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be performed for every online card payment. These token payment scenarios also have to use this new secure way of authentication. &lt;br /&gt;
The initial payment of a token scenario must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
Here is a table to compare the 3DS authentication requirements:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Initial payment&lt;br /&gt;
! Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
| One-click payment || ✔️ || ✔️&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Real life examples ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phone bill&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Payer has a usage-based phone subscription that wants to pay without being present for every charge. She authorizes the phone company to charge her card every month.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, the amount of the subsequent payments may exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TV subscription&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to online streaming of a television channel. She authorizes the phone company to charge her card every month. The subscription fee is the same for every month.&lt;br /&gt;
* Scenario: Recurring payment&lt;br /&gt;
* Explanation: The amount of the subsequent payments will not exceed the initial payment and the charge is regularly monthly-based.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bookclub with &amp;quot;free first month&amp;quot; bonus&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to a book renting service. She authorizes the book club to charge her card every month for a selection of books. The subscription fee is the same for every month however, the first month is free. To ensure the subscription the service requires her to register her card details.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, and the fee will stay the same, the initial payment is zero. So the amount of the next payment will exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Online food delivery service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The food delivery company wants to provide a quick and easy experience for its customer. They decide that the order will be quicker if the customers don&#039;t leave the website to pay for the goods.&lt;br /&gt;
* Scenario: OneClick payment&lt;br /&gt;
* Explanation: The customer will always be there so the other two scenarios are not available.&lt;br /&gt;
&lt;br /&gt;
== How to decide ==&lt;br /&gt;
&lt;br /&gt;
To help you decide on a suitable scenario, please use the decision graph below:&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurrencetype-decision.png|520px]]&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
To be able to integrate your webshop with the Barion Payment Gateway: &lt;br /&gt;
* You must [[Creating_an_account|register a Barion wallet]] at the Barion website or in the Sandbox environment. Learn more about the Sandbox environment [[Sandbox|here]].&lt;br /&gt;
* For this wallet you have to [[Creating_a_shop|create a shop]] which should be approved by Barion.&lt;br /&gt;
* For every currency you plan to conduct payments in you have to make sure there is an account created in your Barion wallet. This means that if you plan to have USD payments then there should be a USD account created in your wallet.&lt;br /&gt;
* To make sure every corner case scenario works for your webshop it is best to top up that account with a small amount (approx. 5-10EUR or your choice of currency around the same value).&lt;br /&gt;
* For the technical communication guide please read this: [[Calling_the_API|Calling the API]]&lt;br /&gt;
&lt;br /&gt;
= The payment process =&lt;br /&gt;
&lt;br /&gt;
The process is divided into two major steps:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 1:  Creating the funding source token|Creating the token]] that represents one of the customer&#039;s funding sources (credit card or e-money wallet)&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Preparing the payment via the Barion API&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Redirecting the customer to the Barion Smart Gateway to select a funding source&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Processing the callback and requesting information about the result of the payment&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 2: Using the token|Using the registered token]] to charge the customer&amp;lt;/li&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1:  Creating the funding source token ==&lt;br /&gt;
To be able to use a token payment scenario first the merchant has to register the token with Barion. The merchant has to make sure that the customer is well aware of the fact that they are giving consent to a tokenized payment. The Barion Smart Gateway UI does not indicate in any way that the payment is a token payment.&lt;br /&gt;
&lt;br /&gt;
The token is registered to the shop and not to the merchant&#039;s Barion account. So if the merchant has multiple shops in its Barion account, the registered tokens can not be shared among them even if the customer is the same. If you want to use tokens in multiple shops, please contact Barion in the Customer center.&lt;br /&gt;
&lt;br /&gt;
=== 1.1 Preparing the payment===&lt;br /&gt;
&lt;br /&gt;
The token registration is basically a [[Responsive_web_payment|normal payment]] with three extra properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* InitiateRecurrence&lt;br /&gt;
* RecurrenceId&lt;br /&gt;
* RecurrenceType&lt;br /&gt;
&lt;br /&gt;
==== InitiateRecurrence====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; property is a bool property. If you set it to &#039;&#039;&#039;true&#039;&#039;&#039; then the payment gateway will consider the payment as a token registration. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This happens even if the customer is already has a registered token, so you are able to re-register a funding source or even a customer. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceId ====&lt;br /&gt;
The next required property for a token registration is the token itself. This is generated by the shop and has to be unique for every registration. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property of the [[Payment-Start-v2|Payment/Start]] request. This token must be saved in the webshops database. A &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; token represents the funding source (bank card or Barion balance) of a customer. Since a customer can have multiple cards and accounts as a funding source make sure that in the webshop&#039;s system multiple tokens can belong to a single customer.&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceType ====&lt;br /&gt;
The third required property is the [[RecurrenceType|Recurrence Type]]. This specifies the scenario. In case of Recurring Payment &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; must also be set.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Merchant Initiated Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The response will be the same as to a [[Responsive_web_payment#Processing_the_successful_response|basic &#039;&#039;&#039;Immediate&#039;&#039;&#039; scenario]]. The &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; property at this point is &#039;&#039;&#039;None&#039;&#039;&#039; since the token is not registered to a funding source yet.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Recurring Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Recurring Payment&#039;&#039;&#039; scenario has some extra restrictions. The merchant has to specify two additional properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt;: The date after the subsequent charges should not accepted.&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt;: The minimum days the merchant has to wait between payments.&lt;br /&gt;
&lt;br /&gt;
Both properties are located in the [[PurchaseInformation]] property and must be specified if this scenario is selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7, 30-33&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;PurchaseInformation&amp;quot;:{&lt;br /&gt;
        &amp;quot;RecurringFrequency&amp;quot;: 10,&lt;br /&gt;
        &amp;quot;RecurringExpiry&amp;quot;: &amp;quot;2022-10-01&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Possible error responses ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentNotAllowed || The token payment is not allowed for the shop identified by the &#039;&#039;&#039;POSKey&#039;&#039;&#039;. Contact Barion to request this feature.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 1.2 Redirecting the customer to the Barion Smart Gateway to select a funding source ===&lt;br /&gt;
&lt;br /&gt;
After a successful payment preparation, the customer is redirected to the secure Barion Smart Gateway to choose a funding source. The funding source the customer selects will be registered to the token. The funding source can either be a Barion e-money balance or a bank card. This means that even though the customer may own multiple cards only the one that was registered to the token can be used for future token payments. To change the funding source attached to the token a new registration should be requested.&lt;br /&gt;
&lt;br /&gt;
=== 1.3 Processing the callback and requesting information about the result of the payment ===&lt;br /&gt;
&lt;br /&gt;
When the payment is completed (either successfully or unsuccessfully) a callback message is sent to the merchant&#039;s system. Once received a [[Payment-GetPaymentState-v2|GetPaymentState]] request must be sent to the Barion API. On how to implement this please read the article about the  [[Callback_mechanism|Callback mechanism]].&lt;br /&gt;
&lt;br /&gt;
The full response of the GetPaymentState request depends on the payment scenario and the structure of the payment. When it comes to token payment there are several properties to look out for. &lt;br /&gt;
* In case the &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; is &#039;&#039;&#039;Succeeded&#039;&#039;&#039; the funding source token is registered and ready to use.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; contains the ID of the token process. This specifies the nature of the token payment. &lt;br /&gt;
&lt;br /&gt;
==== TraceId ====&lt;br /&gt;
&lt;br /&gt;
In case of Recurring payment or Merchant initiated payment scenarios the [[Payment-GetPaymentState-v2|GetPaymentState]] response returns an additional field called &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. The value of this property is generated by the card issuer. The merchant has to save it and submit it in all subsequent Recurring or Merchant initiated payments of the same type, otherwise, the payments can be declined by the issuer. The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; represents the first, customer-present payment and helps the issuer to connect subsequent payments to this initial payment.&lt;br /&gt;
&lt;br /&gt;
====Example GetPaymentState response====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;8, 11-12&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;OrderNumber&amp;quot;: null,&lt;br /&gt;
    &amp;quot;POSId&amp;quot;: &amp;quot;[[SHOPS_PUBLIC_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSName&amp;quot;: &amp;quot;[[MERCHANTS_BARION_SHOPNAME]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSOwnerEmail&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSource&amp;quot;: &amp;quot;BankCard&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;AllowedFundingSources&amp;quot;: [&lt;br /&gt;
        &amp;quot;All&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;GuestCheckout&amp;quot;: true,&lt;br /&gt;
    &amp;quot;CreatedAt&amp;quot;: &amp;quot;2020-11-26T07:52:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ValidUntil&amp;quot;: &amp;quot;2020-11-26T08:22:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;CompletedAt&amp;quot;: &amp;quot;2020-11-26T08:11:54.118Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ReservedUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;DelayedCaptureUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
           ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;Total&amp;quot;: 25.20,&lt;br /&gt;
    &amp;quot;SuggestedLocale&amp;quot;: &amp;quot;hu-HU&amp;quot;,&lt;br /&gt;
    &amp;quot;FraudRiskScore&amp;quot;: null,&lt;br /&gt;
    &amp;quot;RedirectUrl&amp;quot;: &amp;quot;https://merchanturl/Redirect?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;CallbackUrl&amp;quot;: &amp;quot;https://merchanturl/Callback?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Displaying the funding source in a GUI ====&lt;br /&gt;
We strongly advise saving the complete response for future reference. The &amp;lt;code&amp;gt;FundingSource&amp;lt;/code&amp;gt; field tells if the funding source is a Barion balance or a card. If it is a card, it is useful to save [[FundingInformation]] for displaying it for the user, when requesting future payments. The usual way to display funding sources is to show the last 4 digits of the card, with 4 stars, eg: *** 1234. The card used can be obtained from FundingInformation&#039;s [[BankCard]] field. The [[CardType]] field can be used to display the appropriate card logo. You can even show, if the card is expired, and offer to register another one.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; FundingInformation part of the GetPaymentState response &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=json&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be displayed for example as &amp;lt;code&amp;gt;VISA **** 0425 (12/20)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a request-response diagram of the token registration process:&lt;br /&gt;
 &lt;br /&gt;
[[File:Token_payment_initiation.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Step 2: Using the token =&lt;br /&gt;
&lt;br /&gt;
To use an already registered token for a payment, you have to use the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property. To be able to use a token, the initial payment must be in a successful state.&lt;br /&gt;
&lt;br /&gt;
At this point, the merchant has to decide whether this subsequent payment is used for the same token payment scenario or something changed. This is important because the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used for the same scenario, otherwise, the card issuer will decline the charge.&lt;br /&gt;
A &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used again if:&lt;br /&gt;
* the funding source is the same (technically the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* the token payment scenario is the same (technically the &amp;lt;code&amp;gt;RecurrenceType&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* this subsequent request complies with the scenario restrictions (eg: in case of recurring payment the amount of the subsequent payment does not exceed the initial amount)&lt;br /&gt;
&lt;br /&gt;
If the funding source changes, new &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the funding source|described in detail here]]. If the funding source stays the same but the scenario changes or the restrictions are no longer met new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the token payment scenario with an existing token|described here]].&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Recurring payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this case, three extra conditions must be met:&lt;br /&gt;
* the amount of the subsequent payment must not be higher than the initial amount&lt;br /&gt;
* at least that much days must be spent as defined in the initial &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; property&lt;br /&gt;
* the date of the payment must not exceed the day specified in the initial &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; property&lt;br /&gt;
&lt;br /&gt;
Please be aware that in case any of these are no longer valid the merchant has to request a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; as [[#Changing the token payment scenario with an existing token|described here]]. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=These conditions are not enforced by the Barion system so the violation of them will result in a declined charge.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
Payment/start must not include the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; properties (since they are already fixed during the initial payment).&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Recurring payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Merchant Initiated Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario there are no restrictions.&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Merchant Initiated Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 75,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Phone bill&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Example response to this request ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;4,8,11&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;fb582913dc2feb11a49f309c23734b1c&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;RecurrenceResult&amp;quot;: &amp;quot;Successful&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot;: null,&lt;br /&gt;
     ...&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure of the response is the same as the normal &amp;lt;tt&amp;gt;/Payment/Start&amp;lt;/tt&amp;gt; response just the statuses will be different. In this case&lt;br /&gt;
* the payment level &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Succeeded&#039;&#039;&#039; instead of &#039;&#039;&#039;Prepared&#039;&#039;&#039;&lt;br /&gt;
* the &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; will be &#039;&#039;&#039;Successful&#039;&#039;&#039; (or &#039;&#039;&#039;Failed&#039;&#039;&#039;) instead of &#039;&#039;&#039;None&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The value of the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; will be the same as in the request.&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of OneClick Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario, the merchant has to prepare to perform the 3DS v2 authentication of the payer. 3DS authentication is not required in the following cases:&lt;br /&gt;
* the token () was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
* the subsequent payment is a merchant initiated payment.&lt;br /&gt;
&lt;br /&gt;
To perform an off-site 3DS authentication of the payer the merchant has to integrate the client library of the Barion Smart Gateway. Read the detailed instructions here.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is not used in this scenario since the payer is present during the transaction. &lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent OneClick Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 17,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Book: How to shop online&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;How to shop online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Book about shopping online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;piece&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Depending on the type of the subsequent payment, 3DSecure authentication might be required for subsequent payments.&lt;br /&gt;
3DS authentication is not required in the following cases:&lt;br /&gt;
* the token (&amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;) was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
&lt;br /&gt;
=== Prerequisites ===&lt;br /&gt;
&lt;br /&gt;
[[File:Token_payment_2.png]]&lt;br /&gt;
&lt;br /&gt;
=== OneClick payment ===&lt;br /&gt;
==== Step 1 : Initialize oneClick ====&lt;br /&gt;
You have to include the following css and javascript files in the code of your site. These files include all the necessary javascript code and styling to handle the 3DS authentication and display the challenge if necessary.&lt;br /&gt;
&amp;lt;source lang=html&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source &amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to initialize the Barion javascript client:&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const configuration = {&lt;br /&gt;
    onAuthenticationSucceeded: function () {&lt;br /&gt;
        // handle successful authentication by calling the Barion API via merchant&#039;s backend&lt;br /&gt;
        // Call the v2/payment/complete endpoint&lt;br /&gt;
    },&lt;br /&gt;
    onAuthenticationFailed: function () {&lt;br /&gt;
        // Handle unsuccessful authentication result, no charge was made.&lt;br /&gt;
        // The payment might be still valid only the authentication failed&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
const gw= new Barion.OffsiteGw(configuration);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Step 2 : Make a payment  ====&lt;br /&gt;
To use an already registered token for a payment, you have to call the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; and the appropriate [[RecurrenceType|Recurrence Type]] should be sent. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property along with the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Example Payment/Start json request =====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;E31EC263-01DC-40BD-BDF1-38FC7A332434&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot; : &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot; : false,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot; : &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot; : &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot; : &amp;quot;SHOP-XMLP-TRACEID-123&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR002&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;webshop@example.com&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subsription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Processing the Payment/Start response =====&lt;br /&gt;
To this request, the Barion API sends back the required data for the 3DS authentication for the specified paymentId.&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
! Field name&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| PaymentId&lt;br /&gt;
| Payment Identifier of the purchase in Barion&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| ThreeDSAuthClientData&lt;br /&gt;
| basae64 encoded 3DS client data&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Payment/Start response =====&lt;br /&gt;
&amp;lt;source lang=json line style=&amp;quot;word-break: break-all;&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot; : &amp;quot;dce46843-6266-4c1f-b82a-387e0fee9073&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot; : &amp;quot;ewoJIkNhcmRQdWJsaWNJZCI6ICIxYTE5M2E1NDQzNDI0YjJiOGJiMjMyOGRhNWY4NmYzYiIsCgkiUGF5bWVudElkIjogImRjZTQ2ODQzNjI2NjRjMWZiODJhMzg3ZTBmZWU5MDczIiwKCSJPbmVDbGlja0NvbnRlbnRVcmwiOiAiaHR0cDovL3NlY3VyZS5iYXJpb24uY29tL3RocmVlZHMvb25lY2xpY2twYXltZW50IiwKCSJBQ1NTdGFydFByb3RvY29sVmVyc2lvbiI6ICIyLjEuMCIsCgkiQUNTRW5kUHJvdG9jb2xWZXJzaW9uIjogIjIuMS4wIiwKCSJEU1N0YXJ0UHJvdG9jb2xWZXJzaW9uIjogIjIuMS4wIiwKCSJEU0VuZFByb3RvY29sVmVyc2lvbiI6ICIyLjIuMCIsCgkiVGhyZWVEU1NlcnZlclRyYW5zSUQiOiBudWxsLAoJIlRocmVlRFNNZXRob2RVUkwiOiBudWxsLAoJIlRocmVlRFNNZXRob2REYXRhRm9ybSI6ICJleUowYUhKbFpVUlRUV1YwYUc5a1RtOTBhV1pwWTJGMGFXOXVWVkpNSWpvaWFIUjBjSE02THk4elpITXVZbUZ5YVc5dUxtTnZiUzh6WkhNdmRqSXZNMlJ6TFcxbGRHaHZaQzF1YjNScFptbGpZWFJwYjI0aUxDSjBhSEpsWlVSVFUyVnlkbVZ5VkhKaGJuTkpSQ0k2SWpFNE5URTJPR0kxTFRKalkyUXROR0kxWlMxaVlqWm1MVFUzTW1VM00yVTNNemt3TnlKOSIsCgkiRXJyb3JEZXRhaWxzIjogbnVsbCwKCSJWZXJzaW9uIjogIjIuMS4wIgp9Cg==&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Step 3: 3DS authentication &amp;amp; challenge ====&lt;br /&gt;
This data then should be passed onto the &amp;lt;code&amp;gt;authenticate()&amp;lt;/code&amp;gt; method of the offsite gw manager, which will do all the magic to authenticate and display the challenge (if needed).&lt;br /&gt;
&amp;lt;source lang=javascript line highlight=&amp;quot;9&amp;quot;&amp;gt;&lt;br /&gt;
        // call Barion API via merchant&#039;s backend&lt;br /&gt;
        // once the result is returned continue with authentication&lt;br /&gt;
        $.ajax({&lt;br /&gt;
            url: &amp;quot;Url/Of/Your/Payment/Start&amp;quot;,&lt;br /&gt;
            method: &amp;quot;POST&amp;quot;,&lt;br /&gt;
            data: data,&lt;br /&gt;
            success: function (threeDsClientData) {&lt;br /&gt;
               // the threeDsClientData will be in the response of payment/start	&lt;br /&gt;
               gw.authenticate(threeDsClientData);&lt;br /&gt;
            }&lt;br /&gt;
         });&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the request is finished the appropriate callback is fired, the BarionClient was initialized with in [[#Step 1 : Initialize oneClick|Step 1]]. In case of successful authentication, you have to call our [[Payment-Complete-v3|/Payment/Complete]] endpoint, where the actual charge will happen.&lt;br /&gt;
&lt;br /&gt;
=== Recurring payment/Merchant Initiated payment ===&lt;br /&gt;
&lt;br /&gt;
For these types of payments, the subsequent payments are nearly identical to the process of [[#Creating_the_token|Creating the token]]. The only difference is that the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; received in the initial [[Payment-GetPaymentState-v2|GetPaymentState]] response must be sent in the &lt;br /&gt;
[[Payment-Start-v2|Payment/Start]] request. Also don&#039;t forget to set the appropriate [[RecurrenceType|Recurrence Type]].&lt;br /&gt;
&lt;br /&gt;
=== Possible error responses ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| InvalidRecurrenceId|| The token specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is invalid. Check if the token registration was successful.&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentDenied|| Something happened to the user since the token registration, either deleted, suspended, or blocked. The payment s not allowed in these cases.&lt;br /&gt;
|-&lt;br /&gt;
| InsufficientFunds|| If the original payment was with an e-money wallet and the customer doesn&#039;t have enough money to fulfill this charge this error happens.&lt;br /&gt;
|-&lt;br /&gt;
| OriginalPaymentWasntSuccessful || This means that the token belongs to an originally unsuccessful payment so this token can not be used anymore. This could only happen if the original payment was financed with a credit card.&lt;br /&gt;
|-&lt;br /&gt;
|InvalidCurrency || If the original payment was paid with e-money and the current token payment is in a currency that the wallet does not have an account in this error happens.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2861</id>
		<title>Token payment 3D Secure</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2861"/>
		<updated>2020-11-26T11:38:53Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* Example payment/start of a subsequent OneClick Payment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Token Payment with 3D Secure}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{IncompletePage}}&lt;br /&gt;
&lt;br /&gt;
This payment scenario allows the integrator shop to register a token for a customer (and a funding source) in the Barion system and then, later on, using this token, charge the customer without redirecting her to the Barion Smart Gateway UI. The user may be present at the site of the merchant or she can be off-session as well, so the merchant can charge her e.g. for subscriptions. This means that the customer authorizes the shop to charge her card or Barion balance without typing in the card information or Barion login again.&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurring.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=Premium feature|text=This scenario is not allowed automatically for every approved shop and should be requested from Barion!|color=#1993c7}}&lt;br /&gt;
&lt;br /&gt;
= Token payment scenarios =&lt;br /&gt;
Token payment can be used in three use cases: &lt;br /&gt;
* &#039;&#039;&#039;Customer Initiated Payments&#039;&#039;&#039;: when the user is present on the website of the merchant and she decides to pay :&lt;br /&gt;
** &#039;&#039;&#039;OneClick payment&#039;&#039;&#039;: the user is charged upon her request initiated on the website of the merchant. Subsequent payments are subject to PSD2 SCA and as the user is present, she has to go through the authentication process.&lt;br /&gt;
* &#039;&#039;&#039;Merchant Initiated Payments&#039;&#039;&#039;: when the merchant initiates the payment without the user being present. It has two subtypes:&lt;br /&gt;
** &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: the user is charged with the same amount on a regular basis, typically in case of subscriptions. Subsequent payments are exempted from PSD2 SCA, but liability still shifts to the card issuer.&lt;br /&gt;
** &#039;&#039;&#039;MIT (merchant initiated transaction)&#039;&#039;&#039;: the user is charged on an irregular basis and/or with a different amount. Subsequent payments of this type are excluded from PSD2 SCA, the liability is on the merchant.&lt;br /&gt;
&lt;br /&gt;
== Customer participation ==&lt;br /&gt;
&lt;br /&gt;
Since the token scenario is suitable for both customer and merchant initiated payments here is a comparison about who starts the payment. This includes the regular, non-tokenized payment scenario as well:&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot; | Scenario&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Initial payment&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW &lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW&lt;br /&gt;
|-&lt;br /&gt;
| Non token (regular) payment || YES || YES || YES || YES &lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || YES || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| MIT || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #aaa; background-color:#eee; font-size: 0.8em; padding:5px 10px; display:inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; Token payment scenarios can be initiated with already registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; as well, in this case the customer may remain on the merchant&#039;s site. &lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements for the scenarios ==&lt;br /&gt;
&lt;br /&gt;
These token payment scenarios have different requirements, this table below summarizes the key differences.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Payment amount&lt;br /&gt;
! Payment frequency&lt;br /&gt;
! Liability in case of fraud&lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || Various || Various || Card issuer&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || Subsequent amounts must be equal or less than the initial amount  || Initial payment must define a minimum amount of days to wait between charges || Card issuer &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || Various  || Various || Merchant&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 3DS authentication of the payer ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be performed for every online card payment. These token payment scenarios also have to use this new secure way of authentication. &lt;br /&gt;
The initial payment of a token scenario must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
Here is a table to compare the 3DS authentication requirements:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Initial payment&lt;br /&gt;
! Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
| One-click payment || ✔️ || ✔️&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Real life examples ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phone bill&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Payer has a usage-based phone subscription that wants to pay without being present for every charge. She authorizes the phone company to charge her card every month.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, the amount of the subsequent payments may exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TV subscription&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to online streaming of a television channel. She authorizes the phone company to charge her card every month. The subscription fee is the same for every month.&lt;br /&gt;
* Scenario: Recurring payment&lt;br /&gt;
* Explanation: The amount of the subsequent payments will not exceed the initial payment and the charge is regularly monthly-based.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bookclub with &amp;quot;free first month&amp;quot; bonus&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to a book renting service. She authorizes the book club to charge her card every month for a selection of books. The subscription fee is the same for every month however, the first month is free. To ensure the subscription the service requires her to register her card details.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, and the fee will stay the same, the initial payment is zero. So the amount of the next payment will exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Online food delivery service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The food delivery company wants to provide a quick and easy experience for its customer. They decide that the order will be quicker if the customers don&#039;t leave the website to pay for the goods.&lt;br /&gt;
* Scenario: OneClick payment&lt;br /&gt;
* Explanation: The customer will always be there so the other two scenarios are not available.&lt;br /&gt;
&lt;br /&gt;
== How to decide ==&lt;br /&gt;
&lt;br /&gt;
To help you decide on a suitable scenario, please use the decision graph below:&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurrencetype-decision.png|520px]]&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
To be able to integrate your webshop with the Barion Payment Gateway: &lt;br /&gt;
* You must [[Creating_an_account|register a Barion wallet]] at the Barion website or in the Sandbox environment. Learn more about the Sandbox environment [[Sandbox|here]].&lt;br /&gt;
* For this wallet you have to [[Creating_a_shop|create a shop]] which should be approved by Barion.&lt;br /&gt;
* For every currency you plan to conduct payments in you have to make sure there is an account created in your Barion wallet. This means that if you plan to have USD payments then there should be a USD account created in your wallet.&lt;br /&gt;
* To make sure every corner case scenario works for your webshop it is best to top up that account with a small amount (approx. 5-10EUR or your choice of currency around the same value).&lt;br /&gt;
* For the technical communication guide please read this: [[Calling_the_API|Calling the API]]&lt;br /&gt;
&lt;br /&gt;
= The payment process =&lt;br /&gt;
&lt;br /&gt;
The process is divided into two major steps:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 1:  Creating the funding source token|Creating the token]] that represents one of the customer&#039;s funding sources (credit card or e-money wallet)&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Preparing the payment via the Barion API&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Redirecting the customer to the Barion Smart Gateway to select a funding source&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Processing the callback and requesting information about the result of the payment&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 2: Using the token|Using the registered token]] to charge the customer&amp;lt;/li&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1:  Creating the funding source token ==&lt;br /&gt;
To be able to use a token payment scenario first the merchant has to register the token with Barion. The merchant has to make sure that the customer is well aware of the fact that they are giving consent to a tokenized payment. The Barion Smart Gateway UI does not indicate in any way that the payment is a token payment.&lt;br /&gt;
&lt;br /&gt;
The token is registered to the shop and not to the merchant&#039;s Barion account. So if the merchant has multiple shops in its Barion account, the registered tokens can not be shared among them even if the customer is the same. If you want to use tokens in multiple shops, please contact Barion in the Customer center.&lt;br /&gt;
&lt;br /&gt;
=== 1.1 Preparing the payment===&lt;br /&gt;
&lt;br /&gt;
The token registration is basically a [[Responsive_web_payment|normal payment]] with three extra properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* InitiateRecurrence&lt;br /&gt;
* RecurrenceId&lt;br /&gt;
* RecurrenceType&lt;br /&gt;
&lt;br /&gt;
==== InitiateRecurrence====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; property is a bool property. If you set it to &#039;&#039;&#039;true&#039;&#039;&#039; then the payment gateway will consider the payment as a token registration. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This happens even if the customer is already has a registered token, so you are able to re-register a funding source or even a customer. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceId ====&lt;br /&gt;
The next required property for a token registration is the token itself. This is generated by the shop and has to be unique for every registration. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property of the [[Payment-Start-v2|Payment/Start]] request. This token must be saved in the webshops database. A &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; token represents the funding source (bank card or Barion balance) of a customer. Since a customer can have multiple cards and accounts as a funding source make sure that in the webshop&#039;s system multiple tokens can belong to a single customer.&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceType ====&lt;br /&gt;
The third required property is the [[RecurrenceType|Recurrence Type]]. This specifies the scenario. In case of Recurring Payment &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; must also be set.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Merchant Initiated Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The response will be the same as to a [[Responsive_web_payment#Processing_the_successful_response|basic &#039;&#039;&#039;Immediate&#039;&#039;&#039; scenario]]. The &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; property at this point is &#039;&#039;&#039;None&#039;&#039;&#039; since the token is not registered to a funding source yet.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Recurring Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Recurring Payment&#039;&#039;&#039; scenario has some extra restrictions. The merchant has to specify two additional properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt;: The date after the subsequent charges should not accepted.&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt;: The minimum days the merchant has to wait between payments.&lt;br /&gt;
&lt;br /&gt;
Both properties are located in the [[PurchaseInformation]] property and must be specified if this scenario is selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7, 30-33&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;PurchaseInformation&amp;quot;:{&lt;br /&gt;
        &amp;quot;RecurringFrequency&amp;quot;: 10,&lt;br /&gt;
        &amp;quot;RecurringExpiry&amp;quot;: &amp;quot;2022-10-01&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Possible error responses ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentNotAllowed || The token payment is not allowed for the shop identified by the &#039;&#039;&#039;POSKey&#039;&#039;&#039;. Contact Barion to request this feature.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 1.2 Redirecting the customer to the Barion Smart Gateway to select a funding source ===&lt;br /&gt;
&lt;br /&gt;
After a successful payment preparation, the customer is redirected to the secure Barion Smart Gateway to choose a funding source. The funding source the customer selects will be registered to the token. The funding source can either be a Barion e-money balance or a bank card. This means that even though the customer may own multiple cards only the one that was registered to the token can be used for future token payments. To change the funding source attached to the token a new registration should be requested.&lt;br /&gt;
&lt;br /&gt;
=== 1.3 Processing the callback and requesting information about the result of the payment ===&lt;br /&gt;
&lt;br /&gt;
When the payment is completed (either successfully or unsuccessfully) a callback message is sent to the merchant&#039;s system. Once received a [[Payment-GetPaymentState-v2|GetPaymentState]] request must be sent to the Barion API. On how to implement this please read the article about the  [[Callback_mechanism|Callback mechanism]].&lt;br /&gt;
&lt;br /&gt;
The full response of the GetPaymentState request depends on the payment scenario and the structure of the payment. When it comes to token payment there are several properties to look out for. &lt;br /&gt;
* In case the &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; is &#039;&#039;&#039;Succeeded&#039;&#039;&#039; the funding source token is registered and ready to use.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; contains the ID of the token process. This specifies the nature of the token payment. &lt;br /&gt;
&lt;br /&gt;
==== TraceId ====&lt;br /&gt;
&lt;br /&gt;
In case of Recurring payment or Merchant initiated payment scenarios the [[Payment-GetPaymentState-v2|GetPaymentState]] response returns an additional field called &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. The value of this property is generated by the card issuer. The merchant has to save it and submit it in all subsequent Recurring or Merchant initiated payments of the same type, otherwise, the payments can be declined by the issuer. The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; represents the first, customer-present payment and helps the issuer to connect subsequent payments to this initial payment.&lt;br /&gt;
&lt;br /&gt;
====Example GetPaymentState response====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;8, 11-12&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;OrderNumber&amp;quot;: null,&lt;br /&gt;
    &amp;quot;POSId&amp;quot;: &amp;quot;[[SHOPS_PUBLIC_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSName&amp;quot;: &amp;quot;[[MERCHANTS_BARION_SHOPNAME]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSOwnerEmail&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSource&amp;quot;: &amp;quot;BankCard&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;AllowedFundingSources&amp;quot;: [&lt;br /&gt;
        &amp;quot;All&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;GuestCheckout&amp;quot;: true,&lt;br /&gt;
    &amp;quot;CreatedAt&amp;quot;: &amp;quot;2020-11-26T07:52:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ValidUntil&amp;quot;: &amp;quot;2020-11-26T08:22:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;CompletedAt&amp;quot;: &amp;quot;2020-11-26T08:11:54.118Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ReservedUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;DelayedCaptureUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
           ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;Total&amp;quot;: 25.20,&lt;br /&gt;
    &amp;quot;SuggestedLocale&amp;quot;: &amp;quot;hu-HU&amp;quot;,&lt;br /&gt;
    &amp;quot;FraudRiskScore&amp;quot;: null,&lt;br /&gt;
    &amp;quot;RedirectUrl&amp;quot;: &amp;quot;https://merchanturl/Redirect?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;CallbackUrl&amp;quot;: &amp;quot;https://merchanturl/Callback?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Displaying the funding source in a GUI ====&lt;br /&gt;
We strongly advise saving the complete response for future reference. The &amp;lt;code&amp;gt;FundingSource&amp;lt;/code&amp;gt; field tells if the funding source is a Barion balance or a card. If it is a card, it is useful to save [[FundingInformation]] for displaying it for the user, when requesting future payments. The usual way to display funding sources is to show the last 4 digits of the card, with 4 stars, eg: *** 1234. The card used can be obtained from FundingInformation&#039;s [[BankCard]] field. The [[CardType]] field can be used to display the appropriate card logo. You can even show, if the card is expired, and offer to register another one.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; FundingInformation part of the GetPaymentState response &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=json&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be displayed for example as &amp;lt;code&amp;gt;VISA **** 0425 (12/20)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a request-response diagram of the token registration process:&lt;br /&gt;
 &lt;br /&gt;
[[File:Token_payment_initiation.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Step 2: Using the token =&lt;br /&gt;
&lt;br /&gt;
To use an already registered token for a payment, you have to use the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property. To be able to use a token, the initial payment must be in a successful state.&lt;br /&gt;
&lt;br /&gt;
At this point, the merchant has to decide whether this subsequent payment is used for the same token payment scenario or something changed. This is important because the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used for the same scenario, otherwise, the card issuer will decline the charge.&lt;br /&gt;
A &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used again if:&lt;br /&gt;
* the funding source is the same (technically the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* the token payment scenario is the same (technically the &amp;lt;code&amp;gt;RecurrenceType&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* this subsequent request complies with the scenario restrictions (eg: in case of recurring payment the amount of the subsequent payment does not exceed the initial amount)&lt;br /&gt;
&lt;br /&gt;
If the funding source changes, new &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the funding source|described in detail here]]. If the funding source stays the same but the scenario changes or the restrictions are no longer met new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the token payment scenario with an existing token|described here]].&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Recurring payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this case, three extra conditions must be met:&lt;br /&gt;
* the amount of the subsequent payment must not be higher than the initial amount&lt;br /&gt;
* at least that much days must be spent as defined in the initial &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; property&lt;br /&gt;
* the date of the payment must not exceed the day specified in the initial &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; property&lt;br /&gt;
&lt;br /&gt;
Please be aware that in case any of these are no longer valid the merchant has to request a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; as [[#Changing the token payment scenario with an existing token|described here]]. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=These conditions are not enforced by the Barion system so the violation of them will result in a declined charge.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
Payment/start must not include the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; properties (since they are already fixed during the initial payment).&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Recurring payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Merchant Initiated Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario there are no restrictions.&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Merchant Initiated Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 75,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Phone bill&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of OneClick Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario, the merchant has to prepare to perform the 3DS v2 authentication of the payer. 3DS authentication is not required in the following cases:&lt;br /&gt;
* the token () was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
* the subsequent payment is a merchant initiated payment.&lt;br /&gt;
&lt;br /&gt;
To perform an off-site 3DS authentication of the payer the merchant has to integrate the client library of the Barion Smart Gateway. Read the detailed instructions here.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is not used in this scenario since the payer is present during the transaction. &lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent OneClick Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 17,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Book: How to shop online&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;How to shop online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Book about shopping online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;piece&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Depending on the type of the subsequent payment, 3DSecure authentication might be required for subsequent payments.&lt;br /&gt;
3DS authentication is not required in the following cases:&lt;br /&gt;
* the token (&amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;) was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
&lt;br /&gt;
=== Prerequisites ===&lt;br /&gt;
&lt;br /&gt;
[[File:Token_payment_2.png]]&lt;br /&gt;
&lt;br /&gt;
=== OneClick payment ===&lt;br /&gt;
==== Step 1 : Initialize oneClick ====&lt;br /&gt;
You have to include the following css and javascript files in the code of your site. These files include all the necessary javascript code and styling to handle the 3DS authentication and display the challenge if necessary.&lt;br /&gt;
&amp;lt;source lang=html&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source &amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to initialize the Barion javascript client:&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const configuration = {&lt;br /&gt;
    onAuthenticationSucceeded: function () {&lt;br /&gt;
        // handle successful authentication by calling the Barion API via merchant&#039;s backend&lt;br /&gt;
        // Call the v2/payment/complete endpoint&lt;br /&gt;
    },&lt;br /&gt;
    onAuthenticationFailed: function () {&lt;br /&gt;
        // Handle unsuccessful authentication result, no charge was made.&lt;br /&gt;
        // The payment might be still valid only the authentication failed&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
const gw= new Barion.OffsiteGw(configuration);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Step 2 : Make a payment  ====&lt;br /&gt;
To use an already registered token for a payment, you have to call the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; and the appropriate [[RecurrenceType|Recurrence Type]] should be sent. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property along with the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Example Payment/Start json request =====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;E31EC263-01DC-40BD-BDF1-38FC7A332434&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot; : &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot; : false,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot; : &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot; : &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot; : &amp;quot;SHOP-XMLP-TRACEID-123&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR002&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;webshop@example.com&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subsription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Processing the Payment/Start response =====&lt;br /&gt;
To this request, the Barion API sends back the required data for the 3DS authentication for the specified paymentId.&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
! Field name&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| PaymentId&lt;br /&gt;
| Payment Identifier of the purchase in Barion&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| ThreeDSAuthClientData&lt;br /&gt;
| basae64 encoded 3DS client data&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Payment/Start response =====&lt;br /&gt;
&amp;lt;source lang=json line style=&amp;quot;word-break: break-all;&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot; : &amp;quot;dce46843-6266-4c1f-b82a-387e0fee9073&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot; : &amp;quot;ewoJIkNhcmRQdWJsaWNJZCI6ICIxYTE5M2E1NDQzNDI0YjJiOGJiMjMyOGRhNWY4NmYzYiIsCgkiUGF5bWVudElkIjogImRjZTQ2ODQzNjI2NjRjMWZiODJhMzg3ZTBmZWU5MDczIiwKCSJPbmVDbGlja0NvbnRlbnRVcmwiOiAiaHR0cDovL3NlY3VyZS5iYXJpb24uY29tL3RocmVlZHMvb25lY2xpY2twYXltZW50IiwKCSJBQ1NTdGFydFByb3RvY29sVmVyc2lvbiI6ICIyLjEuMCIsCgkiQUNTRW5kUHJvdG9jb2xWZXJzaW9uIjogIjIuMS4wIiwKCSJEU1N0YXJ0UHJvdG9jb2xWZXJzaW9uIjogIjIuMS4wIiwKCSJEU0VuZFByb3RvY29sVmVyc2lvbiI6ICIyLjIuMCIsCgkiVGhyZWVEU1NlcnZlclRyYW5zSUQiOiBudWxsLAoJIlRocmVlRFNNZXRob2RVUkwiOiBudWxsLAoJIlRocmVlRFNNZXRob2REYXRhRm9ybSI6ICJleUowYUhKbFpVUlRUV1YwYUc5a1RtOTBhV1pwWTJGMGFXOXVWVkpNSWpvaWFIUjBjSE02THk4elpITXVZbUZ5YVc5dUxtTnZiUzh6WkhNdmRqSXZNMlJ6TFcxbGRHaHZaQzF1YjNScFptbGpZWFJwYjI0aUxDSjBhSEpsWlVSVFUyVnlkbVZ5VkhKaGJuTkpSQ0k2SWpFNE5URTJPR0kxTFRKalkyUXROR0kxWlMxaVlqWm1MVFUzTW1VM00yVTNNemt3TnlKOSIsCgkiRXJyb3JEZXRhaWxzIjogbnVsbCwKCSJWZXJzaW9uIjogIjIuMS4wIgp9Cg==&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Step 3: 3DS authentication &amp;amp; challenge ====&lt;br /&gt;
This data then should be passed onto the &amp;lt;code&amp;gt;authenticate()&amp;lt;/code&amp;gt; method of the offsite gw manager, which will do all the magic to authenticate and display the challenge (if needed).&lt;br /&gt;
&amp;lt;source lang=javascript line highlight=&amp;quot;9&amp;quot;&amp;gt;&lt;br /&gt;
        // call Barion API via merchant&#039;s backend&lt;br /&gt;
        // once the result is returned continue with authentication&lt;br /&gt;
        $.ajax({&lt;br /&gt;
            url: &amp;quot;Url/Of/Your/Payment/Start&amp;quot;,&lt;br /&gt;
            method: &amp;quot;POST&amp;quot;,&lt;br /&gt;
            data: data,&lt;br /&gt;
            success: function (threeDsClientData) {&lt;br /&gt;
               // the threeDsClientData will be in the response of payment/start	&lt;br /&gt;
               gw.authenticate(threeDsClientData);&lt;br /&gt;
            }&lt;br /&gt;
         });&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the request is finished the appropriate callback is fired, the BarionClient was initialized with in [[#Step 1 : Initialize oneClick|Step 1]]. In case of successful authentication, you have to call our [[Payment-Complete-v3|/Payment/Complete]] endpoint, where the actual charge will happen.&lt;br /&gt;
&lt;br /&gt;
=== Recurring payment/Merchant Initiated payment ===&lt;br /&gt;
&lt;br /&gt;
For these types of payments, the subsequent payments are nearly identical to the process of [[#Creating_the_token|Creating the token]]. The only difference is that the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; received in the initial [[Payment-GetPaymentState-v2|GetPaymentState]] response must be sent in the &lt;br /&gt;
[[Payment-Start-v2|Payment/Start]] request. Also don&#039;t forget to set the appropriate [[RecurrenceType|Recurrence Type]].&lt;br /&gt;
&lt;br /&gt;
=== Possible error responses ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| InvalidRecurrenceId|| The token specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is invalid. Check if the token registration was successful.&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentDenied|| Something happened to the user since the token registration, either deleted, suspended, or blocked. The payment s not allowed in these cases.&lt;br /&gt;
|-&lt;br /&gt;
| InsufficientFunds|| If the original payment was with an e-money wallet and the customer doesn&#039;t have enough money to fulfill this charge this error happens.&lt;br /&gt;
|-&lt;br /&gt;
| OriginalPaymentWasntSuccessful || This means that the token belongs to an originally unsuccessful payment so this token can not be used anymore. This could only happen if the original payment was financed with a credit card.&lt;br /&gt;
|-&lt;br /&gt;
|InvalidCurrency || If the original payment was paid with e-money and the current token payment is in a currency that the wallet does not have an account in this error happens.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2860</id>
		<title>Token payment 3D Secure</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2860"/>
		<updated>2020-11-26T11:37:13Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* The payment process */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Token Payment with 3D Secure}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{IncompletePage}}&lt;br /&gt;
&lt;br /&gt;
This payment scenario allows the integrator shop to register a token for a customer (and a funding source) in the Barion system and then, later on, using this token, charge the customer without redirecting her to the Barion Smart Gateway UI. The user may be present at the site of the merchant or she can be off-session as well, so the merchant can charge her e.g. for subscriptions. This means that the customer authorizes the shop to charge her card or Barion balance without typing in the card information or Barion login again.&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurring.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=Premium feature|text=This scenario is not allowed automatically for every approved shop and should be requested from Barion!|color=#1993c7}}&lt;br /&gt;
&lt;br /&gt;
= Token payment scenarios =&lt;br /&gt;
Token payment can be used in three use cases: &lt;br /&gt;
* &#039;&#039;&#039;Customer Initiated Payments&#039;&#039;&#039;: when the user is present on the website of the merchant and she decides to pay :&lt;br /&gt;
** &#039;&#039;&#039;OneClick payment&#039;&#039;&#039;: the user is charged upon her request initiated on the website of the merchant. Subsequent payments are subject to PSD2 SCA and as the user is present, she has to go through the authentication process.&lt;br /&gt;
* &#039;&#039;&#039;Merchant Initiated Payments&#039;&#039;&#039;: when the merchant initiates the payment without the user being present. It has two subtypes:&lt;br /&gt;
** &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: the user is charged with the same amount on a regular basis, typically in case of subscriptions. Subsequent payments are exempted from PSD2 SCA, but liability still shifts to the card issuer.&lt;br /&gt;
** &#039;&#039;&#039;MIT (merchant initiated transaction)&#039;&#039;&#039;: the user is charged on an irregular basis and/or with a different amount. Subsequent payments of this type are excluded from PSD2 SCA, the liability is on the merchant.&lt;br /&gt;
&lt;br /&gt;
== Customer participation ==&lt;br /&gt;
&lt;br /&gt;
Since the token scenario is suitable for both customer and merchant initiated payments here is a comparison about who starts the payment. This includes the regular, non-tokenized payment scenario as well:&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot; | Scenario&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Initial payment&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW &lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW&lt;br /&gt;
|-&lt;br /&gt;
| Non token (regular) payment || YES || YES || YES || YES &lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || YES || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| MIT || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #aaa; background-color:#eee; font-size: 0.8em; padding:5px 10px; display:inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; Token payment scenarios can be initiated with already registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; as well, in this case the customer may remain on the merchant&#039;s site. &lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements for the scenarios ==&lt;br /&gt;
&lt;br /&gt;
These token payment scenarios have different requirements, this table below summarizes the key differences.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Payment amount&lt;br /&gt;
! Payment frequency&lt;br /&gt;
! Liability in case of fraud&lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || Various || Various || Card issuer&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || Subsequent amounts must be equal or less than the initial amount  || Initial payment must define a minimum amount of days to wait between charges || Card issuer &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || Various  || Various || Merchant&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 3DS authentication of the payer ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be performed for every online card payment. These token payment scenarios also have to use this new secure way of authentication. &lt;br /&gt;
The initial payment of a token scenario must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
Here is a table to compare the 3DS authentication requirements:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Initial payment&lt;br /&gt;
! Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
| One-click payment || ✔️ || ✔️&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Real life examples ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phone bill&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Payer has a usage-based phone subscription that wants to pay without being present for every charge. She authorizes the phone company to charge her card every month.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, the amount of the subsequent payments may exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TV subscription&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to online streaming of a television channel. She authorizes the phone company to charge her card every month. The subscription fee is the same for every month.&lt;br /&gt;
* Scenario: Recurring payment&lt;br /&gt;
* Explanation: The amount of the subsequent payments will not exceed the initial payment and the charge is regularly monthly-based.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bookclub with &amp;quot;free first month&amp;quot; bonus&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to a book renting service. She authorizes the book club to charge her card every month for a selection of books. The subscription fee is the same for every month however, the first month is free. To ensure the subscription the service requires her to register her card details.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, and the fee will stay the same, the initial payment is zero. So the amount of the next payment will exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Online food delivery service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The food delivery company wants to provide a quick and easy experience for its customer. They decide that the order will be quicker if the customers don&#039;t leave the website to pay for the goods.&lt;br /&gt;
* Scenario: OneClick payment&lt;br /&gt;
* Explanation: The customer will always be there so the other two scenarios are not available.&lt;br /&gt;
&lt;br /&gt;
== How to decide ==&lt;br /&gt;
&lt;br /&gt;
To help you decide on a suitable scenario, please use the decision graph below:&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurrencetype-decision.png|520px]]&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
To be able to integrate your webshop with the Barion Payment Gateway: &lt;br /&gt;
* You must [[Creating_an_account|register a Barion wallet]] at the Barion website or in the Sandbox environment. Learn more about the Sandbox environment [[Sandbox|here]].&lt;br /&gt;
* For this wallet you have to [[Creating_a_shop|create a shop]] which should be approved by Barion.&lt;br /&gt;
* For every currency you plan to conduct payments in you have to make sure there is an account created in your Barion wallet. This means that if you plan to have USD payments then there should be a USD account created in your wallet.&lt;br /&gt;
* To make sure every corner case scenario works for your webshop it is best to top up that account with a small amount (approx. 5-10EUR or your choice of currency around the same value).&lt;br /&gt;
* For the technical communication guide please read this: [[Calling_the_API|Calling the API]]&lt;br /&gt;
&lt;br /&gt;
= The payment process =&lt;br /&gt;
&lt;br /&gt;
The process is divided into two major steps:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 1:  Creating the funding source token|Creating the token]] that represents one of the customer&#039;s funding sources (credit card or e-money wallet)&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Preparing the payment via the Barion API&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Redirecting the customer to the Barion Smart Gateway to select a funding source&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Processing the callback and requesting information about the result of the payment&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 2: Using the token|Using the registered token]] to charge the customer&amp;lt;/li&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1:  Creating the funding source token ==&lt;br /&gt;
To be able to use a token payment scenario first the merchant has to register the token with Barion. The merchant has to make sure that the customer is well aware of the fact that they are giving consent to a tokenized payment. The Barion Smart Gateway UI does not indicate in any way that the payment is a token payment.&lt;br /&gt;
&lt;br /&gt;
The token is registered to the shop and not to the merchant&#039;s Barion account. So if the merchant has multiple shops in its Barion account, the registered tokens can not be shared among them even if the customer is the same. If you want to use tokens in multiple shops, please contact Barion in the Customer center.&lt;br /&gt;
&lt;br /&gt;
=== 1.1 Preparing the payment===&lt;br /&gt;
&lt;br /&gt;
The token registration is basically a [[Responsive_web_payment|normal payment]] with three extra properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* InitiateRecurrence&lt;br /&gt;
* RecurrenceId&lt;br /&gt;
* RecurrenceType&lt;br /&gt;
&lt;br /&gt;
==== InitiateRecurrence====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; property is a bool property. If you set it to &#039;&#039;&#039;true&#039;&#039;&#039; then the payment gateway will consider the payment as a token registration. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This happens even if the customer is already has a registered token, so you are able to re-register a funding source or even a customer. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceId ====&lt;br /&gt;
The next required property for a token registration is the token itself. This is generated by the shop and has to be unique for every registration. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property of the [[Payment-Start-v2|Payment/Start]] request. This token must be saved in the webshops database. A &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; token represents the funding source (bank card or Barion balance) of a customer. Since a customer can have multiple cards and accounts as a funding source make sure that in the webshop&#039;s system multiple tokens can belong to a single customer.&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceType ====&lt;br /&gt;
The third required property is the [[RecurrenceType|Recurrence Type]]. This specifies the scenario. In case of Recurring Payment &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; must also be set.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Merchant Initiated Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The response will be the same as to a [[Responsive_web_payment#Processing_the_successful_response|basic &#039;&#039;&#039;Immediate&#039;&#039;&#039; scenario]]. The &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; property at this point is &#039;&#039;&#039;None&#039;&#039;&#039; since the token is not registered to a funding source yet.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Recurring Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Recurring Payment&#039;&#039;&#039; scenario has some extra restrictions. The merchant has to specify two additional properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt;: The date after the subsequent charges should not accepted.&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt;: The minimum days the merchant has to wait between payments.&lt;br /&gt;
&lt;br /&gt;
Both properties are located in the [[PurchaseInformation]] property and must be specified if this scenario is selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7, 30-33&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;PurchaseInformation&amp;quot;:{&lt;br /&gt;
        &amp;quot;RecurringFrequency&amp;quot;: 10,&lt;br /&gt;
        &amp;quot;RecurringExpiry&amp;quot;: &amp;quot;2022-10-01&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Possible error responses ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentNotAllowed || The token payment is not allowed for the shop identified by the &#039;&#039;&#039;POSKey&#039;&#039;&#039;. Contact Barion to request this feature.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 1.2 Redirecting the customer to the Barion Smart Gateway to select a funding source ===&lt;br /&gt;
&lt;br /&gt;
After a successful payment preparation, the customer is redirected to the secure Barion Smart Gateway to choose a funding source. The funding source the customer selects will be registered to the token. The funding source can either be a Barion e-money balance or a bank card. This means that even though the customer may own multiple cards only the one that was registered to the token can be used for future token payments. To change the funding source attached to the token a new registration should be requested.&lt;br /&gt;
&lt;br /&gt;
=== 1.3 Processing the callback and requesting information about the result of the payment ===&lt;br /&gt;
&lt;br /&gt;
When the payment is completed (either successfully or unsuccessfully) a callback message is sent to the merchant&#039;s system. Once received a [[Payment-GetPaymentState-v2|GetPaymentState]] request must be sent to the Barion API. On how to implement this please read the article about the  [[Callback_mechanism|Callback mechanism]].&lt;br /&gt;
&lt;br /&gt;
The full response of the GetPaymentState request depends on the payment scenario and the structure of the payment. When it comes to token payment there are several properties to look out for. &lt;br /&gt;
* In case the &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; is &#039;&#039;&#039;Succeeded&#039;&#039;&#039; the funding source token is registered and ready to use.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; contains the ID of the token process. This specifies the nature of the token payment. &lt;br /&gt;
&lt;br /&gt;
==== TraceId ====&lt;br /&gt;
&lt;br /&gt;
In case of Recurring payment or Merchant initiated payment scenarios the [[Payment-GetPaymentState-v2|GetPaymentState]] response returns an additional field called &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. The value of this property is generated by the card issuer. The merchant has to save it and submit it in all subsequent Recurring or Merchant initiated payments of the same type, otherwise, the payments can be declined by the issuer. The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; represents the first, customer-present payment and helps the issuer to connect subsequent payments to this initial payment.&lt;br /&gt;
&lt;br /&gt;
====Example GetPaymentState response====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;8, 11-12&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;OrderNumber&amp;quot;: null,&lt;br /&gt;
    &amp;quot;POSId&amp;quot;: &amp;quot;[[SHOPS_PUBLIC_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSName&amp;quot;: &amp;quot;[[MERCHANTS_BARION_SHOPNAME]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSOwnerEmail&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSource&amp;quot;: &amp;quot;BankCard&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;AllowedFundingSources&amp;quot;: [&lt;br /&gt;
        &amp;quot;All&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;GuestCheckout&amp;quot;: true,&lt;br /&gt;
    &amp;quot;CreatedAt&amp;quot;: &amp;quot;2020-11-26T07:52:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ValidUntil&amp;quot;: &amp;quot;2020-11-26T08:22:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;CompletedAt&amp;quot;: &amp;quot;2020-11-26T08:11:54.118Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ReservedUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;DelayedCaptureUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
           ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;Total&amp;quot;: 25.20,&lt;br /&gt;
    &amp;quot;SuggestedLocale&amp;quot;: &amp;quot;hu-HU&amp;quot;,&lt;br /&gt;
    &amp;quot;FraudRiskScore&amp;quot;: null,&lt;br /&gt;
    &amp;quot;RedirectUrl&amp;quot;: &amp;quot;https://merchanturl/Redirect?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;CallbackUrl&amp;quot;: &amp;quot;https://merchanturl/Callback?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Displaying the funding source in a GUI ====&lt;br /&gt;
We strongly advise saving the complete response for future reference. The &amp;lt;code&amp;gt;FundingSource&amp;lt;/code&amp;gt; field tells if the funding source is a Barion balance or a card. If it is a card, it is useful to save [[FundingInformation]] for displaying it for the user, when requesting future payments. The usual way to display funding sources is to show the last 4 digits of the card, with 4 stars, eg: *** 1234. The card used can be obtained from FundingInformation&#039;s [[BankCard]] field. The [[CardType]] field can be used to display the appropriate card logo. You can even show, if the card is expired, and offer to register another one.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; FundingInformation part of the GetPaymentState response &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=json&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be displayed for example as &amp;lt;code&amp;gt;VISA **** 0425 (12/20)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a request-response diagram of the token registration process:&lt;br /&gt;
 &lt;br /&gt;
[[File:Token_payment_initiation.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Step 2: Using the token =&lt;br /&gt;
&lt;br /&gt;
To use an already registered token for a payment, you have to use the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property. To be able to use a token, the initial payment must be in a successful state.&lt;br /&gt;
&lt;br /&gt;
At this point, the merchant has to decide whether this subsequent payment is used for the same token payment scenario or something changed. This is important because the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used for the same scenario, otherwise, the card issuer will decline the charge.&lt;br /&gt;
A &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used again if:&lt;br /&gt;
* the funding source is the same (technically the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* the token payment scenario is the same (technically the &amp;lt;code&amp;gt;RecurrenceType&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* this subsequent request complies with the scenario restrictions (eg: in case of recurring payment the amount of the subsequent payment does not exceed the initial amount)&lt;br /&gt;
&lt;br /&gt;
If the funding source changes, new &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the funding source|described in detail here]]. If the funding source stays the same but the scenario changes or the restrictions are no longer met new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the token payment scenario with an existing token|described here]].&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Recurring payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this case, three extra conditions must be met:&lt;br /&gt;
* the amount of the subsequent payment must not be higher than the initial amount&lt;br /&gt;
* at least that much days must be spent as defined in the initial &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; property&lt;br /&gt;
* the date of the payment must not exceed the day specified in the initial &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; property&lt;br /&gt;
&lt;br /&gt;
Please be aware that in case any of these are no longer valid the merchant has to request a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; as [[#Changing the token payment scenario with an existing token|described here]]. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=These conditions are not enforced by the Barion system so the violation of them will result in a declined charge.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
Payment/start must not include the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; properties (since they are already fixed during the initial payment).&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Recurring payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Merchant Initiated Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario there are no restrictions.&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Merchant Initiated Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 75,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Phone bill&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of OneClick Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario, the merchant has to prepare to perform the 3DS v2 authentication of the payer. 3DS authentication is not required in the following cases:&lt;br /&gt;
* the token () was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
* the subsequent payment is a merchant initiated payment.&lt;br /&gt;
&lt;br /&gt;
To perform an off-site 3DS authentication of the payer the merchant has to integrate the client library of the Barion Smart Gateway. Read the detailed instructions here.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is not used in this scenario since the payer is present during the transaction. &lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent OneClick Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 17,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Book: How to shop online&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;How to shop online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Book about shopping online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;piece&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Depending on the type of the subsequent payment, 3DSecure authentication might be required for subsequent payments.&lt;br /&gt;
3DS authentication is not required in the following cases:&lt;br /&gt;
* the token (&amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;) was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prerequisites ===&lt;br /&gt;
&lt;br /&gt;
[[File:Token_payment_2.png]]&lt;br /&gt;
&lt;br /&gt;
=== OneClick payment ===&lt;br /&gt;
==== Step 1 : Initialize oneClick ====&lt;br /&gt;
You have to include the following css and javascript files in the code of your site. These files include all the necessary javascript code and styling to handle the 3DS authentication and display the challenge if necessary.&lt;br /&gt;
&amp;lt;source lang=html&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source &amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to initialize the Barion javascript client:&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const configuration = {&lt;br /&gt;
    onAuthenticationSucceeded: function () {&lt;br /&gt;
        // handle successful authentication by calling the Barion API via merchant&#039;s backend&lt;br /&gt;
        // Call the v2/payment/complete endpoint&lt;br /&gt;
    },&lt;br /&gt;
    onAuthenticationFailed: function () {&lt;br /&gt;
        // Handle unsuccessful authentication result, no charge was made.&lt;br /&gt;
        // The payment might be still valid only the authentication failed&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
const gw= new Barion.OffsiteGw(configuration);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Step 2 : Make a payment  ====&lt;br /&gt;
To use an already registered token for a payment, you have to call the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; and the appropriate [[RecurrenceType|Recurrence Type]] should be sent. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property along with the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Example Payment/Start json request =====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;E31EC263-01DC-40BD-BDF1-38FC7A332434&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot; : &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot; : false,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot; : &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot; : &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot; : &amp;quot;SHOP-XMLP-TRACEID-123&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR002&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;webshop@example.com&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subsription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Processing the Payment/Start response =====&lt;br /&gt;
To this request, the Barion API sends back the required data for the 3DS authentication for the specified paymentId.&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
! Field name&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| PaymentId&lt;br /&gt;
| Payment Identifier of the purchase in Barion&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| ThreeDSAuthClientData&lt;br /&gt;
| basae64 encoded 3DS client data&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Payment/Start response =====&lt;br /&gt;
&amp;lt;source lang=json line style=&amp;quot;word-break: break-all;&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot; : &amp;quot;dce46843-6266-4c1f-b82a-387e0fee9073&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot; : &amp;quot;ewoJIkNhcmRQdWJsaWNJZCI6ICIxYTE5M2E1NDQzNDI0YjJiOGJiMjMyOGRhNWY4NmYzYiIsCgkiUGF5bWVudElkIjogImRjZTQ2ODQzNjI2NjRjMWZiODJhMzg3ZTBmZWU5MDczIiwKCSJPbmVDbGlja0NvbnRlbnRVcmwiOiAiaHR0cDovL3NlY3VyZS5iYXJpb24uY29tL3RocmVlZHMvb25lY2xpY2twYXltZW50IiwKCSJBQ1NTdGFydFByb3RvY29sVmVyc2lvbiI6ICIyLjEuMCIsCgkiQUNTRW5kUHJvdG9jb2xWZXJzaW9uIjogIjIuMS4wIiwKCSJEU1N0YXJ0UHJvdG9jb2xWZXJzaW9uIjogIjIuMS4wIiwKCSJEU0VuZFByb3RvY29sVmVyc2lvbiI6ICIyLjIuMCIsCgkiVGhyZWVEU1NlcnZlclRyYW5zSUQiOiBudWxsLAoJIlRocmVlRFNNZXRob2RVUkwiOiBudWxsLAoJIlRocmVlRFNNZXRob2REYXRhRm9ybSI6ICJleUowYUhKbFpVUlRUV1YwYUc5a1RtOTBhV1pwWTJGMGFXOXVWVkpNSWpvaWFIUjBjSE02THk4elpITXVZbUZ5YVc5dUxtTnZiUzh6WkhNdmRqSXZNMlJ6TFcxbGRHaHZaQzF1YjNScFptbGpZWFJwYjI0aUxDSjBhSEpsWlVSVFUyVnlkbVZ5VkhKaGJuTkpSQ0k2SWpFNE5URTJPR0kxTFRKalkyUXROR0kxWlMxaVlqWm1MVFUzTW1VM00yVTNNemt3TnlKOSIsCgkiRXJyb3JEZXRhaWxzIjogbnVsbCwKCSJWZXJzaW9uIjogIjIuMS4wIgp9Cg==&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Step 3: 3DS authentication &amp;amp; challenge ====&lt;br /&gt;
This data then should be passed onto the &amp;lt;code&amp;gt;authenticate()&amp;lt;/code&amp;gt; method of the offsite gw manager, which will do all the magic to authenticate and display the challenge (if needed).&lt;br /&gt;
&amp;lt;source lang=javascript line highlight=&amp;quot;9&amp;quot;&amp;gt;&lt;br /&gt;
        // call Barion API via merchant&#039;s backend&lt;br /&gt;
        // once the result is returned continue with authentication&lt;br /&gt;
        $.ajax({&lt;br /&gt;
            url: &amp;quot;Url/Of/Your/Payment/Start&amp;quot;,&lt;br /&gt;
            method: &amp;quot;POST&amp;quot;,&lt;br /&gt;
            data: data,&lt;br /&gt;
            success: function (threeDsClientData) {&lt;br /&gt;
               // the threeDsClientData will be in the response of payment/start	&lt;br /&gt;
               gw.authenticate(threeDsClientData);&lt;br /&gt;
            }&lt;br /&gt;
         });&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the request is finished the appropriate callback is fired, the BarionClient was initialized with in [[#Step 1 : Initialize oneClick|Step 1]]. In case of successful authentication, you have to call our [[Payment-Complete-v3|/Payment/Complete]] endpoint, where the actual charge will happen.&lt;br /&gt;
&lt;br /&gt;
=== Recurring payment/Merchant Initiated payment ===&lt;br /&gt;
&lt;br /&gt;
For these types of payments, the subsequent payments are nearly identical to the process of [[#Creating_the_token|Creating the token]]. The only difference is that the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; received in the initial [[Payment-GetPaymentState-v2|GetPaymentState]] response must be sent in the &lt;br /&gt;
[[Payment-Start-v2|Payment/Start]] request. Also don&#039;t forget to set the appropriate [[RecurrenceType|Recurrence Type]].&lt;br /&gt;
&lt;br /&gt;
=== Possible error responses ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| InvalidRecurrenceId|| The token specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is invalid. Check if the token registration was successful.&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentDenied|| Something happened to the user since the token registration, either deleted, suspended, or blocked. The payment s not allowed in these cases.&lt;br /&gt;
|-&lt;br /&gt;
| InsufficientFunds|| If the original payment was with an e-money wallet and the customer doesn&#039;t have enough money to fulfill this charge this error happens.&lt;br /&gt;
|-&lt;br /&gt;
| OriginalPaymentWasntSuccessful || This means that the token belongs to an originally unsuccessful payment so this token can not be used anymore. This could only happen if the original payment was financed with a credit card.&lt;br /&gt;
|-&lt;br /&gt;
|InvalidCurrency || If the original payment was paid with e-money and the current token payment is in a currency that the wallet does not have an account in this error happens.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2859</id>
		<title>Token payment 3D Secure</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2859"/>
		<updated>2020-11-26T11:36:45Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* Step 2: Using the token */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Token Payment with 3D Secure}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{IncompletePage}}&lt;br /&gt;
&lt;br /&gt;
This payment scenario allows the integrator shop to register a token for a customer (and a funding source) in the Barion system and then, later on, using this token, charge the customer without redirecting her to the Barion Smart Gateway UI. The user may be present at the site of the merchant or she can be off-session as well, so the merchant can charge her e.g. for subscriptions. This means that the customer authorizes the shop to charge her card or Barion balance without typing in the card information or Barion login again.&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurring.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=Premium feature|text=This scenario is not allowed automatically for every approved shop and should be requested from Barion!|color=#1993c7}}&lt;br /&gt;
&lt;br /&gt;
= Token payment scenarios =&lt;br /&gt;
Token payment can be used in three use cases: &lt;br /&gt;
* &#039;&#039;&#039;Customer Initiated Payments&#039;&#039;&#039;: when the user is present on the website of the merchant and she decides to pay :&lt;br /&gt;
** &#039;&#039;&#039;OneClick payment&#039;&#039;&#039;: the user is charged upon her request initiated on the website of the merchant. Subsequent payments are subject to PSD2 SCA and as the user is present, she has to go through the authentication process.&lt;br /&gt;
* &#039;&#039;&#039;Merchant Initiated Payments&#039;&#039;&#039;: when the merchant initiates the payment without the user being present. It has two subtypes:&lt;br /&gt;
** &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: the user is charged with the same amount on a regular basis, typically in case of subscriptions. Subsequent payments are exempted from PSD2 SCA, but liability still shifts to the card issuer.&lt;br /&gt;
** &#039;&#039;&#039;MIT (merchant initiated transaction)&#039;&#039;&#039;: the user is charged on an irregular basis and/or with a different amount. Subsequent payments of this type are excluded from PSD2 SCA, the liability is on the merchant.&lt;br /&gt;
&lt;br /&gt;
== Customer participation ==&lt;br /&gt;
&lt;br /&gt;
Since the token scenario is suitable for both customer and merchant initiated payments here is a comparison about who starts the payment. This includes the regular, non-tokenized payment scenario as well:&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot; | Scenario&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Initial payment&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW &lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW&lt;br /&gt;
|-&lt;br /&gt;
| Non token (regular) payment || YES || YES || YES || YES &lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || YES || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| MIT || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #aaa; background-color:#eee; font-size: 0.8em; padding:5px 10px; display:inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; Token payment scenarios can be initiated with already registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; as well, in this case the customer may remain on the merchant&#039;s site. &lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements for the scenarios ==&lt;br /&gt;
&lt;br /&gt;
These token payment scenarios have different requirements, this table below summarizes the key differences.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Payment amount&lt;br /&gt;
! Payment frequency&lt;br /&gt;
! Liability in case of fraud&lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || Various || Various || Card issuer&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || Subsequent amounts must be equal or less than the initial amount  || Initial payment must define a minimum amount of days to wait between charges || Card issuer &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || Various  || Various || Merchant&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 3DS authentication of the payer ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be performed for every online card payment. These token payment scenarios also have to use this new secure way of authentication. &lt;br /&gt;
The initial payment of a token scenario must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
Here is a table to compare the 3DS authentication requirements:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Initial payment&lt;br /&gt;
! Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
| One-click payment || ✔️ || ✔️&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Real life examples ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phone bill&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Payer has a usage-based phone subscription that wants to pay without being present for every charge. She authorizes the phone company to charge her card every month.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, the amount of the subsequent payments may exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TV subscription&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to online streaming of a television channel. She authorizes the phone company to charge her card every month. The subscription fee is the same for every month.&lt;br /&gt;
* Scenario: Recurring payment&lt;br /&gt;
* Explanation: The amount of the subsequent payments will not exceed the initial payment and the charge is regularly monthly-based.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bookclub with &amp;quot;free first month&amp;quot; bonus&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to a book renting service. She authorizes the book club to charge her card every month for a selection of books. The subscription fee is the same for every month however, the first month is free. To ensure the subscription the service requires her to register her card details.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, and the fee will stay the same, the initial payment is zero. So the amount of the next payment will exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Online food delivery service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The food delivery company wants to provide a quick and easy experience for its customer. They decide that the order will be quicker if the customers don&#039;t leave the website to pay for the goods.&lt;br /&gt;
* Scenario: OneClick payment&lt;br /&gt;
* Explanation: The customer will always be there so the other two scenarios are not available.&lt;br /&gt;
&lt;br /&gt;
== How to decide ==&lt;br /&gt;
&lt;br /&gt;
To help you decide on a suitable scenario, please use the decision graph below:&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurrencetype-decision.png|520px]]&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
To be able to integrate your webshop with the Barion Payment Gateway: &lt;br /&gt;
* You must [[Creating_an_account|register a Barion wallet]] at the Barion website or in the Sandbox environment. Learn more about the Sandbox environment [[Sandbox|here]].&lt;br /&gt;
* For this wallet you have to [[Creating_a_shop|create a shop]] which should be approved by Barion.&lt;br /&gt;
* For every currency you plan to conduct payments in you have to make sure there is an account created in your Barion wallet. This means that if you plan to have USD payments then there should be a USD account created in your wallet.&lt;br /&gt;
* To make sure every corner case scenario works for your webshop it is best to top up that account with a small amount (approx. 5-10EUR or your choice of currency around the same value).&lt;br /&gt;
* For the technical communication guide please read this: [[Calling_the_API|Calling the API]]&lt;br /&gt;
&lt;br /&gt;
= The payment process =&lt;br /&gt;
&lt;br /&gt;
The process is divided into two major steps:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 1:  Creating the funding source token|Creating the token]] that represents one of the customer&#039;s funding sources (credit card or e-money wallet)&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Preparing the payment via the Barion API&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Redirecting the customer to the Barion Smart Gateway to select a funding source&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Processing the callback and requesting information about the result of the payment&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 2: Using the token|Using the registered token]] to charge the customer&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Sending the payment request to the Barion API &lt;br /&gt;
             &amp;lt;ol&amp;gt;&lt;br /&gt;
                &amp;lt;li&amp;gt;Using the token for the same token payment scenario&amp;lt;/li&amp;gt;&lt;br /&gt;
                &amp;lt;li&amp;gt;Using the token for a different token payment scenario&amp;lt;/li&amp;gt;&lt;br /&gt;
            &amp;lt;/ol&amp;gt;&lt;br /&gt;
         &amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Performing on-site 3DS authentication (if needed)&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1:  Creating the funding source token ==&lt;br /&gt;
To be able to use a token payment scenario first the merchant has to register the token with Barion. The merchant has to make sure that the customer is well aware of the fact that they are giving consent to a tokenized payment. The Barion Smart Gateway UI does not indicate in any way that the payment is a token payment.&lt;br /&gt;
&lt;br /&gt;
The token is registered to the shop and not to the merchant&#039;s Barion account. So if the merchant has multiple shops in its Barion account, the registered tokens can not be shared among them even if the customer is the same. If you want to use tokens in multiple shops, please contact Barion in the Customer center.&lt;br /&gt;
&lt;br /&gt;
=== 1.1 Preparing the payment===&lt;br /&gt;
&lt;br /&gt;
The token registration is basically a [[Responsive_web_payment|normal payment]] with three extra properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* InitiateRecurrence&lt;br /&gt;
* RecurrenceId&lt;br /&gt;
* RecurrenceType&lt;br /&gt;
&lt;br /&gt;
==== InitiateRecurrence====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; property is a bool property. If you set it to &#039;&#039;&#039;true&#039;&#039;&#039; then the payment gateway will consider the payment as a token registration. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This happens even if the customer is already has a registered token, so you are able to re-register a funding source or even a customer. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceId ====&lt;br /&gt;
The next required property for a token registration is the token itself. This is generated by the shop and has to be unique for every registration. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property of the [[Payment-Start-v2|Payment/Start]] request. This token must be saved in the webshops database. A &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; token represents the funding source (bank card or Barion balance) of a customer. Since a customer can have multiple cards and accounts as a funding source make sure that in the webshop&#039;s system multiple tokens can belong to a single customer.&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceType ====&lt;br /&gt;
The third required property is the [[RecurrenceType|Recurrence Type]]. This specifies the scenario. In case of Recurring Payment &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; must also be set.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Merchant Initiated Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The response will be the same as to a [[Responsive_web_payment#Processing_the_successful_response|basic &#039;&#039;&#039;Immediate&#039;&#039;&#039; scenario]]. The &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; property at this point is &#039;&#039;&#039;None&#039;&#039;&#039; since the token is not registered to a funding source yet.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Recurring Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Recurring Payment&#039;&#039;&#039; scenario has some extra restrictions. The merchant has to specify two additional properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt;: The date after the subsequent charges should not accepted.&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt;: The minimum days the merchant has to wait between payments.&lt;br /&gt;
&lt;br /&gt;
Both properties are located in the [[PurchaseInformation]] property and must be specified if this scenario is selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7, 30-33&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;PurchaseInformation&amp;quot;:{&lt;br /&gt;
        &amp;quot;RecurringFrequency&amp;quot;: 10,&lt;br /&gt;
        &amp;quot;RecurringExpiry&amp;quot;: &amp;quot;2022-10-01&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Possible error responses ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentNotAllowed || The token payment is not allowed for the shop identified by the &#039;&#039;&#039;POSKey&#039;&#039;&#039;. Contact Barion to request this feature.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 1.2 Redirecting the customer to the Barion Smart Gateway to select a funding source ===&lt;br /&gt;
&lt;br /&gt;
After a successful payment preparation, the customer is redirected to the secure Barion Smart Gateway to choose a funding source. The funding source the customer selects will be registered to the token. The funding source can either be a Barion e-money balance or a bank card. This means that even though the customer may own multiple cards only the one that was registered to the token can be used for future token payments. To change the funding source attached to the token a new registration should be requested.&lt;br /&gt;
&lt;br /&gt;
=== 1.3 Processing the callback and requesting information about the result of the payment ===&lt;br /&gt;
&lt;br /&gt;
When the payment is completed (either successfully or unsuccessfully) a callback message is sent to the merchant&#039;s system. Once received a [[Payment-GetPaymentState-v2|GetPaymentState]] request must be sent to the Barion API. On how to implement this please read the article about the  [[Callback_mechanism|Callback mechanism]].&lt;br /&gt;
&lt;br /&gt;
The full response of the GetPaymentState request depends on the payment scenario and the structure of the payment. When it comes to token payment there are several properties to look out for. &lt;br /&gt;
* In case the &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; is &#039;&#039;&#039;Succeeded&#039;&#039;&#039; the funding source token is registered and ready to use.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; contains the ID of the token process. This specifies the nature of the token payment. &lt;br /&gt;
&lt;br /&gt;
==== TraceId ====&lt;br /&gt;
&lt;br /&gt;
In case of Recurring payment or Merchant initiated payment scenarios the [[Payment-GetPaymentState-v2|GetPaymentState]] response returns an additional field called &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. The value of this property is generated by the card issuer. The merchant has to save it and submit it in all subsequent Recurring or Merchant initiated payments of the same type, otherwise, the payments can be declined by the issuer. The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; represents the first, customer-present payment and helps the issuer to connect subsequent payments to this initial payment.&lt;br /&gt;
&lt;br /&gt;
====Example GetPaymentState response====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;8, 11-12&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;OrderNumber&amp;quot;: null,&lt;br /&gt;
    &amp;quot;POSId&amp;quot;: &amp;quot;[[SHOPS_PUBLIC_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSName&amp;quot;: &amp;quot;[[MERCHANTS_BARION_SHOPNAME]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSOwnerEmail&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSource&amp;quot;: &amp;quot;BankCard&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;AllowedFundingSources&amp;quot;: [&lt;br /&gt;
        &amp;quot;All&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;GuestCheckout&amp;quot;: true,&lt;br /&gt;
    &amp;quot;CreatedAt&amp;quot;: &amp;quot;2020-11-26T07:52:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ValidUntil&amp;quot;: &amp;quot;2020-11-26T08:22:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;CompletedAt&amp;quot;: &amp;quot;2020-11-26T08:11:54.118Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ReservedUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;DelayedCaptureUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
           ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;Total&amp;quot;: 25.20,&lt;br /&gt;
    &amp;quot;SuggestedLocale&amp;quot;: &amp;quot;hu-HU&amp;quot;,&lt;br /&gt;
    &amp;quot;FraudRiskScore&amp;quot;: null,&lt;br /&gt;
    &amp;quot;RedirectUrl&amp;quot;: &amp;quot;https://merchanturl/Redirect?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;CallbackUrl&amp;quot;: &amp;quot;https://merchanturl/Callback?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Displaying the funding source in a GUI ====&lt;br /&gt;
We strongly advise saving the complete response for future reference. The &amp;lt;code&amp;gt;FundingSource&amp;lt;/code&amp;gt; field tells if the funding source is a Barion balance or a card. If it is a card, it is useful to save [[FundingInformation]] for displaying it for the user, when requesting future payments. The usual way to display funding sources is to show the last 4 digits of the card, with 4 stars, eg: *** 1234. The card used can be obtained from FundingInformation&#039;s [[BankCard]] field. The [[CardType]] field can be used to display the appropriate card logo. You can even show, if the card is expired, and offer to register another one.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; FundingInformation part of the GetPaymentState response &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=json&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be displayed for example as &amp;lt;code&amp;gt;VISA **** 0425 (12/20)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a request-response diagram of the token registration process:&lt;br /&gt;
 &lt;br /&gt;
[[File:Token_payment_initiation.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Step 2: Using the token =&lt;br /&gt;
&lt;br /&gt;
To use an already registered token for a payment, you have to use the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property. To be able to use a token, the initial payment must be in a successful state.&lt;br /&gt;
&lt;br /&gt;
At this point, the merchant has to decide whether this subsequent payment is used for the same token payment scenario or something changed. This is important because the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used for the same scenario, otherwise, the card issuer will decline the charge.&lt;br /&gt;
A &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used again if:&lt;br /&gt;
* the funding source is the same (technically the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* the token payment scenario is the same (technically the &amp;lt;code&amp;gt;RecurrenceType&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* this subsequent request complies with the scenario restrictions (eg: in case of recurring payment the amount of the subsequent payment does not exceed the initial amount)&lt;br /&gt;
&lt;br /&gt;
If the funding source changes, new &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the funding source|described in detail here]]. If the funding source stays the same but the scenario changes or the restrictions are no longer met new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the token payment scenario with an existing token|described here]].&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Recurring payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this case, three extra conditions must be met:&lt;br /&gt;
* the amount of the subsequent payment must not be higher than the initial amount&lt;br /&gt;
* at least that much days must be spent as defined in the initial &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; property&lt;br /&gt;
* the date of the payment must not exceed the day specified in the initial &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; property&lt;br /&gt;
&lt;br /&gt;
Please be aware that in case any of these are no longer valid the merchant has to request a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; as [[#Changing the token payment scenario with an existing token|described here]]. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=These conditions are not enforced by the Barion system so the violation of them will result in a declined charge.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
Payment/start must not include the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; properties (since they are already fixed during the initial payment).&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Recurring payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of Merchant Initiated Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario there are no restrictions.&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Merchant Initiated Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 75,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Phone bill&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Subsequent payments in case of OneClick Payment scenario ==&lt;br /&gt;
&lt;br /&gt;
In this scenario, the merchant has to prepare to perform the 3DS v2 authentication of the payer. 3DS authentication is not required in the following cases:&lt;br /&gt;
* the token () was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
* the subsequent payment is a merchant initiated payment.&lt;br /&gt;
&lt;br /&gt;
To perform an off-site 3DS authentication of the payer the merchant has to integrate the client library of the Barion Smart Gateway. Read the detailed instructions here.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is not used in this scenario since the payer is present during the transaction. &lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent OneClick Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 17,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Book: How to shop online&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;How to shop online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Book about shopping online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;piece&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Depending on the type of the subsequent payment, 3DSecure authentication might be required for subsequent payments.&lt;br /&gt;
3DS authentication is not required in the following cases:&lt;br /&gt;
* the token (&amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;) was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prerequisites ===&lt;br /&gt;
&lt;br /&gt;
[[File:Token_payment_2.png]]&lt;br /&gt;
&lt;br /&gt;
=== OneClick payment ===&lt;br /&gt;
==== Step 1 : Initialize oneClick ====&lt;br /&gt;
You have to include the following css and javascript files in the code of your site. These files include all the necessary javascript code and styling to handle the 3DS authentication and display the challenge if necessary.&lt;br /&gt;
&amp;lt;source lang=html&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source &amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to initialize the Barion javascript client:&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const configuration = {&lt;br /&gt;
    onAuthenticationSucceeded: function () {&lt;br /&gt;
        // handle successful authentication by calling the Barion API via merchant&#039;s backend&lt;br /&gt;
        // Call the v2/payment/complete endpoint&lt;br /&gt;
    },&lt;br /&gt;
    onAuthenticationFailed: function () {&lt;br /&gt;
        // Handle unsuccessful authentication result, no charge was made.&lt;br /&gt;
        // The payment might be still valid only the authentication failed&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
const gw= new Barion.OffsiteGw(configuration);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Step 2 : Make a payment  ====&lt;br /&gt;
To use an already registered token for a payment, you have to call the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; and the appropriate [[RecurrenceType|Recurrence Type]] should be sent. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property along with the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Example Payment/Start json request =====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;E31EC263-01DC-40BD-BDF1-38FC7A332434&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot; : &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot; : false,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot; : &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot; : &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot; : &amp;quot;SHOP-XMLP-TRACEID-123&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR002&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;webshop@example.com&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subsription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Processing the Payment/Start response =====&lt;br /&gt;
To this request, the Barion API sends back the required data for the 3DS authentication for the specified paymentId.&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
! Field name&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| PaymentId&lt;br /&gt;
| Payment Identifier of the purchase in Barion&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| ThreeDSAuthClientData&lt;br /&gt;
| basae64 encoded 3DS client data&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Payment/Start response =====&lt;br /&gt;
&amp;lt;source lang=json line style=&amp;quot;word-break: break-all;&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot; : &amp;quot;dce46843-6266-4c1f-b82a-387e0fee9073&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot; : &amp;quot;ewoJIkNhcmRQdWJsaWNJZCI6ICIxYTE5M2E1NDQzNDI0YjJiOGJiMjMyOGRhNWY4NmYzYiIsCgkiUGF5bWVudElkIjogImRjZTQ2ODQzNjI2NjRjMWZiODJhMzg3ZTBmZWU5MDczIiwKCSJPbmVDbGlja0NvbnRlbnRVcmwiOiAiaHR0cDovL3NlY3VyZS5iYXJpb24uY29tL3RocmVlZHMvb25lY2xpY2twYXltZW50IiwKCSJBQ1NTdGFydFByb3RvY29sVmVyc2lvbiI6ICIyLjEuMCIsCgkiQUNTRW5kUHJvdG9jb2xWZXJzaW9uIjogIjIuMS4wIiwKCSJEU1N0YXJ0UHJvdG9jb2xWZXJzaW9uIjogIjIuMS4wIiwKCSJEU0VuZFByb3RvY29sVmVyc2lvbiI6ICIyLjIuMCIsCgkiVGhyZWVEU1NlcnZlclRyYW5zSUQiOiBudWxsLAoJIlRocmVlRFNNZXRob2RVUkwiOiBudWxsLAoJIlRocmVlRFNNZXRob2REYXRhRm9ybSI6ICJleUowYUhKbFpVUlRUV1YwYUc5a1RtOTBhV1pwWTJGMGFXOXVWVkpNSWpvaWFIUjBjSE02THk4elpITXVZbUZ5YVc5dUxtTnZiUzh6WkhNdmRqSXZNMlJ6TFcxbGRHaHZaQzF1YjNScFptbGpZWFJwYjI0aUxDSjBhSEpsWlVSVFUyVnlkbVZ5VkhKaGJuTkpSQ0k2SWpFNE5URTJPR0kxTFRKalkyUXROR0kxWlMxaVlqWm1MVFUzTW1VM00yVTNNemt3TnlKOSIsCgkiRXJyb3JEZXRhaWxzIjogbnVsbCwKCSJWZXJzaW9uIjogIjIuMS4wIgp9Cg==&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Step 3: 3DS authentication &amp;amp; challenge ====&lt;br /&gt;
This data then should be passed onto the &amp;lt;code&amp;gt;authenticate()&amp;lt;/code&amp;gt; method of the offsite gw manager, which will do all the magic to authenticate and display the challenge (if needed).&lt;br /&gt;
&amp;lt;source lang=javascript line highlight=&amp;quot;9&amp;quot;&amp;gt;&lt;br /&gt;
        // call Barion API via merchant&#039;s backend&lt;br /&gt;
        // once the result is returned continue with authentication&lt;br /&gt;
        $.ajax({&lt;br /&gt;
            url: &amp;quot;Url/Of/Your/Payment/Start&amp;quot;,&lt;br /&gt;
            method: &amp;quot;POST&amp;quot;,&lt;br /&gt;
            data: data,&lt;br /&gt;
            success: function (threeDsClientData) {&lt;br /&gt;
               // the threeDsClientData will be in the response of payment/start	&lt;br /&gt;
               gw.authenticate(threeDsClientData);&lt;br /&gt;
            }&lt;br /&gt;
         });&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the request is finished the appropriate callback is fired, the BarionClient was initialized with in [[#Step 1 : Initialize oneClick|Step 1]]. In case of successful authentication, you have to call our [[Payment-Complete-v3|/Payment/Complete]] endpoint, where the actual charge will happen.&lt;br /&gt;
&lt;br /&gt;
=== Recurring payment/Merchant Initiated payment ===&lt;br /&gt;
&lt;br /&gt;
For these types of payments, the subsequent payments are nearly identical to the process of [[#Creating_the_token|Creating the token]]. The only difference is that the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; received in the initial [[Payment-GetPaymentState-v2|GetPaymentState]] response must be sent in the &lt;br /&gt;
[[Payment-Start-v2|Payment/Start]] request. Also don&#039;t forget to set the appropriate [[RecurrenceType|Recurrence Type]].&lt;br /&gt;
&lt;br /&gt;
=== Possible error responses ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| InvalidRecurrenceId|| The token specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is invalid. Check if the token registration was successful.&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentDenied|| Something happened to the user since the token registration, either deleted, suspended, or blocked. The payment s not allowed in these cases.&lt;br /&gt;
|-&lt;br /&gt;
| InsufficientFunds|| If the original payment was with an e-money wallet and the customer doesn&#039;t have enough money to fulfill this charge this error happens.&lt;br /&gt;
|-&lt;br /&gt;
| OriginalPaymentWasntSuccessful || This means that the token belongs to an originally unsuccessful payment so this token can not be used anymore. This could only happen if the original payment was financed with a credit card.&lt;br /&gt;
|-&lt;br /&gt;
|InvalidCurrency || If the original payment was paid with e-money and the current token payment is in a currency that the wallet does not have an account in this error happens.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2858</id>
		<title>Token payment 3D Secure</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2858"/>
		<updated>2020-11-26T11:35:15Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* 2.1 Sending the payment request to the Barion API */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Token Payment with 3D Secure}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{IncompletePage}}&lt;br /&gt;
&lt;br /&gt;
This payment scenario allows the integrator shop to register a token for a customer (and a funding source) in the Barion system and then, later on, using this token, charge the customer without redirecting her to the Barion Smart Gateway UI. The user may be present at the site of the merchant or she can be off-session as well, so the merchant can charge her e.g. for subscriptions. This means that the customer authorizes the shop to charge her card or Barion balance without typing in the card information or Barion login again.&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurring.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=Premium feature|text=This scenario is not allowed automatically for every approved shop and should be requested from Barion!|color=#1993c7}}&lt;br /&gt;
&lt;br /&gt;
= Token payment scenarios =&lt;br /&gt;
Token payment can be used in three use cases: &lt;br /&gt;
* &#039;&#039;&#039;Customer Initiated Payments&#039;&#039;&#039;: when the user is present on the website of the merchant and she decides to pay :&lt;br /&gt;
** &#039;&#039;&#039;OneClick payment&#039;&#039;&#039;: the user is charged upon her request initiated on the website of the merchant. Subsequent payments are subject to PSD2 SCA and as the user is present, she has to go through the authentication process.&lt;br /&gt;
* &#039;&#039;&#039;Merchant Initiated Payments&#039;&#039;&#039;: when the merchant initiates the payment without the user being present. It has two subtypes:&lt;br /&gt;
** &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: the user is charged with the same amount on a regular basis, typically in case of subscriptions. Subsequent payments are exempted from PSD2 SCA, but liability still shifts to the card issuer.&lt;br /&gt;
** &#039;&#039;&#039;MIT (merchant initiated transaction)&#039;&#039;&#039;: the user is charged on an irregular basis and/or with a different amount. Subsequent payments of this type are excluded from PSD2 SCA, the liability is on the merchant.&lt;br /&gt;
&lt;br /&gt;
== Customer participation ==&lt;br /&gt;
&lt;br /&gt;
Since the token scenario is suitable for both customer and merchant initiated payments here is a comparison about who starts the payment. This includes the regular, non-tokenized payment scenario as well:&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot; | Scenario&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Initial payment&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW &lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW&lt;br /&gt;
|-&lt;br /&gt;
| Non token (regular) payment || YES || YES || YES || YES &lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || YES || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| MIT || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #aaa; background-color:#eee; font-size: 0.8em; padding:5px 10px; display:inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; Token payment scenarios can be initiated with already registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; as well, in this case the customer may remain on the merchant&#039;s site. &lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements for the scenarios ==&lt;br /&gt;
&lt;br /&gt;
These token payment scenarios have different requirements, this table below summarizes the key differences.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Payment amount&lt;br /&gt;
! Payment frequency&lt;br /&gt;
! Liability in case of fraud&lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || Various || Various || Card issuer&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || Subsequent amounts must be equal or less than the initial amount  || Initial payment must define a minimum amount of days to wait between charges || Card issuer &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || Various  || Various || Merchant&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 3DS authentication of the payer ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be performed for every online card payment. These token payment scenarios also have to use this new secure way of authentication. &lt;br /&gt;
The initial payment of a token scenario must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
Here is a table to compare the 3DS authentication requirements:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Initial payment&lt;br /&gt;
! Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
| One-click payment || ✔️ || ✔️&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Real life examples ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phone bill&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Payer has a usage-based phone subscription that wants to pay without being present for every charge. She authorizes the phone company to charge her card every month.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, the amount of the subsequent payments may exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TV subscription&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to online streaming of a television channel. She authorizes the phone company to charge her card every month. The subscription fee is the same for every month.&lt;br /&gt;
* Scenario: Recurring payment&lt;br /&gt;
* Explanation: The amount of the subsequent payments will not exceed the initial payment and the charge is regularly monthly-based.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bookclub with &amp;quot;free first month&amp;quot; bonus&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to a book renting service. She authorizes the book club to charge her card every month for a selection of books. The subscription fee is the same for every month however, the first month is free. To ensure the subscription the service requires her to register her card details.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, and the fee will stay the same, the initial payment is zero. So the amount of the next payment will exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Online food delivery service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The food delivery company wants to provide a quick and easy experience for its customer. They decide that the order will be quicker if the customers don&#039;t leave the website to pay for the goods.&lt;br /&gt;
* Scenario: OneClick payment&lt;br /&gt;
* Explanation: The customer will always be there so the other two scenarios are not available.&lt;br /&gt;
&lt;br /&gt;
== How to decide ==&lt;br /&gt;
&lt;br /&gt;
To help you decide on a suitable scenario, please use the decision graph below:&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurrencetype-decision.png|520px]]&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
To be able to integrate your webshop with the Barion Payment Gateway: &lt;br /&gt;
* You must [[Creating_an_account|register a Barion wallet]] at the Barion website or in the Sandbox environment. Learn more about the Sandbox environment [[Sandbox|here]].&lt;br /&gt;
* For this wallet you have to [[Creating_a_shop|create a shop]] which should be approved by Barion.&lt;br /&gt;
* For every currency you plan to conduct payments in you have to make sure there is an account created in your Barion wallet. This means that if you plan to have USD payments then there should be a USD account created in your wallet.&lt;br /&gt;
* To make sure every corner case scenario works for your webshop it is best to top up that account with a small amount (approx. 5-10EUR or your choice of currency around the same value).&lt;br /&gt;
* For the technical communication guide please read this: [[Calling_the_API|Calling the API]]&lt;br /&gt;
&lt;br /&gt;
= The payment process =&lt;br /&gt;
&lt;br /&gt;
The process is divided into two major steps:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 1:  Creating the funding source token|Creating the token]] that represents one of the customer&#039;s funding sources (credit card or e-money wallet)&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Preparing the payment via the Barion API&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Redirecting the customer to the Barion Smart Gateway to select a funding source&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Processing the callback and requesting information about the result of the payment&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 2: Using the token|Using the registered token]] to charge the customer&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Sending the payment request to the Barion API &lt;br /&gt;
             &amp;lt;ol&amp;gt;&lt;br /&gt;
                &amp;lt;li&amp;gt;Using the token for the same token payment scenario&amp;lt;/li&amp;gt;&lt;br /&gt;
                &amp;lt;li&amp;gt;Using the token for a different token payment scenario&amp;lt;/li&amp;gt;&lt;br /&gt;
            &amp;lt;/ol&amp;gt;&lt;br /&gt;
         &amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Performing on-site 3DS authentication (if needed)&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1:  Creating the funding source token ==&lt;br /&gt;
To be able to use a token payment scenario first the merchant has to register the token with Barion. The merchant has to make sure that the customer is well aware of the fact that they are giving consent to a tokenized payment. The Barion Smart Gateway UI does not indicate in any way that the payment is a token payment.&lt;br /&gt;
&lt;br /&gt;
The token is registered to the shop and not to the merchant&#039;s Barion account. So if the merchant has multiple shops in its Barion account, the registered tokens can not be shared among them even if the customer is the same. If you want to use tokens in multiple shops, please contact Barion in the Customer center.&lt;br /&gt;
&lt;br /&gt;
=== 1.1 Preparing the payment===&lt;br /&gt;
&lt;br /&gt;
The token registration is basically a [[Responsive_web_payment|normal payment]] with three extra properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* InitiateRecurrence&lt;br /&gt;
* RecurrenceId&lt;br /&gt;
* RecurrenceType&lt;br /&gt;
&lt;br /&gt;
==== InitiateRecurrence====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; property is a bool property. If you set it to &#039;&#039;&#039;true&#039;&#039;&#039; then the payment gateway will consider the payment as a token registration. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This happens even if the customer is already has a registered token, so you are able to re-register a funding source or even a customer. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceId ====&lt;br /&gt;
The next required property for a token registration is the token itself. This is generated by the shop and has to be unique for every registration. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property of the [[Payment-Start-v2|Payment/Start]] request. This token must be saved in the webshops database. A &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; token represents the funding source (bank card or Barion balance) of a customer. Since a customer can have multiple cards and accounts as a funding source make sure that in the webshop&#039;s system multiple tokens can belong to a single customer.&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceType ====&lt;br /&gt;
The third required property is the [[RecurrenceType|Recurrence Type]]. This specifies the scenario. In case of Recurring Payment &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; must also be set.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Merchant Initiated Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The response will be the same as to a [[Responsive_web_payment#Processing_the_successful_response|basic &#039;&#039;&#039;Immediate&#039;&#039;&#039; scenario]]. The &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; property at this point is &#039;&#039;&#039;None&#039;&#039;&#039; since the token is not registered to a funding source yet.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Recurring Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Recurring Payment&#039;&#039;&#039; scenario has some extra restrictions. The merchant has to specify two additional properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt;: The date after the subsequent charges should not accepted.&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt;: The minimum days the merchant has to wait between payments.&lt;br /&gt;
&lt;br /&gt;
Both properties are located in the [[PurchaseInformation]] property and must be specified if this scenario is selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7, 30-33&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;PurchaseInformation&amp;quot;:{&lt;br /&gt;
        &amp;quot;RecurringFrequency&amp;quot;: 10,&lt;br /&gt;
        &amp;quot;RecurringExpiry&amp;quot;: &amp;quot;2022-10-01&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Possible error responses ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentNotAllowed || The token payment is not allowed for the shop identified by the &#039;&#039;&#039;POSKey&#039;&#039;&#039;. Contact Barion to request this feature.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 1.2 Redirecting the customer to the Barion Smart Gateway to select a funding source ===&lt;br /&gt;
&lt;br /&gt;
After a successful payment preparation, the customer is redirected to the secure Barion Smart Gateway to choose a funding source. The funding source the customer selects will be registered to the token. The funding source can either be a Barion e-money balance or a bank card. This means that even though the customer may own multiple cards only the one that was registered to the token can be used for future token payments. To change the funding source attached to the token a new registration should be requested.&lt;br /&gt;
&lt;br /&gt;
=== 1.3 Processing the callback and requesting information about the result of the payment ===&lt;br /&gt;
&lt;br /&gt;
When the payment is completed (either successfully or unsuccessfully) a callback message is sent to the merchant&#039;s system. Once received a [[Payment-GetPaymentState-v2|GetPaymentState]] request must be sent to the Barion API. On how to implement this please read the article about the  [[Callback_mechanism|Callback mechanism]].&lt;br /&gt;
&lt;br /&gt;
The full response of the GetPaymentState request depends on the payment scenario and the structure of the payment. When it comes to token payment there are several properties to look out for. &lt;br /&gt;
* In case the &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; is &#039;&#039;&#039;Succeeded&#039;&#039;&#039; the funding source token is registered and ready to use.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; contains the ID of the token process. This specifies the nature of the token payment. &lt;br /&gt;
&lt;br /&gt;
==== TraceId ====&lt;br /&gt;
&lt;br /&gt;
In case of Recurring payment or Merchant initiated payment scenarios the [[Payment-GetPaymentState-v2|GetPaymentState]] response returns an additional field called &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. The value of this property is generated by the card issuer. The merchant has to save it and submit it in all subsequent Recurring or Merchant initiated payments of the same type, otherwise, the payments can be declined by the issuer. The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; represents the first, customer-present payment and helps the issuer to connect subsequent payments to this initial payment.&lt;br /&gt;
&lt;br /&gt;
====Example GetPaymentState response====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;8, 11-12&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;OrderNumber&amp;quot;: null,&lt;br /&gt;
    &amp;quot;POSId&amp;quot;: &amp;quot;[[SHOPS_PUBLIC_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSName&amp;quot;: &amp;quot;[[MERCHANTS_BARION_SHOPNAME]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSOwnerEmail&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSource&amp;quot;: &amp;quot;BankCard&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;AllowedFundingSources&amp;quot;: [&lt;br /&gt;
        &amp;quot;All&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;GuestCheckout&amp;quot;: true,&lt;br /&gt;
    &amp;quot;CreatedAt&amp;quot;: &amp;quot;2020-11-26T07:52:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ValidUntil&amp;quot;: &amp;quot;2020-11-26T08:22:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;CompletedAt&amp;quot;: &amp;quot;2020-11-26T08:11:54.118Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ReservedUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;DelayedCaptureUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
           ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;Total&amp;quot;: 25.20,&lt;br /&gt;
    &amp;quot;SuggestedLocale&amp;quot;: &amp;quot;hu-HU&amp;quot;,&lt;br /&gt;
    &amp;quot;FraudRiskScore&amp;quot;: null,&lt;br /&gt;
    &amp;quot;RedirectUrl&amp;quot;: &amp;quot;https://merchanturl/Redirect?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;CallbackUrl&amp;quot;: &amp;quot;https://merchanturl/Callback?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Displaying the funding source in a GUI ====&lt;br /&gt;
We strongly advise saving the complete response for future reference. The &amp;lt;code&amp;gt;FundingSource&amp;lt;/code&amp;gt; field tells if the funding source is a Barion balance or a card. If it is a card, it is useful to save [[FundingInformation]] for displaying it for the user, when requesting future payments. The usual way to display funding sources is to show the last 4 digits of the card, with 4 stars, eg: *** 1234. The card used can be obtained from FundingInformation&#039;s [[BankCard]] field. The [[CardType]] field can be used to display the appropriate card logo. You can even show, if the card is expired, and offer to register another one.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; FundingInformation part of the GetPaymentState response &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=json&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be displayed for example as &amp;lt;code&amp;gt;VISA **** 0425 (12/20)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a request-response diagram of the token registration process:&lt;br /&gt;
 &lt;br /&gt;
[[File:Token_payment_initiation.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Step 2: Using the token =&lt;br /&gt;
&lt;br /&gt;
==2.1 Sending the payment request to the Barion API ==&lt;br /&gt;
&lt;br /&gt;
To use an already registered token for a payment, you have to use the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property. To be able to use a token, the initial payment must be in a successful state.&lt;br /&gt;
&lt;br /&gt;
At this point, the merchant has to decide whether this subsequent payment is used for the same token payment scenario or something changed. This is important because the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used for the same scenario, otherwise, the card issuer will decline the charge.&lt;br /&gt;
A &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used again if:&lt;br /&gt;
* the funding source is the same (technically the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* the token payment scenario is the same (technically the &amp;lt;code&amp;gt;RecurrenceType&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* this subsequent request complies with the scenario restrictions (eg: in case of recurring payment the amount of the subsequent payment does not exceed the initial amount)&lt;br /&gt;
&lt;br /&gt;
If the funding source changes, new &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the funding source|described in detail here]]. If the funding source stays the same but the scenario changes or the restrictions are no longer met new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the token payment scenario with an existing token|described here]].&lt;br /&gt;
&lt;br /&gt;
=== Subsequent payment in case of Recurring payment scenario ===&lt;br /&gt;
&lt;br /&gt;
In this case, three extra conditions must be met:&lt;br /&gt;
* the amount of the subsequent payment must not be higher than the initial amount&lt;br /&gt;
* at least that much days must be spent as defined in the initial &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; property&lt;br /&gt;
* the date of the payment must not exceed the day specified in the initial &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; property&lt;br /&gt;
&lt;br /&gt;
Please be aware that in case any of these are no longer valid the merchant has to request a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; as [[#Changing the token payment scenario with an existing token|described here]]. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=These conditions are not enforced by the Barion system so the violation of them will result in a declined charge.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
Payment/start must not include the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; properties (since they are already fixed during the initial payment).&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Recurring payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Subsequent payment in case of Merchant Initiated Payment scenario ===&lt;br /&gt;
&lt;br /&gt;
In this scenario there are no restrictions.&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Merchant Initiated Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;KBYRR55322844552124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 75,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Phone bill&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Usage fee for 2020/12&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 75,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Subsequent payment in case of OneClick Payment scenario ===&lt;br /&gt;
&lt;br /&gt;
In this scenario, the merchant has to prepare to perform the 3DS v2 authentication of the payer. 3DS authentication is not required in the following cases:&lt;br /&gt;
* the token () was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
* the subsequent payment is a merchant initiated payment.&lt;br /&gt;
&lt;br /&gt;
To perform an off-site 3DS authentication of the payer the merchant has to integrate the client library of the Barion Smart Gateway. Read the detailed instructions here.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; is not used in this scenario since the payer is present during the transaction. &lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent OneClick Payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 17,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Book: How to shop online&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;How to shop online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Book about shopping online&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;piece&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 17,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-02&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Depending on the type of the subsequent payment, 3DSecure authentication might be required for subsequent payments.&lt;br /&gt;
3DS authentication is not required in the following cases:&lt;br /&gt;
* the token (&amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt;) was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prerequisites ===&lt;br /&gt;
&lt;br /&gt;
[[File:Token_payment_2.png]]&lt;br /&gt;
&lt;br /&gt;
=== OneClick payment ===&lt;br /&gt;
==== Step 1 : Initialize oneClick ====&lt;br /&gt;
You have to include the following css and javascript files in the code of your site. These files include all the necessary javascript code and styling to handle the 3DS authentication and display the challenge if necessary.&lt;br /&gt;
&amp;lt;source lang=html&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source &amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to initialize the Barion javascript client:&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const configuration = {&lt;br /&gt;
    onAuthenticationSucceeded: function () {&lt;br /&gt;
        // handle successful authentication by calling the Barion API via merchant&#039;s backend&lt;br /&gt;
        // Call the v2/payment/complete endpoint&lt;br /&gt;
    },&lt;br /&gt;
    onAuthenticationFailed: function () {&lt;br /&gt;
        // Handle unsuccessful authentication result, no charge was made.&lt;br /&gt;
        // The payment might be still valid only the authentication failed&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
const gw= new Barion.OffsiteGw(configuration);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Step 2 : Make a payment  ====&lt;br /&gt;
To use an already registered token for a payment, you have to call the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; and the appropriate [[RecurrenceType|Recurrence Type]] should be sent. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property along with the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Example Payment/Start json request =====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;E31EC263-01DC-40BD-BDF1-38FC7A332434&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot; : &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot; : false,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot; : &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot; : &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot; : &amp;quot;SHOP-XMLP-TRACEID-123&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR002&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;webshop@example.com&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subsription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Processing the Payment/Start response =====&lt;br /&gt;
To this request, the Barion API sends back the required data for the 3DS authentication for the specified paymentId.&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
! Field name&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| PaymentId&lt;br /&gt;
| Payment Identifier of the purchase in Barion&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| ThreeDSAuthClientData&lt;br /&gt;
| basae64 encoded 3DS client data&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Payment/Start response =====&lt;br /&gt;
&amp;lt;source lang=json line style=&amp;quot;word-break: break-all;&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot; : &amp;quot;dce46843-6266-4c1f-b82a-387e0fee9073&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot; : &amp;quot;ewoJIkNhcmRQdWJsaWNJZCI6ICIxYTE5M2E1NDQzNDI0YjJiOGJiMjMyOGRhNWY4NmYzYiIsCgkiUGF5bWVudElkIjogImRjZTQ2ODQzNjI2NjRjMWZiODJhMzg3ZTBmZWU5MDczIiwKCSJPbmVDbGlja0NvbnRlbnRVcmwiOiAiaHR0cDovL3NlY3VyZS5iYXJpb24uY29tL3RocmVlZHMvb25lY2xpY2twYXltZW50IiwKCSJBQ1NTdGFydFByb3RvY29sVmVyc2lvbiI6ICIyLjEuMCIsCgkiQUNTRW5kUHJvdG9jb2xWZXJzaW9uIjogIjIuMS4wIiwKCSJEU1N0YXJ0UHJvdG9jb2xWZXJzaW9uIjogIjIuMS4wIiwKCSJEU0VuZFByb3RvY29sVmVyc2lvbiI6ICIyLjIuMCIsCgkiVGhyZWVEU1NlcnZlclRyYW5zSUQiOiBudWxsLAoJIlRocmVlRFNNZXRob2RVUkwiOiBudWxsLAoJIlRocmVlRFNNZXRob2REYXRhRm9ybSI6ICJleUowYUhKbFpVUlRUV1YwYUc5a1RtOTBhV1pwWTJGMGFXOXVWVkpNSWpvaWFIUjBjSE02THk4elpITXVZbUZ5YVc5dUxtTnZiUzh6WkhNdmRqSXZNMlJ6TFcxbGRHaHZaQzF1YjNScFptbGpZWFJwYjI0aUxDSjBhSEpsWlVSVFUyVnlkbVZ5VkhKaGJuTkpSQ0k2SWpFNE5URTJPR0kxTFRKalkyUXROR0kxWlMxaVlqWm1MVFUzTW1VM00yVTNNemt3TnlKOSIsCgkiRXJyb3JEZXRhaWxzIjogbnVsbCwKCSJWZXJzaW9uIjogIjIuMS4wIgp9Cg==&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Step 3: 3DS authentication &amp;amp; challenge ====&lt;br /&gt;
This data then should be passed onto the &amp;lt;code&amp;gt;authenticate()&amp;lt;/code&amp;gt; method of the offsite gw manager, which will do all the magic to authenticate and display the challenge (if needed).&lt;br /&gt;
&amp;lt;source lang=javascript line highlight=&amp;quot;9&amp;quot;&amp;gt;&lt;br /&gt;
        // call Barion API via merchant&#039;s backend&lt;br /&gt;
        // once the result is returned continue with authentication&lt;br /&gt;
        $.ajax({&lt;br /&gt;
            url: &amp;quot;Url/Of/Your/Payment/Start&amp;quot;,&lt;br /&gt;
            method: &amp;quot;POST&amp;quot;,&lt;br /&gt;
            data: data,&lt;br /&gt;
            success: function (threeDsClientData) {&lt;br /&gt;
               // the threeDsClientData will be in the response of payment/start	&lt;br /&gt;
               gw.authenticate(threeDsClientData);&lt;br /&gt;
            }&lt;br /&gt;
         });&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the request is finished the appropriate callback is fired, the BarionClient was initialized with in [[#Step 1 : Initialize oneClick|Step 1]]. In case of successful authentication, you have to call our [[Payment-Complete-v3|/Payment/Complete]] endpoint, where the actual charge will happen.&lt;br /&gt;
&lt;br /&gt;
=== Recurring payment/Merchant Initiated payment ===&lt;br /&gt;
&lt;br /&gt;
For these types of payments, the subsequent payments are nearly identical to the process of [[#Creating_the_token|Creating the token]]. The only difference is that the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; received in the initial [[Payment-GetPaymentState-v2|GetPaymentState]] response must be sent in the &lt;br /&gt;
[[Payment-Start-v2|Payment/Start]] request. Also don&#039;t forget to set the appropriate [[RecurrenceType|Recurrence Type]].&lt;br /&gt;
&lt;br /&gt;
=== Possible error responses ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| InvalidRecurrenceId|| The token specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is invalid. Check if the token registration was successful.&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentDenied|| Something happened to the user since the token registration, either deleted, suspended, or blocked. The payment s not allowed in these cases.&lt;br /&gt;
|-&lt;br /&gt;
| InsufficientFunds|| If the original payment was with an e-money wallet and the customer doesn&#039;t have enough money to fulfill this charge this error happens.&lt;br /&gt;
|-&lt;br /&gt;
| OriginalPaymentWasntSuccessful || This means that the token belongs to an originally unsuccessful payment so this token can not be used anymore. This could only happen if the original payment was financed with a credit card.&lt;br /&gt;
|-&lt;br /&gt;
|InvalidCurrency || If the original payment was paid with e-money and the current token payment is in a currency that the wallet does not have an account in this error happens.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2857</id>
		<title>Token payment 3D Secure</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2857"/>
		<updated>2020-11-26T11:18:15Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* Subsequent payment in case of Recurring payment scenario */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Token Payment with 3D Secure}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{IncompletePage}}&lt;br /&gt;
&lt;br /&gt;
This payment scenario allows the integrator shop to register a token for a customer (and a funding source) in the Barion system and then, later on, using this token, charge the customer without redirecting her to the Barion Smart Gateway UI. The user may be present at the site of the merchant or she can be off-session as well, so the merchant can charge her e.g. for subscriptions. This means that the customer authorizes the shop to charge her card or Barion balance without typing in the card information or Barion login again.&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurring.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=Premium feature|text=This scenario is not allowed automatically for every approved shop and should be requested from Barion!|color=#1993c7}}&lt;br /&gt;
&lt;br /&gt;
= Token payment scenarios =&lt;br /&gt;
Token payment can be used in three use cases: &lt;br /&gt;
* &#039;&#039;&#039;Customer Initiated Payments&#039;&#039;&#039;: when the user is present on the website of the merchant and she decides to pay :&lt;br /&gt;
** &#039;&#039;&#039;OneClick payment&#039;&#039;&#039;: the user is charged upon her request initiated on the website of the merchant. Subsequent payments are subject to PSD2 SCA and as the user is present, she has to go through the authentication process.&lt;br /&gt;
* &#039;&#039;&#039;Merchant Initiated Payments&#039;&#039;&#039;: when the merchant initiates the payment without the user being present. It has two subtypes:&lt;br /&gt;
** &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: the user is charged with the same amount on a regular basis, typically in case of subscriptions. Subsequent payments are exempted from PSD2 SCA, but liability still shifts to the card issuer.&lt;br /&gt;
** &#039;&#039;&#039;MIT (merchant initiated transaction)&#039;&#039;&#039;: the user is charged on an irregular basis and/or with a different amount. Subsequent payments of this type are excluded from PSD2 SCA, the liability is on the merchant.&lt;br /&gt;
&lt;br /&gt;
== Customer participation ==&lt;br /&gt;
&lt;br /&gt;
Since the token scenario is suitable for both customer and merchant initiated payments here is a comparison about who starts the payment. This includes the regular, non-tokenized payment scenario as well:&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot; | Scenario&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Initial payment&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW &lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW&lt;br /&gt;
|-&lt;br /&gt;
| Non token (regular) payment || YES || YES || YES || YES &lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || YES || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| MIT || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #aaa; background-color:#eee; font-size: 0.8em; padding:5px 10px; display:inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; Token payment scenarios can be initiated with already registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; as well, in this case the customer may remain on the merchant&#039;s site. &lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements for the scenarios ==&lt;br /&gt;
&lt;br /&gt;
These token payment scenarios have different requirements, this table below summarizes the key differences.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Payment amount&lt;br /&gt;
! Payment frequency&lt;br /&gt;
! Liability in case of fraud&lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || Various || Various || Card issuer&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || Subsequent amounts must be equal or less than the initial amount  || Initial payment must define a minimum amount of days to wait between charges || Card issuer &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || Various  || Various || Merchant&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 3DS authentication of the payer ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be performed for every online card payment. These token payment scenarios also have to use this new secure way of authentication. &lt;br /&gt;
The initial payment of a token scenario must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
Here is a table to compare the 3DS authentication requirements:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Initial payment&lt;br /&gt;
! Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
| One-click payment || ✔️ || ✔️&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Real life examples ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phone bill&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Payer has a usage-based phone subscription that wants to pay without being present for every charge. She authorizes the phone company to charge her card every month.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, the amount of the subsequent payments may exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TV subscription&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to online streaming of a television channel. She authorizes the phone company to charge her card every month. The subscription fee is the same for every month.&lt;br /&gt;
* Scenario: Recurring payment&lt;br /&gt;
* Explanation: The amount of the subsequent payments will not exceed the initial payment and the charge is regularly monthly-based.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bookclub with &amp;quot;free first month&amp;quot; bonus&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to a book renting service. She authorizes the book club to charge her card every month for a selection of books. The subscription fee is the same for every month however, the first month is free. To ensure the subscription the service requires her to register her card details.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, and the fee will stay the same, the initial payment is zero. So the amount of the next payment will exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Online food delivery service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The food delivery company wants to provide a quick and easy experience for its customer. They decide that the order will be quicker if the customers don&#039;t leave the website to pay for the goods.&lt;br /&gt;
* Scenario: OneClick payment&lt;br /&gt;
* Explanation: The customer will always be there so the other two scenarios are not available.&lt;br /&gt;
&lt;br /&gt;
== How to decide ==&lt;br /&gt;
&lt;br /&gt;
To help you decide on a suitable scenario, please use the decision graph below:&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurrencetype-decision.png|520px]]&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
To be able to integrate your webshop with the Barion Payment Gateway: &lt;br /&gt;
* You must [[Creating_an_account|register a Barion wallet]] at the Barion website or in the Sandbox environment. Learn more about the Sandbox environment [[Sandbox|here]].&lt;br /&gt;
* For this wallet you have to [[Creating_a_shop|create a shop]] which should be approved by Barion.&lt;br /&gt;
* For every currency you plan to conduct payments in you have to make sure there is an account created in your Barion wallet. This means that if you plan to have USD payments then there should be a USD account created in your wallet.&lt;br /&gt;
* To make sure every corner case scenario works for your webshop it is best to top up that account with a small amount (approx. 5-10EUR or your choice of currency around the same value).&lt;br /&gt;
* For the technical communication guide please read this: [[Calling_the_API|Calling the API]]&lt;br /&gt;
&lt;br /&gt;
= The payment process =&lt;br /&gt;
&lt;br /&gt;
The process is divided into two major steps:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 1:  Creating the funding source token|Creating the token]] that represents one of the customer&#039;s funding sources (credit card or e-money wallet)&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Preparing the payment via the Barion API&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Redirecting the customer to the Barion Smart Gateway to select a funding source&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Processing the callback and requesting information about the result of the payment&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 2: Using the token|Using the registered token]] to charge the customer&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Sending the payment request to the Barion API &lt;br /&gt;
             &amp;lt;ol&amp;gt;&lt;br /&gt;
                &amp;lt;li&amp;gt;Using the token for the same token payment scenario&amp;lt;/li&amp;gt;&lt;br /&gt;
                &amp;lt;li&amp;gt;Using the token for a different token payment scenario&amp;lt;/li&amp;gt;&lt;br /&gt;
            &amp;lt;/ol&amp;gt;&lt;br /&gt;
         &amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Performing on-site 3DS authentication (if needed)&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1:  Creating the funding source token ==&lt;br /&gt;
To be able to use a token payment scenario first the merchant has to register the token with Barion. The merchant has to make sure that the customer is well aware of the fact that they are giving consent to a tokenized payment. The Barion Smart Gateway UI does not indicate in any way that the payment is a token payment.&lt;br /&gt;
&lt;br /&gt;
The token is registered to the shop and not to the merchant&#039;s Barion account. So if the merchant has multiple shops in its Barion account, the registered tokens can not be shared among them even if the customer is the same. If you want to use tokens in multiple shops, please contact Barion in the Customer center.&lt;br /&gt;
&lt;br /&gt;
=== 1.1 Preparing the payment===&lt;br /&gt;
&lt;br /&gt;
The token registration is basically a [[Responsive_web_payment|normal payment]] with three extra properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* InitiateRecurrence&lt;br /&gt;
* RecurrenceId&lt;br /&gt;
* RecurrenceType&lt;br /&gt;
&lt;br /&gt;
==== InitiateRecurrence====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; property is a bool property. If you set it to &#039;&#039;&#039;true&#039;&#039;&#039; then the payment gateway will consider the payment as a token registration. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This happens even if the customer is already has a registered token, so you are able to re-register a funding source or even a customer. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceId ====&lt;br /&gt;
The next required property for a token registration is the token itself. This is generated by the shop and has to be unique for every registration. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property of the [[Payment-Start-v2|Payment/Start]] request. This token must be saved in the webshops database. A &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; token represents the funding source (bank card or Barion balance) of a customer. Since a customer can have multiple cards and accounts as a funding source make sure that in the webshop&#039;s system multiple tokens can belong to a single customer.&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceType ====&lt;br /&gt;
The third required property is the [[RecurrenceType|Recurrence Type]]. This specifies the scenario. In case of Recurring Payment &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; must also be set.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Merchant Initiated Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The response will be the same as to a [[Responsive_web_payment#Processing_the_successful_response|basic &#039;&#039;&#039;Immediate&#039;&#039;&#039; scenario]]. The &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; property at this point is &#039;&#039;&#039;None&#039;&#039;&#039; since the token is not registered to a funding source yet.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Recurring Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Recurring Payment&#039;&#039;&#039; scenario has some extra restrictions. The merchant has to specify two additional properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt;: The date after the subsequent charges should not accepted.&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt;: The minimum days the merchant has to wait between payments.&lt;br /&gt;
&lt;br /&gt;
Both properties are located in the [[PurchaseInformation]] property and must be specified if this scenario is selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7, 30-33&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;PurchaseInformation&amp;quot;:{&lt;br /&gt;
        &amp;quot;RecurringFrequency&amp;quot;: 10,&lt;br /&gt;
        &amp;quot;RecurringExpiry&amp;quot;: &amp;quot;2022-10-01&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Possible error responses ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentNotAllowed || The token payment is not allowed for the shop identified by the &#039;&#039;&#039;POSKey&#039;&#039;&#039;. Contact Barion to request this feature.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 1.2 Redirecting the customer to the Barion Smart Gateway to select a funding source ===&lt;br /&gt;
&lt;br /&gt;
After a successful payment preparation, the customer is redirected to the secure Barion Smart Gateway to choose a funding source. The funding source the customer selects will be registered to the token. The funding source can either be a Barion e-money balance or a bank card. This means that even though the customer may own multiple cards only the one that was registered to the token can be used for future token payments. To change the funding source attached to the token a new registration should be requested.&lt;br /&gt;
&lt;br /&gt;
=== 1.3 Processing the callback and requesting information about the result of the payment ===&lt;br /&gt;
&lt;br /&gt;
When the payment is completed (either successfully or unsuccessfully) a callback message is sent to the merchant&#039;s system. Once received a [[Payment-GetPaymentState-v2|GetPaymentState]] request must be sent to the Barion API. On how to implement this please read the article about the  [[Callback_mechanism|Callback mechanism]].&lt;br /&gt;
&lt;br /&gt;
The full response of the GetPaymentState request depends on the payment scenario and the structure of the payment. When it comes to token payment there are several properties to look out for. &lt;br /&gt;
* In case the &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; is &#039;&#039;&#039;Succeeded&#039;&#039;&#039; the funding source token is registered and ready to use.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; contains the ID of the token process. This specifies the nature of the token payment. &lt;br /&gt;
&lt;br /&gt;
==== TraceId ====&lt;br /&gt;
&lt;br /&gt;
In case of Recurring payment or Merchant initiated payment scenarios the [[Payment-GetPaymentState-v2|GetPaymentState]] response returns an additional field called &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. The value of this property is generated by the card issuer. The merchant has to save it and submit it in all subsequent Recurring or Merchant initiated payments of the same type, otherwise, the payments can be declined by the issuer. The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; represents the first, customer-present payment and helps the issuer to connect subsequent payments to this initial payment.&lt;br /&gt;
&lt;br /&gt;
====Example GetPaymentState response====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;8, 11-12&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;OrderNumber&amp;quot;: null,&lt;br /&gt;
    &amp;quot;POSId&amp;quot;: &amp;quot;[[SHOPS_PUBLIC_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSName&amp;quot;: &amp;quot;[[MERCHANTS_BARION_SHOPNAME]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSOwnerEmail&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSource&amp;quot;: &amp;quot;BankCard&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;AllowedFundingSources&amp;quot;: [&lt;br /&gt;
        &amp;quot;All&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;GuestCheckout&amp;quot;: true,&lt;br /&gt;
    &amp;quot;CreatedAt&amp;quot;: &amp;quot;2020-11-26T07:52:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ValidUntil&amp;quot;: &amp;quot;2020-11-26T08:22:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;CompletedAt&amp;quot;: &amp;quot;2020-11-26T08:11:54.118Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ReservedUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;DelayedCaptureUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
           ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;Total&amp;quot;: 25.20,&lt;br /&gt;
    &amp;quot;SuggestedLocale&amp;quot;: &amp;quot;hu-HU&amp;quot;,&lt;br /&gt;
    &amp;quot;FraudRiskScore&amp;quot;: null,&lt;br /&gt;
    &amp;quot;RedirectUrl&amp;quot;: &amp;quot;https://merchanturl/Redirect?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;CallbackUrl&amp;quot;: &amp;quot;https://merchanturl/Callback?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Displaying the funding source in a GUI ====&lt;br /&gt;
We strongly advise saving the complete response for future reference. The &amp;lt;code&amp;gt;FundingSource&amp;lt;/code&amp;gt; field tells if the funding source is a Barion balance or a card. If it is a card, it is useful to save [[FundingInformation]] for displaying it for the user, when requesting future payments. The usual way to display funding sources is to show the last 4 digits of the card, with 4 stars, eg: *** 1234. The card used can be obtained from FundingInformation&#039;s [[BankCard]] field. The [[CardType]] field can be used to display the appropriate card logo. You can even show, if the card is expired, and offer to register another one.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; FundingInformation part of the GetPaymentState response &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=json&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be displayed for example as &amp;lt;code&amp;gt;VISA **** 0425 (12/20)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a request-response diagram of the token registration process:&lt;br /&gt;
 &lt;br /&gt;
[[File:Token_payment_initiation.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Step 2: Using the token =&lt;br /&gt;
&lt;br /&gt;
==2.1 Sending the payment request to the Barion API ==&lt;br /&gt;
&lt;br /&gt;
To use an already registered token for a payment, you have to use the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
At this point, the merchant has to decide whether this subsequent payment is used for the same token payment scenario or something changed. This is important because the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used for the same scenario, otherwise, the card issuer will decline the charge.&lt;br /&gt;
A &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used again if:&lt;br /&gt;
* the funding source is the same (technically the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* the token payment scenario is the same (technically the &amp;lt;code&amp;gt;RecurrenceType&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* this subsequent request complies with the scenario restrictions (eg: in case of recurring payment the amount of the subsequent payment does not exceed the initial amount)&lt;br /&gt;
&lt;br /&gt;
If the funding source changes, new &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the funding source|described in detail here]]. If the funding source stays the same but the scenario changes or the restrictions are no longer met new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the token payment scenario with an existing token|described here]].&lt;br /&gt;
&lt;br /&gt;
=== Subsequent payment in case of Recurring payment scenario ===&lt;br /&gt;
&lt;br /&gt;
In this case, three extra conditions must be met:&lt;br /&gt;
* the amount of the subsequent payment must not be higher than the initial amount&lt;br /&gt;
* at least that much days must be spent as defined in the initial &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; property&lt;br /&gt;
* the date of the payment must not exceed the day specified in the initial &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; property&lt;br /&gt;
&lt;br /&gt;
Please be aware that in case any of these are no longer valid the merchant has to request a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; as [[#Changing the token payment scenario with an existing token|described here]]. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=These conditions are not enforced by the Barion system so the violation of them will result in a declined charge.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
Payment/start must not include the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; properties (since they are already fixed during the initial payment).&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Recurring payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Depending on the type of the subsequent payment, 3DSecure authentication might be required for subsequent payments.&lt;br /&gt;
3DS authentication is not required in the following cases:&lt;br /&gt;
* the token was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
* the subsequent payment is a merchant initiated payment.&lt;br /&gt;
&lt;br /&gt;
=== Prerequisites ===&lt;br /&gt;
To be able to use a token, the initial payment must be in a successful state.&lt;br /&gt;
&lt;br /&gt;
[[File:Token_payment_2.png]]&lt;br /&gt;
&lt;br /&gt;
=== OneClick payment ===&lt;br /&gt;
==== Step 1 : Initialize oneClick ====&lt;br /&gt;
You have to include the following css and javascript files in the code of your site. These files include all the necessary javascript code and styling to handle the 3DS authentication and display the challenge if necessary.&lt;br /&gt;
&amp;lt;source lang=html&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source &amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to initialize the Barion javascript client:&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const configuration = {&lt;br /&gt;
    onAuthenticationSucceeded: function () {&lt;br /&gt;
        // handle successful authentication by calling the Barion API via merchant&#039;s backend&lt;br /&gt;
        // Call the v2/payment/complete endpoint&lt;br /&gt;
    },&lt;br /&gt;
    onAuthenticationFailed: function () {&lt;br /&gt;
        // Handle unsuccessful authentication result, no charge was made.&lt;br /&gt;
        // The payment might be still valid only the authentication failed&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
const gw= new Barion.OffsiteGw(configuration);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Step 2 : Make a payment  ====&lt;br /&gt;
To use an already registered token for a payment, you have to call the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; and the appropriate [[RecurrenceType|Recurrence Type]] should be sent. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property along with the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Example Payment/Start json request =====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;E31EC263-01DC-40BD-BDF1-38FC7A332434&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot; : &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot; : false,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot; : &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot; : &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot; : &amp;quot;SHOP-XMLP-TRACEID-123&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR002&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;webshop@example.com&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subsription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Processing the Payment/Start response =====&lt;br /&gt;
To this request, the Barion API sends back the required data for the 3DS authentication for the specified paymentId.&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
! Field name&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| PaymentId&lt;br /&gt;
| Payment Identifier of the purchase in Barion&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| ThreeDSAuthClientData&lt;br /&gt;
| basae64 encoded 3DS client data&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Payment/Start response =====&lt;br /&gt;
&amp;lt;source lang=json line style=&amp;quot;word-break: break-all;&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot; : &amp;quot;dce46843-6266-4c1f-b82a-387e0fee9073&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot; : &amp;quot;ewoJIkNhcmRQdWJsaWNJZCI6ICIxYTE5M2E1NDQzNDI0YjJiOGJiMjMyOGRhNWY4NmYzYiIsCgkiUGF5bWVudElkIjogImRjZTQ2ODQzNjI2NjRjMWZiODJhMzg3ZTBmZWU5MDczIiwKCSJPbmVDbGlja0NvbnRlbnRVcmwiOiAiaHR0cDovL3NlY3VyZS5iYXJpb24uY29tL3RocmVlZHMvb25lY2xpY2twYXltZW50IiwKCSJBQ1NTdGFydFByb3RvY29sVmVyc2lvbiI6ICIyLjEuMCIsCgkiQUNTRW5kUHJvdG9jb2xWZXJzaW9uIjogIjIuMS4wIiwKCSJEU1N0YXJ0UHJvdG9jb2xWZXJzaW9uIjogIjIuMS4wIiwKCSJEU0VuZFByb3RvY29sVmVyc2lvbiI6ICIyLjIuMCIsCgkiVGhyZWVEU1NlcnZlclRyYW5zSUQiOiBudWxsLAoJIlRocmVlRFNNZXRob2RVUkwiOiBudWxsLAoJIlRocmVlRFNNZXRob2REYXRhRm9ybSI6ICJleUowYUhKbFpVUlRUV1YwYUc5a1RtOTBhV1pwWTJGMGFXOXVWVkpNSWpvaWFIUjBjSE02THk4elpITXVZbUZ5YVc5dUxtTnZiUzh6WkhNdmRqSXZNMlJ6TFcxbGRHaHZaQzF1YjNScFptbGpZWFJwYjI0aUxDSjBhSEpsWlVSVFUyVnlkbVZ5VkhKaGJuTkpSQ0k2SWpFNE5URTJPR0kxTFRKalkyUXROR0kxWlMxaVlqWm1MVFUzTW1VM00yVTNNemt3TnlKOSIsCgkiRXJyb3JEZXRhaWxzIjogbnVsbCwKCSJWZXJzaW9uIjogIjIuMS4wIgp9Cg==&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Step 3: 3DS authentication &amp;amp; challenge ====&lt;br /&gt;
This data then should be passed onto the &amp;lt;code&amp;gt;authenticate()&amp;lt;/code&amp;gt; method of the offsite gw manager, which will do all the magic to authenticate and display the challenge (if needed).&lt;br /&gt;
&amp;lt;source lang=javascript line highlight=&amp;quot;9&amp;quot;&amp;gt;&lt;br /&gt;
        // call Barion API via merchant&#039;s backend&lt;br /&gt;
        // once the result is returned continue with authentication&lt;br /&gt;
        $.ajax({&lt;br /&gt;
            url: &amp;quot;Url/Of/Your/Payment/Start&amp;quot;,&lt;br /&gt;
            method: &amp;quot;POST&amp;quot;,&lt;br /&gt;
            data: data,&lt;br /&gt;
            success: function (threeDsClientData) {&lt;br /&gt;
               // the threeDsClientData will be in the response of payment/start	&lt;br /&gt;
               gw.authenticate(threeDsClientData);&lt;br /&gt;
            }&lt;br /&gt;
         });&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the request is finished the appropriate callback is fired, the BarionClient was initialized with in [[#Step 1 : Initialize oneClick|Step 1]]. In case of successful authentication, you have to call our [[Payment-Complete-v3|/Payment/Complete]] endpoint, where the actual charge will happen.&lt;br /&gt;
&lt;br /&gt;
=== Recurring payment/Merchant Initiated payment ===&lt;br /&gt;
&lt;br /&gt;
For these types of payments, the subsequent payments are nearly identical to the process of [[#Creating_the_token|Creating the token]]. The only difference is that the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; received in the initial [[Payment-GetPaymentState-v2|GetPaymentState]] response must be sent in the &lt;br /&gt;
[[Payment-Start-v2|Payment/Start]] request. Also don&#039;t forget to set the appropriate [[RecurrenceType|Recurrence Type]].&lt;br /&gt;
&lt;br /&gt;
=== Possible error responses ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| InvalidRecurrenceId|| The token specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is invalid. Check if the token registration was successful.&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentDenied|| Something happened to the user since the token registration, either deleted, suspended, or blocked. The payment s not allowed in these cases.&lt;br /&gt;
|-&lt;br /&gt;
| InsufficientFunds|| If the original payment was with an e-money wallet and the customer doesn&#039;t have enough money to fulfill this charge this error happens.&lt;br /&gt;
|-&lt;br /&gt;
| OriginalPaymentWasntSuccessful || This means that the token belongs to an originally unsuccessful payment so this token can not be used anymore. This could only happen if the original payment was financed with a credit card.&lt;br /&gt;
|-&lt;br /&gt;
|InvalidCurrency || If the original payment was paid with e-money and the current token payment is in a currency that the wallet does not have an account in this error happens.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2856</id>
		<title>Token payment 3D Secure</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2856"/>
		<updated>2020-11-26T11:17:14Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* Subsequent payment in case of Recurring payment scenario */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Token Payment with 3D Secure}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{IncompletePage}}&lt;br /&gt;
&lt;br /&gt;
This payment scenario allows the integrator shop to register a token for a customer (and a funding source) in the Barion system and then, later on, using this token, charge the customer without redirecting her to the Barion Smart Gateway UI. The user may be present at the site of the merchant or she can be off-session as well, so the merchant can charge her e.g. for subscriptions. This means that the customer authorizes the shop to charge her card or Barion balance without typing in the card information or Barion login again.&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurring.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=Premium feature|text=This scenario is not allowed automatically for every approved shop and should be requested from Barion!|color=#1993c7}}&lt;br /&gt;
&lt;br /&gt;
= Token payment scenarios =&lt;br /&gt;
Token payment can be used in three use cases: &lt;br /&gt;
* &#039;&#039;&#039;Customer Initiated Payments&#039;&#039;&#039;: when the user is present on the website of the merchant and she decides to pay :&lt;br /&gt;
** &#039;&#039;&#039;OneClick payment&#039;&#039;&#039;: the user is charged upon her request initiated on the website of the merchant. Subsequent payments are subject to PSD2 SCA and as the user is present, she has to go through the authentication process.&lt;br /&gt;
* &#039;&#039;&#039;Merchant Initiated Payments&#039;&#039;&#039;: when the merchant initiates the payment without the user being present. It has two subtypes:&lt;br /&gt;
** &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: the user is charged with the same amount on a regular basis, typically in case of subscriptions. Subsequent payments are exempted from PSD2 SCA, but liability still shifts to the card issuer.&lt;br /&gt;
** &#039;&#039;&#039;MIT (merchant initiated transaction)&#039;&#039;&#039;: the user is charged on an irregular basis and/or with a different amount. Subsequent payments of this type are excluded from PSD2 SCA, the liability is on the merchant.&lt;br /&gt;
&lt;br /&gt;
== Customer participation ==&lt;br /&gt;
&lt;br /&gt;
Since the token scenario is suitable for both customer and merchant initiated payments here is a comparison about who starts the payment. This includes the regular, non-tokenized payment scenario as well:&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot; | Scenario&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Initial payment&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW &lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW&lt;br /&gt;
|-&lt;br /&gt;
| Non token (regular) payment || YES || YES || YES || YES &lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || YES || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| MIT || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #aaa; background-color:#eee; font-size: 0.8em; padding:5px 10px; display:inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; Token payment scenarios can be initiated with already registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; as well, in this case the customer may remain on the merchant&#039;s site. &lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements for the scenarios ==&lt;br /&gt;
&lt;br /&gt;
These token payment scenarios have different requirements, this table below summarizes the key differences.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Payment amount&lt;br /&gt;
! Payment frequency&lt;br /&gt;
! Liability in case of fraud&lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || Various || Various || Card issuer&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || Subsequent amounts must be equal or less than the initial amount  || Initial payment must define a minimum amount of days to wait between charges || Card issuer &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || Various  || Various || Merchant&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 3DS authentication of the payer ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be performed for every online card payment. These token payment scenarios also have to use this new secure way of authentication. &lt;br /&gt;
The initial payment of a token scenario must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
Here is a table to compare the 3DS authentication requirements:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Initial payment&lt;br /&gt;
! Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
| One-click payment || ✔️ || ✔️&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Real life examples ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phone bill&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Payer has a usage-based phone subscription that wants to pay without being present for every charge. She authorizes the phone company to charge her card every month.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, the amount of the subsequent payments may exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TV subscription&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to online streaming of a television channel. She authorizes the phone company to charge her card every month. The subscription fee is the same for every month.&lt;br /&gt;
* Scenario: Recurring payment&lt;br /&gt;
* Explanation: The amount of the subsequent payments will not exceed the initial payment and the charge is regularly monthly-based.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bookclub with &amp;quot;free first month&amp;quot; bonus&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to a book renting service. She authorizes the book club to charge her card every month for a selection of books. The subscription fee is the same for every month however, the first month is free. To ensure the subscription the service requires her to register her card details.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, and the fee will stay the same, the initial payment is zero. So the amount of the next payment will exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Online food delivery service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The food delivery company wants to provide a quick and easy experience for its customer. They decide that the order will be quicker if the customers don&#039;t leave the website to pay for the goods.&lt;br /&gt;
* Scenario: OneClick payment&lt;br /&gt;
* Explanation: The customer will always be there so the other two scenarios are not available.&lt;br /&gt;
&lt;br /&gt;
== How to decide ==&lt;br /&gt;
&lt;br /&gt;
To help you decide on a suitable scenario, please use the decision graph below:&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurrencetype-decision.png|520px]]&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
To be able to integrate your webshop with the Barion Payment Gateway: &lt;br /&gt;
* You must [[Creating_an_account|register a Barion wallet]] at the Barion website or in the Sandbox environment. Learn more about the Sandbox environment [[Sandbox|here]].&lt;br /&gt;
* For this wallet you have to [[Creating_a_shop|create a shop]] which should be approved by Barion.&lt;br /&gt;
* For every currency you plan to conduct payments in you have to make sure there is an account created in your Barion wallet. This means that if you plan to have USD payments then there should be a USD account created in your wallet.&lt;br /&gt;
* To make sure every corner case scenario works for your webshop it is best to top up that account with a small amount (approx. 5-10EUR or your choice of currency around the same value).&lt;br /&gt;
* For the technical communication guide please read this: [[Calling_the_API|Calling the API]]&lt;br /&gt;
&lt;br /&gt;
= The payment process =&lt;br /&gt;
&lt;br /&gt;
The process is divided into two major steps:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 1:  Creating the funding source token|Creating the token]] that represents one of the customer&#039;s funding sources (credit card or e-money wallet)&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Preparing the payment via the Barion API&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Redirecting the customer to the Barion Smart Gateway to select a funding source&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Processing the callback and requesting information about the result of the payment&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 2: Using the token|Using the registered token]] to charge the customer&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Sending the payment request to the Barion API &lt;br /&gt;
             &amp;lt;ol&amp;gt;&lt;br /&gt;
                &amp;lt;li&amp;gt;Using the token for the same token payment scenario&amp;lt;/li&amp;gt;&lt;br /&gt;
                &amp;lt;li&amp;gt;Using the token for a different token payment scenario&amp;lt;/li&amp;gt;&lt;br /&gt;
            &amp;lt;/ol&amp;gt;&lt;br /&gt;
         &amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Performing on-site 3DS authentication (if needed)&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1:  Creating the funding source token ==&lt;br /&gt;
To be able to use a token payment scenario first the merchant has to register the token with Barion. The merchant has to make sure that the customer is well aware of the fact that they are giving consent to a tokenized payment. The Barion Smart Gateway UI does not indicate in any way that the payment is a token payment.&lt;br /&gt;
&lt;br /&gt;
The token is registered to the shop and not to the merchant&#039;s Barion account. So if the merchant has multiple shops in its Barion account, the registered tokens can not be shared among them even if the customer is the same. If you want to use tokens in multiple shops, please contact Barion in the Customer center.&lt;br /&gt;
&lt;br /&gt;
=== 1.1 Preparing the payment===&lt;br /&gt;
&lt;br /&gt;
The token registration is basically a [[Responsive_web_payment|normal payment]] with three extra properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* InitiateRecurrence&lt;br /&gt;
* RecurrenceId&lt;br /&gt;
* RecurrenceType&lt;br /&gt;
&lt;br /&gt;
==== InitiateRecurrence====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; property is a bool property. If you set it to &#039;&#039;&#039;true&#039;&#039;&#039; then the payment gateway will consider the payment as a token registration. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This happens even if the customer is already has a registered token, so you are able to re-register a funding source or even a customer. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceId ====&lt;br /&gt;
The next required property for a token registration is the token itself. This is generated by the shop and has to be unique for every registration. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property of the [[Payment-Start-v2|Payment/Start]] request. This token must be saved in the webshops database. A &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; token represents the funding source (bank card or Barion balance) of a customer. Since a customer can have multiple cards and accounts as a funding source make sure that in the webshop&#039;s system multiple tokens can belong to a single customer.&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceType ====&lt;br /&gt;
The third required property is the [[RecurrenceType|Recurrence Type]]. This specifies the scenario. In case of Recurring Payment &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; must also be set.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Merchant Initiated Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The response will be the same as to a [[Responsive_web_payment#Processing_the_successful_response|basic &#039;&#039;&#039;Immediate&#039;&#039;&#039; scenario]]. The &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; property at this point is &#039;&#039;&#039;None&#039;&#039;&#039; since the token is not registered to a funding source yet.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Recurring Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Recurring Payment&#039;&#039;&#039; scenario has some extra restrictions. The merchant has to specify two additional properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt;: The date after the subsequent charges should not accepted.&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt;: The minimum days the merchant has to wait between payments.&lt;br /&gt;
&lt;br /&gt;
Both properties are located in the [[PurchaseInformation]] property and must be specified if this scenario is selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7, 30-33&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;PurchaseInformation&amp;quot;:{&lt;br /&gt;
        &amp;quot;RecurringFrequency&amp;quot;: 10,&lt;br /&gt;
        &amp;quot;RecurringExpiry&amp;quot;: &amp;quot;2022-10-01&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Possible error responses ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentNotAllowed || The token payment is not allowed for the shop identified by the &#039;&#039;&#039;POSKey&#039;&#039;&#039;. Contact Barion to request this feature.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 1.2 Redirecting the customer to the Barion Smart Gateway to select a funding source ===&lt;br /&gt;
&lt;br /&gt;
After a successful payment preparation, the customer is redirected to the secure Barion Smart Gateway to choose a funding source. The funding source the customer selects will be registered to the token. The funding source can either be a Barion e-money balance or a bank card. This means that even though the customer may own multiple cards only the one that was registered to the token can be used for future token payments. To change the funding source attached to the token a new registration should be requested.&lt;br /&gt;
&lt;br /&gt;
=== 1.3 Processing the callback and requesting information about the result of the payment ===&lt;br /&gt;
&lt;br /&gt;
When the payment is completed (either successfully or unsuccessfully) a callback message is sent to the merchant&#039;s system. Once received a [[Payment-GetPaymentState-v2|GetPaymentState]] request must be sent to the Barion API. On how to implement this please read the article about the  [[Callback_mechanism|Callback mechanism]].&lt;br /&gt;
&lt;br /&gt;
The full response of the GetPaymentState request depends on the payment scenario and the structure of the payment. When it comes to token payment there are several properties to look out for. &lt;br /&gt;
* In case the &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; is &#039;&#039;&#039;Succeeded&#039;&#039;&#039; the funding source token is registered and ready to use.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; contains the ID of the token process. This specifies the nature of the token payment. &lt;br /&gt;
&lt;br /&gt;
==== TraceId ====&lt;br /&gt;
&lt;br /&gt;
In case of Recurring payment or Merchant initiated payment scenarios the [[Payment-GetPaymentState-v2|GetPaymentState]] response returns an additional field called &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. The value of this property is generated by the card issuer. The merchant has to save it and submit it in all subsequent Recurring or Merchant initiated payments of the same type, otherwise, the payments can be declined by the issuer. The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; represents the first, customer-present payment and helps the issuer to connect subsequent payments to this initial payment.&lt;br /&gt;
&lt;br /&gt;
====Example GetPaymentState response====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;8, 11-12&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;OrderNumber&amp;quot;: null,&lt;br /&gt;
    &amp;quot;POSId&amp;quot;: &amp;quot;[[SHOPS_PUBLIC_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSName&amp;quot;: &amp;quot;[[MERCHANTS_BARION_SHOPNAME]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSOwnerEmail&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSource&amp;quot;: &amp;quot;BankCard&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;AllowedFundingSources&amp;quot;: [&lt;br /&gt;
        &amp;quot;All&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;GuestCheckout&amp;quot;: true,&lt;br /&gt;
    &amp;quot;CreatedAt&amp;quot;: &amp;quot;2020-11-26T07:52:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ValidUntil&amp;quot;: &amp;quot;2020-11-26T08:22:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;CompletedAt&amp;quot;: &amp;quot;2020-11-26T08:11:54.118Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ReservedUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;DelayedCaptureUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
           ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;Total&amp;quot;: 25.20,&lt;br /&gt;
    &amp;quot;SuggestedLocale&amp;quot;: &amp;quot;hu-HU&amp;quot;,&lt;br /&gt;
    &amp;quot;FraudRiskScore&amp;quot;: null,&lt;br /&gt;
    &amp;quot;RedirectUrl&amp;quot;: &amp;quot;https://merchanturl/Redirect?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;CallbackUrl&amp;quot;: &amp;quot;https://merchanturl/Callback?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Displaying the funding source in a GUI ====&lt;br /&gt;
We strongly advise saving the complete response for future reference. The &amp;lt;code&amp;gt;FundingSource&amp;lt;/code&amp;gt; field tells if the funding source is a Barion balance or a card. If it is a card, it is useful to save [[FundingInformation]] for displaying it for the user, when requesting future payments. The usual way to display funding sources is to show the last 4 digits of the card, with 4 stars, eg: *** 1234. The card used can be obtained from FundingInformation&#039;s [[BankCard]] field. The [[CardType]] field can be used to display the appropriate card logo. You can even show, if the card is expired, and offer to register another one.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; FundingInformation part of the GetPaymentState response &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=json&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be displayed for example as &amp;lt;code&amp;gt;VISA **** 0425 (12/20)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a request-response diagram of the token registration process:&lt;br /&gt;
 &lt;br /&gt;
[[File:Token_payment_initiation.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Step 2: Using the token =&lt;br /&gt;
&lt;br /&gt;
==2.1 Sending the payment request to the Barion API ==&lt;br /&gt;
&lt;br /&gt;
To use an already registered token for a payment, you have to use the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
At this point, the merchant has to decide whether this subsequent payment is used for the same token payment scenario or something changed. This is important because the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used for the same scenario, otherwise, the card issuer will decline the charge.&lt;br /&gt;
A &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used again if:&lt;br /&gt;
* the funding source is the same (technically the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* the token payment scenario is the same (technically the &amp;lt;code&amp;gt;RecurrenceType&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* this subsequent request complies with the scenario restrictions (eg: in case of recurring payment the amount of the subsequent payment does not exceed the initial amount)&lt;br /&gt;
&lt;br /&gt;
If the funding source changes, new &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the funding source|described in detail here]]. If the funding source stays the same but the scenario changes or the restrictions are no longer met new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the token payment scenario with an existing token|described here]].&lt;br /&gt;
&lt;br /&gt;
=== Subsequent payment in case of Recurring payment scenario ===&lt;br /&gt;
&lt;br /&gt;
In this case, three extra conditions must be met:&lt;br /&gt;
* the amount of the subsequent payment must not be higher than the initial amount&lt;br /&gt;
* at least that much days must be spent as defined in the initial &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; property&lt;br /&gt;
* the date of the payment must not exceed the day specified in the initial &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; property&lt;br /&gt;
&lt;br /&gt;
Please be aware that in case any of these does not stand the merchant has to request a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; as [[#Changing the token payment scenario with an existing token|described here]]. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=These conditions are not enforced by the Barion system so the violation of them will result in a declined charge.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
Payment/start must not include the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; properties (since they are already fixed during the initial payment).&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Recurring payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Depending on the type of the subsequent payment, 3DSecure authentication might be required for subsequent payments.&lt;br /&gt;
3DS authentication is not required in the following cases:&lt;br /&gt;
* the token was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
* the subsequent payment is a merchant initiated payment.&lt;br /&gt;
&lt;br /&gt;
=== Prerequisites ===&lt;br /&gt;
To be able to use a token, the initial payment must be in a successful state.&lt;br /&gt;
&lt;br /&gt;
[[File:Token_payment_2.png]]&lt;br /&gt;
&lt;br /&gt;
=== OneClick payment ===&lt;br /&gt;
==== Step 1 : Initialize oneClick ====&lt;br /&gt;
You have to include the following css and javascript files in the code of your site. These files include all the necessary javascript code and styling to handle the 3DS authentication and display the challenge if necessary.&lt;br /&gt;
&amp;lt;source lang=html&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source &amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to initialize the Barion javascript client:&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const configuration = {&lt;br /&gt;
    onAuthenticationSucceeded: function () {&lt;br /&gt;
        // handle successful authentication by calling the Barion API via merchant&#039;s backend&lt;br /&gt;
        // Call the v2/payment/complete endpoint&lt;br /&gt;
    },&lt;br /&gt;
    onAuthenticationFailed: function () {&lt;br /&gt;
        // Handle unsuccessful authentication result, no charge was made.&lt;br /&gt;
        // The payment might be still valid only the authentication failed&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
const gw= new Barion.OffsiteGw(configuration);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Step 2 : Make a payment  ====&lt;br /&gt;
To use an already registered token for a payment, you have to call the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; and the appropriate [[RecurrenceType|Recurrence Type]] should be sent. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property along with the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Example Payment/Start json request =====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;E31EC263-01DC-40BD-BDF1-38FC7A332434&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot; : &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot; : false,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot; : &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot; : &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot; : &amp;quot;SHOP-XMLP-TRACEID-123&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR002&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;webshop@example.com&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subsription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Processing the Payment/Start response =====&lt;br /&gt;
To this request, the Barion API sends back the required data for the 3DS authentication for the specified paymentId.&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
! Field name&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| PaymentId&lt;br /&gt;
| Payment Identifier of the purchase in Barion&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| ThreeDSAuthClientData&lt;br /&gt;
| basae64 encoded 3DS client data&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Payment/Start response =====&lt;br /&gt;
&amp;lt;source lang=json line style=&amp;quot;word-break: break-all;&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot; : &amp;quot;dce46843-6266-4c1f-b82a-387e0fee9073&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot; : &amp;quot;ewoJIkNhcmRQdWJsaWNJZCI6ICIxYTE5M2E1NDQzNDI0YjJiOGJiMjMyOGRhNWY4NmYzYiIsCgkiUGF5bWVudElkIjogImRjZTQ2ODQzNjI2NjRjMWZiODJhMzg3ZTBmZWU5MDczIiwKCSJPbmVDbGlja0NvbnRlbnRVcmwiOiAiaHR0cDovL3NlY3VyZS5iYXJpb24uY29tL3RocmVlZHMvb25lY2xpY2twYXltZW50IiwKCSJBQ1NTdGFydFByb3RvY29sVmVyc2lvbiI6ICIyLjEuMCIsCgkiQUNTRW5kUHJvdG9jb2xWZXJzaW9uIjogIjIuMS4wIiwKCSJEU1N0YXJ0UHJvdG9jb2xWZXJzaW9uIjogIjIuMS4wIiwKCSJEU0VuZFByb3RvY29sVmVyc2lvbiI6ICIyLjIuMCIsCgkiVGhyZWVEU1NlcnZlclRyYW5zSUQiOiBudWxsLAoJIlRocmVlRFNNZXRob2RVUkwiOiBudWxsLAoJIlRocmVlRFNNZXRob2REYXRhRm9ybSI6ICJleUowYUhKbFpVUlRUV1YwYUc5a1RtOTBhV1pwWTJGMGFXOXVWVkpNSWpvaWFIUjBjSE02THk4elpITXVZbUZ5YVc5dUxtTnZiUzh6WkhNdmRqSXZNMlJ6TFcxbGRHaHZaQzF1YjNScFptbGpZWFJwYjI0aUxDSjBhSEpsWlVSVFUyVnlkbVZ5VkhKaGJuTkpSQ0k2SWpFNE5URTJPR0kxTFRKalkyUXROR0kxWlMxaVlqWm1MVFUzTW1VM00yVTNNemt3TnlKOSIsCgkiRXJyb3JEZXRhaWxzIjogbnVsbCwKCSJWZXJzaW9uIjogIjIuMS4wIgp9Cg==&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Step 3: 3DS authentication &amp;amp; challenge ====&lt;br /&gt;
This data then should be passed onto the &amp;lt;code&amp;gt;authenticate()&amp;lt;/code&amp;gt; method of the offsite gw manager, which will do all the magic to authenticate and display the challenge (if needed).&lt;br /&gt;
&amp;lt;source lang=javascript line highlight=&amp;quot;9&amp;quot;&amp;gt;&lt;br /&gt;
        // call Barion API via merchant&#039;s backend&lt;br /&gt;
        // once the result is returned continue with authentication&lt;br /&gt;
        $.ajax({&lt;br /&gt;
            url: &amp;quot;Url/Of/Your/Payment/Start&amp;quot;,&lt;br /&gt;
            method: &amp;quot;POST&amp;quot;,&lt;br /&gt;
            data: data,&lt;br /&gt;
            success: function (threeDsClientData) {&lt;br /&gt;
               // the threeDsClientData will be in the response of payment/start	&lt;br /&gt;
               gw.authenticate(threeDsClientData);&lt;br /&gt;
            }&lt;br /&gt;
         });&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the request is finished the appropriate callback is fired, the BarionClient was initialized with in [[#Step 1 : Initialize oneClick|Step 1]]. In case of successful authentication, you have to call our [[Payment-Complete-v3|/Payment/Complete]] endpoint, where the actual charge will happen.&lt;br /&gt;
&lt;br /&gt;
=== Recurring payment/Merchant Initiated payment ===&lt;br /&gt;
&lt;br /&gt;
For these types of payments, the subsequent payments are nearly identical to the process of [[#Creating_the_token|Creating the token]]. The only difference is that the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; received in the initial [[Payment-GetPaymentState-v2|GetPaymentState]] response must be sent in the &lt;br /&gt;
[[Payment-Start-v2|Payment/Start]] request. Also don&#039;t forget to set the appropriate [[RecurrenceType|Recurrence Type]].&lt;br /&gt;
&lt;br /&gt;
=== Possible error responses ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| InvalidRecurrenceId|| The token specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is invalid. Check if the token registration was successful.&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentDenied|| Something happened to the user since the token registration, either deleted, suspended, or blocked. The payment s not allowed in these cases.&lt;br /&gt;
|-&lt;br /&gt;
| InsufficientFunds|| If the original payment was with an e-money wallet and the customer doesn&#039;t have enough money to fulfill this charge this error happens.&lt;br /&gt;
|-&lt;br /&gt;
| OriginalPaymentWasntSuccessful || This means that the token belongs to an originally unsuccessful payment so this token can not be used anymore. This could only happen if the original payment was financed with a credit card.&lt;br /&gt;
|-&lt;br /&gt;
|InvalidCurrency || If the original payment was paid with e-money and the current token payment is in a currency that the wallet does not have an account in this error happens.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2855</id>
		<title>Token payment 3D Secure</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2855"/>
		<updated>2020-11-26T11:16:55Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* 2.1 Sending the payment request to the Barion API */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Token Payment with 3D Secure}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{IncompletePage}}&lt;br /&gt;
&lt;br /&gt;
This payment scenario allows the integrator shop to register a token for a customer (and a funding source) in the Barion system and then, later on, using this token, charge the customer without redirecting her to the Barion Smart Gateway UI. The user may be present at the site of the merchant or she can be off-session as well, so the merchant can charge her e.g. for subscriptions. This means that the customer authorizes the shop to charge her card or Barion balance without typing in the card information or Barion login again.&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurring.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=Premium feature|text=This scenario is not allowed automatically for every approved shop and should be requested from Barion!|color=#1993c7}}&lt;br /&gt;
&lt;br /&gt;
= Token payment scenarios =&lt;br /&gt;
Token payment can be used in three use cases: &lt;br /&gt;
* &#039;&#039;&#039;Customer Initiated Payments&#039;&#039;&#039;: when the user is present on the website of the merchant and she decides to pay :&lt;br /&gt;
** &#039;&#039;&#039;OneClick payment&#039;&#039;&#039;: the user is charged upon her request initiated on the website of the merchant. Subsequent payments are subject to PSD2 SCA and as the user is present, she has to go through the authentication process.&lt;br /&gt;
* &#039;&#039;&#039;Merchant Initiated Payments&#039;&#039;&#039;: when the merchant initiates the payment without the user being present. It has two subtypes:&lt;br /&gt;
** &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: the user is charged with the same amount on a regular basis, typically in case of subscriptions. Subsequent payments are exempted from PSD2 SCA, but liability still shifts to the card issuer.&lt;br /&gt;
** &#039;&#039;&#039;MIT (merchant initiated transaction)&#039;&#039;&#039;: the user is charged on an irregular basis and/or with a different amount. Subsequent payments of this type are excluded from PSD2 SCA, the liability is on the merchant.&lt;br /&gt;
&lt;br /&gt;
== Customer participation ==&lt;br /&gt;
&lt;br /&gt;
Since the token scenario is suitable for both customer and merchant initiated payments here is a comparison about who starts the payment. This includes the regular, non-tokenized payment scenario as well:&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot; | Scenario&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Initial payment&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW &lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW&lt;br /&gt;
|-&lt;br /&gt;
| Non token (regular) payment || YES || YES || YES || YES &lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || YES || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| MIT || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #aaa; background-color:#eee; font-size: 0.8em; padding:5px 10px; display:inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; Token payment scenarios can be initiated with already registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; as well, in this case the customer may remain on the merchant&#039;s site. &lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements for the scenarios ==&lt;br /&gt;
&lt;br /&gt;
These token payment scenarios have different requirements, this table below summarizes the key differences.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Payment amount&lt;br /&gt;
! Payment frequency&lt;br /&gt;
! Liability in case of fraud&lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || Various || Various || Card issuer&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || Subsequent amounts must be equal or less than the initial amount  || Initial payment must define a minimum amount of days to wait between charges || Card issuer &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || Various  || Various || Merchant&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 3DS authentication of the payer ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be performed for every online card payment. These token payment scenarios also have to use this new secure way of authentication. &lt;br /&gt;
The initial payment of a token scenario must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
Here is a table to compare the 3DS authentication requirements:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Initial payment&lt;br /&gt;
! Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
| One-click payment || ✔️ || ✔️&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Real life examples ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phone bill&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Payer has a usage-based phone subscription that wants to pay without being present for every charge. She authorizes the phone company to charge her card every month.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, the amount of the subsequent payments may exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TV subscription&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to online streaming of a television channel. She authorizes the phone company to charge her card every month. The subscription fee is the same for every month.&lt;br /&gt;
* Scenario: Recurring payment&lt;br /&gt;
* Explanation: The amount of the subsequent payments will not exceed the initial payment and the charge is regularly monthly-based.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bookclub with &amp;quot;free first month&amp;quot; bonus&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to a book renting service. She authorizes the book club to charge her card every month for a selection of books. The subscription fee is the same for every month however, the first month is free. To ensure the subscription the service requires her to register her card details.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, and the fee will stay the same, the initial payment is zero. So the amount of the next payment will exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Online food delivery service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The food delivery company wants to provide a quick and easy experience for its customer. They decide that the order will be quicker if the customers don&#039;t leave the website to pay for the goods.&lt;br /&gt;
* Scenario: OneClick payment&lt;br /&gt;
* Explanation: The customer will always be there so the other two scenarios are not available.&lt;br /&gt;
&lt;br /&gt;
== How to decide ==&lt;br /&gt;
&lt;br /&gt;
To help you decide on a suitable scenario, please use the decision graph below:&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurrencetype-decision.png|520px]]&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
To be able to integrate your webshop with the Barion Payment Gateway: &lt;br /&gt;
* You must [[Creating_an_account|register a Barion wallet]] at the Barion website or in the Sandbox environment. Learn more about the Sandbox environment [[Sandbox|here]].&lt;br /&gt;
* For this wallet you have to [[Creating_a_shop|create a shop]] which should be approved by Barion.&lt;br /&gt;
* For every currency you plan to conduct payments in you have to make sure there is an account created in your Barion wallet. This means that if you plan to have USD payments then there should be a USD account created in your wallet.&lt;br /&gt;
* To make sure every corner case scenario works for your webshop it is best to top up that account with a small amount (approx. 5-10EUR or your choice of currency around the same value).&lt;br /&gt;
* For the technical communication guide please read this: [[Calling_the_API|Calling the API]]&lt;br /&gt;
&lt;br /&gt;
= The payment process =&lt;br /&gt;
&lt;br /&gt;
The process is divided into two major steps:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 1:  Creating the funding source token|Creating the token]] that represents one of the customer&#039;s funding sources (credit card or e-money wallet)&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Preparing the payment via the Barion API&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Redirecting the customer to the Barion Smart Gateway to select a funding source&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Processing the callback and requesting information about the result of the payment&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 2: Using the token|Using the registered token]] to charge the customer&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Sending the payment request to the Barion API &lt;br /&gt;
             &amp;lt;ol&amp;gt;&lt;br /&gt;
                &amp;lt;li&amp;gt;Using the token for the same token payment scenario&amp;lt;/li&amp;gt;&lt;br /&gt;
                &amp;lt;li&amp;gt;Using the token for a different token payment scenario&amp;lt;/li&amp;gt;&lt;br /&gt;
            &amp;lt;/ol&amp;gt;&lt;br /&gt;
         &amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Performing on-site 3DS authentication (if needed)&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1:  Creating the funding source token ==&lt;br /&gt;
To be able to use a token payment scenario first the merchant has to register the token with Barion. The merchant has to make sure that the customer is well aware of the fact that they are giving consent to a tokenized payment. The Barion Smart Gateway UI does not indicate in any way that the payment is a token payment.&lt;br /&gt;
&lt;br /&gt;
The token is registered to the shop and not to the merchant&#039;s Barion account. So if the merchant has multiple shops in its Barion account, the registered tokens can not be shared among them even if the customer is the same. If you want to use tokens in multiple shops, please contact Barion in the Customer center.&lt;br /&gt;
&lt;br /&gt;
=== 1.1 Preparing the payment===&lt;br /&gt;
&lt;br /&gt;
The token registration is basically a [[Responsive_web_payment|normal payment]] with three extra properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* InitiateRecurrence&lt;br /&gt;
* RecurrenceId&lt;br /&gt;
* RecurrenceType&lt;br /&gt;
&lt;br /&gt;
==== InitiateRecurrence====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; property is a bool property. If you set it to &#039;&#039;&#039;true&#039;&#039;&#039; then the payment gateway will consider the payment as a token registration. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This happens even if the customer is already has a registered token, so you are able to re-register a funding source or even a customer. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceId ====&lt;br /&gt;
The next required property for a token registration is the token itself. This is generated by the shop and has to be unique for every registration. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property of the [[Payment-Start-v2|Payment/Start]] request. This token must be saved in the webshops database. A &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; token represents the funding source (bank card or Barion balance) of a customer. Since a customer can have multiple cards and accounts as a funding source make sure that in the webshop&#039;s system multiple tokens can belong to a single customer.&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceType ====&lt;br /&gt;
The third required property is the [[RecurrenceType|Recurrence Type]]. This specifies the scenario. In case of Recurring Payment &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; must also be set.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Merchant Initiated Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The response will be the same as to a [[Responsive_web_payment#Processing_the_successful_response|basic &#039;&#039;&#039;Immediate&#039;&#039;&#039; scenario]]. The &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; property at this point is &#039;&#039;&#039;None&#039;&#039;&#039; since the token is not registered to a funding source yet.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Recurring Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Recurring Payment&#039;&#039;&#039; scenario has some extra restrictions. The merchant has to specify two additional properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt;: The date after the subsequent charges should not accepted.&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt;: The minimum days the merchant has to wait between payments.&lt;br /&gt;
&lt;br /&gt;
Both properties are located in the [[PurchaseInformation]] property and must be specified if this scenario is selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7, 30-33&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;PurchaseInformation&amp;quot;:{&lt;br /&gt;
        &amp;quot;RecurringFrequency&amp;quot;: 10,&lt;br /&gt;
        &amp;quot;RecurringExpiry&amp;quot;: &amp;quot;2022-10-01&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Possible error responses ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentNotAllowed || The token payment is not allowed for the shop identified by the &#039;&#039;&#039;POSKey&#039;&#039;&#039;. Contact Barion to request this feature.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 1.2 Redirecting the customer to the Barion Smart Gateway to select a funding source ===&lt;br /&gt;
&lt;br /&gt;
After a successful payment preparation, the customer is redirected to the secure Barion Smart Gateway to choose a funding source. The funding source the customer selects will be registered to the token. The funding source can either be a Barion e-money balance or a bank card. This means that even though the customer may own multiple cards only the one that was registered to the token can be used for future token payments. To change the funding source attached to the token a new registration should be requested.&lt;br /&gt;
&lt;br /&gt;
=== 1.3 Processing the callback and requesting information about the result of the payment ===&lt;br /&gt;
&lt;br /&gt;
When the payment is completed (either successfully or unsuccessfully) a callback message is sent to the merchant&#039;s system. Once received a [[Payment-GetPaymentState-v2|GetPaymentState]] request must be sent to the Barion API. On how to implement this please read the article about the  [[Callback_mechanism|Callback mechanism]].&lt;br /&gt;
&lt;br /&gt;
The full response of the GetPaymentState request depends on the payment scenario and the structure of the payment. When it comes to token payment there are several properties to look out for. &lt;br /&gt;
* In case the &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; is &#039;&#039;&#039;Succeeded&#039;&#039;&#039; the funding source token is registered and ready to use.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; contains the ID of the token process. This specifies the nature of the token payment. &lt;br /&gt;
&lt;br /&gt;
==== TraceId ====&lt;br /&gt;
&lt;br /&gt;
In case of Recurring payment or Merchant initiated payment scenarios the [[Payment-GetPaymentState-v2|GetPaymentState]] response returns an additional field called &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. The value of this property is generated by the card issuer. The merchant has to save it and submit it in all subsequent Recurring or Merchant initiated payments of the same type, otherwise, the payments can be declined by the issuer. The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; represents the first, customer-present payment and helps the issuer to connect subsequent payments to this initial payment.&lt;br /&gt;
&lt;br /&gt;
====Example GetPaymentState response====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;8, 11-12&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;OrderNumber&amp;quot;: null,&lt;br /&gt;
    &amp;quot;POSId&amp;quot;: &amp;quot;[[SHOPS_PUBLIC_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSName&amp;quot;: &amp;quot;[[MERCHANTS_BARION_SHOPNAME]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSOwnerEmail&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSource&amp;quot;: &amp;quot;BankCard&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;AllowedFundingSources&amp;quot;: [&lt;br /&gt;
        &amp;quot;All&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;GuestCheckout&amp;quot;: true,&lt;br /&gt;
    &amp;quot;CreatedAt&amp;quot;: &amp;quot;2020-11-26T07:52:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ValidUntil&amp;quot;: &amp;quot;2020-11-26T08:22:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;CompletedAt&amp;quot;: &amp;quot;2020-11-26T08:11:54.118Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ReservedUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;DelayedCaptureUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
           ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;Total&amp;quot;: 25.20,&lt;br /&gt;
    &amp;quot;SuggestedLocale&amp;quot;: &amp;quot;hu-HU&amp;quot;,&lt;br /&gt;
    &amp;quot;FraudRiskScore&amp;quot;: null,&lt;br /&gt;
    &amp;quot;RedirectUrl&amp;quot;: &amp;quot;https://merchanturl/Redirect?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;CallbackUrl&amp;quot;: &amp;quot;https://merchanturl/Callback?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Displaying the funding source in a GUI ====&lt;br /&gt;
We strongly advise saving the complete response for future reference. The &amp;lt;code&amp;gt;FundingSource&amp;lt;/code&amp;gt; field tells if the funding source is a Barion balance or a card. If it is a card, it is useful to save [[FundingInformation]] for displaying it for the user, when requesting future payments. The usual way to display funding sources is to show the last 4 digits of the card, with 4 stars, eg: *** 1234. The card used can be obtained from FundingInformation&#039;s [[BankCard]] field. The [[CardType]] field can be used to display the appropriate card logo. You can even show, if the card is expired, and offer to register another one.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; FundingInformation part of the GetPaymentState response &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=json&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be displayed for example as &amp;lt;code&amp;gt;VISA **** 0425 (12/20)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a request-response diagram of the token registration process:&lt;br /&gt;
 &lt;br /&gt;
[[File:Token_payment_initiation.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Step 2: Using the token =&lt;br /&gt;
&lt;br /&gt;
==2.1 Sending the payment request to the Barion API ==&lt;br /&gt;
&lt;br /&gt;
To use an already registered token for a payment, you have to use the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
At this point, the merchant has to decide whether this subsequent payment is used for the same token payment scenario or something changed. This is important because the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used for the same scenario, otherwise, the card issuer will decline the charge.&lt;br /&gt;
A &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used again if:&lt;br /&gt;
* the funding source is the same (technically the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* the token payment scenario is the same (technically the &amp;lt;code&amp;gt;RecurrenceType&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* this subsequent request complies with the scenario restrictions (eg: in case of recurring payment the amount of the subsequent payment does not exceed the initial amount)&lt;br /&gt;
&lt;br /&gt;
If the funding source changes, new &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the funding source|described in detail here]]. If the funding source stays the same but the scenario changes or the restrictions are no longer met new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the token payment scenario with an existing token|described here]].&lt;br /&gt;
&lt;br /&gt;
=== Subsequent payment in case of Recurring payment scenario ===&lt;br /&gt;
&lt;br /&gt;
In this case, three extra conditions must be met:&lt;br /&gt;
* the amount of the subsequent payment must not be higher than the initial amount&lt;br /&gt;
* at least that much days must be spent as defined in the initial &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; property&lt;br /&gt;
* the date of the payment must not exceed the day specified in the initial &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; property&lt;br /&gt;
&lt;br /&gt;
Please be aware that in case any of these does not stand the merchant has to request a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; as [#Changing the token payment scenario with an existing token|described here]]. &lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=IMPORTANT|text=These conditions are not enforced by the Barion system so the violation of them will result in a declined charge.|color=#FF7A3D}}&lt;br /&gt;
&lt;br /&gt;
Payment/start must not include the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; properties (since they are already fixed during the initial payment).&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Recurring payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Depending on the type of the subsequent payment, 3DSecure authentication might be required for subsequent payments.&lt;br /&gt;
3DS authentication is not required in the following cases:&lt;br /&gt;
* the token was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
* the subsequent payment is a merchant initiated payment.&lt;br /&gt;
&lt;br /&gt;
=== Prerequisites ===&lt;br /&gt;
To be able to use a token, the initial payment must be in a successful state.&lt;br /&gt;
&lt;br /&gt;
[[File:Token_payment_2.png]]&lt;br /&gt;
&lt;br /&gt;
=== OneClick payment ===&lt;br /&gt;
==== Step 1 : Initialize oneClick ====&lt;br /&gt;
You have to include the following css and javascript files in the code of your site. These files include all the necessary javascript code and styling to handle the 3DS authentication and display the challenge if necessary.&lt;br /&gt;
&amp;lt;source lang=html&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source &amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to initialize the Barion javascript client:&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const configuration = {&lt;br /&gt;
    onAuthenticationSucceeded: function () {&lt;br /&gt;
        // handle successful authentication by calling the Barion API via merchant&#039;s backend&lt;br /&gt;
        // Call the v2/payment/complete endpoint&lt;br /&gt;
    },&lt;br /&gt;
    onAuthenticationFailed: function () {&lt;br /&gt;
        // Handle unsuccessful authentication result, no charge was made.&lt;br /&gt;
        // The payment might be still valid only the authentication failed&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
const gw= new Barion.OffsiteGw(configuration);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Step 2 : Make a payment  ====&lt;br /&gt;
To use an already registered token for a payment, you have to call the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; and the appropriate [[RecurrenceType|Recurrence Type]] should be sent. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property along with the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Example Payment/Start json request =====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;E31EC263-01DC-40BD-BDF1-38FC7A332434&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot; : &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot; : false,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot; : &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot; : &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot; : &amp;quot;SHOP-XMLP-TRACEID-123&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR002&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;webshop@example.com&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subsription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Processing the Payment/Start response =====&lt;br /&gt;
To this request, the Barion API sends back the required data for the 3DS authentication for the specified paymentId.&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
! Field name&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| PaymentId&lt;br /&gt;
| Payment Identifier of the purchase in Barion&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| ThreeDSAuthClientData&lt;br /&gt;
| basae64 encoded 3DS client data&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Payment/Start response =====&lt;br /&gt;
&amp;lt;source lang=json line style=&amp;quot;word-break: break-all;&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot; : &amp;quot;dce46843-6266-4c1f-b82a-387e0fee9073&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot; : &amp;quot;ewoJIkNhcmRQdWJsaWNJZCI6ICIxYTE5M2E1NDQzNDI0YjJiOGJiMjMyOGRhNWY4NmYzYiIsCgkiUGF5bWVudElkIjogImRjZTQ2ODQzNjI2NjRjMWZiODJhMzg3ZTBmZWU5MDczIiwKCSJPbmVDbGlja0NvbnRlbnRVcmwiOiAiaHR0cDovL3NlY3VyZS5iYXJpb24uY29tL3RocmVlZHMvb25lY2xpY2twYXltZW50IiwKCSJBQ1NTdGFydFByb3RvY29sVmVyc2lvbiI6ICIyLjEuMCIsCgkiQUNTRW5kUHJvdG9jb2xWZXJzaW9uIjogIjIuMS4wIiwKCSJEU1N0YXJ0UHJvdG9jb2xWZXJzaW9uIjogIjIuMS4wIiwKCSJEU0VuZFByb3RvY29sVmVyc2lvbiI6ICIyLjIuMCIsCgkiVGhyZWVEU1NlcnZlclRyYW5zSUQiOiBudWxsLAoJIlRocmVlRFNNZXRob2RVUkwiOiBudWxsLAoJIlRocmVlRFNNZXRob2REYXRhRm9ybSI6ICJleUowYUhKbFpVUlRUV1YwYUc5a1RtOTBhV1pwWTJGMGFXOXVWVkpNSWpvaWFIUjBjSE02THk4elpITXVZbUZ5YVc5dUxtTnZiUzh6WkhNdmRqSXZNMlJ6TFcxbGRHaHZaQzF1YjNScFptbGpZWFJwYjI0aUxDSjBhSEpsWlVSVFUyVnlkbVZ5VkhKaGJuTkpSQ0k2SWpFNE5URTJPR0kxTFRKalkyUXROR0kxWlMxaVlqWm1MVFUzTW1VM00yVTNNemt3TnlKOSIsCgkiRXJyb3JEZXRhaWxzIjogbnVsbCwKCSJWZXJzaW9uIjogIjIuMS4wIgp9Cg==&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Step 3: 3DS authentication &amp;amp; challenge ====&lt;br /&gt;
This data then should be passed onto the &amp;lt;code&amp;gt;authenticate()&amp;lt;/code&amp;gt; method of the offsite gw manager, which will do all the magic to authenticate and display the challenge (if needed).&lt;br /&gt;
&amp;lt;source lang=javascript line highlight=&amp;quot;9&amp;quot;&amp;gt;&lt;br /&gt;
        // call Barion API via merchant&#039;s backend&lt;br /&gt;
        // once the result is returned continue with authentication&lt;br /&gt;
        $.ajax({&lt;br /&gt;
            url: &amp;quot;Url/Of/Your/Payment/Start&amp;quot;,&lt;br /&gt;
            method: &amp;quot;POST&amp;quot;,&lt;br /&gt;
            data: data,&lt;br /&gt;
            success: function (threeDsClientData) {&lt;br /&gt;
               // the threeDsClientData will be in the response of payment/start	&lt;br /&gt;
               gw.authenticate(threeDsClientData);&lt;br /&gt;
            }&lt;br /&gt;
         });&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the request is finished the appropriate callback is fired, the BarionClient was initialized with in [[#Step 1 : Initialize oneClick|Step 1]]. In case of successful authentication, you have to call our [[Payment-Complete-v3|/Payment/Complete]] endpoint, where the actual charge will happen.&lt;br /&gt;
&lt;br /&gt;
=== Recurring payment/Merchant Initiated payment ===&lt;br /&gt;
&lt;br /&gt;
For these types of payments, the subsequent payments are nearly identical to the process of [[#Creating_the_token|Creating the token]]. The only difference is that the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; received in the initial [[Payment-GetPaymentState-v2|GetPaymentState]] response must be sent in the &lt;br /&gt;
[[Payment-Start-v2|Payment/Start]] request. Also don&#039;t forget to set the appropriate [[RecurrenceType|Recurrence Type]].&lt;br /&gt;
&lt;br /&gt;
=== Possible error responses ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| InvalidRecurrenceId|| The token specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is invalid. Check if the token registration was successful.&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentDenied|| Something happened to the user since the token registration, either deleted, suspended, or blocked. The payment s not allowed in these cases.&lt;br /&gt;
|-&lt;br /&gt;
| InsufficientFunds|| If the original payment was with an e-money wallet and the customer doesn&#039;t have enough money to fulfill this charge this error happens.&lt;br /&gt;
|-&lt;br /&gt;
| OriginalPaymentWasntSuccessful || This means that the token belongs to an originally unsuccessful payment so this token can not be used anymore. This could only happen if the original payment was financed with a credit card.&lt;br /&gt;
|-&lt;br /&gt;
|InvalidCurrency || If the original payment was paid with e-money and the current token payment is in a currency that the wallet does not have an account in this error happens.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
	<entry>
		<id>https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2854</id>
		<title>Token payment 3D Secure</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=Token_payment_3D_Secure&amp;diff=2854"/>
		<updated>2020-11-26T11:15:15Z</updated>

		<summary type="html">&lt;p&gt;Botza: /* 2.1 Sending the payment request to the Barion API */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{PageTitle|title=Token Payment with 3D Secure}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
{{IncompletePage}}&lt;br /&gt;
&lt;br /&gt;
This payment scenario allows the integrator shop to register a token for a customer (and a funding source) in the Barion system and then, later on, using this token, charge the customer without redirecting her to the Barion Smart Gateway UI. The user may be present at the site of the merchant or she can be off-session as well, so the merchant can charge her e.g. for subscriptions. This means that the customer authorizes the shop to charge her card or Barion balance without typing in the card information or Barion login again.&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurring.png|1500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{NotificationBox|title=Premium feature|text=This scenario is not allowed automatically for every approved shop and should be requested from Barion!|color=#1993c7}}&lt;br /&gt;
&lt;br /&gt;
= Token payment scenarios =&lt;br /&gt;
Token payment can be used in three use cases: &lt;br /&gt;
* &#039;&#039;&#039;Customer Initiated Payments&#039;&#039;&#039;: when the user is present on the website of the merchant and she decides to pay :&lt;br /&gt;
** &#039;&#039;&#039;OneClick payment&#039;&#039;&#039;: the user is charged upon her request initiated on the website of the merchant. Subsequent payments are subject to PSD2 SCA and as the user is present, she has to go through the authentication process.&lt;br /&gt;
* &#039;&#039;&#039;Merchant Initiated Payments&#039;&#039;&#039;: when the merchant initiates the payment without the user being present. It has two subtypes:&lt;br /&gt;
** &#039;&#039;&#039;Recurring payment&#039;&#039;&#039;: the user is charged with the same amount on a regular basis, typically in case of subscriptions. Subsequent payments are exempted from PSD2 SCA, but liability still shifts to the card issuer.&lt;br /&gt;
** &#039;&#039;&#039;MIT (merchant initiated transaction)&#039;&#039;&#039;: the user is charged on an irregular basis and/or with a different amount. Subsequent payments of this type are excluded from PSD2 SCA, the liability is on the merchant.&lt;br /&gt;
&lt;br /&gt;
== Customer participation ==&lt;br /&gt;
&lt;br /&gt;
Since the token scenario is suitable for both customer and merchant initiated payments here is a comparison about who starts the payment. This includes the regular, non-tokenized payment scenario as well:&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
|-&lt;br /&gt;
! rowspan=&amp;quot;2&amp;quot; | Scenario&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Initial payment&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW &lt;br /&gt;
! Customer present&lt;br /&gt;
! Customer at Barion Smart GW&lt;br /&gt;
|-&lt;br /&gt;
| Non token (regular) payment || YES || YES || YES || YES &lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || YES || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
| MIT || YES || YES/NO&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; || style=&amp;quot;background:#FFE2C4&amp;quot; | NO || style=&amp;quot;background:#FFE2C4&amp;quot; | NO &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;border: 1px solid #aaa; background-color:#eee; font-size: 0.8em; padding:5px 10px; display:inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;sup&amp;gt;1&amp;lt;/sup&amp;gt; Token payment scenarios can be initiated with already registered &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; as well, in this case the customer may remain on the merchant&#039;s site. &lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements for the scenarios ==&lt;br /&gt;
&lt;br /&gt;
These token payment scenarios have different requirements, this table below summarizes the key differences.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Payment amount&lt;br /&gt;
! Payment frequency&lt;br /&gt;
! Liability in case of fraud&lt;br /&gt;
|-&lt;br /&gt;
| OneClick payment || Various || Various || Card issuer&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || Subsequent amounts must be equal or less than the initial amount  || Initial payment must define a minimum amount of days to wait between charges || Card issuer &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || Various  || Various || Merchant&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 3DS authentication of the payer ==&lt;br /&gt;
&lt;br /&gt;
The new more secure 3DS v2 authentication must be performed for every online card payment. These token payment scenarios also have to use this new secure way of authentication. &lt;br /&gt;
The initial payment of a token scenario must be authenticated every time although the subsequent payments may be exempted in certain cases. &lt;br /&gt;
&lt;br /&gt;
Here is a table to compare the 3DS authentication requirements:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
! Initial payment&lt;br /&gt;
! Subsequent payments&lt;br /&gt;
|-&lt;br /&gt;
| One-click payment || ✔️ || ✔️&lt;br /&gt;
|-&lt;br /&gt;
| Recurring payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
| Merchant initiated payment || ✔️ || &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Real life examples ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phone bill&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Payer has a usage-based phone subscription that wants to pay without being present for every charge. She authorizes the phone company to charge her card every month.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, the amount of the subsequent payments may exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TV subscription&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to online streaming of a television channel. She authorizes the phone company to charge her card every month. The subscription fee is the same for every month.&lt;br /&gt;
* Scenario: Recurring payment&lt;br /&gt;
* Explanation: The amount of the subsequent payments will not exceed the initial payment and the charge is regularly monthly-based.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bookclub with &amp;quot;free first month&amp;quot; bonus&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
Payer subscribes to a book renting service. She authorizes the book club to charge her card every month for a selection of books. The subscription fee is the same for every month however, the first month is free. To ensure the subscription the service requires her to register her card details.&lt;br /&gt;
* Scenario: Merchant Initiated Transaction&lt;br /&gt;
* Explanation: Despite the frequency of the charges is monthly, and the fee will stay the same, the initial payment is zero. So the amount of the next payment will exceed the initial payment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Online food delivery service&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The food delivery company wants to provide a quick and easy experience for its customer. They decide that the order will be quicker if the customers don&#039;t leave the website to pay for the goods.&lt;br /&gt;
* Scenario: OneClick payment&lt;br /&gt;
* Explanation: The customer will always be there so the other two scenarios are not available.&lt;br /&gt;
&lt;br /&gt;
== How to decide ==&lt;br /&gt;
&lt;br /&gt;
To help you decide on a suitable scenario, please use the decision graph below:&lt;br /&gt;
&lt;br /&gt;
[[File:3ds-recurrencetype-decision.png|520px]]&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
To be able to integrate your webshop with the Barion Payment Gateway: &lt;br /&gt;
* You must [[Creating_an_account|register a Barion wallet]] at the Barion website or in the Sandbox environment. Learn more about the Sandbox environment [[Sandbox|here]].&lt;br /&gt;
* For this wallet you have to [[Creating_a_shop|create a shop]] which should be approved by Barion.&lt;br /&gt;
* For every currency you plan to conduct payments in you have to make sure there is an account created in your Barion wallet. This means that if you plan to have USD payments then there should be a USD account created in your wallet.&lt;br /&gt;
* To make sure every corner case scenario works for your webshop it is best to top up that account with a small amount (approx. 5-10EUR or your choice of currency around the same value).&lt;br /&gt;
* For the technical communication guide please read this: [[Calling_the_API|Calling the API]]&lt;br /&gt;
&lt;br /&gt;
= The payment process =&lt;br /&gt;
&lt;br /&gt;
The process is divided into two major steps:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 1:  Creating the funding source token|Creating the token]] that represents one of the customer&#039;s funding sources (credit card or e-money wallet)&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Preparing the payment via the Barion API&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Redirecting the customer to the Barion Smart Gateway to select a funding source&amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Processing the callback and requesting information about the result of the payment&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li&amp;gt;[[#Step 2: Using the token|Using the registered token]] to charge the customer&lt;br /&gt;
      &amp;lt;ol&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Sending the payment request to the Barion API &lt;br /&gt;
             &amp;lt;ol&amp;gt;&lt;br /&gt;
                &amp;lt;li&amp;gt;Using the token for the same token payment scenario&amp;lt;/li&amp;gt;&lt;br /&gt;
                &amp;lt;li&amp;gt;Using the token for a different token payment scenario&amp;lt;/li&amp;gt;&lt;br /&gt;
            &amp;lt;/ol&amp;gt;&lt;br /&gt;
         &amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li&amp;gt;Performing on-site 3DS authentication (if needed)&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ol&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1:  Creating the funding source token ==&lt;br /&gt;
To be able to use a token payment scenario first the merchant has to register the token with Barion. The merchant has to make sure that the customer is well aware of the fact that they are giving consent to a tokenized payment. The Barion Smart Gateway UI does not indicate in any way that the payment is a token payment.&lt;br /&gt;
&lt;br /&gt;
The token is registered to the shop and not to the merchant&#039;s Barion account. So if the merchant has multiple shops in its Barion account, the registered tokens can not be shared among them even if the customer is the same. If you want to use tokens in multiple shops, please contact Barion in the Customer center.&lt;br /&gt;
&lt;br /&gt;
=== 1.1 Preparing the payment===&lt;br /&gt;
&lt;br /&gt;
The token registration is basically a [[Responsive_web_payment|normal payment]] with three extra properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* InitiateRecurrence&lt;br /&gt;
* RecurrenceId&lt;br /&gt;
* RecurrenceType&lt;br /&gt;
&lt;br /&gt;
==== InitiateRecurrence====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; property is a bool property. If you set it to &#039;&#039;&#039;true&#039;&#039;&#039; then the payment gateway will consider the payment as a token registration. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This happens even if the customer is already has a registered token, so you are able to re-register a funding source or even a customer. &#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceId ====&lt;br /&gt;
The next required property for a token registration is the token itself. This is generated by the shop and has to be unique for every registration. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property of the [[Payment-Start-v2|Payment/Start]] request. This token must be saved in the webshops database. A &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; token represents the funding source (bank card or Barion balance) of a customer. Since a customer can have multiple cards and accounts as a funding source make sure that in the webshop&#039;s system multiple tokens can belong to a single customer.&lt;br /&gt;
&lt;br /&gt;
==== RecurrenceType ====&lt;br /&gt;
The third required property is the [[RecurrenceType|Recurrence Type]]. This specifies the scenario. In case of Recurring Payment &amp;lt;code&amp;gt;PurchaseInformation.RecurringExpiry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PurchaseInformation.RecurringFrequency&amp;lt;/code&amp;gt; must also be set.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Merchant Initiated Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The response will be the same as to a [[Responsive_web_payment#Processing_the_successful_response|basic &#039;&#039;&#039;Immediate&#039;&#039;&#039; scenario]]. The &amp;lt;code&amp;gt;RecurrenceResult&amp;lt;/code&amp;gt; property at this point is &#039;&#039;&#039;None&#039;&#039;&#039; since the token is not registered to a funding source yet.&lt;br /&gt;
&lt;br /&gt;
==== Example JSON request for a Recurring Payment scenario ====&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Recurring Payment&#039;&#039;&#039; scenario has some extra restrictions. The merchant has to specify two additional properties in the [[Payment-Start-v2|Payment/Start]] request:&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt;: The date after the subsequent charges should not accepted.&lt;br /&gt;
* &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt;: The minimum days the merchant has to wait between payments.&lt;br /&gt;
&lt;br /&gt;
Both properties are located in the [[PurchaseInformation]] property and must be specified if this scenario is selected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-7, 30-33&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: true,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;PurchaseInformation&amp;quot;:{&lt;br /&gt;
        &amp;quot;RecurringFrequency&amp;quot;: 10,&lt;br /&gt;
        &amp;quot;RecurringExpiry&amp;quot;: &amp;quot;2022-10-01&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Possible error responses ====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentNotAllowed || The token payment is not allowed for the shop identified by the &#039;&#039;&#039;POSKey&#039;&#039;&#039;. Contact Barion to request this feature.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 1.2 Redirecting the customer to the Barion Smart Gateway to select a funding source ===&lt;br /&gt;
&lt;br /&gt;
After a successful payment preparation, the customer is redirected to the secure Barion Smart Gateway to choose a funding source. The funding source the customer selects will be registered to the token. The funding source can either be a Barion e-money balance or a bank card. This means that even though the customer may own multiple cards only the one that was registered to the token can be used for future token payments. To change the funding source attached to the token a new registration should be requested.&lt;br /&gt;
&lt;br /&gt;
=== 1.3 Processing the callback and requesting information about the result of the payment ===&lt;br /&gt;
&lt;br /&gt;
When the payment is completed (either successfully or unsuccessfully) a callback message is sent to the merchant&#039;s system. Once received a [[Payment-GetPaymentState-v2|GetPaymentState]] request must be sent to the Barion API. On how to implement this please read the article about the  [[Callback_mechanism|Callback mechanism]].&lt;br /&gt;
&lt;br /&gt;
The full response of the GetPaymentState request depends on the payment scenario and the structure of the payment. When it comes to token payment there are several properties to look out for. &lt;br /&gt;
* In case the &amp;lt;code&amp;gt;Status&amp;lt;/code&amp;gt; is &#039;&#039;&#039;Succeeded&#039;&#039;&#039; the funding source token is registered and ready to use.&lt;br /&gt;
* The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; contains the ID of the token process. This specifies the nature of the token payment. &lt;br /&gt;
&lt;br /&gt;
==== TraceId ====&lt;br /&gt;
&lt;br /&gt;
In case of Recurring payment or Merchant initiated payment scenarios the [[Payment-GetPaymentState-v2|GetPaymentState]] response returns an additional field called &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;. The value of this property is generated by the card issuer. The merchant has to save it and submit it in all subsequent Recurring or Merchant initiated payments of the same type, otherwise, the payments can be declined by the issuer. The &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; represents the first, customer-present payment and helps the issuer to connect subsequent payments to this initial payment.&lt;br /&gt;
&lt;br /&gt;
====Example GetPaymentState response====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;8, 11-12&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot;: &amp;quot;2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;OrderNumber&amp;quot;: null,&lt;br /&gt;
    &amp;quot;POSId&amp;quot;: &amp;quot;[[SHOPS_PUBLIC_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSName&amp;quot;: &amp;quot;[[MERCHANTS_BARION_SHOPNAME]]&amp;quot;,&lt;br /&gt;
    &amp;quot;POSOwnerEmail&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
    &amp;quot;Status&amp;quot;: &amp;quot;Succeeded&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSource&amp;quot;: &amp;quot;BankCard&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;MerchantInitiatedPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;AllowedFundingSources&amp;quot;: [&lt;br /&gt;
        &amp;quot;All&amp;quot;&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;GuestCheckout&amp;quot;: true,&lt;br /&gt;
    &amp;quot;CreatedAt&amp;quot;: &amp;quot;2020-11-26T07:52:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ValidUntil&amp;quot;: &amp;quot;2020-11-26T08:22:48.9Z&amp;quot;,&lt;br /&gt;
    &amp;quot;CompletedAt&amp;quot;: &amp;quot;2020-11-26T08:11:54.118Z&amp;quot;,&lt;br /&gt;
    &amp;quot;ReservedUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;DelayedCaptureUntil&amp;quot;: null,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
           ...&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;quot;Total&amp;quot;: 25.20,&lt;br /&gt;
    &amp;quot;SuggestedLocale&amp;quot;: &amp;quot;hu-HU&amp;quot;,&lt;br /&gt;
    &amp;quot;FraudRiskScore&amp;quot;: null,&lt;br /&gt;
    &amp;quot;RedirectUrl&amp;quot;: &amp;quot;https://merchanturl/Redirect?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;CallbackUrl&amp;quot;: &amp;quot;https://merchanturl/Callback?paymentId=2a9f3260bc2feb118bc3001dd8b71cc4&amp;quot;,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Errors&amp;quot;: []&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Displaying the funding source in a GUI ====&lt;br /&gt;
We strongly advise saving the complete response for future reference. The &amp;lt;code&amp;gt;FundingSource&amp;lt;/code&amp;gt; field tells if the funding source is a Barion balance or a card. If it is a card, it is useful to save [[FundingInformation]] for displaying it for the user, when requesting future payments. The usual way to display funding sources is to show the last 4 digits of the card, with 4 stars, eg: *** 1234. The card used can be obtained from FundingInformation&#039;s [[BankCard]] field. The [[CardType]] field can be used to display the appropriate card logo. You can even show, if the card is expired, and offer to register another one.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; FundingInformation part of the GetPaymentState response &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=json&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
    &amp;quot;FundingInformation&amp;quot;: {&lt;br /&gt;
        &amp;quot;BankCard&amp;quot;: {&lt;br /&gt;
            &amp;quot;MaskedPan&amp;quot;: &amp;quot;0425&amp;quot;,&lt;br /&gt;
            &amp;quot;BankCardType&amp;quot;: &amp;quot;Visa&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruYear&amp;quot;: &amp;quot;2020&amp;quot;,&lt;br /&gt;
            &amp;quot;ValidThruMonth&amp;quot;: &amp;quot;12&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;AuthorizationCode&amp;quot;: &amp;quot;512244&amp;quot;,&lt;br /&gt;
        &amp;quot;ProcessResult&amp;quot;: &amp;quot;Successful&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be displayed for example as &amp;lt;code&amp;gt;VISA **** 0425 (12/20)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a request-response diagram of the token registration process:&lt;br /&gt;
 &lt;br /&gt;
[[File:Token_payment_initiation.jpg]]&lt;br /&gt;
&lt;br /&gt;
= Step 2: Using the token =&lt;br /&gt;
&lt;br /&gt;
==2.1 Sending the payment request to the Barion API ==&lt;br /&gt;
&lt;br /&gt;
To use an already registered token for a payment, you have to use the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property.&lt;br /&gt;
&lt;br /&gt;
At this point, the merchant has to decide whether this subsequent payment is used for the same token payment scenario or something changed. This is important because the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used for the same scenario, otherwise, the card issuer will decline the charge.&lt;br /&gt;
A &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; can only be used again if:&lt;br /&gt;
* the funding source is the same (technically the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* the token payment scenario is the same (technically the &amp;lt;code&amp;gt;RecurrenceType&amp;lt;/code&amp;gt; is the same)&lt;br /&gt;
* this subsequent request complies with the scenario restrictions (eg: in case of recurring payment the amount of the subsequent payment does not exceed the initial amount)&lt;br /&gt;
&lt;br /&gt;
If the funding source changes, new &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the funding source|described in detail here]]. If the funding source stays the same but the scenario changes or the restrictions are no longer met new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; must be requested. The process to do that is [[#Changing the token payment scenario with an existing token|described here]].&lt;br /&gt;
&lt;br /&gt;
=== Subsequent payment in case of Recurring payment scenario ===&lt;br /&gt;
&lt;br /&gt;
In this case, three extra conditions must be met:&lt;br /&gt;
* the amount of the subsequent payment must not be higher than the initial amount&lt;br /&gt;
* at least that much days must be spent as defined in the initial &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; property&lt;br /&gt;
* the date of the payment must not exceed the day specified in the initial &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; property&lt;br /&gt;
&lt;br /&gt;
Please be aware that in case any of these does not stand the merchant has to request a new &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; as [#Changing the token payment scenario with an existing token|described here]]. These conditions are not enforced by the Barion system so the violation of them will result in a declined charge.&lt;br /&gt;
&lt;br /&gt;
Payment/start must not include the &amp;lt;code&amp;gt;RecurringFrequency&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RecurringExpiry&amp;lt;/code&amp;gt; properties (since they are already fixed during the initial payment).&lt;br /&gt;
&lt;br /&gt;
==== Example payment/start of a subsequent Recurring payment ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;[[SECRET_POS_KEY]]&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot;: &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot;: false,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot;: &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot;: &amp;quot;RecurringPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot;: &amp;quot;FGTRR55322843442124780&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;GuestCheckOut&amp;quot; : true,&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-001/TR001&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;[[MERCHANTS_BARION_EMAIL]]&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subscription fee for the first month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Depending on the type of the subsequent payment, 3DSecure authentication might be required for subsequent payments.&lt;br /&gt;
3DS authentication is not required in the following cases:&lt;br /&gt;
* the token was requested before 3DS came into effect,&lt;br /&gt;
* the original payment was not initialized by bank card,&lt;br /&gt;
* the subsequent payment is a merchant initiated payment.&lt;br /&gt;
&lt;br /&gt;
=== Prerequisites ===&lt;br /&gt;
To be able to use a token, the initial payment must be in a successful state.&lt;br /&gt;
&lt;br /&gt;
[[File:Token_payment_2.png]]&lt;br /&gt;
&lt;br /&gt;
=== OneClick payment ===&lt;br /&gt;
==== Step 1 : Initialize oneClick ====&lt;br /&gt;
You have to include the following css and javascript files in the code of your site. These files include all the necessary javascript code and styling to handle the 3DS authentication and display the challenge if necessary.&lt;br /&gt;
&amp;lt;source lang=html&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://secure.barion.com/static/barion.offsitegw.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source &amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you have to initialize the Barion javascript client:&lt;br /&gt;
&amp;lt;source lang=javascript&amp;gt;&lt;br /&gt;
const configuration = {&lt;br /&gt;
    onAuthenticationSucceeded: function () {&lt;br /&gt;
        // handle successful authentication by calling the Barion API via merchant&#039;s backend&lt;br /&gt;
        // Call the v2/payment/complete endpoint&lt;br /&gt;
    },&lt;br /&gt;
    onAuthenticationFailed: function () {&lt;br /&gt;
        // Handle unsuccessful authentication result, no charge was made.&lt;br /&gt;
        // The payment might be still valid only the authentication failed&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
const gw= new Barion.OffsiteGw(configuration);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Step 2 : Make a payment  ====&lt;br /&gt;
To use an already registered token for a payment, you have to call the same [[Payment-Start-v2|/Payment/Start]] API endpoint but the &amp;lt;code&amp;gt;InitiateRecurrence&amp;lt;/code&amp;gt; should be set to &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; and the appropriate [[RecurrenceType|Recurrence Type]] should be sent. This tells the Barion API to use the token for payment instead of only registering it. The token should be specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; property along with the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Example Payment/Start json request =====&lt;br /&gt;
&amp;lt;source lang=json line highlight=&amp;quot;5-8&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;POSKey&amp;quot;: &amp;quot;E31EC263-01DC-40BD-BDF1-38FC7A332434&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentType&amp;quot; : &amp;quot;Immediate&amp;quot;,&lt;br /&gt;
    &amp;quot;PaymentRequestId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002&amp;quot;,&lt;br /&gt;
    &amp;quot;InitiateRecurrence&amp;quot; : false,&lt;br /&gt;
    &amp;quot;RecurrenceType&amp;quot; : &amp;quot;OneClickPayment&amp;quot;,&lt;br /&gt;
    &amp;quot;RecurrenceId&amp;quot; : &amp;quot;SHOP-XMLP-TOKEN-ABC-123&amp;quot;,&lt;br /&gt;
    &amp;quot;TraceId&amp;quot; : &amp;quot;SHOP-XMLP-TRACEID-123&amp;quot;,&lt;br /&gt;
    &amp;quot;FundingSources&amp;quot;: [&amp;quot;All&amp;quot;],&lt;br /&gt;
    &amp;quot;Currency&amp;quot;: &amp;quot;EUR&amp;quot;,&lt;br /&gt;
    &amp;quot;Transactions&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;POSTransactionId&amp;quot;: &amp;quot;EXMPLSHOP-PM-002/TR002&amp;quot;,&lt;br /&gt;
            &amp;quot;Payee&amp;quot;: &amp;quot;webshop@example.com&amp;quot;,&lt;br /&gt;
            &amp;quot;Total&amp;quot;: 25.2,&lt;br /&gt;
            &amp;quot;Comment&amp;quot;: &amp;quot;Subsription fee for the second month&amp;quot;,&lt;br /&gt;
            &amp;quot;Items&amp;quot;: [&lt;br /&gt;
                {&lt;br /&gt;
                    &amp;quot;Name&amp;quot;: &amp;quot;Website subscription&amp;quot;,&lt;br /&gt;
                    &amp;quot;Description&amp;quot;: &amp;quot;Website subscription for one month&amp;quot;,&lt;br /&gt;
                    &amp;quot;Quantity&amp;quot;: 1,&lt;br /&gt;
                    &amp;quot;Unit&amp;quot;: &amp;quot;month&amp;quot;,&lt;br /&gt;
                    &amp;quot;UnitPrice&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;ItemTotal&amp;quot;: 25.2,&lt;br /&gt;
                    &amp;quot;SKU&amp;quot;: &amp;quot;EXMPLSHOP/SKU/PHC-01&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            ]&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Processing the Payment/Start response =====&lt;br /&gt;
To this request, the Barion API sends back the required data for the 3DS authentication for the specified paymentId.&lt;br /&gt;
&lt;br /&gt;
{|class=wikitable&lt;br /&gt;
! Field name&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| PaymentId&lt;br /&gt;
| Payment Identifier of the purchase in Barion&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| ThreeDSAuthClientData&lt;br /&gt;
| basae64 encoded 3DS client data&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Example Payment/Start response =====&lt;br /&gt;
&amp;lt;source lang=json line style=&amp;quot;word-break: break-all;&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;PaymentId&amp;quot; : &amp;quot;dce46843-6266-4c1f-b82a-387e0fee9073&amp;quot;,&lt;br /&gt;
    &amp;quot;ThreeDSAuthClientData&amp;quot; : &amp;quot;ewoJIkNhcmRQdWJsaWNJZCI6ICIxYTE5M2E1NDQzNDI0YjJiOGJiMjMyOGRhNWY4NmYzYiIsCgkiUGF5bWVudElkIjogImRjZTQ2ODQzNjI2NjRjMWZiODJhMzg3ZTBmZWU5MDczIiwKCSJPbmVDbGlja0NvbnRlbnRVcmwiOiAiaHR0cDovL3NlY3VyZS5iYXJpb24uY29tL3RocmVlZHMvb25lY2xpY2twYXltZW50IiwKCSJBQ1NTdGFydFByb3RvY29sVmVyc2lvbiI6ICIyLjEuMCIsCgkiQUNTRW5kUHJvdG9jb2xWZXJzaW9uIjogIjIuMS4wIiwKCSJEU1N0YXJ0UHJvdG9jb2xWZXJzaW9uIjogIjIuMS4wIiwKCSJEU0VuZFByb3RvY29sVmVyc2lvbiI6ICIyLjIuMCIsCgkiVGhyZWVEU1NlcnZlclRyYW5zSUQiOiBudWxsLAoJIlRocmVlRFNNZXRob2RVUkwiOiBudWxsLAoJIlRocmVlRFNNZXRob2REYXRhRm9ybSI6ICJleUowYUhKbFpVUlRUV1YwYUc5a1RtOTBhV1pwWTJGMGFXOXVWVkpNSWpvaWFIUjBjSE02THk4elpITXVZbUZ5YVc5dUxtTnZiUzh6WkhNdmRqSXZNMlJ6TFcxbGRHaHZaQzF1YjNScFptbGpZWFJwYjI0aUxDSjBhSEpsWlVSVFUyVnlkbVZ5VkhKaGJuTkpSQ0k2SWpFNE5URTJPR0kxTFRKalkyUXROR0kxWlMxaVlqWm1MVFUzTW1VM00yVTNNemt3TnlKOSIsCgkiRXJyb3JEZXRhaWxzIjogbnVsbCwKCSJWZXJzaW9uIjogIjIuMS4wIgp9Cg==&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Step 3: 3DS authentication &amp;amp; challenge ====&lt;br /&gt;
This data then should be passed onto the &amp;lt;code&amp;gt;authenticate()&amp;lt;/code&amp;gt; method of the offsite gw manager, which will do all the magic to authenticate and display the challenge (if needed).&lt;br /&gt;
&amp;lt;source lang=javascript line highlight=&amp;quot;9&amp;quot;&amp;gt;&lt;br /&gt;
        // call Barion API via merchant&#039;s backend&lt;br /&gt;
        // once the result is returned continue with authentication&lt;br /&gt;
        $.ajax({&lt;br /&gt;
            url: &amp;quot;Url/Of/Your/Payment/Start&amp;quot;,&lt;br /&gt;
            method: &amp;quot;POST&amp;quot;,&lt;br /&gt;
            data: data,&lt;br /&gt;
            success: function (threeDsClientData) {&lt;br /&gt;
               // the threeDsClientData will be in the response of payment/start	&lt;br /&gt;
               gw.authenticate(threeDsClientData);&lt;br /&gt;
            }&lt;br /&gt;
         });&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the request is finished the appropriate callback is fired, the BarionClient was initialized with in [[#Step 1 : Initialize oneClick|Step 1]]. In case of successful authentication, you have to call our [[Payment-Complete-v3|/Payment/Complete]] endpoint, where the actual charge will happen.&lt;br /&gt;
&lt;br /&gt;
=== Recurring payment/Merchant Initiated payment ===&lt;br /&gt;
&lt;br /&gt;
For these types of payments, the subsequent payments are nearly identical to the process of [[#Creating_the_token|Creating the token]]. The only difference is that the &amp;lt;code&amp;gt;TraceId&amp;lt;/code&amp;gt; received in the initial [[Payment-GetPaymentState-v2|GetPaymentState]] response must be sent in the &lt;br /&gt;
[[Payment-Start-v2|Payment/Start]] request. Also don&#039;t forget to set the appropriate [[RecurrenceType|Recurrence Type]].&lt;br /&gt;
&lt;br /&gt;
=== Possible error responses ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable api-table&amp;quot;&lt;br /&gt;
! Error code || Description&lt;br /&gt;
|-&lt;br /&gt;
| InvalidRecurrenceId|| The token specified in the &amp;lt;code&amp;gt;RecurrenceId&amp;lt;/code&amp;gt; is invalid. Check if the token registration was successful.&lt;br /&gt;
|-&lt;br /&gt;
| RecurringPaymentDenied|| Something happened to the user since the token registration, either deleted, suspended, or blocked. The payment s not allowed in these cases.&lt;br /&gt;
|-&lt;br /&gt;
| InsufficientFunds|| If the original payment was with an e-money wallet and the customer doesn&#039;t have enough money to fulfill this charge this error happens.&lt;br /&gt;
|-&lt;br /&gt;
| OriginalPaymentWasntSuccessful || This means that the token belongs to an originally unsuccessful payment so this token can not be used anymore. This could only happen if the original payment was financed with a credit card.&lt;br /&gt;
|-&lt;br /&gt;
|InvalidCurrency || If the original payment was paid with e-money and the current token payment is in a currency that the wallet does not have an account in this error happens.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Botza</name></author>
	</entry>
</feed>