<?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: Multiple payments with AcceptJS called async in Integration and Testing</title>
    <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Multiple-payments-with-AcceptJS-called-async/m-p/59599#M34178</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I noticed that I was passing&amp;nbsp;&lt;U&gt;this&lt;/U&gt;.responseHandler&amp;nbsp;rather than&amp;nbsp;&lt;U&gt;namespace-name&lt;/U&gt;.responseHandler to Accept.dispatchData&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Changed and works perfectly!&lt;/P&gt;</description>
    <pubDate>Wed, 30 Aug 2017 13:01:46 GMT</pubDate>
    <dc:creator>sudwebdesign77</dc:creator>
    <dc:date>2017-08-30T13:01:46Z</dc:date>
    <item>
      <title>Multiple payments with AcceptJS called async</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Multiple-payments-with-AcceptJS-called-async/m-p/59572#M34154</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have an app that has products from multiple vendors. &amp;nbsp;Each vendor can setup their own payment gateway ( Authorize or Paypal).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When a user checkouts, they may have products in their cart from multiple vendors. &amp;nbsp;The cart displays how&amp;nbsp;their payment will be split&amp;nbsp;and so sets user expectation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a JS controller which loops through the cart and requests payment according to the vendor's gateway.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's quite possible therefore that I would need to get a token using AcceptJS for more than 1 checkout occurence.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have isolated my code similar to in your demo for each vendor by using namespace objects each with a unique name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;eg:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;var ANAJSManagerVV2G = new function() {
         //     ^^^^ randomized unique code
            this.orderId = '';
            this.submitted=false;
                    
            this.makePayment = function(orderId) {
              // this contains the code as in your demo....
             // and i works fine where there is only 1 item in the cart
            }&lt;BR /&gt;            this.responseHandler = function(response) {&lt;BR /&gt;                console.log(response.messages);&lt;BR /&gt;                if (response.messages.resultCode === "Error") {&lt;BR /&gt;                  for (var i = 0; i &amp;lt; response.messages.message.length; i++) {&lt;BR /&gt;                    console.log(response.messages.message[i].code + ": " + response.messages.message[i].text);&lt;BR /&gt;                  }&lt;BR /&gt;                  alert("acceptJS library error!")&lt;BR /&gt;                } else {&lt;BR /&gt;                  console.log(response.opaqueData.dataDescriptor);&lt;BR /&gt;                  console.log(response.opaqueData.dataValue);&lt;BR /&gt;                  ANAJSManagerVV2G.processTransaction(response.opaqueData);&lt;BR /&gt;                  // ^^^ callback using namespace&lt;BR /&gt;                }
}&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;note that the namespace object has a 4char randomized ending AND the callback uses the namespace identifier.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The namespace object contains an order-id which identifies the relevant line item, so that on the callback, I can then process the appropriate transaction in my backend.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I look at my network tab in chrome, I see 2 calls to request.api as expected, each call uses the credentials of the appropriate vendor. &amp;nbsp;However, I get the same token string back for both, plus it looks like ONLY the second namespace callback is being called.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Perhaps&amp;nbsp;I should use a deferred object to call in a loop syncronously (or jQuery queue) rather than calling async.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How does this look your end? &amp;nbsp;Are you overlaying&amp;nbsp;the two calls into one, perhaps as they come from the same IP address?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It works fine when there is only one item in the cart, so my logic is OK.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Thanks&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2017 15:06:41 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Multiple-payments-with-AcceptJS-called-async/m-p/59572#M34154</guid>
      <dc:creator>sudwebdesign77</dc:creator>
      <dc:date>2017-08-29T15:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple payments with AcceptJS called async</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Multiple-payments-with-AcceptJS-called-async/m-p/59599#M34178</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I noticed that I was passing&amp;nbsp;&lt;U&gt;this&lt;/U&gt;.responseHandler&amp;nbsp;rather than&amp;nbsp;&lt;U&gt;namespace-name&lt;/U&gt;.responseHandler to Accept.dispatchData&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Changed and works perfectly!&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2017 13:01:46 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Multiple-payments-with-AcceptJS-called-async/m-p/59599#M34178</guid>
      <dc:creator>sudwebdesign77</dc:creator>
      <dc:date>2017-08-30T13:01:46Z</dc:date>
    </item>
  </channel>
</rss>

