{"__v":23,"_id":"5612796d09bdc51700696fdf","category":{"__v":31,"_id":"55ffceca0e2b090d008633b2","pages":["55ffcedffeaf310d007dd6d6","55ffd0879e7ccf0d000a1e09","55ffddd1feaf310d007dd6e8","55ffdee4feaf310d007dd6ea","55ffe2336932a00d00ba7abf","55ffeb898c0c9d0d00dcacd0","55fff74c6932a00d00ba7b0c","55fff9df0c703d1900952fe1","55fffecb6932a00d00ba7b1b","55ffffd49e7ccf0d000a1e49","560001159e7ccf0d000a1e4d","560004126932a00d00ba7b2a","560006ef0c703d1900952ffc","560009fa8c0c9d0d00dcad0d","5601137f9137690d00335697","560120f34ea1b40d003bf1a4","5601221bf01fb90d00d4bf7e","5601274781a9670d006d1514","5601292881a9670d006d1516","56012ab3f01fb90d00d4bf88","56012c754ea1b40d003bf1b9","56012d824ea1b40d003bf1c0","56053e9df6b86e0d00284ad1","560541907c8e580d0001afe8","56123c063cf4bc0d00554e37","561264c70157131900b45863","561272d60157131900b45870","5612796d09bdc51700696fdf","56138c7a6fd7042b008f0187","5613a63d46c35f3500773c06","5613a79a44d6662b0071f5d9"],"project":"55edea207145f717001ac12c","version":"55edea207145f717001ac12f","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-09-21T09:32:58.200Z","from_sync":false,"order":0,"slug":"sdk","title":"SDK"},"project":"55edea207145f717001ac12c","user":"55ede9ed1452cd0d009e5e6b","version":{"__v":11,"_id":"55edea207145f717001ac12f","project":"55edea207145f717001ac12c","createdAt":"2015-09-07T19:48:48.670Z","releaseDate":"2015-09-07T19:48:48.670Z","categories":["55edea217145f717001ac130","55ffa8038c0c9d0d00dcac72","55ffbaa48c0c9d0d00dcac88","55ffbd3e8c0c9d0d00dcac8b","55ffbee40e2b090d00863393","55ffc4306932a00d00ba7a85","55ffc66bfeaf310d007dd6c8","55ffc9c2feaf310d007dd6d1","55ffceca0e2b090d008633b2","560111b06811d00d00ceb34e","560262e74f15002100ee4445"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-10-05T13:21:49.035Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":30,"body":"[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"This feature is available only to systems integrated within the Business plan. [Check the pricing](https://developers.rublon.com/98/Pricing).\"\n}\n[/block]\nIf you are concerned about the security of some of your more sensitive transactions, e.g. financial transfers, changing your password or email address, Rublon provides the means for confirming such processes in a secure way. This feature is similar in operation to the Rublon-confirmed authentication, however instead of scanning a QR code the user is required to answer a question displayed in the Rublon mobile app via a push notification.\n\nAfter initiating a Rublon-confirmed transaction, a message will be displayed in the mobile app, asking the user to confirm the transaction. The contents of such message is prepared by the integrated system itself and can contain information which will help the user identify which transaction the message pertains to, e.g. the amount of a money transfer or info about the changed password. The user will have to confirm the transaction by pressing \"YES\" or deny it by pressing \"NO\".\n\nConfirmation of the transaction should be initiated only after a user is logged in and the user's unique Id and email address are known.\n[block:html]\n{\n  \"html\": \"<div>\\n  <!-- Nav tabs -->\\n  <ul class=\\\"nav nav-tabs langnav\\\" role=\\\"tablist\\\">\\n    <li role=\\\"presentation\\\" class=\\\"active\\\"><a href=\\\"#php\\\" aria-controls=\\\"php\\\" role=\\\"tab\\\" data-toggle=\\\"tab\\\">PHP</a></li>\\n    <li role=\\\"presentation\\\"><a href=\\\"#net\\\" aria-controls=\\\"net\\\" role=\\\"tab\\\" data-toggle=\\\"tab\\\">.NET</a></li>\\n    <li role=\\\"presentation\\\"><a href=\\\"#java\\\" aria-controls=\\\"java\\\" role=\\\"tab\\\" data-toggle=\\\"tab\\\">Java</a></li>\\n    <li role=\\\"presentation\\\"><a href=\\\"#python\\\" aria-controls=\\\"python\\\" role=\\\"tab\\\" data-toggle=\\\"tab\\\">Python</a></li>\\n  </ul>\\n\\n  <!-- Tab panes -->\\n  <div class=\\\"tab-content\\\">\\n    <div role=\\\"tabpanel\\\" class=\\\"tab-pane active\\\" id=\\\"php\\\">\\n      <br/>\\n      <p>The <code>Rublon2Factor::confirm()</code> method will check the user's protection status (using the email address hash) and return a URL address which the web browser should redirect to (if the user is protected by Rublon), or <code>NULL</code>, if the user protection is not active.</p>\\n<table>\\n\\t<caption><code>Rublon2Factor::confirm()</code> method arguments</caption>\\n\\t<thead><tr>\\n\\t\\t<th>Name</th>\\n\\t\\t<th>Type</th>\\n\\t\\t<th>Description</th>\\n\\t</tr></thead>\\n\\t<tbody>\\n\\t\\t<tr><td><code>$callbackUrl</code></td><td>string</td><td>The integrated system's callback URL\\n</td></tr>\\n\\t\\t<tr><td><code>$userId</code></td><td>string</td><td>The integrated system's user's unique Id which will allow to log in the user upon successful authentication</td></tr>\\n\\t\\t<tr><td><code>$userEmail</code></td><td>string</td><td>The user's email address in the integrated system which will allow to check the user's protection status and matching the user to a Rublon account</td></tr>\\n\\t\\t<tr><td><code>$confirmMessage</code></td><td>string</td><td>Contents of the message displayed in the mobile app\\n</td></tr>\\n\\t\\t<tr><td><code>$consumerParams</code></td><td>array</td><td>Additional transaction parameters (optional)</td></tr>    \\n\\t</tbody>\\n</table> \\n      <h3>Initiating transaction confirmation</h3>\\n      <p>An example of confirming a sensitive transaction using Rublon:</p>\\n<!-- ngSwitchWhen: textarea --><!-- TODO: Make this generic using 'default' --><!-- ngSwitchWhen: api-header --><!-- ngSwitchWhen: code --><div class=\\\"ng-scope\\\" ng-switch-when=\\\"code\\\"><div type=\\\"section.type\\\" ng-model=\\\"section.data\\\" class=\\\"block-code block-show-code ng-isolate-scope ng-pristine ng-valid\\\">\\n  <div class=\\\"code-tabs ng-hide\\\" ng-show=\\\"data.codes.length > 1 || (data.codes.length == 1 &amp;&amp; data.codes[0].status)\\\">\\n    <!-- ngRepeat: tab in data.codes track by $id($index) --><div class=\\\"ng-scope tab on\\\" ng-class=\\\"{tab: true, on:$index==current, off:$index!=current}\\\" ng-repeat=\\\"tab in data.codes track by $id($index)\\\">\\n      <a href=\\\"\\\" ng-click=\\\"choose($index)\\\">\\n        <!-- ngIf: tab.status -->\\n        <!-- ngIf: !tab.status --><span class=\\\"ng-scope ng-binding\\\" ng-if=\\\"!tab.status\\\">\\n          PHP\\n        </span><!-- end ngIf: !tab.status -->\\n      </a><span class=\\\"ng-hide\\\" ng-hide=\\\"$last\\\">·</span>\\n    </div><!-- end ngRepeat: tab in data.codes track by $id($index) -->\\n  </div>\\n\\n  <!-- ngRepeat: tab in data.codes track by $id($index) --><div class=\\\"ng-scope\\\" ng-repeat=\\\"tab in data.codes track by $id($index)\\\" ng-show=\\\"$index==current\\\">\\n  <pre class=\\\"cm-s-neo\\\" data-mode=\\\"php\\\"><span class=\\\"cm-meta\\\">&lt;?</span>\\n<span class=\\\"cm-comment\\\">/**</span>\\n <span class=\\\"cm-comment\\\">* Transaction confirmation.</span>\\n <span class=\\\"cm-comment\\\">* </span>\\n <span class=\\\"cm-comment\\\">* :::at:::param int $transId Transaction Id</span>\\n <span class=\\\"cm-comment\\\">* @param int $amount Transaction amount</span>\\n <span class=\\\"cm-comment\\\">*/</span>\\n<span class=\\\"cm-keyword\\\">function</span> <span class=\\\"cm-def\\\">confirmTransaction</span>(<span class=\\\"cm-variable-2\\\">$transId</span>, <span class=\\\"cm-variable-2\\\">$amount</span>) {\\n  <span class=\\\"cm-variable-2\\\">$user</span> <span class=\\\"cm-operator\\\">=</span> <span class=\\\"cm-variable-2\\\">$_SESSION</span>[<span class=\\\"cm-string\\\">'user'</span>];\\n  <span class=\\\"cm-variable-2\\\">$rublon</span> <span class=\\\"cm-operator\\\">=</span> <span class=\\\"cm-keyword\\\">new</span> <span class=\\\"cm-variable\\\">Rublon2Factor</span>(<span class=\\\"cm-string\\\">\\\"</span><span class=\\\"cm-string\\\">your_system_token\\\"</span>, <span class=\\\"cm-string\\\">\\\"</span><span class=\\\"cm-string\\\">your_access_key\\\"</span>);\\n  <span class=\\\"cm-keyword\\\">try</span> { <span class=\\\"cm-comment\\\">// Initiate Rublon authentication</span>\\n    <span class=\\\"cm-variable-2\\\">$url</span> <span class=\\\"cm-operator\\\">=</span> <span class=\\\"cm-variable-2\\\">$rublon</span><span class=\\\"cm-operator\\\">-&gt;</span><span class=\\\"cm-variable\\\">confirm</span>(\\n      <span class=\\\"cm-variable-2\\\">$callbackUrl</span> <span class=\\\"cm-operator\\\">=</span> <span class=\\\"cm-string\\\">\\\"</span><span class=\\\"cm-string\\\">http://example.com/rublon_transaction_confirm.php\\\"</span>,\\n      <span class=\\\"cm-variable-2\\\">$user</span>[<span class=\\\"cm-string\\\">\\\"</span><span class=\\\"cm-string\\\">id\\\"</span>], <span class=\\\"cm-comment\\\">// User Id</span>\\n      <span class=\\\"cm-variable-2\\\">$user</span>[<span class=\\\"cm-string\\\">\\\"</span><span class=\\\"cm-string\\\">email\\\"</span>], <span class=\\\"cm-comment\\\">// User email</span>\\n      <span class=\\\"cm-variable-2\\\">$msg</span> <span class=\\\"cm-operator\\\">=</span> <span class=\\\"cm-builtin\\\">sprintf</span>(<span class=\\\"cm-string\\\">\\\"</span><span class=\\\"cm-string\\\">Do you confirm transaction no. %d with the amount of %d?\\\"</span>, <span class=\\\"cm-variable-2\\\">$transId</span>, <span class=\\\"cm-variable-2\\\">$amount</span>),\\n      <span class=\\\"cm-variable-2\\\">$params</span> <span class=\\\"cm-operator\\\">=</span> <span class=\\\"cm-keyword\\\">array</span>(<span class=\\\"cm-string\\\">\\\"</span><span class=\\\"cm-string\\\">transId\\\"</span> <span class=\\\"cm-operator\\\">=&gt;</span> <span class=\\\"cm-variable-2\\\">$transId</span>) <span class=\\\"cm-comment\\\">// Additional transaction parameters</span>\\n    );\\n\\n    <span class=\\\"cm-keyword\\\">if</span> (<span class=\\\"cm-operator\\\">!</span><span class=\\\"cm-keyword\\\">empty</span>(<span class=\\\"cm-variable-2\\\">$url</span>)) { <span class=\\\"cm-comment\\\">// Rublon protection is active</span>\\n      <span class=\\\"cm-comment\\\">// Redirect the web browser to Rublon servers</span>\\n      <span class=\\\"cm-comment\\\">// to confirm the transaction:</span>\\n      <span class=\\\"cm-builtin\\\">header</span>(<span class=\\\"cm-string\\\">'Location: '</span> . <span class=\\\"cm-variable-2\\\">$url</span>);\\n    }\\n\\n  } <span class=\\\"cm-keyword\\\">catch</span> (<span class=\\\"cm-variable\\\">RublonException</span> <span class=\\\"cm-variable-2\\\">$e</span>) {\\n    <span class=\\\"cm-comment\\\">// An error occurred</span>\\n    <span class=\\\"cm-keyword\\\">die</span>(<span class=\\\"cm-string\\\">\\\"</span><span class=\\\"cm-string\\\">There was an error, please try again later.\\\"</span>);\\n  }\\n\\n  <span class=\\\"cm-comment\\\">/* If we're here, the user's account is not protected by Rublon,</span>\\n  <span class=\\\"cm-comment\\\">so the user should confirm the transaction some other way. */</span>\\n  <span class=\\\"cm-keyword\\\">return</span> <span class=\\\"cm-atom\\\">true</span>;\\n}</pre>\\n</div><!-- end ngRepeat: tab in data.codes track by $id($index) -->\\n</div></div><!-- ngSwitchWhen: image --><!-- ngSwitchWhen: embed --><!-- ngSwitchWhen: callout --><!-- ngSwitchWhen: parameters --><!-- ngSwitchWhen: html -->\\n\\n \\n      <p>If the user's account is protected by Rublon, calling the <code>Rublon2Factor::confirm()</code> method will return a URL address which the user's web browser should redirect to so as to scan a QR code and confirm the transaction.</p>\\n\\n      <h3>Finalizing the transaction</h3>\\n\\n<p>Finalizing the whole process involves invoking a callback URL, similarly to the authentication process. In the callback the user's answer to the transaction confirmation question, given by the user in the Rublon mobile app, can be obtained and processed.</p>\\n\\n<p>An example of confirming a transaction in the callback:</p>\\n\\n      <!-- ngSwitchWhen: textarea --><!-- TODO: Make this generic using 'default' --><!-- ngSwitchWhen: api-header --><!-- ngSwitchWhen: code --><div class=\\\"ng-scope\\\" ng-switch-when=\\\"code\\\"><div type=\\\"section.type\\\" ng-model=\\\"section.data\\\" class=\\\"block-code block-show-code ng-isolate-scope ng-pristine ng-valid\\\">\\n  <div class=\\\"code-tabs ng-hide\\\" ng-show=\\\"data.codes.length > 1 || (data.codes.length == 1 &amp;&amp; data.codes[0].status)\\\">\\n    <!-- ngRepeat: tab in data.codes track by $id($index) --><div class=\\\"ng-scope tab on\\\" ng-class=\\\"{tab: true, on:$index==current, off:$index!=current}\\\" ng-repeat=\\\"tab in data.codes track by $id($index)\\\">\\n      <a href=\\\"\\\" ng-click=\\\"choose($index)\\\">\\n        <!-- ngIf: tab.status -->\\n        <!-- ngIf: !tab.status --><span class=\\\"ng-scope ng-binding\\\" ng-if=\\\"!tab.status\\\">\\n          PHP\\n        </span><!-- end ngIf: !tab.status -->\\n      </a><span class=\\\"ng-hide\\\" ng-hide=\\\"$last\\\">·</span>\\n    </div><!-- end ngRepeat: tab in data.codes track by $id($index) -->\\n  </div>\\n\\n  <!-- ngRepeat: tab in data.codes track by $id($index) --><div class=\\\"ng-scope\\\" ng-repeat=\\\"tab in data.codes track by $id($index)\\\" ng-show=\\\"$index==current\\\">\\n  <pre class=\\\"cm-s-neo\\\" data-mode=\\\"php\\\"><span class=\\\"cm-meta\\\">&lt;?</span>\\n<span class=\\\"cm-variable-2\\\">$rublon</span> <span class=\\\"cm-operator\\\">=</span> <span class=\\\"cm-keyword\\\">new</span> <span class=\\\"cm-variable\\\">Rublon2Factor</span>(<span class=\\\"cm-string\\\">\\\"</span><span class=\\\"cm-string\\\">your_system_token\\\"</span>, <span class=\\\"cm-string\\\">\\\"</span><span class=\\\"cm-string\\\">your_access_key\\\"</span>);\\n<span class=\\\"cm-keyword\\\">try</span> {\\n  <span class=\\\"cm-variable-2\\\">$callback</span> <span class=\\\"cm-operator\\\">=</span> <span class=\\\"cm-keyword\\\">new</span> <span class=\\\"cm-variable\\\">Rublon2FactorCallback</span>(<span class=\\\"cm-variable-2\\\">$rublon</span>);\\n  <span class=\\\"cm-variable-2\\\">$callback</span><span class=\\\"cm-operator\\\">-&gt;</span><span class=\\\"cm-variable\\\">call</span>(\\n    <span class=\\\"cm-variable-2\\\">$successHandler</span> <span class=\\\"cm-operator\\\">=</span> <span class=\\\"cm-keyword\\\">function</span>(<span class=\\\"cm-variable-2\\\">$userId</span>, <span class=\\\"cm-variable\\\">Rublon2FactorCallback</span> <span class=\\\"cm-variable-2\\\">$callback</span>) {\\n      <span class=\\\"cm-variable-2\\\">$params</span> <span class=\\\"cm-operator\\\">=</span> <span class=\\\"cm-variable-2\\\">$callback</span><span class=\\\"cm-operator\\\">-&gt;</span><span class=\\\"cm-variable\\\">getCredentials</span>()<span class=\\\"cm-operator\\\">-&gt;</span><span class=\\\"cm-variable\\\">getResponse</span>();\\n      <span class=\\\"cm-keyword\\\">if</span> (<span class=\\\"cm-keyword\\\">isset</span>(<span class=\\\"cm-variable-2\\\">$params</span>[<span class=\\\"cm-string\\\">'transId'</span>])) {\\n        <span class=\\\"cm-keyword\\\">if</span> (<span class=\\\"cm-variable\\\">RublonAPICredentials</span>::<span class=\\\"cm-variable\\\">CONFIRM_RESULT_YES</span> <span class=\\\"cm-operator\\\">==</span> <span class=\\\"cm-variable-2\\\">$callback</span><span class=\\\"cm-operator\\\">-&gt;</span><span class=\\\"cm-variable\\\">getCredentials</span>()<span class=\\\"cm-operator\\\">-&gt;</span><span class=\\\"cm-variable\\\">getConfirmResult</span>()) {\\n          <span class=\\\"cm-comment\\\">// Transaction confirmed, do something with it:</span>\\n          <span class=\\\"cm-variable\\\">transaction_confirmed</span>(<span class=\\\"cm-variable-2\\\">$params</span>[<span class=\\\"cm-string\\\">'transId'</span>]);\\n        } <span class=\\\"cm-keyword\\\">else</span> {\\n          <span class=\\\"cm-comment\\\">// Transaction denied, cancel and clean:</span>\\n          <span class=\\\"cm-variable\\\">transaction_denied</span>(<span class=\\\"cm-variable-2\\\">$params</span>[<span class=\\\"cm-string\\\">'transId'</span>]);\\n        }\\n      }\\n    },\\n    <span class=\\\"cm-variable-2\\\">$cancelHandler</span> <span class=\\\"cm-operator\\\">=</span> <span class=\\\"cm-keyword\\\">function</span>(<span class=\\\"cm-variable\\\">Rublon2FactorCallback</span> <span class=\\\"cm-variable-2\\\">$callback</span>) {\\n      <span class=\\\"cm-comment\\\">// Cancel the process</span>\\n      <span class=\\\"cm-variable\\\">redirect</span>(<span class=\\\"cm-string\\\">\\\"</span><span class=\\\"cm-string\\\">/dashboard\\\"</span>);\\n    }\\n  );\\n  \\n  <span class=\\\"cm-comment\\\">// The process was successful</span>\\n  <span class=\\\"cm-variable\\\">redirect</span>(<span class=\\\"cm-string\\\">\\\"</span><span class=\\\"cm-string\\\">/dashboard\\\"</span>);\\n\\n} <span class=\\\"cm-keyword\\\">catch</span> (<span class=\\\"cm-variable\\\">RublonException</span> <span class=\\\"cm-variable-2\\\">$e</span>) {\\n  <span class=\\\"cm-comment\\\">// Please handle this error in the better way:</span>\\n  <span class=\\\"cm-keyword\\\">die</span>(<span class=\\\"cm-variable-2\\\">$e</span><span class=\\\"cm-operator\\\">-&gt;</span><span class=\\\"cm-variable\\\">getMessage</span>());\\n}</pre>\\n</div><!-- end ngRepeat: tab in data.codes track by $id($index) -->\\n</div></div><!-- ngSwitchWhen: image --><!-- ngSwitchWhen: embed --><!-- ngSwitchWhen: callout --><!-- ngSwitchWhen: parameters --><!-- ngSwitchWhen: html -->\\n      \\n    </div>\\n    <div role=\\\"tabpanel\\\" class=\\\"tab-pane\\\" id=\\\"net\\\">\\n      <br/>\\n      <p>The <code>Rublon2Factor.Confirm()</code> method will check the user's protection status (using the email address hash) and return a URL address which the web browser should redirect to (if the user is protected by Rublon), or <code>null</code>, if the user protection is not active.</p>\\n<table>\\n\\t<caption><code>Rublon2Factor.Confirm()</code> method arguments</caption>\\n\\t<thead><tr>\\n\\t\\t<th>Name</th>\\n\\t\\t<th>Type</th>\\n\\t\\t<th>Description</th>\\n\\t</tr></thead>\\n\\t<tbody>\\n\\t\\t<tr><td><code>callbackUrl</code></td><td>string</td><td>The integrated system's callback URL\\n</td></tr>\\n\\t\\t<tr><td><code>userId</code></td><td>string</td><td>The integrated system's user's unique Id which will allow to log in the user upon successful authentication</td></tr>\\n\\t\\t<tr><td><code>userEmail</code></td><td>string</td><td>The user's email address in the integrated system which will allow to check the user's protection status and matching the user to a Rublon account</td></tr>\\n\\t\\t<tr><td><code>confirmMessage</code></td><td>string</td><td>Contents of the message displayed in the mobile app\\n</td></tr>\\n\\t\\t<tr><td><code>consumerParams</code></td><td>JObject</td><td>Additional transaction parameters (optional)</td></tr>    \\n\\t</tbody>\\n</table>  \\n      <h3>Initiating transaction confirmation</h3>\\n      <p>An example of confirming a sensitive transaction using Rublon:</p>\\n<!-- ngSwitchWhen: textarea --><!-- TODO: Make this generic using 'default' --><!-- ngSwitchWhen: api-header --><!-- ngSwitchWhen: code --><div class=\\\"ng-scope\\\" ng-switch-when=\\\"code\\\"><div type=\\\"section.type\\\" ng-model=\\\"section.data\\\" class=\\\"block-code block-show-code ng-isolate-scope ng-pristine ng-valid\\\">\\n  <div class=\\\"code-tabs ng-hide\\\" ng-show=\\\"data.codes.length > 1 || (data.codes.length == 1 &amp;&amp; data.codes[0].status)\\\">\\n    <!-- ngRepeat: tab in data.codes track by $id($index) --><div class=\\\"ng-scope tab on\\\" ng-class=\\\"{tab: true, on:$index==current, off:$index!=current}\\\" ng-repeat=\\\"tab in data.codes track by $id($index)\\\">\\n      <a href=\\\"\\\" ng-click=\\\"choose($index)\\\">\\n        <!-- ngIf: tab.status -->\\n        <!-- ngIf: !tab.status --><span class=\\\"ng-scope ng-binding\\\" ng-if=\\\"!tab.status\\\">\\n          C#\\n        </span><!-- end ngIf: !tab.status -->\\n      </a><span class=\\\"ng-hide\\\" ng-hide=\\\"$last\\\">·</span>\\n    </div><!-- end ngRepeat: tab in data.codes track by $id($index) -->\\n  </div>\\n\\n  <!-- ngRepeat: tab in data.codes track by $id($index) --><div class=\\\"ng-scope\\\" ng-repeat=\\\"tab in data.codes track by $id($index)\\\" ng-show=\\\"$index==current\\\">\\n  <pre class=\\\"cm-s-neo\\\" data-mode=\\\"csharp\\\"><span class=\\\"cm-comment\\\">//</span>\\n<span class=\\\"cm-comment\\\">// Transaction confirmation.</span>\\n<span class=\\\"cm-comment\\\">// </span>\\n<span class=\\\"cm-variable\\\">void</span> <span class=\\\"cm-variable\\\">confirmTransaction</span>(<span class=\\\"cm-variable\\\">string</span> <span class=\\\"cm-variable\\\">transId</span>, <span class=\\\"cm-variable\\\">int</span> <span class=\\\"cm-variable\\\">amount</span>) \\n{\\n    <span class=\\\"cm-variable\\\">User</span> <span class=\\\"cm-variable\\\">user</span> <span class=\\\"cm-operator\\\">=</span> (<span class=\\\"cm-variable\\\">User</span>)<span class=\\\"cm-variable\\\">Session</span>[<span class=\\\"cm-string\\\">\\\"loggedUser\\\"</span>];\\n    <span class=\\\"cm-variable\\\">Rublon2Factor</span> <span class=\\\"cm-variable\\\">rublon</span> <span class=\\\"cm-operator\\\">=</span> <span class=\\\"cm-variable\\\">new</span> <span class=\\\"cm-variable\\\">Rublon2Factor</span>\\n    (\\n        <span class=\\\"cm-comment\\\">// systemToken:</span>\\n        <span class=\\\"cm-string\\\">\\\"A69FC450848B4B94A040416DC4421523\\\"</span>,\\n        <span class=\\\"cm-comment\\\">// secretKey:</span>\\n        <span class=\\\"cm-string\\\">\\\"bLS6NDP7pGjg346S4IHqTHgQQjjSLw3CyApvz5iRjYzgIPN4e9EOi1cQJLrTlvLoHY8zeqg4ILrItYidKJ6JjEUZaA6pR1tZMwSZ\\\"</span>\\n    );\\n\\n    <span class=\\\"cm-variable\\\">JObject</span> <span class=\\\"cm-variable\\\">parameters</span> <span class=\\\"cm-operator\\\">=</span> <span class=\\\"cm-variable\\\">new</span> <span class=\\\"cm-variable\\\">JObject</span>();\\n    <span class=\\\"cm-variable\\\">parameters</span>.<span class=\\\"cm-variable\\\">Add</span>(<span class=\\\"cm-string\\\">\\\"transId\\\"</span>, <span class=\\\"cm-variable\\\">transId</span>);\\n    \\n    <span class=\\\"cm-variable\\\">try</span> <span class=\\\"cm-comment\\\">// Initiate Rublon authentication</span>\\n    {\\n        <span class=\\\"cm-variable\\\">string</span> <span class=\\\"cm-variable\\\">url</span> <span class=\\\"cm-operator\\\">=</span> <span class=\\\"cm-variable\\\">rublon</span>.<span class=\\\"cm-variable\\\">Confirm</span>\\n        (\\n            <span class=\\\"cm-string\\\">\\\"http://example.com/TransactionConfirmCallback\\\"</span>, <span class=\\\"cm-comment\\\">// callback URL</span>\\n            <span class=\\\"cm-variable\\\">user</span>.<span class=\\\"cm-variable\\\">Id</span>, <span class=\\\"cm-comment\\\">// User Id</span>\\n            <span class=\\\"cm-variable\\\">user</span>.<span class=\\\"cm-variable\\\">Email</span>, <span class=\\\"cm-comment\\\">// User email</span>\\n            <span class=\\\"cm-variable\\\">string</span>.<span class=\\\"cm-variable\\\">format</span>(<span class=\\\"cm-string\\\">\\\"Do you confirm transaction no. {0} with the amount of {1}?\\\"</span>, <span class=\\\"cm-variable\\\">transId</span>, <span class=\\\"cm-variable\\\">amount</span>),\\n            <span class=\\\"cm-variable\\\">parameters</span>\\n        );\\n\\n        <span class=\\\"cm-variable\\\">if</span> (<span class=\\\"cm-variable\\\">url</span> <span class=\\\"cm-operator\\\">!=</span> <span class=\\\"cm-variable\\\">null</span>) <span class=\\\"cm-comment\\\">// Rublon protection is active</span>\\n        {\\n            <span class=\\\"cm-comment\\\">// Redirect the web browser to Rublon servers</span>\\n            <span class=\\\"cm-comment\\\">// to confirm the transaction:</span>\\n            <span class=\\\"cm-variable\\\">Response</span>.<span class=\\\"cm-variable\\\">Redirect</span>(<span class=\\\"cm-variable\\\">url</span>);\\n        }\\n    } \\n    <span class=\\\"cm-variable\\\">catch</span> (<span class=\\\"cm-variable\\\">RublonException</span> <span class=\\\"cm-variable\\\">ex</span>) \\n    {\\n        <span class=\\\"cm-comment\\\">// An error occurred</span>\\n        <span class=\\\"cm-variable\\\">throw</span>;\\n    }\\n\\n    <span class=\\\"cm-comment\\\">/* If we're here, the user's account is not protected by Rublon,</span>\\n    <span class=\\\"cm-comment\\\">so the user should confirm the transaction some other way</span>\\n    <span class=\\\"cm-comment\\\">or bypass the confirmation. */</span>\\n}</pre>\\n</div><!-- end ngRepeat: tab in data.codes track by $id($index) -->\\n</div></div><!-- ngSwitchWhen: image --><!-- ngSwitchWhen: embed --><!-- ngSwitchWhen: callout --><!-- ngSwitchWhen: parameters --><!-- ngSwitchWhen: html -->\\n      <p>If the user's account is protected by Rublon, calling the <code>Rublon2Factor.Confirm()</code> method will return a URL address which the user's web browser should redirect to so as to scan a QR code and confirm the transaction.</p>\\n\\n      <h3>Finalizing the transaction</h3>\\n\\n<p>Finalizing the whole process involves invoking a callback URL, similarly to the authentication process. In the callback the user's answer to the transaction confirmation question, given by the user in the Rublon mobile app, can be obtained and processed.</p>\\n\\n<p>An example of confirming a transaction in the callback:</p>\\n<!-- ngSwitchWhen: textarea --><!-- TODO: Make this generic using 'default' --><!-- ngSwitchWhen: api-header --><!-- ngSwitchWhen: code --><div class=\\\"ng-scope\\\" ng-switch-when=\\\"code\\\"><div type=\\\"section.type\\\" ng-model=\\\"section.data\\\" class=\\\"block-code block-show-code ng-isolate-scope ng-pristine ng-valid\\\">\\n  <div class=\\\"code-tabs ng-hide\\\" ng-show=\\\"data.codes.length > 1 || (data.codes.length == 1 &amp;&amp; data.codes[0].status)\\\">\\n    <!-- ngRepeat: tab in data.codes track by $id($index) --><div class=\\\"ng-scope tab on\\\" ng-class=\\\"{tab: true, on:$index==current, off:$index!=current}\\\" ng-repeat=\\\"tab in data.codes track by $id($index)\\\">\\n      <a href=\\\"\\\" ng-click=\\\"choose($index)\\\">\\n        <!-- ngIf: tab.status -->\\n        <!-- ngIf: !tab.status --><span class=\\\"ng-scope ng-binding\\\" ng-if=\\\"!tab.status\\\">\\n          C#\\n        </span><!-- end ngIf: !tab.status -->\\n      </a><span class=\\\"ng-hide\\\" ng-hide=\\\"$last\\\">·</span>\\n    </div><!-- end ngRepeat: tab in data.codes track by $id($index) -->\\n  </div>\\n\\n  <!-- ngRepeat: tab in data.codes track by $id($index) --><div class=\\\"ng-scope\\\" ng-repeat=\\\"tab in data.codes track by $id($index)\\\" ng-show=\\\"$index==current\\\">\\n  <pre class=\\\"cm-s-neo\\\" data-mode=\\\"csharp\\\"><span class=\\\"cm-variable\\\">class</span> <span class=\\\"cm-variable\\\">TransactionCallback</span> : <span class=\\\"cm-variable\\\">Rublon2FactorCallback</span> \\n{\\n    <span class=\\\"cm-variable\\\">protected</span> <span class=\\\"cm-variable\\\">override</span> <span class=\\\"cm-variable\\\">string</span> <span class=\\\"cm-variable\\\">getState</span>() \\n    {\\n        <span class=\\\"cm-variable\\\">return</span> <span class=\\\"cm-variable\\\">Request</span>.<span class=\\\"cm-variable\\\">Params</span>[<span class=\\\"cm-variable\\\">PARAMETER_STATE</span>];\\n    }\\n    \\n    <span class=\\\"cm-variable\\\">protected</span> <span class=\\\"cm-variable\\\">override</span> <span class=\\\"cm-variable\\\">string</span> <span class=\\\"cm-variable\\\">getAccessToken</span>() \\n    {\\n        <span class=\\\"cm-variable\\\">return</span> <span class=\\\"cm-variable\\\">Request</span>.<span class=\\\"cm-variable\\\">Params</span>[<span class=\\\"cm-variable\\\">PARAMETER_ACCESS_TOKEN</span>];\\n    }\\n    \\n    <span class=\\\"cm-variable\\\">protected</span> <span class=\\\"cm-variable\\\">override</span> <span class=\\\"cm-variable\\\">void</span> <span class=\\\"cm-variable\\\">handleCancel</span>() \\n    {\\n        <span class=\\\"cm-variable\\\">Response</span>.<span class=\\\"cm-variable\\\">Redirect</span>(<span class=\\\"cm-string\\\">\\\"/TransactionConfirm\\\"</span>);\\n    }\\n    \\n    <span class=\\\"cm-variable\\\">protected</span> <span class=\\\"cm-variable\\\">override</span> <span class=\\\"cm-variable\\\">void</span> <span class=\\\"cm-variable\\\">handleError</span>() \\n    {\\n        <span class=\\\"cm-variable\\\">Response</span>.<span class=\\\"cm-variable\\\">Redirect</span>(<span class=\\\"cm-string\\\">\\\"/TransactionConfirm/?msg=rublon-error\\\"</span>);\\n    }\\n    \\n    <span class=\\\"cm-variable\\\">protected</span> <span class=\\\"cm-variable\\\">override</span> <span class=\\\"cm-variable\\\">void</span> <span class=\\\"cm-variable\\\">userAuthenticated</span>(<span class=\\\"cm-variable\\\">string</span> <span class=\\\"cm-variable\\\">userId</span>) \\n    {\\n        <span class=\\\"cm-variable\\\">Credentials</span> <span class=\\\"cm-variable\\\">result</span> <span class=\\\"cm-operator\\\">=</span> <span class=\\\"cm-variable\\\">credentials</span>.<span class=\\\"cm-variable\\\">ResponseResult</span>;\\n        <span class=\\\"cm-variable\\\">string</span> <span class=\\\"cm-variable\\\">transactionId</span> <span class=\\\"cm-operator\\\">=</span> <span class=\\\"cm-variable\\\">result</span>.<span class=\\\"cm-variable\\\">Value</span>(<span class=\\\"cm-string\\\">\\\"transId\\\"</span>);\\n        <span class=\\\"cm-variable\\\">if</span> (<span class=\\\"cm-operator\\\">!</span><span class=\\\"cm-variable\\\">string</span>.<span class=\\\"cm-variable\\\">IsNullOrEmpty</span>(<span class=\\\"cm-variable\\\">transactionId</span>))\\n        {\\n            <span class=\\\"cm-variable\\\">if</span> (<span class=\\\"cm-variable\\\">credentials</span>.<span class=\\\"cm-variable\\\">GetConfirmResult</span>() <span class=\\\"cm-operator\\\">==</span> <span class=\\\"cm-variable\\\">Credentials</span>.<span class=\\\"cm-variable\\\">CONFIRM_RESULT_YES</span>)\\n            {\\n                <span class=\\\"cm-variable\\\">Response</span>.<span class=\\\"cm-variable\\\">Redirect</span>(<span class=\\\"cm-string\\\">\\\"/ConfirmSuccess\\\"</span>);\\n            }\\n            <span class=\\\"cm-variable\\\">else</span>\\n            {\\n                <span class=\\\"cm-variable\\\">Response</span>.<span class=\\\"cm-variable\\\">Redirect</span>(<span class=\\\"cm-string\\\">\\\"/ConfirmFailed\\\"</span>);\\n            }\\n        }\\n    }    \\n}\\n\\n...\\n\\n<span class=\\\"cm-variable\\\">Rublon2Factor</span> <span class=\\\"cm-variable\\\">rublon</span> <span class=\\\"cm-operator\\\">=</span> <span class=\\\"cm-variable\\\">new</span> <span class=\\\"cm-variable\\\">Rublon2Factor</span>\\n(\\n    <span class=\\\"cm-string\\\">\\\"A69FC450848B4B94A040416DC4421523\\\"</span>,\\n    <span class=\\\"cm-string\\\">\\\"bLS6NDP7pGjg346S4IHqTHgQQjjSLw3CyApvz5iRjYzgIPN4e9EOi1cQJLrTlvLoHY8zeqg4ILrItYidKJ6JjEUZaA6pR1tZMwSZ\\\"</span>\\n);\\n\\n<span class=\\\"cm-variable\\\">try</span> \\n{\\n    <span class=\\\"cm-variable\\\">Rublon2FactorCallback</span> <span class=\\\"cm-variable\\\">callback</span> <span class=\\\"cm-operator\\\">=</span> <span class=\\\"cm-variable\\\">new</span> <span class=\\\"cm-variable\\\">TransactionCallback</span>(<span class=\\\"cm-variable\\\">rublon</span>);\\n    <span class=\\\"cm-variable\\\">callback</span>.<span class=\\\"cm-variable\\\">Call</span>();\\n} \\n<span class=\\\"cm-variable\\\">catch</span> (<span class=\\\"cm-variable\\\">CallbackException</span> <span class=\\\"cm-variable\\\">ex</span>) \\n{\\n    <span class=\\\"cm-comment\\\">// Please handle this error in the better way:</span>\\n    <span class=\\\"cm-variable\\\">throw</span>;\\n}</pre>\\n</div><!-- end ngRepeat: tab in data.codes track by $id($index) -->\\n</div></div><!-- ngSwitchWhen: image --><!-- ngSwitchWhen: embed --><!-- ngSwitchWhen: callout --><!-- ngSwitchWhen: parameters --><!-- ngSwitchWhen: html -->      \\n    </div>\\n    <div role=\\\"tabpanel\\\" class=\\\"tab-pane\\\" id=\\\"java\\\">\\n      <br/>\\n      <p>The <code>Rublon2Factor.confirm()</code> method will check the user's protection status (using the email address hash) and return a URL address which the web browser should redirect to (if the user is protected by Rublon), or <code>null</code>, if the user protection is not active.</p>\\n<table>\\n\\t<caption><code>Rublon2Factor.confirm()</code> method arguments</caption>\\n\\t<thead><tr>\\n\\t\\t<th>Name</th>\\n\\t\\t<th>Type</th>\\n\\t\\t<th>Description</th>\\n\\t</tr></thead>\\n\\t<tbody>\\n\\t\\t<tr><td><code>callbackUrl</code></td><td>String</td><td>The integrated system's callback URL\\n</td></tr>\\n\\t\\t<tr><td><code>userId</code></td><td>String</td><td>The integrated system's user's unique Id which will allow to log in the user upon successful authentication</td></tr>\\n\\t\\t<tr><td><code>userEmail</code></td><td>String</td><td>The user's email address in the integrated system which will allow to check the user's protection status and matching the user to a Rublon account</td></tr>\\n\\t\\t<tr><td><code>confirmMessage</code></td><td>String</td><td>Contents of the message displayed in the mobile app\\n</td></tr>\\n\\t\\t<tr><td><code>consumerParams</code></td><td>JSONObject</td><td>Additional transaction parameters (optional)</td></tr>    \\n\\t</tbody>\\n</table>\\n      <h3>Initiating transaction confirmation</h3>\\n      <p>An example of confirming a sensitive transaction using Rublon:</p>\\n      \\n<!-- ngSwitchWhen: textarea --><!-- TODO: Make this generic using 'default' --><!-- ngSwitchWhen: api-header --><!-- ngSwitchWhen: code --><div class=\\\"ng-scope\\\" ng-switch-when=\\\"code\\\"><div type=\\\"section.type\\\" ng-model=\\\"section.data\\\" class=\\\"block-code block-show-code ng-isolate-scope ng-pristine ng-valid\\\">\\n  <div class=\\\"code-tabs ng-hide\\\" ng-show=\\\"data.codes.length > 1 || (data.codes.length == 1 &amp;&amp; data.codes[0].status)\\\">\\n    <!-- ngRepeat: tab in data.codes track by $id($index) --><div class=\\\"ng-scope tab on\\\" ng-class=\\\"{tab: true, on:$index==current, off:$index!=current}\\\" ng-repeat=\\\"tab in data.codes track by $id($index)\\\">\\n      <a href=\\\"\\\" ng-click=\\\"choose($index)\\\">\\n        <!-- ngIf: tab.status -->\\n        <!-- ngIf: !tab.status --><span class=\\\"ng-scope ng-binding\\\" ng-if=\\\"!tab.status\\\">\\n          Java\\n        </span><!-- end ngIf: !tab.status -->\\n      </a><span class=\\\"ng-hide\\\" ng-hide=\\\"$last\\\">·</span>\\n    </div><!-- end ngRepeat: tab in data.codes track by $id($index) -->\\n  </div>\\n\\n  <!-- ngRepeat: tab in data.codes track by $id($index) --><div class=\\\"ng-scope\\\" ng-repeat=\\\"tab in data.codes track by $id($index)\\\" ng-show=\\\"$index==current\\\">\\n  <pre class=\\\"cm-s-neo\\\" data-mode=\\\"java\\\"><span class=\\\"cm-comment\\\">/**</span>\\n<span class=\\\"cm-comment\\\">* Transaction confirmation.</span>\\n<span class=\\\"cm-comment\\\">* </span>\\n<span class=\\\"cm-comment\\\">* @param transId Transaction Id</span>\\n<span class=\\\"cm-comment\\\">* @param amount Transaction amount</span>\\n<span class=\\\"cm-comment\\\">*/</span>\\n<span class=\\\"cm-variable-3\\\">void</span> <span class=\\\"cm-def\\\">confirmTransaction</span>(<span class=\\\"cm-variable-3\\\">String</span> <span class=\\\"cm-variable\\\">transId</span>, <span class=\\\"cm-variable-3\\\">int</span> <span class=\\\"cm-variable\\\">amount</span>) {\\n  <span class=\\\"cm-variable\\\">User</span> <span class=\\\"cm-variable\\\">user</span> <span class=\\\"cm-operator\\\">=</span> <span class=\\\"cm-variable\\\">Session</span>.<span class=\\\"cm-variable\\\">getUser</span>();\\n  <span class=\\\"cm-variable\\\">Rublon2Factor</span> <span class=\\\"cm-variable\\\">rublon</span> <span class=\\\"cm-operator\\\">=</span> <span class=\\\"cm-keyword\\\">new</span> <span class=\\\"cm-variable\\\">Rublon2Factor</span>(<span class=\\\"cm-string\\\">\\\"your_system_token\\\"</span>, <span class=\\\"cm-string\\\">\\\"your_access_key\\\"</span>);\\n    \\n  <span class=\\\"cm-keyword\\\">try</span> { <span class=\\\"cm-comment\\\">// Initiate Rublon authentication</span>\\n    <span class=\\\"cm-variable-3\\\">String</span> <span class=\\\"cm-variable\\\">url</span> <span class=\\\"cm-operator\\\">=</span> <span class=\\\"cm-variable\\\">rublon</span>.<span class=\\\"cm-variable\\\">confirm</span>(\\n      <span class=\\\"cm-string\\\">\\\"http://example.com/rublon_transaction_confirm\\\"</span>, <span class=\\\"cm-comment\\\">// callback URL</span>\\n      <span class=\\\"cm-variable\\\">user</span>.<span class=\\\"cm-variable\\\">getId</span>(), <span class=\\\"cm-comment\\\">// User Id</span>\\n      <span class=\\\"cm-variable\\\">user</span>.<span class=\\\"cm-variable\\\">getEmail</span>(), <span class=\\\"cm-comment\\\">// User email</span>\\n      <span class=\\\"cm-variable-3\\\">String</span>.<span class=\\\"cm-variable\\\">format</span>(<span class=\\\"cm-string\\\">\\\"Do you confirm transaction no. %s with the amount of %d?\\\"</span>, <span class=\\\"cm-variable\\\">transId</span>, <span class=\\\"cm-variable\\\">amount</span>),\\n      <span class=\\\"cm-comment\\\">// Additional transaction parameters:</span>\\n      <span class=\\\"cm-keyword\\\">new</span> <span class=\\\"cm-variable\\\">JSONObject</span>() {{\\n        <span class=\\\"cm-variable\\\">put</span>(<span class=\\\"cm-string\\\">\\\"transId\\\"</span>, <span class=\\\"cm-variable\\\">transId</span>);\\n      }}\\n    );\\n      \\n    <span class=\\\"cm-keyword\\\">if</span> (<span class=\\\"cm-variable\\\">url</span> <span class=\\\"cm-operator\\\">!=</span> <span class=\\\"cm-atom\\\">null</span>) { <span class=\\\"cm-comment\\\">// Rublon protection is active</span>\\n      <span class=\\\"cm-comment\\\">// Redirect the web browser to Rublon servers</span>\\n      <span class=\\\"cm-comment\\\">// to confirm the transaction:</span>\\n      <span class=\\\"cm-variable\\\">HttpServer</span>.<span class=\\\"cm-variable\\\">sendHeader</span>(<span class=\\\"cm-string\\\">\\\"Location\\\"</span>, <span class=\\\"cm-variable\\\">url</span>); \\n    }\\n      \\n  } <span class=\\\"cm-keyword\\\">catch</span> (<span class=\\\"cm-variable\\\">RublonException</span> <span class=\\\"cm-variable\\\">e</span>) {\\n    <span class=\\\"cm-comment\\\">// An error occurred</span>\\n    <span class=\\\"cm-variable\\\">HttpServer</span>.<span class=\\\"cm-variable\\\">setStatus</span>(<span class=\\\"cm-number\\\">500</span>);\\n    <span class=\\\"cm-variable\\\">HttpServer</span>.<span class=\\\"cm-variable\\\">setResponse</span>(<span class=\\\"cm-string\\\">\\\"There was an error, please try again later.\\\"</span>);\\n  }\\n    \\n  <span class=\\\"cm-comment\\\">/* If we're here, the user's account is not protected by Rublon,</span>\\n  <span class=\\\"cm-comment\\\">so the user should confirm the transaction some other way</span>\\n  <span class=\\\"cm-comment\\\">or bypass the confirmation. */</span>\\n}</pre>\\n</div><!-- end ngRepeat: tab in data.codes track by $id($index) -->\\n</div></div><!-- ngSwitchWhen: image --><!-- ngSwitchWhen: embed --><!-- ngSwitchWhen: callout --><!-- ngSwitchWhen: parameters --><!-- ngSwitchWhen: html -->\\n      <p>If the user's account is protected by Rublon, calling the <code>Rublon2Factor.confirm()</code> method will return a URL address which the user's web browser should redirect to so as to scan a QR code and confirm the transaction.</p>\\n\\n      <h3>Finalizing the transaction</h3>\\n\\n<p>Finalizing the whole process involves invoking a callback URL, similarly to the authentication process. In the callback the user's answer to the transaction confirmation question, given by the user in the Rublon mobile app, can be obtained and processed.</p>\\n\\n<p>An example of confirming a transaction in the callback:</p>\\n     <div type=\\\"section.type\\\" ng-model=\\\"section.data\\\" class=\\\"block-code block-show-code ng-isolate-scope ng-pristine ng-valid\\\">\\n  <div class=\\\"code-tabs ng-hide\\\" ng-show=\\\"data.codes.length > 1 || (data.codes.length == 1 &amp;&amp; data.codes[0].status)\\\">\\n    <!-- ngRepeat: tab in data.codes track by $id($index) --><div class=\\\"ng-scope tab on\\\" ng-class=\\\"{tab: true, on:$index==current, off:$index!=current}\\\" ng-repeat=\\\"tab in data.codes track by $id($index)\\\">\\n      <a href=\\\"\\\" ng-click=\\\"choose($index)\\\">\\n        <!-- ngIf: tab.status -->\\n        <!-- ngIf: !tab.status --><span class=\\\"ng-scope ng-binding\\\" ng-if=\\\"!tab.status\\\">\\n          PHP\\n        </span><!-- end ngIf: !tab.status -->\\n      </a><span class=\\\"ng-hide\\\" ng-hide=\\\"$last\\\">·</span>\\n    </div><!-- end ngRepeat: tab in data.codes track by $id($index) -->\\n  </div>\\n\\n  <!-- ngRepeat: tab in data.codes track by $id($index) --><div class=\\\"ng-scope\\\" ng-repeat=\\\"tab in data.codes track by $id($index)\\\" ng-show=\\\"$index==current\\\">\\n  <pre class=\\\"cm-s-neo\\\" data-mode=\\\"php\\\"><span class=\\\"cm-meta\\\">&lt;?</span>\\n<span class=\\\"cm-variable-2\\\">$rublon</span> <span class=\\\"cm-operator\\\">=</span> <span class=\\\"cm-keyword\\\">new</span> <span class=\\\"cm-variable\\\">Rublon2Factor</span>(<span class=\\\"cm-string\\\">\\\"</span><span class=\\\"cm-string\\\">your_system_token\\\"</span>, <span class=\\\"cm-string\\\">\\\"</span><span class=\\\"cm-string\\\">your_access_key\\\"</span>);\\n<span class=\\\"cm-keyword\\\">try</span> {\\n  <span class=\\\"cm-variable-2\\\">$callback</span> <span class=\\\"cm-operator\\\">=</span> <span class=\\\"cm-keyword\\\">new</span> <span class=\\\"cm-variable\\\">Rublon2FactorCallback</span>(<span class=\\\"cm-variable-2\\\">$rublon</span>);\\n  <span class=\\\"cm-variable-2\\\">$callback</span><span class=\\\"cm-operator\\\">-&gt;</span><span class=\\\"cm-variable\\\">call</span>(\\n    <span class=\\\"cm-variable-2\\\">$successHandler</span> <span class=\\\"cm-operator\\\">=</span> <span class=\\\"cm-keyword\\\">function</span>(<span class=\\\"cm-variable-2\\\">$userId</span>, <span class=\\\"cm-variable\\\">Rublon2FactorCallback</span> <span class=\\\"cm-variable-2\\\">$callback</span>) {\\n      <span class=\\\"cm-variable-2\\\">$params</span> <span class=\\\"cm-operator\\\">=</span> <span class=\\\"cm-variable-2\\\">$callback</span><span class=\\\"cm-operator\\\">-&gt;</span><span class=\\\"cm-variable\\\">getCredentials</span>()<span class=\\\"cm-operator\\\">-&gt;</span><span class=\\\"cm-variable\\\">getResponse</span>();\\n      <span class=\\\"cm-keyword\\\">if</span> (<span class=\\\"cm-keyword\\\">isset</span>(<span class=\\\"cm-variable-2\\\">$params</span>[<span class=\\\"cm-string\\\">'transId'</span>])) {\\n        <span class=\\\"cm-keyword\\\">if</span> (<span class=\\\"cm-variable\\\">RublonAPICredentials</span>::<span class=\\\"cm-variable\\\">CONFIRM_RESULT_YES</span> <span class=\\\"cm-operator\\\">==</span> <span class=\\\"cm-variable-2\\\">$callback</span><span class=\\\"cm-operator\\\">-&gt;</span><span class=\\\"cm-variable\\\">getCredentials</span>()<span class=\\\"cm-operator\\\">-&gt;</span><span class=\\\"cm-variable\\\">getConfirmResult</span>()) {\\n          <span class=\\\"cm-comment\\\">// Transaction confirmed, do something with it:</span>\\n          <span class=\\\"cm-variable\\\">transaction_confirmed</span>(<span class=\\\"cm-variable-2\\\">$params</span>[<span class=\\\"cm-string\\\">'transId'</span>]);\\n        } <span class=\\\"cm-keyword\\\">else</span> {\\n          <span class=\\\"cm-comment\\\">// Transaction denied, cancel and clean:</span>\\n          <span class=\\\"cm-variable\\\">transaction_denied</span>(<span class=\\\"cm-variable-2\\\">$params</span>[<span class=\\\"cm-string\\\">'transId'</span>]);\\n        }\\n      }\\n    },\\n    <span class=\\\"cm-variable-2\\\">$cancelHandler</span> <span class=\\\"cm-operator\\\">=</span> <span class=\\\"cm-keyword\\\">function</span>(<span class=\\\"cm-variable\\\">Rublon2FactorCallback</span> <span class=\\\"cm-variable-2\\\">$callback</span>) {\\n      <span class=\\\"cm-comment\\\">// Cancel the process</span>\\n      <span class=\\\"cm-variable\\\">redirect</span>(<span class=\\\"cm-string\\\">\\\"</span><span class=\\\"cm-string\\\">/dashboard\\\"</span>);\\n    }\\n  );\\n  \\n  <span class=\\\"cm-comment\\\">// The process was successful</span>\\n  <span class=\\\"cm-variable\\\">redirect</span>(<span class=\\\"cm-string\\\">\\\"</span><span class=\\\"cm-string\\\">/dashboard\\\"</span>);\\n\\n} <span class=\\\"cm-keyword\\\">catch</span> (<span class=\\\"cm-variable\\\">RublonException</span> <span class=\\\"cm-variable-2\\\">$e</span>) {\\n  <span class=\\\"cm-comment\\\">// Please handle this error in the better way:</span>\\n  <span class=\\\"cm-keyword\\\">die</span>(<span class=\\\"cm-variable-2\\\">$e</span><span class=\\\"cm-operator\\\">-&gt;</span><span class=\\\"cm-variable\\\">getMessage</span>());\\n}</pre>\\n</div><!-- end ngRepeat: tab in data.codes track by $id($index) -->\\n</div>    \\n    </div>\\n    <div role=\\\"tabpanel\\\" class=\\\"tab-pane\\\" id=\\\"python\\\">\\n      <br/>\\n      <p>The <code>Rublon2Factor.confirm()</code> method will check the user's protection status (using the email address hash) and return a URL address which the web browser should redirect to (if the user is protected by Rublon), or <code>null</code>, if the user protection is not active.</p>\\n<table>\\n\\t<caption><code>Rublon2Factor.confirm()</code> method arguments</caption>\\n\\t<thead><tr>\\n\\t\\t<th>Name</th>\\n\\t\\t<th>Type</th>\\n\\t\\t<th>Description</th>\\n\\t</tr></thead>\\n\\t<tbody>\\n\\t\\t<tr><td><code>callback_url</code></td><td>str</td><td>The integrated system's callback URL\\n</td></tr>\\n\\t\\t<tr><td><code>user_id</code></td><td>str</td><td>The integrated system's user's unique Id which will allow to log in the user upon successful authentication</td></tr>\\n\\t\\t<tr><td><code>user_email</code></td><td>str</td><td>The user's email address in the integrated system which will allow to check the user's protection status and matching the user to a Rublon account</td></tr>\\n\\t\\t<tr><td><code>confirm_message</code></td><td>str</td><td>Contents of the message displayed in the mobile app\\n</td></tr>\\n\\t\\t<tr><td><code>consumer_params</code></td><td>dict</td><td>Additional transaction parameters (optional)</td></tr>    \\n\\t</tbody>\\n</table>\\n      <h3>Initiating transaction confirmation</h3>\\n      <p>An example of confirming a sensitive transaction using Rublon:</p>\\n\\n<div type=\\\"section.type\\\" ng-model=\\\"section.data\\\" class=\\\"block-code block-show-code ng-isolate-scope ng-pristine ng-valid\\\">\\n  <div class=\\\"code-tabs ng-hide\\\" ng-show=\\\"data.codes.length > 1 || (data.codes.length == 1 &amp;&amp; data.codes[0].status)\\\">\\n    <!-- ngRepeat: tab in data.codes track by $id($index) --><div class=\\\"ng-scope tab on\\\" ng-class=\\\"{tab: true, on:$index==current, off:$index!=current}\\\" ng-repeat=\\\"tab in data.codes track by $id($index)\\\">\\n      <a href=\\\"\\\" ng-click=\\\"choose($index)\\\">\\n        <!-- ngIf: tab.status -->\\n        <!-- ngIf: !tab.status --><span class=\\\"ng-scope ng-binding\\\" ng-if=\\\"!tab.status\\\">\\n          Python\\n        </span><!-- end ngIf: !tab.status -->\\n      </a><span class=\\\"ng-hide\\\" ng-hide=\\\"$last\\\">·</span>\\n    </div><!-- end ngRepeat: tab in data.codes track by $id($index) -->\\n  </div>\\n\\n  <!-- ngRepeat: tab in data.codes track by $id($index) --><div class=\\\"ng-scope\\\" ng-repeat=\\\"tab in data.codes track by $id($index)\\\" ng-show=\\\"$index==current\\\">\\n  <pre class=\\\"cm-s-neo\\\" data-mode=\\\"python\\\"><span class=\\\"cm-comment\\\"># Transaction confirmation.</span>\\n<span class=\\\"cm-keyword\\\">def</span> <span class=\\\"cm-def\\\">confirm_transaction</span>(<span class=\\\"cm-variable\\\">trans_id</span>, <span class=\\\"cm-variable\\\">amount</span>)\\n    <span class=\\\"cm-variable\\\">RUBLON_SYSTEM_TOKEN</span> = <span class=\\\"cm-string\\\">\\\"your_system_token\\\"</span>\\n    <span class=\\\"cm-variable\\\">RUBLON_SECRET_KEY</span> = <span class=\\\"cm-string\\\">\\\"your_secret_key\\\"</span>\\n    <span class=\\\"cm-variable\\\">callback_url</span> = <span class=\\\"cm-string\\\">\\\"http://example.com/rublon_transaction_confirm\\\"</span>,\\n    <span class=\\\"cm-variable\\\">user</span> = <span class=\\\"cm-variable\\\">session</span>[<span class=\\\"cm-string\\\">'user'</span>]\\n    <span class=\\\"cm-variable\\\">confirm_message</span> = <span class=\\\"cm-string\\\">\\\"Do you confirm transaction no. {0} with the amount of {1}?\\\"</span>.<span class=\\\"cm-builtin\\\">format</span>(<span class=\\\"cm-variable\\\">trans_id</span>, <span class=\\\"cm-variable\\\">amount</span>)\\n    <span class=\\\"cm-variable\\\">consumer_params</span> = {<span class=\\\"cm-string\\\">'trans_id'</span>: <span class=\\\"cm-variable\\\">trans_id</span>}\\n  \\n    <span class=\\\"cm-variable\\\">rublon</span> = <span class=\\\"cm-variable\\\">Rublon2Factor</span>(<span class=\\\"cm-variable\\\">RUBLON_SYSTEM_TOKEN</span>, <span class=\\\"cm-variable\\\">RUBLON_SECRET_KEY</span>)\\n  \\n    <span class=\\\"cm-comment\\\"># Initiate Rublon authentication</span>\\n    <span class=\\\"cm-keyword\\\">try</span>:\\n        <span class=\\\"cm-variable\\\">url</span> = <span class=\\\"cm-variable\\\">rublon</span>.<span class=\\\"cm-variable\\\">confirm</span>(<span class=\\\"cm-variable\\\">callback_url</span>, <span class=\\\"cm-variable\\\">user</span>[<span class=\\\"cm-string\\\">'id'</span>], <span class=\\\"cm-variable\\\">user</span>[<span class=\\\"cm-string\\\">'email'</span>], <span class=\\\"cm-variable\\\">confirm_message</span>, <span class=\\\"cm-variable\\\">consumer_params</span>)\\n    \\n        <span class=\\\"cm-comment\\\">#Rublon protection is active</span>\\n        <span class=\\\"cm-keyword\\\">if</span> <span class=\\\"cm-variable\\\">url</span> : \\n            <span class=\\\"cm-comment\\\">#Redirect the web browser to Rublon servers to confirm the transaction</span>\\n            <span class=\\\"cm-keyword\\\">return</span> <span class=\\\"cm-variable\\\">redirect</span>(<span class=\\\"cm-variable\\\">url</span>)\\n        <span class=\\\"cm-keyword\\\">break</span>\\n    <span class=\\\"cm-keyword\\\">except</span> <span class=\\\"cm-variable\\\">RublonException</span>:\\n        <span class=\\\"cm-keyword\\\">raise</span>\\n\\n    <span class=\\\"cm-comment\\\">#If we're here, the user's account is not protected by Rublon,</span>\\n    <span class=\\\"cm-comment\\\">#so the user should confirm the transaction some other way.</span></pre>\\n</div><!-- end ngRepeat: tab in data.codes track by $id($index) -->\\n</div>\\n      <p>If the user's account is protected by Rublon, calling the <code>Rublon2Factor.confirm()</code> method will return a URL address which the user's web browser should redirect to so as to scan a QR code and confirm the transaction.</p>\\n\\n      <h3>Finalizing the transaction</h3>\\n\\n<p>Finalizing the whole process involves invoking a callback URL, similarly to the authentication process. In the callback the user's answer to the transaction confirmation question, given by the user in the Rublon mobile app, can be obtained and processed.</p>\\n<!--\\n<p>An example of confirming a transaction in the callback:</p>\\n      <pre><code>\\n      \\n      </code></pre>      -->\\n    </div>\\n  </div>\\n\\n</div>\\n<style>\\n.langnav > li > a {\\n    padding: 3px 15px;\\n}\\ncaption{\\n\\t\\tmargin:10px;\\n}\\n.tab-pane h3 {\\n    color: #555;\\n    font-size: 17px;\\n    font-weight: 700;\\n    text-transform: uppercase;\\n}  \\n</style>\"\n}\n[/block]","excerpt":"","slug":"sdk-secure-transaction-confirmation","type":"basic","title":"Secure transaction confirmation"}

Secure transaction confirmation


[block:callout] { "type": "info", "body": "This feature is available only to systems integrated within the Business plan. [Check the pricing](https://developers.rublon.com/98/Pricing)." } [/block] If you are concerned about the security of some of your more sensitive transactions, e.g. financial transfers, changing your password or email address, Rublon provides the means for confirming such processes in a secure way. This feature is similar in operation to the Rublon-confirmed authentication, however instead of scanning a QR code the user is required to answer a question displayed in the Rublon mobile app via a push notification. After initiating a Rublon-confirmed transaction, a message will be displayed in the mobile app, asking the user to confirm the transaction. The contents of such message is prepared by the integrated system itself and can contain information which will help the user identify which transaction the message pertains to, e.g. the amount of a money transfer or info about the changed password. The user will have to confirm the transaction by pressing "YES" or deny it by pressing "NO". Confirmation of the transaction should be initiated only after a user is logged in and the user's unique Id and email address are known. [block:html] { "html": "<div>\n <!-- Nav tabs -->\n <ul class=\"nav nav-tabs langnav\" role=\"tablist\">\n <li role=\"presentation\" class=\"active\"><a href=\"#php\" aria-controls=\"php\" role=\"tab\" data-toggle=\"tab\">PHP</a></li>\n <li role=\"presentation\"><a href=\"#net\" aria-controls=\"net\" role=\"tab\" data-toggle=\"tab\">.NET</a></li>\n <li role=\"presentation\"><a href=\"#java\" aria-controls=\"java\" role=\"tab\" data-toggle=\"tab\">Java</a></li>\n <li role=\"presentation\"><a href=\"#python\" aria-controls=\"python\" role=\"tab\" data-toggle=\"tab\">Python</a></li>\n </ul>\n\n <!-- Tab panes -->\n <div class=\"tab-content\">\n <div role=\"tabpanel\" class=\"tab-pane active\" id=\"php\">\n <br/>\n <p>The <code>Rublon2Factor::confirm()</code> method will check the user's protection status (using the email address hash) and return a URL address which the web browser should redirect to (if the user is protected by Rublon), or <code>NULL</code>, if the user protection is not active.</p>\n<table>\n\t<caption><code>Rublon2Factor::confirm()</code> method arguments</caption>\n\t<thead><tr>\n\t\t<th>Name</th>\n\t\t<th>Type</th>\n\t\t<th>Description</th>\n\t</tr></thead>\n\t<tbody>\n\t\t<tr><td><code>$callbackUrl</code></td><td>string</td><td>The integrated system's callback URL\n</td></tr>\n\t\t<tr><td><code>$userId</code></td><td>string</td><td>The integrated system's user's unique Id which will allow to log in the user upon successful authentication</td></tr>\n\t\t<tr><td><code>$userEmail</code></td><td>string</td><td>The user's email address in the integrated system which will allow to check the user's protection status and matching the user to a Rublon account</td></tr>\n\t\t<tr><td><code>$confirmMessage</code></td><td>string</td><td>Contents of the message displayed in the mobile app\n</td></tr>\n\t\t<tr><td><code>$consumerParams</code></td><td>array</td><td>Additional transaction parameters (optional)</td></tr> \n\t</tbody>\n</table> \n <h3>Initiating transaction confirmation</h3>\n <p>An example of confirming a sensitive transaction using Rublon:</p>\n<!-- ngSwitchWhen: textarea --><!-- TODO: Make this generic using 'default' --><!-- ngSwitchWhen: api-header --><!-- ngSwitchWhen: code --><div class=\"ng-scope\" ng-switch-when=\"code\"><div type=\"section.type\" ng-model=\"section.data\" class=\"block-code block-show-code ng-isolate-scope ng-pristine ng-valid\">\n <div class=\"code-tabs ng-hide\" ng-show=\"data.codes.length > 1 || (data.codes.length == 1 &amp;&amp; data.codes[0].status)\">\n <!-- ngRepeat: tab in data.codes track by $id($index) --><div class=\"ng-scope tab on\" ng-class=\"{tab: true, on:$index==current, off:$index!=current}\" ng-repeat=\"tab in data.codes track by $id($index)\">\n <a href=\"\" ng-click=\"choose($index)\">\n <!-- ngIf: tab.status -->\n <!-- ngIf: !tab.status --><span class=\"ng-scope ng-binding\" ng-if=\"!tab.status\">\n PHP\n </span><!-- end ngIf: !tab.status -->\n </a><span class=\"ng-hide\" ng-hide=\"$last\">·</span>\n </div><!-- end ngRepeat: tab in data.codes track by $id($index) -->\n </div>\n\n <!-- ngRepeat: tab in data.codes track by $id($index) --><div class=\"ng-scope\" ng-repeat=\"tab in data.codes track by $id($index)\" ng-show=\"$index==current\">\n <pre class=\"cm-s-neo\" data-mode=\"php\"><span class=\"cm-meta\">&lt;?</span>\n<span class=\"cm-comment\">/**</span>\n <span class=\"cm-comment\">* Transaction confirmation.</span>\n <span class=\"cm-comment\">* </span>\n <span class=\"cm-comment\">* @param int $transId Transaction Id</span>\n <span class=\"cm-comment\">* @param int $amount Transaction amount</span>\n <span class=\"cm-comment\">*/</span>\n<span class=\"cm-keyword\">function</span> <span class=\"cm-def\">confirmTransaction</span>(<span class=\"cm-variable-2\">$transId</span>, <span class=\"cm-variable-2\">$amount</span>) {\n <span class=\"cm-variable-2\">$user</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable-2\">$_SESSION</span>[<span class=\"cm-string\">'user'</span>];\n <span class=\"cm-variable-2\">$rublon</span> <span class=\"cm-operator\">=</span> <span class=\"cm-keyword\">new</span> <span class=\"cm-variable\">Rublon2Factor</span>(<span class=\"cm-string\">\"</span><span class=\"cm-string\">your_system_token\"</span>, <span class=\"cm-string\">\"</span><span class=\"cm-string\">your_access_key\"</span>);\n <span class=\"cm-keyword\">try</span> { <span class=\"cm-comment\">// Initiate Rublon authentication</span>\n <span class=\"cm-variable-2\">$url</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable-2\">$rublon</span><span class=\"cm-operator\">-&gt;</span><span class=\"cm-variable\">confirm</span>(\n <span class=\"cm-variable-2\">$callbackUrl</span> <span class=\"cm-operator\">=</span> <span class=\"cm-string\">\"</span><span class=\"cm-string\">http://example.com/rublon_transaction_confirm.php\"</span>,\n <span class=\"cm-variable-2\">$user</span>[<span class=\"cm-string\">\"</span><span class=\"cm-string\">id\"</span>], <span class=\"cm-comment\">// User Id</span>\n <span class=\"cm-variable-2\">$user</span>[<span class=\"cm-string\">\"</span><span class=\"cm-string\">email\"</span>], <span class=\"cm-comment\">// User email</span>\n <span class=\"cm-variable-2\">$msg</span> <span class=\"cm-operator\">=</span> <span class=\"cm-builtin\">sprintf</span>(<span class=\"cm-string\">\"</span><span class=\"cm-string\">Do you confirm transaction no. %d with the amount of %d?\"</span>, <span class=\"cm-variable-2\">$transId</span>, <span class=\"cm-variable-2\">$amount</span>),\n <span class=\"cm-variable-2\">$params</span> <span class=\"cm-operator\">=</span> <span class=\"cm-keyword\">array</span>(<span class=\"cm-string\">\"</span><span class=\"cm-string\">transId\"</span> <span class=\"cm-operator\">=&gt;</span> <span class=\"cm-variable-2\">$transId</span>) <span class=\"cm-comment\">// Additional transaction parameters</span>\n );\n\n <span class=\"cm-keyword\">if</span> (<span class=\"cm-operator\">!</span><span class=\"cm-keyword\">empty</span>(<span class=\"cm-variable-2\">$url</span>)) { <span class=\"cm-comment\">// Rublon protection is active</span>\n <span class=\"cm-comment\">// Redirect the web browser to Rublon servers</span>\n <span class=\"cm-comment\">// to confirm the transaction:</span>\n <span class=\"cm-builtin\">header</span>(<span class=\"cm-string\">'Location: '</span> . <span class=\"cm-variable-2\">$url</span>);\n }\n\n } <span class=\"cm-keyword\">catch</span> (<span class=\"cm-variable\">RublonException</span> <span class=\"cm-variable-2\">$e</span>) {\n <span class=\"cm-comment\">// An error occurred</span>\n <span class=\"cm-keyword\">die</span>(<span class=\"cm-string\">\"</span><span class=\"cm-string\">There was an error, please try again later.\"</span>);\n }\n\n <span class=\"cm-comment\">/* If we're here, the user's account is not protected by Rublon,</span>\n <span class=\"cm-comment\">so the user should confirm the transaction some other way. */</span>\n <span class=\"cm-keyword\">return</span> <span class=\"cm-atom\">true</span>;\n}</pre>\n</div><!-- end ngRepeat: tab in data.codes track by $id($index) -->\n</div></div><!-- ngSwitchWhen: image --><!-- ngSwitchWhen: embed --><!-- ngSwitchWhen: callout --><!-- ngSwitchWhen: parameters --><!-- ngSwitchWhen: html -->\n\n \n <p>If the user's account is protected by Rublon, calling the <code>Rublon2Factor::confirm()</code> method will return a URL address which the user's web browser should redirect to so as to scan a QR code and confirm the transaction.</p>\n\n <h3>Finalizing the transaction</h3>\n\n<p>Finalizing the whole process involves invoking a callback URL, similarly to the authentication process. In the callback the user's answer to the transaction confirmation question, given by the user in the Rublon mobile app, can be obtained and processed.</p>\n\n<p>An example of confirming a transaction in the callback:</p>\n\n <!-- ngSwitchWhen: textarea --><!-- TODO: Make this generic using 'default' --><!-- ngSwitchWhen: api-header --><!-- ngSwitchWhen: code --><div class=\"ng-scope\" ng-switch-when=\"code\"><div type=\"section.type\" ng-model=\"section.data\" class=\"block-code block-show-code ng-isolate-scope ng-pristine ng-valid\">\n <div class=\"code-tabs ng-hide\" ng-show=\"data.codes.length > 1 || (data.codes.length == 1 &amp;&amp; data.codes[0].status)\">\n <!-- ngRepeat: tab in data.codes track by $id($index) --><div class=\"ng-scope tab on\" ng-class=\"{tab: true, on:$index==current, off:$index!=current}\" ng-repeat=\"tab in data.codes track by $id($index)\">\n <a href=\"\" ng-click=\"choose($index)\">\n <!-- ngIf: tab.status -->\n <!-- ngIf: !tab.status --><span class=\"ng-scope ng-binding\" ng-if=\"!tab.status\">\n PHP\n </span><!-- end ngIf: !tab.status -->\n </a><span class=\"ng-hide\" ng-hide=\"$last\">·</span>\n </div><!-- end ngRepeat: tab in data.codes track by $id($index) -->\n </div>\n\n <!-- ngRepeat: tab in data.codes track by $id($index) --><div class=\"ng-scope\" ng-repeat=\"tab in data.codes track by $id($index)\" ng-show=\"$index==current\">\n <pre class=\"cm-s-neo\" data-mode=\"php\"><span class=\"cm-meta\">&lt;?</span>\n<span class=\"cm-variable-2\">$rublon</span> <span class=\"cm-operator\">=</span> <span class=\"cm-keyword\">new</span> <span class=\"cm-variable\">Rublon2Factor</span>(<span class=\"cm-string\">\"</span><span class=\"cm-string\">your_system_token\"</span>, <span class=\"cm-string\">\"</span><span class=\"cm-string\">your_access_key\"</span>);\n<span class=\"cm-keyword\">try</span> {\n <span class=\"cm-variable-2\">$callback</span> <span class=\"cm-operator\">=</span> <span class=\"cm-keyword\">new</span> <span class=\"cm-variable\">Rublon2FactorCallback</span>(<span class=\"cm-variable-2\">$rublon</span>);\n <span class=\"cm-variable-2\">$callback</span><span class=\"cm-operator\">-&gt;</span><span class=\"cm-variable\">call</span>(\n <span class=\"cm-variable-2\">$successHandler</span> <span class=\"cm-operator\">=</span> <span class=\"cm-keyword\">function</span>(<span class=\"cm-variable-2\">$userId</span>, <span class=\"cm-variable\">Rublon2FactorCallback</span> <span class=\"cm-variable-2\">$callback</span>) {\n <span class=\"cm-variable-2\">$params</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable-2\">$callback</span><span class=\"cm-operator\">-&gt;</span><span class=\"cm-variable\">getCredentials</span>()<span class=\"cm-operator\">-&gt;</span><span class=\"cm-variable\">getResponse</span>();\n <span class=\"cm-keyword\">if</span> (<span class=\"cm-keyword\">isset</span>(<span class=\"cm-variable-2\">$params</span>[<span class=\"cm-string\">'transId'</span>])) {\n <span class=\"cm-keyword\">if</span> (<span class=\"cm-variable\">RublonAPICredentials</span>::<span class=\"cm-variable\">CONFIRM_RESULT_YES</span> <span class=\"cm-operator\">==</span> <span class=\"cm-variable-2\">$callback</span><span class=\"cm-operator\">-&gt;</span><span class=\"cm-variable\">getCredentials</span>()<span class=\"cm-operator\">-&gt;</span><span class=\"cm-variable\">getConfirmResult</span>()) {\n <span class=\"cm-comment\">// Transaction confirmed, do something with it:</span>\n <span class=\"cm-variable\">transaction_confirmed</span>(<span class=\"cm-variable-2\">$params</span>[<span class=\"cm-string\">'transId'</span>]);\n } <span class=\"cm-keyword\">else</span> {\n <span class=\"cm-comment\">// Transaction denied, cancel and clean:</span>\n <span class=\"cm-variable\">transaction_denied</span>(<span class=\"cm-variable-2\">$params</span>[<span class=\"cm-string\">'transId'</span>]);\n }\n }\n },\n <span class=\"cm-variable-2\">$cancelHandler</span> <span class=\"cm-operator\">=</span> <span class=\"cm-keyword\">function</span>(<span class=\"cm-variable\">Rublon2FactorCallback</span> <span class=\"cm-variable-2\">$callback</span>) {\n <span class=\"cm-comment\">// Cancel the process</span>\n <span class=\"cm-variable\">redirect</span>(<span class=\"cm-string\">\"</span><span class=\"cm-string\">/dashboard\"</span>);\n }\n );\n \n <span class=\"cm-comment\">// The process was successful</span>\n <span class=\"cm-variable\">redirect</span>(<span class=\"cm-string\">\"</span><span class=\"cm-string\">/dashboard\"</span>);\n\n} <span class=\"cm-keyword\">catch</span> (<span class=\"cm-variable\">RublonException</span> <span class=\"cm-variable-2\">$e</span>) {\n <span class=\"cm-comment\">// Please handle this error in the better way:</span>\n <span class=\"cm-keyword\">die</span>(<span class=\"cm-variable-2\">$e</span><span class=\"cm-operator\">-&gt;</span><span class=\"cm-variable\">getMessage</span>());\n}</pre>\n</div><!-- end ngRepeat: tab in data.codes track by $id($index) -->\n</div></div><!-- ngSwitchWhen: image --><!-- ngSwitchWhen: embed --><!-- ngSwitchWhen: callout --><!-- ngSwitchWhen: parameters --><!-- ngSwitchWhen: html -->\n \n </div>\n <div role=\"tabpanel\" class=\"tab-pane\" id=\"net\">\n <br/>\n <p>The <code>Rublon2Factor.Confirm()</code> method will check the user's protection status (using the email address hash) and return a URL address which the web browser should redirect to (if the user is protected by Rublon), or <code>null</code>, if the user protection is not active.</p>\n<table>\n\t<caption><code>Rublon2Factor.Confirm()</code> method arguments</caption>\n\t<thead><tr>\n\t\t<th>Name</th>\n\t\t<th>Type</th>\n\t\t<th>Description</th>\n\t</tr></thead>\n\t<tbody>\n\t\t<tr><td><code>callbackUrl</code></td><td>string</td><td>The integrated system's callback URL\n</td></tr>\n\t\t<tr><td><code>userId</code></td><td>string</td><td>The integrated system's user's unique Id which will allow to log in the user upon successful authentication</td></tr>\n\t\t<tr><td><code>userEmail</code></td><td>string</td><td>The user's email address in the integrated system which will allow to check the user's protection status and matching the user to a Rublon account</td></tr>\n\t\t<tr><td><code>confirmMessage</code></td><td>string</td><td>Contents of the message displayed in the mobile app\n</td></tr>\n\t\t<tr><td><code>consumerParams</code></td><td>JObject</td><td>Additional transaction parameters (optional)</td></tr> \n\t</tbody>\n</table> \n <h3>Initiating transaction confirmation</h3>\n <p>An example of confirming a sensitive transaction using Rublon:</p>\n<!-- ngSwitchWhen: textarea --><!-- TODO: Make this generic using 'default' --><!-- ngSwitchWhen: api-header --><!-- ngSwitchWhen: code --><div class=\"ng-scope\" ng-switch-when=\"code\"><div type=\"section.type\" ng-model=\"section.data\" class=\"block-code block-show-code ng-isolate-scope ng-pristine ng-valid\">\n <div class=\"code-tabs ng-hide\" ng-show=\"data.codes.length > 1 || (data.codes.length == 1 &amp;&amp; data.codes[0].status)\">\n <!-- ngRepeat: tab in data.codes track by $id($index) --><div class=\"ng-scope tab on\" ng-class=\"{tab: true, on:$index==current, off:$index!=current}\" ng-repeat=\"tab in data.codes track by $id($index)\">\n <a href=\"\" ng-click=\"choose($index)\">\n <!-- ngIf: tab.status -->\n <!-- ngIf: !tab.status --><span class=\"ng-scope ng-binding\" ng-if=\"!tab.status\">\n C#\n </span><!-- end ngIf: !tab.status -->\n </a><span class=\"ng-hide\" ng-hide=\"$last\">·</span>\n </div><!-- end ngRepeat: tab in data.codes track by $id($index) -->\n </div>\n\n <!-- ngRepeat: tab in data.codes track by $id($index) --><div class=\"ng-scope\" ng-repeat=\"tab in data.codes track by $id($index)\" ng-show=\"$index==current\">\n <pre class=\"cm-s-neo\" data-mode=\"csharp\"><span class=\"cm-comment\">//</span>\n<span class=\"cm-comment\">// Transaction confirmation.</span>\n<span class=\"cm-comment\">// </span>\n<span class=\"cm-variable\">void</span> <span class=\"cm-variable\">confirmTransaction</span>(<span class=\"cm-variable\">string</span> <span class=\"cm-variable\">transId</span>, <span class=\"cm-variable\">int</span> <span class=\"cm-variable\">amount</span>) \n{\n <span class=\"cm-variable\">User</span> <span class=\"cm-variable\">user</span> <span class=\"cm-operator\">=</span> (<span class=\"cm-variable\">User</span>)<span class=\"cm-variable\">Session</span>[<span class=\"cm-string\">\"loggedUser\"</span>];\n <span class=\"cm-variable\">Rublon2Factor</span> <span class=\"cm-variable\">rublon</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable\">new</span> <span class=\"cm-variable\">Rublon2Factor</span>\n (\n <span class=\"cm-comment\">// systemToken:</span>\n <span class=\"cm-string\">\"A69FC450848B4B94A040416DC4421523\"</span>,\n <span class=\"cm-comment\">// secretKey:</span>\n <span class=\"cm-string\">\"bLS6NDP7pGjg346S4IHqTHgQQjjSLw3CyApvz5iRjYzgIPN4e9EOi1cQJLrTlvLoHY8zeqg4ILrItYidKJ6JjEUZaA6pR1tZMwSZ\"</span>\n );\n\n <span class=\"cm-variable\">JObject</span> <span class=\"cm-variable\">parameters</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable\">new</span> <span class=\"cm-variable\">JObject</span>();\n <span class=\"cm-variable\">parameters</span>.<span class=\"cm-variable\">Add</span>(<span class=\"cm-string\">\"transId\"</span>, <span class=\"cm-variable\">transId</span>);\n \n <span class=\"cm-variable\">try</span> <span class=\"cm-comment\">// Initiate Rublon authentication</span>\n {\n <span class=\"cm-variable\">string</span> <span class=\"cm-variable\">url</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable\">rublon</span>.<span class=\"cm-variable\">Confirm</span>\n (\n <span class=\"cm-string\">\"http://example.com/TransactionConfirmCallback\"</span>, <span class=\"cm-comment\">// callback URL</span>\n <span class=\"cm-variable\">user</span>.<span class=\"cm-variable\">Id</span>, <span class=\"cm-comment\">// User Id</span>\n <span class=\"cm-variable\">user</span>.<span class=\"cm-variable\">Email</span>, <span class=\"cm-comment\">// User email</span>\n <span class=\"cm-variable\">string</span>.<span class=\"cm-variable\">format</span>(<span class=\"cm-string\">\"Do you confirm transaction no. {0} with the amount of {1}?\"</span>, <span class=\"cm-variable\">transId</span>, <span class=\"cm-variable\">amount</span>),\n <span class=\"cm-variable\">parameters</span>\n );\n\n <span class=\"cm-variable\">if</span> (<span class=\"cm-variable\">url</span> <span class=\"cm-operator\">!=</span> <span class=\"cm-variable\">null</span>) <span class=\"cm-comment\">// Rublon protection is active</span>\n {\n <span class=\"cm-comment\">// Redirect the web browser to Rublon servers</span>\n <span class=\"cm-comment\">// to confirm the transaction:</span>\n <span class=\"cm-variable\">Response</span>.<span class=\"cm-variable\">Redirect</span>(<span class=\"cm-variable\">url</span>);\n }\n } \n <span class=\"cm-variable\">catch</span> (<span class=\"cm-variable\">RublonException</span> <span class=\"cm-variable\">ex</span>) \n {\n <span class=\"cm-comment\">// An error occurred</span>\n <span class=\"cm-variable\">throw</span>;\n }\n\n <span class=\"cm-comment\">/* If we're here, the user's account is not protected by Rublon,</span>\n <span class=\"cm-comment\">so the user should confirm the transaction some other way</span>\n <span class=\"cm-comment\">or bypass the confirmation. */</span>\n}</pre>\n</div><!-- end ngRepeat: tab in data.codes track by $id($index) -->\n</div></div><!-- ngSwitchWhen: image --><!-- ngSwitchWhen: embed --><!-- ngSwitchWhen: callout --><!-- ngSwitchWhen: parameters --><!-- ngSwitchWhen: html -->\n <p>If the user's account is protected by Rublon, calling the <code>Rublon2Factor.Confirm()</code> method will return a URL address which the user's web browser should redirect to so as to scan a QR code and confirm the transaction.</p>\n\n <h3>Finalizing the transaction</h3>\n\n<p>Finalizing the whole process involves invoking a callback URL, similarly to the authentication process. In the callback the user's answer to the transaction confirmation question, given by the user in the Rublon mobile app, can be obtained and processed.</p>\n\n<p>An example of confirming a transaction in the callback:</p>\n<!-- ngSwitchWhen: textarea --><!-- TODO: Make this generic using 'default' --><!-- ngSwitchWhen: api-header --><!-- ngSwitchWhen: code --><div class=\"ng-scope\" ng-switch-when=\"code\"><div type=\"section.type\" ng-model=\"section.data\" class=\"block-code block-show-code ng-isolate-scope ng-pristine ng-valid\">\n <div class=\"code-tabs ng-hide\" ng-show=\"data.codes.length > 1 || (data.codes.length == 1 &amp;&amp; data.codes[0].status)\">\n <!-- ngRepeat: tab in data.codes track by $id($index) --><div class=\"ng-scope tab on\" ng-class=\"{tab: true, on:$index==current, off:$index!=current}\" ng-repeat=\"tab in data.codes track by $id($index)\">\n <a href=\"\" ng-click=\"choose($index)\">\n <!-- ngIf: tab.status -->\n <!-- ngIf: !tab.status --><span class=\"ng-scope ng-binding\" ng-if=\"!tab.status\">\n C#\n </span><!-- end ngIf: !tab.status -->\n </a><span class=\"ng-hide\" ng-hide=\"$last\">·</span>\n </div><!-- end ngRepeat: tab in data.codes track by $id($index) -->\n </div>\n\n <!-- ngRepeat: tab in data.codes track by $id($index) --><div class=\"ng-scope\" ng-repeat=\"tab in data.codes track by $id($index)\" ng-show=\"$index==current\">\n <pre class=\"cm-s-neo\" data-mode=\"csharp\"><span class=\"cm-variable\">class</span> <span class=\"cm-variable\">TransactionCallback</span> : <span class=\"cm-variable\">Rublon2FactorCallback</span> \n{\n <span class=\"cm-variable\">protected</span> <span class=\"cm-variable\">override</span> <span class=\"cm-variable\">string</span> <span class=\"cm-variable\">getState</span>() \n {\n <span class=\"cm-variable\">return</span> <span class=\"cm-variable\">Request</span>.<span class=\"cm-variable\">Params</span>[<span class=\"cm-variable\">PARAMETER_STATE</span>];\n }\n \n <span class=\"cm-variable\">protected</span> <span class=\"cm-variable\">override</span> <span class=\"cm-variable\">string</span> <span class=\"cm-variable\">getAccessToken</span>() \n {\n <span class=\"cm-variable\">return</span> <span class=\"cm-variable\">Request</span>.<span class=\"cm-variable\">Params</span>[<span class=\"cm-variable\">PARAMETER_ACCESS_TOKEN</span>];\n }\n \n <span class=\"cm-variable\">protected</span> <span class=\"cm-variable\">override</span> <span class=\"cm-variable\">void</span> <span class=\"cm-variable\">handleCancel</span>() \n {\n <span class=\"cm-variable\">Response</span>.<span class=\"cm-variable\">Redirect</span>(<span class=\"cm-string\">\"/TransactionConfirm\"</span>);\n }\n \n <span class=\"cm-variable\">protected</span> <span class=\"cm-variable\">override</span> <span class=\"cm-variable\">void</span> <span class=\"cm-variable\">handleError</span>() \n {\n <span class=\"cm-variable\">Response</span>.<span class=\"cm-variable\">Redirect</span>(<span class=\"cm-string\">\"/TransactionConfirm/?msg=rublon-error\"</span>);\n }\n \n <span class=\"cm-variable\">protected</span> <span class=\"cm-variable\">override</span> <span class=\"cm-variable\">void</span> <span class=\"cm-variable\">userAuthenticated</span>(<span class=\"cm-variable\">string</span> <span class=\"cm-variable\">userId</span>) \n {\n <span class=\"cm-variable\">Credentials</span> <span class=\"cm-variable\">result</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable\">credentials</span>.<span class=\"cm-variable\">ResponseResult</span>;\n <span class=\"cm-variable\">string</span> <span class=\"cm-variable\">transactionId</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable\">result</span>.<span class=\"cm-variable\">Value</span>(<span class=\"cm-string\">\"transId\"</span>);\n <span class=\"cm-variable\">if</span> (<span class=\"cm-operator\">!</span><span class=\"cm-variable\">string</span>.<span class=\"cm-variable\">IsNullOrEmpty</span>(<span class=\"cm-variable\">transactionId</span>))\n {\n <span class=\"cm-variable\">if</span> (<span class=\"cm-variable\">credentials</span>.<span class=\"cm-variable\">GetConfirmResult</span>() <span class=\"cm-operator\">==</span> <span class=\"cm-variable\">Credentials</span>.<span class=\"cm-variable\">CONFIRM_RESULT_YES</span>)\n {\n <span class=\"cm-variable\">Response</span>.<span class=\"cm-variable\">Redirect</span>(<span class=\"cm-string\">\"/ConfirmSuccess\"</span>);\n }\n <span class=\"cm-variable\">else</span>\n {\n <span class=\"cm-variable\">Response</span>.<span class=\"cm-variable\">Redirect</span>(<span class=\"cm-string\">\"/ConfirmFailed\"</span>);\n }\n }\n } \n}\n\n...\n\n<span class=\"cm-variable\">Rublon2Factor</span> <span class=\"cm-variable\">rublon</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable\">new</span> <span class=\"cm-variable\">Rublon2Factor</span>\n(\n <span class=\"cm-string\">\"A69FC450848B4B94A040416DC4421523\"</span>,\n <span class=\"cm-string\">\"bLS6NDP7pGjg346S4IHqTHgQQjjSLw3CyApvz5iRjYzgIPN4e9EOi1cQJLrTlvLoHY8zeqg4ILrItYidKJ6JjEUZaA6pR1tZMwSZ\"</span>\n);\n\n<span class=\"cm-variable\">try</span> \n{\n <span class=\"cm-variable\">Rublon2FactorCallback</span> <span class=\"cm-variable\">callback</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable\">new</span> <span class=\"cm-variable\">TransactionCallback</span>(<span class=\"cm-variable\">rublon</span>);\n <span class=\"cm-variable\">callback</span>.<span class=\"cm-variable\">Call</span>();\n} \n<span class=\"cm-variable\">catch</span> (<span class=\"cm-variable\">CallbackException</span> <span class=\"cm-variable\">ex</span>) \n{\n <span class=\"cm-comment\">// Please handle this error in the better way:</span>\n <span class=\"cm-variable\">throw</span>;\n}</pre>\n</div><!-- end ngRepeat: tab in data.codes track by $id($index) -->\n</div></div><!-- ngSwitchWhen: image --><!-- ngSwitchWhen: embed --><!-- ngSwitchWhen: callout --><!-- ngSwitchWhen: parameters --><!-- ngSwitchWhen: html --> \n </div>\n <div role=\"tabpanel\" class=\"tab-pane\" id=\"java\">\n <br/>\n <p>The <code>Rublon2Factor.confirm()</code> method will check the user's protection status (using the email address hash) and return a URL address which the web browser should redirect to (if the user is protected by Rublon), or <code>null</code>, if the user protection is not active.</p>\n<table>\n\t<caption><code>Rublon2Factor.confirm()</code> method arguments</caption>\n\t<thead><tr>\n\t\t<th>Name</th>\n\t\t<th>Type</th>\n\t\t<th>Description</th>\n\t</tr></thead>\n\t<tbody>\n\t\t<tr><td><code>callbackUrl</code></td><td>String</td><td>The integrated system's callback URL\n</td></tr>\n\t\t<tr><td><code>userId</code></td><td>String</td><td>The integrated system's user's unique Id which will allow to log in the user upon successful authentication</td></tr>\n\t\t<tr><td><code>userEmail</code></td><td>String</td><td>The user's email address in the integrated system which will allow to check the user's protection status and matching the user to a Rublon account</td></tr>\n\t\t<tr><td><code>confirmMessage</code></td><td>String</td><td>Contents of the message displayed in the mobile app\n</td></tr>\n\t\t<tr><td><code>consumerParams</code></td><td>JSONObject</td><td>Additional transaction parameters (optional)</td></tr> \n\t</tbody>\n</table>\n <h3>Initiating transaction confirmation</h3>\n <p>An example of confirming a sensitive transaction using Rublon:</p>\n \n<!-- ngSwitchWhen: textarea --><!-- TODO: Make this generic using 'default' --><!-- ngSwitchWhen: api-header --><!-- ngSwitchWhen: code --><div class=\"ng-scope\" ng-switch-when=\"code\"><div type=\"section.type\" ng-model=\"section.data\" class=\"block-code block-show-code ng-isolate-scope ng-pristine ng-valid\">\n <div class=\"code-tabs ng-hide\" ng-show=\"data.codes.length > 1 || (data.codes.length == 1 &amp;&amp; data.codes[0].status)\">\n <!-- ngRepeat: tab in data.codes track by $id($index) --><div class=\"ng-scope tab on\" ng-class=\"{tab: true, on:$index==current, off:$index!=current}\" ng-repeat=\"tab in data.codes track by $id($index)\">\n <a href=\"\" ng-click=\"choose($index)\">\n <!-- ngIf: tab.status -->\n <!-- ngIf: !tab.status --><span class=\"ng-scope ng-binding\" ng-if=\"!tab.status\">\n Java\n </span><!-- end ngIf: !tab.status -->\n </a><span class=\"ng-hide\" ng-hide=\"$last\">·</span>\n </div><!-- end ngRepeat: tab in data.codes track by $id($index) -->\n </div>\n\n <!-- ngRepeat: tab in data.codes track by $id($index) --><div class=\"ng-scope\" ng-repeat=\"tab in data.codes track by $id($index)\" ng-show=\"$index==current\">\n <pre class=\"cm-s-neo\" data-mode=\"java\"><span class=\"cm-comment\">/**</span>\n<span class=\"cm-comment\">* Transaction confirmation.</span>\n<span class=\"cm-comment\">* </span>\n<span class=\"cm-comment\">* @param transId Transaction Id</span>\n<span class=\"cm-comment\">* @param amount Transaction amount</span>\n<span class=\"cm-comment\">*/</span>\n<span class=\"cm-variable-3\">void</span> <span class=\"cm-def\">confirmTransaction</span>(<span class=\"cm-variable-3\">String</span> <span class=\"cm-variable\">transId</span>, <span class=\"cm-variable-3\">int</span> <span class=\"cm-variable\">amount</span>) {\n <span class=\"cm-variable\">User</span> <span class=\"cm-variable\">user</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable\">Session</span>.<span class=\"cm-variable\">getUser</span>();\n <span class=\"cm-variable\">Rublon2Factor</span> <span class=\"cm-variable\">rublon</span> <span class=\"cm-operator\">=</span> <span class=\"cm-keyword\">new</span> <span class=\"cm-variable\">Rublon2Factor</span>(<span class=\"cm-string\">\"your_system_token\"</span>, <span class=\"cm-string\">\"your_access_key\"</span>);\n \n <span class=\"cm-keyword\">try</span> { <span class=\"cm-comment\">// Initiate Rublon authentication</span>\n <span class=\"cm-variable-3\">String</span> <span class=\"cm-variable\">url</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable\">rublon</span>.<span class=\"cm-variable\">confirm</span>(\n <span class=\"cm-string\">\"http://example.com/rublon_transaction_confirm\"</span>, <span class=\"cm-comment\">// callback URL</span>\n <span class=\"cm-variable\">user</span>.<span class=\"cm-variable\">getId</span>(), <span class=\"cm-comment\">// User Id</span>\n <span class=\"cm-variable\">user</span>.<span class=\"cm-variable\">getEmail</span>(), <span class=\"cm-comment\">// User email</span>\n <span class=\"cm-variable-3\">String</span>.<span class=\"cm-variable\">format</span>(<span class=\"cm-string\">\"Do you confirm transaction no. %s with the amount of %d?\"</span>, <span class=\"cm-variable\">transId</span>, <span class=\"cm-variable\">amount</span>),\n <span class=\"cm-comment\">// Additional transaction parameters:</span>\n <span class=\"cm-keyword\">new</span> <span class=\"cm-variable\">JSONObject</span>() {{\n <span class=\"cm-variable\">put</span>(<span class=\"cm-string\">\"transId\"</span>, <span class=\"cm-variable\">transId</span>);\n }}\n );\n \n <span class=\"cm-keyword\">if</span> (<span class=\"cm-variable\">url</span> <span class=\"cm-operator\">!=</span> <span class=\"cm-atom\">null</span>) { <span class=\"cm-comment\">// Rublon protection is active</span>\n <span class=\"cm-comment\">// Redirect the web browser to Rublon servers</span>\n <span class=\"cm-comment\">// to confirm the transaction:</span>\n <span class=\"cm-variable\">HttpServer</span>.<span class=\"cm-variable\">sendHeader</span>(<span class=\"cm-string\">\"Location\"</span>, <span class=\"cm-variable\">url</span>); \n }\n \n } <span class=\"cm-keyword\">catch</span> (<span class=\"cm-variable\">RublonException</span> <span class=\"cm-variable\">e</span>) {\n <span class=\"cm-comment\">// An error occurred</span>\n <span class=\"cm-variable\">HttpServer</span>.<span class=\"cm-variable\">setStatus</span>(<span class=\"cm-number\">500</span>);\n <span class=\"cm-variable\">HttpServer</span>.<span class=\"cm-variable\">setResponse</span>(<span class=\"cm-string\">\"There was an error, please try again later.\"</span>);\n }\n \n <span class=\"cm-comment\">/* If we're here, the user's account is not protected by Rublon,</span>\n <span class=\"cm-comment\">so the user should confirm the transaction some other way</span>\n <span class=\"cm-comment\">or bypass the confirmation. */</span>\n}</pre>\n</div><!-- end ngRepeat: tab in data.codes track by $id($index) -->\n</div></div><!-- ngSwitchWhen: image --><!-- ngSwitchWhen: embed --><!-- ngSwitchWhen: callout --><!-- ngSwitchWhen: parameters --><!-- ngSwitchWhen: html -->\n <p>If the user's account is protected by Rublon, calling the <code>Rublon2Factor.confirm()</code> method will return a URL address which the user's web browser should redirect to so as to scan a QR code and confirm the transaction.</p>\n\n <h3>Finalizing the transaction</h3>\n\n<p>Finalizing the whole process involves invoking a callback URL, similarly to the authentication process. In the callback the user's answer to the transaction confirmation question, given by the user in the Rublon mobile app, can be obtained and processed.</p>\n\n<p>An example of confirming a transaction in the callback:</p>\n <div type=\"section.type\" ng-model=\"section.data\" class=\"block-code block-show-code ng-isolate-scope ng-pristine ng-valid\">\n <div class=\"code-tabs ng-hide\" ng-show=\"data.codes.length > 1 || (data.codes.length == 1 &amp;&amp; data.codes[0].status)\">\n <!-- ngRepeat: tab in data.codes track by $id($index) --><div class=\"ng-scope tab on\" ng-class=\"{tab: true, on:$index==current, off:$index!=current}\" ng-repeat=\"tab in data.codes track by $id($index)\">\n <a href=\"\" ng-click=\"choose($index)\">\n <!-- ngIf: tab.status -->\n <!-- ngIf: !tab.status --><span class=\"ng-scope ng-binding\" ng-if=\"!tab.status\">\n PHP\n </span><!-- end ngIf: !tab.status -->\n </a><span class=\"ng-hide\" ng-hide=\"$last\">·</span>\n </div><!-- end ngRepeat: tab in data.codes track by $id($index) -->\n </div>\n\n <!-- ngRepeat: tab in data.codes track by $id($index) --><div class=\"ng-scope\" ng-repeat=\"tab in data.codes track by $id($index)\" ng-show=\"$index==current\">\n <pre class=\"cm-s-neo\" data-mode=\"php\"><span class=\"cm-meta\">&lt;?</span>\n<span class=\"cm-variable-2\">$rublon</span> <span class=\"cm-operator\">=</span> <span class=\"cm-keyword\">new</span> <span class=\"cm-variable\">Rublon2Factor</span>(<span class=\"cm-string\">\"</span><span class=\"cm-string\">your_system_token\"</span>, <span class=\"cm-string\">\"</span><span class=\"cm-string\">your_access_key\"</span>);\n<span class=\"cm-keyword\">try</span> {\n <span class=\"cm-variable-2\">$callback</span> <span class=\"cm-operator\">=</span> <span class=\"cm-keyword\">new</span> <span class=\"cm-variable\">Rublon2FactorCallback</span>(<span class=\"cm-variable-2\">$rublon</span>);\n <span class=\"cm-variable-2\">$callback</span><span class=\"cm-operator\">-&gt;</span><span class=\"cm-variable\">call</span>(\n <span class=\"cm-variable-2\">$successHandler</span> <span class=\"cm-operator\">=</span> <span class=\"cm-keyword\">function</span>(<span class=\"cm-variable-2\">$userId</span>, <span class=\"cm-variable\">Rublon2FactorCallback</span> <span class=\"cm-variable-2\">$callback</span>) {\n <span class=\"cm-variable-2\">$params</span> <span class=\"cm-operator\">=</span> <span class=\"cm-variable-2\">$callback</span><span class=\"cm-operator\">-&gt;</span><span class=\"cm-variable\">getCredentials</span>()<span class=\"cm-operator\">-&gt;</span><span class=\"cm-variable\">getResponse</span>();\n <span class=\"cm-keyword\">if</span> (<span class=\"cm-keyword\">isset</span>(<span class=\"cm-variable-2\">$params</span>[<span class=\"cm-string\">'transId'</span>])) {\n <span class=\"cm-keyword\">if</span> (<span class=\"cm-variable\">RublonAPICredentials</span>::<span class=\"cm-variable\">CONFIRM_RESULT_YES</span> <span class=\"cm-operator\">==</span> <span class=\"cm-variable-2\">$callback</span><span class=\"cm-operator\">-&gt;</span><span class=\"cm-variable\">getCredentials</span>()<span class=\"cm-operator\">-&gt;</span><span class=\"cm-variable\">getConfirmResult</span>()) {\n <span class=\"cm-comment\">// Transaction confirmed, do something with it:</span>\n <span class=\"cm-variable\">transaction_confirmed</span>(<span class=\"cm-variable-2\">$params</span>[<span class=\"cm-string\">'transId'</span>]);\n } <span class=\"cm-keyword\">else</span> {\n <span class=\"cm-comment\">// Transaction denied, cancel and clean:</span>\n <span class=\"cm-variable\">transaction_denied</span>(<span class=\"cm-variable-2\">$params</span>[<span class=\"cm-string\">'transId'</span>]);\n }\n }\n },\n <span class=\"cm-variable-2\">$cancelHandler</span> <span class=\"cm-operator\">=</span> <span class=\"cm-keyword\">function</span>(<span class=\"cm-variable\">Rublon2FactorCallback</span> <span class=\"cm-variable-2\">$callback</span>) {\n <span class=\"cm-comment\">// Cancel the process</span>\n <span class=\"cm-variable\">redirect</span>(<span class=\"cm-string\">\"</span><span class=\"cm-string\">/dashboard\"</span>);\n }\n );\n \n <span class=\"cm-comment\">// The process was successful</span>\n <span class=\"cm-variable\">redirect</span>(<span class=\"cm-string\">\"</span><span class=\"cm-string\">/dashboard\"</span>);\n\n} <span class=\"cm-keyword\">catch</span> (<span class=\"cm-variable\">RublonException</span> <span class=\"cm-variable-2\">$e</span>) {\n <span class=\"cm-comment\">// Please handle this error in the better way:</span>\n <span class=\"cm-keyword\">die</span>(<span class=\"cm-variable-2\">$e</span><span class=\"cm-operator\">-&gt;</span><span class=\"cm-variable\">getMessage</span>());\n}</pre>\n</div><!-- end ngRepeat: tab in data.codes track by $id($index) -->\n</div> \n </div>\n <div role=\"tabpanel\" class=\"tab-pane\" id=\"python\">\n <br/>\n <p>The <code>Rublon2Factor.confirm()</code> method will check the user's protection status (using the email address hash) and return a URL address which the web browser should redirect to (if the user is protected by Rublon), or <code>null</code>, if the user protection is not active.</p>\n<table>\n\t<caption><code>Rublon2Factor.confirm()</code> method arguments</caption>\n\t<thead><tr>\n\t\t<th>Name</th>\n\t\t<th>Type</th>\n\t\t<th>Description</th>\n\t</tr></thead>\n\t<tbody>\n\t\t<tr><td><code>callback_url</code></td><td>str</td><td>The integrated system's callback URL\n</td></tr>\n\t\t<tr><td><code>user_id</code></td><td>str</td><td>The integrated system's user's unique Id which will allow to log in the user upon successful authentication</td></tr>\n\t\t<tr><td><code>user_email</code></td><td>str</td><td>The user's email address in the integrated system which will allow to check the user's protection status and matching the user to a Rublon account</td></tr>\n\t\t<tr><td><code>confirm_message</code></td><td>str</td><td>Contents of the message displayed in the mobile app\n</td></tr>\n\t\t<tr><td><code>consumer_params</code></td><td>dict</td><td>Additional transaction parameters (optional)</td></tr> \n\t</tbody>\n</table>\n <h3>Initiating transaction confirmation</h3>\n <p>An example of confirming a sensitive transaction using Rublon:</p>\n\n<div type=\"section.type\" ng-model=\"section.data\" class=\"block-code block-show-code ng-isolate-scope ng-pristine ng-valid\">\n <div class=\"code-tabs ng-hide\" ng-show=\"data.codes.length > 1 || (data.codes.length == 1 &amp;&amp; data.codes[0].status)\">\n <!-- ngRepeat: tab in data.codes track by $id($index) --><div class=\"ng-scope tab on\" ng-class=\"{tab: true, on:$index==current, off:$index!=current}\" ng-repeat=\"tab in data.codes track by $id($index)\">\n <a href=\"\" ng-click=\"choose($index)\">\n <!-- ngIf: tab.status -->\n <!-- ngIf: !tab.status --><span class=\"ng-scope ng-binding\" ng-if=\"!tab.status\">\n Python\n </span><!-- end ngIf: !tab.status -->\n </a><span class=\"ng-hide\" ng-hide=\"$last\">·</span>\n </div><!-- end ngRepeat: tab in data.codes track by $id($index) -->\n </div>\n\n <!-- ngRepeat: tab in data.codes track by $id($index) --><div class=\"ng-scope\" ng-repeat=\"tab in data.codes track by $id($index)\" ng-show=\"$index==current\">\n <pre class=\"cm-s-neo\" data-mode=\"python\"><span class=\"cm-comment\"># Transaction confirmation.</span>\n<span class=\"cm-keyword\">def</span> <span class=\"cm-def\">confirm_transaction</span>(<span class=\"cm-variable\">trans_id</span>, <span class=\"cm-variable\">amount</span>)\n <span class=\"cm-variable\">RUBLON_SYSTEM_TOKEN</span> = <span class=\"cm-string\">\"your_system_token\"</span>\n <span class=\"cm-variable\">RUBLON_SECRET_KEY</span> = <span class=\"cm-string\">\"your_secret_key\"</span>\n <span class=\"cm-variable\">callback_url</span> = <span class=\"cm-string\">\"http://example.com/rublon_transaction_confirm\"</span>,\n <span class=\"cm-variable\">user</span> = <span class=\"cm-variable\">session</span>[<span class=\"cm-string\">'user'</span>]\n <span class=\"cm-variable\">confirm_message</span> = <span class=\"cm-string\">\"Do you confirm transaction no. {0} with the amount of {1}?\"</span>.<span class=\"cm-builtin\">format</span>(<span class=\"cm-variable\">trans_id</span>, <span class=\"cm-variable\">amount</span>)\n <span class=\"cm-variable\">consumer_params</span> = {<span class=\"cm-string\">'trans_id'</span>: <span class=\"cm-variable\">trans_id</span>}\n \n <span class=\"cm-variable\">rublon</span> = <span class=\"cm-variable\">Rublon2Factor</span>(<span class=\"cm-variable\">RUBLON_SYSTEM_TOKEN</span>, <span class=\"cm-variable\">RUBLON_SECRET_KEY</span>)\n \n <span class=\"cm-comment\"># Initiate Rublon authentication</span>\n <span class=\"cm-keyword\">try</span>:\n <span class=\"cm-variable\">url</span> = <span class=\"cm-variable\">rublon</span>.<span class=\"cm-variable\">confirm</span>(<span class=\"cm-variable\">callback_url</span>, <span class=\"cm-variable\">user</span>[<span class=\"cm-string\">'id'</span>], <span class=\"cm-variable\">user</span>[<span class=\"cm-string\">'email'</span>], <span class=\"cm-variable\">confirm_message</span>, <span class=\"cm-variable\">consumer_params</span>)\n \n <span class=\"cm-comment\">#Rublon protection is active</span>\n <span class=\"cm-keyword\">if</span> <span class=\"cm-variable\">url</span> : \n <span class=\"cm-comment\">#Redirect the web browser to Rublon servers to confirm the transaction</span>\n <span class=\"cm-keyword\">return</span> <span class=\"cm-variable\">redirect</span>(<span class=\"cm-variable\">url</span>)\n <span class=\"cm-keyword\">break</span>\n <span class=\"cm-keyword\">except</span> <span class=\"cm-variable\">RublonException</span>:\n <span class=\"cm-keyword\">raise</span>\n\n <span class=\"cm-comment\">#If we're here, the user's account is not protected by Rublon,</span>\n <span class=\"cm-comment\">#so the user should confirm the transaction some other way.</span></pre>\n</div><!-- end ngRepeat: tab in data.codes track by $id($index) -->\n</div>\n <p>If the user's account is protected by Rublon, calling the <code>Rublon2Factor.confirm()</code> method will return a URL address which the user's web browser should redirect to so as to scan a QR code and confirm the transaction.</p>\n\n <h3>Finalizing the transaction</h3>\n\n<p>Finalizing the whole process involves invoking a callback URL, similarly to the authentication process. In the callback the user's answer to the transaction confirmation question, given by the user in the Rublon mobile app, can be obtained and processed.</p>\n<!--\n<p>An example of confirming a transaction in the callback:</p>\n <pre><code>\n \n </code></pre> -->\n </div>\n </div>\n\n</div>\n<style>\n.langnav > li > a {\n padding: 3px 15px;\n}\ncaption{\n\t\tmargin:10px;\n}\n.tab-pane h3 {\n color: #555;\n font-size: 17px;\n font-weight: 700;\n text-transform: uppercase;\n} \n</style>" } [/block]