<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://balvesh.github.io//blog/feed.xml" rel="self" type="application/atom+xml" /><link href="https://balvesh.github.io//blog/" rel="alternate" type="text/html" /><updated>2024-08-15T18:23:23+00:00</updated><id>https://balvesh.github.io//blog/feed.xml</id><title type="html">Balvesh Rakkar’s Blog</title><subtitle>Insights and experiences in Magento development, performance optimization, and more.</subtitle><author><name>Balvesh Rakkar</name><email>balveshr@gmail.com</email></author><entry><title type="html">SPLIT TRANSACTION - PAY PAL EXPRESS</title><link href="https://balvesh.github.io//blog/2024/08/15/title.html" rel="alternate" type="text/html" title="SPLIT TRANSACTION - PAY PAL EXPRESS" /><published>2024-08-15T00:00:00+00:00</published><updated>2024-08-15T00:00:00+00:00</updated><id>https://balvesh.github.io//blog/2024/08/15/title</id><content type="html" xml:base="https://balvesh.github.io//blog/2024/08/15/title.html"><![CDATA[<h2 id="descritpion">DESCRITPION</h2>

<ul>
  <li>There was an implementation to be worked on for a project in which we were placing mixed orders(2 orders being placed) and paying through Pay Pal as 1 transaction.</li>
  <li>The ask was to differentiate between different orders payments with an individual transaction id.</li>
</ul>

<h2 id="ask-challange">ASK/ CHALLANGE</h2>

<p>The challanges that were faced while doing a feasibility study for the same:</p>

<ol>
  <li>Customer must always see the payment being made as a full amount on frontend.</li>
  <li>The Payment Action should be authorization.</li>
  <li>Individual transaction ids to be shown for each captures.</li>
</ol>

<h2 id="proposed-solution">PROPOSED SOLUTION</h2>

<p><img src="images/paypal-flow.png" alt="" /></p>

<h2 id="requests">Requests</h2>

<h3 id="setexpresscheckout">SetExpressCheckout</h3>
<p>This method basically sets the transaction amount which in our case would be full amount.</p>

<ul>
  <li>
    <p><strong>Request:</strong>
<code class="language-plaintext highlighter-rouge">['PAYMENTACTION',
'AMT',
'CURRENCYCODE',
'RETURNURL',
'CANCELURL',
'INVNUM',
'SOLUTIONTYPE',
'NOSHIPPING',
'GIROPAYCANCELURL',
'GIROPAYSUCCESSURL',
'BANKTXNPENDINGURL',
'PAGESTYLE',
'HDRIMG',
'HDRBORDERCOLOR',
'HDRBACKCOLOR',
'PAYFLOWCOLOR',
'LOCALECODE',
'BILLINGTYPE',
'SUBJECT',
'ITEMAMT',
'SHIPPINGAMT',
'TAXAMT',
'REQBILLINGADDRESS',
'USERSELECTEDFUNDINGSOURCE']</code></p>
  </li>
  <li>
    <p><strong>Response</strong>: <code class="language-plaintext highlighter-rouge">['TOKEN']</code></p>
  </li>
</ul>

<h3 id="getexpresscheckout">GetExpressCheckout</h3>

<p>This method validates the token for the transaction before we DoExpressCheckoutPayment</p>

<ul>
  <li><strong>Request:</strong> <code class="language-plaintext highlighter-rouge">['TOKEN', 'SUBJECT']</code></li>
</ul>

<h3 id="doexpresscheckoutpayment">DoExpressCheckoutPayment</h3>

<p>This method does the autorisation of the transaction with full amount. And it returns the Authorisation Id which is the reference ID for different Captures.</p>

<ul>
  <li>
    <p><strong>Request:</strong><code class="language-plaintext highlighter-rouge">['TOKEN',
      'PAYERID',
      'PAYMENTACTION',
      'AMT',
      'CURRENCYCODE',
      'IPADDRESS',
      'BUTTONSOURCE',
      'NOTIFYURL',
      'RETURNFMFDETAILS',
      'SUBJECT',
      'ITEMAMT',
      'SHIPPINGAMT',
      'TAXAMT']</code></p>
  </li>
  <li>
    <p><strong>Response:</strong> <code class="language-plaintext highlighter-rouge">['TRANSACTIONID',
      'AMT',
      'PAYMENTSTATUS',
      'PENDINGREASON',
      'REDIRECTREQUIRED]</code></p>
  </li>
</ul>

<h3 id="docapture">DoCapture</h3>

<p>This method get called when we invoice the order and what caught my eye here is the  <strong><code class="language-plaintext highlighter-rouge">COMPLETETYPE</code></strong> paramter we pass in the request.</p>

<p>We can tell Pay Pal that is this the final transaction or there will be more captures for this transaction id.</p>

<p>So we can send either of these values for this parameter:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>- $request["COMPLETETYPE"] = "NotComplete";
					OR
- $request["COMPLETETYPE"] = "Complete";
</code></pre></div></div>

<p><strong>Note</strong>: <em>Auth Id to be sent in the request is is basically the Transaction Id we get from DoExpressCheckoutPayment</em></p>

<ul>
  <li>
    <p><strong>Request:</strong><code class="language-plaintext highlighter-rouge">['AUTHORIZATIONID', 'COMPLETETYPE', 'AMT', 'CURRENCYCODE', 'NOTE', 'INVNUM']</code></p>
  </li>
  <li>
    <p><strong>Response:</strong> ` [‘TRANSACTIONID’, ‘CURRENCYCODE’, ‘AMT’, ‘PAYMENTSTATUS’, ‘PENDINGREASON’]`</p>
  </li>
</ul>

<h2 id="references">REFERENCES</h2>

<ul>
  <li><a href="https://developer.paypal.com/api/nvp-soap/set-express-checkout-nvp/">Set Express Checkout</a></li>
  <li><a href="https://developer.paypal.com/api/nvp-soap/do-express-checkout-payment-nvp/">Do Express Checkout</a></li>
  <li><a href="https://developer.paypal.com/api/nvp-soap/set-express-checkout-nvp/#link-paymentdetailstypefields">Payment Type Fields- set-express-checkout</a></li>
  <li><a href="https://developer.paypal.com/api/nvp-soap/do-authorization-nvp/">Do Auth</a></li>
  <li><a href="https://developer.paypal.com/api/nvp-soap/do-capture-nvp/">Do Capture</a></li>
</ul>]]></content><author><name>Balvesh Rakkar</name><email>balveshr@gmail.com</email></author><summary type="html"><![CDATA[DESCRITPION]]></summary></entry></feed>