<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Flex Microform v2 - Capture Context and JS Libraries in cybersource APIs</title>
    <link>https://community.developer.cybersource.com/t5/cybersource-APIs/Flex-Microform-v2-Capture-Context-and-JS-Libraries/m-p/90955#M1995</link>
    <description>&lt;P&gt;Evening all. Thanks to the awsm gent Martin&amp;nbsp;@ Visa, got some pointers that I'd been missing. Here's a summary for those of you playing along at home:&lt;/P&gt;&lt;P&gt;1. Calling&amp;nbsp;&lt;STRONG&gt;Cybersource\Api\MicroformIntegrationApi&amp;nbsp; with the method&amp;nbsp;generateCaptureContext &lt;/STRONG&gt;works, and results in an Object that for this purpose I'll call $keyResponse.&lt;/P&gt;&lt;P&gt;2. Field [0] of $keyResponse is the full blown JWT.&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. Decoding this key, using the following snippet:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;$decodedContext&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;json_decode&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;base64_decode&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;str_replace&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'_'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;'/'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;str_replace&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'-'&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;'+'&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;explode&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'.'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;$keyResponse&lt;/SPAN&gt;&lt;SPAN&gt;[&lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;])[&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;]))));&lt;BR /&gt;&lt;/SPAN&gt;&amp;nbsp; &amp;nbsp;...gives you a new object.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;4. There are three bits of data that you need:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; a) $keyResponse[0] is the full capture context -- this is what is passed to the JS call later [ see #6 below ]&lt;BR /&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; b)&amp;nbsp;&lt;SPAN&gt;$decodedContext&lt;/SPAN&gt;&lt;SPAN&gt;-&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;ctx&lt;/SPAN&gt;&lt;SPAN&gt;[&lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;]-&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;data&lt;/SPAN&gt;&lt;SPAN&gt;-&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;clientLibrary&amp;nbsp; -- this is the full URL and path for the JS library that is used to validate the capture context and encrypt the token payload.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;c)&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;$decodedContext&lt;/SPAN&gt;&lt;SPAN&gt;-&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;ctx&lt;/SPAN&gt;&lt;SPAN&gt;[&lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;]-&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;data&lt;/SPAN&gt;&lt;SPAN&gt;-&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;clientLibraryIntegrity -- this is the sha-256 integrity check string for the clientLibrary&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;5) Passing control of this over to the client side in JS, you then need to load the script of JS library returned in 4b)&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;6) The captureContext is used in instantiating a Flex object that is described by this code library:&amp;nbsp; &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;i.e.&amp;nbsp; new flexbit = new Flex(captureContext);&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;...and away you go with the rest of the implementation.&lt;/SPAN&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 16 Dec 2024 11:47:37 GMT</pubDate>
    <dc:creator>mr_al</dc:creator>
    <dc:date>2024-12-16T11:47:37Z</dc:date>
    <item>
      <title>Flex Microform v2 - Capture Context and JS Libraries</title>
      <link>https://community.developer.cybersource.com/t5/cybersource-APIs/Flex-Microform-v2-Capture-Context-and-JS-Libraries/m-p/90951#M1993</link>
      <description>&lt;P&gt;Evening all,&lt;/P&gt;&lt;P&gt;The scenario is that we are migration from using the 0.11 Microform to the 2.0 Microform.&lt;/P&gt;&lt;P&gt;Build environment is PHP backend, JS front end.&amp;nbsp; &amp;nbsp;The 0.11 solution is working successfully.&lt;/P&gt;&lt;P&gt;The latest PHP Rest Client PHP libraries have been installed and code has been tweaked to cater for changes in payload requirements. Rather than a direct CURL call to the endpoints as described &lt;A href="https://developer.cybersource.com/docs/cybs/en-us/digital-accept-flex/developer/all/rest/digital-accept-flex/microform-integ-v2/microform-integ-getting-started-v2/micro-getting-started-ss-setup/creating-server-side-context-v2.html" target="_blank" rel="noopener"&gt;HERE we are using the provided Classes from the Github repository recently updated &lt;/A&gt;&lt;A href="https://github.com/CyberSource/cybersource-rest-client-php" target="_blank" rel="noopener"&gt;HERE.&amp;nbsp;&amp;nbsp;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;There are two different Classes that are presented in these libraries:&lt;/P&gt;&lt;P&gt;1.&amp;nbsp;&lt;STRONG&gt;Cybersource\Api\MicroformIntegrationApi&amp;nbsp; with the method&amp;nbsp;&lt;STRONG&gt;generateCaptureContext&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;2.&amp;nbsp;&lt;STRONG&gt;Cybersource\Api\FlexAPIApi&amp;nbsp;with the method&amp;nbsp;&lt;STRONG&gt;generateFlexAPIcaptureContext&amp;nbsp;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Both do the job and produce a Capture Context.&amp;nbsp; We are using #1.&amp;nbsp; It produces a Capture Context jwt string successfully.&lt;/P&gt;&lt;P&gt;In our dev/test environment, we have been trying to use the provided JS library&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;FONT color="#0000FF"&gt;&lt;FONT color="#0000FF"&gt;&lt;SPAN class=""&gt;&lt;A href="https://testflex" target="_blank" rel="noopener"&gt;https://testflex.&lt;SPAN class=""&gt;cybersource&lt;SPAN class=""&gt;.com/microform/bundle/v2/flex-microform.min.js&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;DIV&gt;&lt;FONT color="#000000"&gt;&lt;FONT color="#000000"&gt;&lt;SPAN class=""&gt;as per the instructions at &lt;A href="https://developer.cybersource.com/docs/cybs/en-us/digital-accept-flex/developer/all/rest/digital-accept-flex/microform-integ-v2/microform-integ-getting-started-v2/setting-up-client-side-v2.html" target="_blank" rel="noopener"&gt;THIS PAGE .&amp;nbsp;&amp;nbsp;&lt;/A&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;DIV&gt;&lt;FONT color="#000000"&gt;&lt;FONT color="#000000"&gt;&lt;SPAN class=""&gt;&lt;BR /&gt;However... when calling the&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;var flex=new Flex(captureContext);&amp;nbsp; &amp;nbsp; it fails with an INVALID CAPTURE CONTEXT message.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;DIV&gt;&amp;nbsp;&lt;DIV&gt;&lt;FONT color="#000000"&gt;&lt;FONT color="#000000"&gt;&lt;SPAN class=""&gt;We've tried all various combinations of variable elements and different API calls and classes, but to no avail.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;DIV&gt;&amp;nbsp;&lt;DIV&gt;&lt;FONT color="#000000"&gt;&lt;FONT color="#000000"&gt;&lt;FONT color="#000000"&gt;&lt;SPAN class=""&gt;Ironically -- keeping the v2 token generation on the PHP side but passing it through the &lt;STRONG&gt;new Flex instantiation on the&amp;nbsp;&lt;U&gt;v0.11 javascript library&lt;STRONG&gt;&amp;nbsp;&lt;STRONG&gt; [&amp;nbsp;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/U&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;A href="https://testflex.cybersource.com/cybersource/assets/microform/0.11/flex-microform.min.js" target="_blank" rel="noopener"&gt;https://testflex.cybersource.com/cybersource/assets/microform/0.11/flex-microform.min.js&amp;nbsp;] somehow works.&lt;BR /&gt;&lt;BR /&gt;&lt;U&gt;So - unsure as to what the 'new' Javascript microform v2 is failing on the new capture context generation... but the old one isn't.&lt;/U&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;U&gt;Any thoughts or experience to contribute to this one will be greatly appreciated!&lt;/U&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;U&gt;thanks and cheers,&lt;/U&gt;&lt;/A&gt;&lt;DIV&gt;&amp;nbsp;&lt;DIV&gt;&amp;nbsp;&lt;DIV&gt;Al&amp;nbsp;&lt;DIV&gt;&amp;nbsp;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 14 Dec 2024 12:02:23 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/cybersource-APIs/Flex-Microform-v2-Capture-Context-and-JS-Libraries/m-p/90951#M1993</guid>
      <dc:creator>mr_al</dc:creator>
      <dc:date>2024-12-14T12:02:23Z</dc:date>
    </item>
    <item>
      <title>Re: Flex Microform v2 - Capture Context and JS Libraries</title>
      <link>https://community.developer.cybersource.com/t5/cybersource-APIs/Flex-Microform-v2-Capture-Context-and-JS-Libraries/m-p/90955#M1995</link>
      <description>&lt;P&gt;Evening all. Thanks to the awsm gent Martin&amp;nbsp;@ Visa, got some pointers that I'd been missing. Here's a summary for those of you playing along at home:&lt;/P&gt;&lt;P&gt;1. Calling&amp;nbsp;&lt;STRONG&gt;Cybersource\Api\MicroformIntegrationApi&amp;nbsp; with the method&amp;nbsp;generateCaptureContext &lt;/STRONG&gt;works, and results in an Object that for this purpose I'll call $keyResponse.&lt;/P&gt;&lt;P&gt;2. Field [0] of $keyResponse is the full blown JWT.&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. Decoding this key, using the following snippet:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;$decodedContext&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;json_decode&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;base64_decode&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;str_replace&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'_'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;'/'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;str_replace&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'-'&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;'+'&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;explode&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'.'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;$keyResponse&lt;/SPAN&gt;&lt;SPAN&gt;[&lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;])[&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;]))));&lt;BR /&gt;&lt;/SPAN&gt;&amp;nbsp; &amp;nbsp;...gives you a new object.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;4. There are three bits of data that you need:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; a) $keyResponse[0] is the full capture context -- this is what is passed to the JS call later [ see #6 below ]&lt;BR /&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; b)&amp;nbsp;&lt;SPAN&gt;$decodedContext&lt;/SPAN&gt;&lt;SPAN&gt;-&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;ctx&lt;/SPAN&gt;&lt;SPAN&gt;[&lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;]-&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;data&lt;/SPAN&gt;&lt;SPAN&gt;-&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;clientLibrary&amp;nbsp; -- this is the full URL and path for the JS library that is used to validate the capture context and encrypt the token payload.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;c)&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;$decodedContext&lt;/SPAN&gt;&lt;SPAN&gt;-&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;ctx&lt;/SPAN&gt;&lt;SPAN&gt;[&lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;]-&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;data&lt;/SPAN&gt;&lt;SPAN&gt;-&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;clientLibraryIntegrity -- this is the sha-256 integrity check string for the clientLibrary&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;5) Passing control of this over to the client side in JS, you then need to load the script of JS library returned in 4b)&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;6) The captureContext is used in instantiating a Flex object that is described by this code library:&amp;nbsp; &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;i.e.&amp;nbsp; new flexbit = new Flex(captureContext);&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;...and away you go with the rest of the implementation.&lt;/SPAN&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2024 11:47:37 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/cybersource-APIs/Flex-Microform-v2-Capture-Context-and-JS-Libraries/m-p/90955#M1995</guid>
      <dc:creator>mr_al</dc:creator>
      <dc:date>2024-12-16T11:47:37Z</dc:date>
    </item>
  </channel>
</rss>

