{"id":2222,"date":"2013-08-28T07:58:40","date_gmt":"2013-08-28T07:58:40","guid":{"rendered":"http:\/\/webkul.com\/blog\/?p=2222"},"modified":"2024-02-23T07:18:55","modified_gmt":"2024-02-23T07:18:55","slug":"implement-adaptive-payments","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/implement-adaptive-payments\/","title":{"rendered":"Implement Adaptive Payments"},"content":{"rendered":"\n<pre class=\"EnlighterJSRAW\">ini_set(&quot;track_errors&quot;, true);\n\/\/set PayPal Endpoint to sandbox\n$sandbox=&quot;&quot;;\n$API_AppID = XXXXXXXXXXXXXXXXXXX;\/\/your adaptive payment app Id\n\/\/value for check sandbox enable or disable\n$sandboxstatus=1;\nif($sandboxstatus==1){\n\t$sandbox=&quot;sandbox.&quot;;\n\t$API_AppID=&quot;APP-80W284485P519543T&quot;;\n}\n$url = trim(&quot;https:\/\/svcs.&quot;.$sandbox.&quot;paypal.com\/AdaptivePayments\/Pay&quot;);\n\/\/PayPal API Credentials\n$API_UserName = XXXXXXXXXXXXXXXXXXX;\/\/TODO\n$API_Password = XXXXXXXXXXXXXXXXXXX;\/\/TODO\n$API_Signature = XXXXXXXXXXXXXXXXXXX;\/\/TODO\t\n\/\/Default App ID for Sandbox\t\n$API_RequestFormat = &quot;NV&quot;;\n$API_ResponseFormat = &quot;NV&quot;;\n\n$bodyparams = array (\n\t&quot;requestEnvelope.errorLanguage&quot; =&gt; &quot;en_US&quot;,\n\t&quot;actionType&quot; =&gt; &quot;PAY&quot;,\n\t&quot;currencyCode&quot; =&gt; &quot;USD&quot;,\/\/currency Code\n\t&quot;cancelUrl&quot; =&gt; &quot;&quot;,\/\/ cancle url\n\t&quot;returnUrl&quot; =&gt; &quot;paymentsuccess&quot;,\/\/return url\n\t&quot;ipnNotificationUrl&quot; =&gt; &quot;paymentnotify&quot;\/\/notification url that return all data related to payment\n);\n\n$finalcart=array(\n        array(&#039;paypalid&#039;=&gt;&quot;partner1&quot;,&#039;price&#039;=&gt;50),\n        array(&#039;paypalid&#039;=&gt;&quot;partner2&quot;,&#039;price&#039;=&gt;50),\n        array(&#039;paypalid&#039;=&gt;&quot;partner3&quot;,&#039;price&#039;=&gt;50),\n        array(&#039;paypalid&#039;=&gt;&quot;partner4&quot;,&#039;price&#039;=&gt;50),\n        array(&#039;paypalid&#039;=&gt;&quot;partner5&quot;,&#039;price&#039;=&gt;50)\n      );\n\n$i=0;\nforeach($finalcart as $partner){\n\t$temp=array(&quot;receiverList.receiver($i).email&quot;=&gt;$partner&#091;&#039;paypalid&#039;],&quot;receiverList.receiver($i).amount&quot;=&gt;$partner&#091;&#039;price&#039;]);\n\t$bodyparams+=$temp;\t\n\t$i++;\n}\n\n\/\/ convert payload array into url encoded query string\n$body_data = http_build_query($bodyparams, &quot;&quot;, chr(38));\ntry{\n   \/\/create request and add headers\n   $params = array(&quot;http&quot; =&gt; array( \n      &quot;method&quot; =&gt; &quot;POST&quot;,\n      &quot;content&quot; =&gt; $body_data,\n      &quot;header&quot; =&gt; &quot;X-PAYPAL-SECURITY-USERID: &quot; . $API_UserName . &quot;\\r\\n&quot; .\n                     &quot;X-PAYPAL-SECURITY-SIGNATURE: &quot; . $API_Signature . &quot;\\r\\n&quot; .\n                     &quot;X-PAYPAL-SECURITY-PASSWORD: &quot; . $API_Password . &quot;\\r\\n&quot; .\n                     &quot;X-PAYPAL-APPLICATION-ID: &quot; . $API_AppID . &quot;\\r\\n&quot; .\n                     &quot;X-PAYPAL-REQUEST-DATA-FORMAT: &quot; . $API_RequestFormat . &quot;\\r\\n&quot; .\n                     &quot;X-PAYPAL-RESPONSE-DATA-FORMAT: &quot; . $API_ResponseFormat . &quot;\\r\\n&quot; \n   ));\n   \/\/create stream context\n   $ctx = stream_context_create($params);\n   \/\/open the stream and send request\n   $fp = @fopen($url, &quot;r&quot;, false, $ctx);\n   \/\/get response\n   $response = stream_get_contents($fp);\n   \/\/check to see if stream is open\n   if ($response === false) {\n      throw new Exception(&quot;php error message = &quot; . &quot;$php_errormsg&quot;);\n   }\n   \/\/close the stream\n   fclose($fp);\n   \/\/parse the ap key from the response\n   $keyArray = explode(&quot;&amp;&quot;, $response);\n   foreach ($keyArray as $rVal){\n       list($qKey, $qVal) = explode (&quot;=&quot;, $rVal);\n       $kArray&#091;$qKey] = $qVal;\n   }\n   \/\/set url to approve the transaction\n   $payPalURL = &quot;https:\/\/www.&quot;.$sandbox.&quot;paypal.com\/webscr?cmd=_ap-payment&amp;paykey=&quot; . $kArray&#091;&quot;payKey&quot;];\n   \/\/print the url to screen for testing purposes\n   If ( $kArray&#091;&quot;responseEnvelope.ack&quot;] == &quot;Success&quot;) {\n\techo &#039;&lt;p&gt;&lt;a id=&quot;paypalredirect&quot; href=&quot;&#039; . $payPalURL . &#039;&quot;&gt; Click here if you are not redirected within 10 seconds...&lt;\/a&gt; &lt;\/p&gt;&#039;;\n\techo &#039;&lt;script type=&quot;text\/javascript&quot;&gt;\t\n\t        function redirect(){\n\t\t   document.getElementById(&quot;paypalredirect&quot;).click();\n\t        }\n\t        setTimeout(redirect, 2000);\n              &lt;\/script&gt;&#039;;\n   }\n   else {\n     echo &#039;ERROR Code: &#039; .  $kArray&#091;&quot;error(0).errorId&quot;] . &quot; &lt;br\/&gt;&quot;;\n     echo &#039;ERROR Message: &#039; .  urldecode($kArray&#091;&quot;error(0).message&quot;]) . &quot; &lt;br\/&gt;&quot;;\n  }\n}\ncatch(Exception $e) {\n\techo &quot;Message: ||&quot; .$e-&gt;getMessage().&quot;||&quot;;\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[406,365],"tags":[],"class_list":["post-2222","post","type-post","status-publish","format-standard","hentry","category-adaptive-payment-paypal","category-paypal"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Implement Adaptive Payments - Webkul Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/implement-adaptive-payments\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Implement Adaptive Payments - Webkul Blog\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/implement-adaptive-payments\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2013-08-28T07:58:40+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-02-23T07:18:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Abhishek Singh\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Abhishek Singh\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/implement-adaptive-payments\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/implement-adaptive-payments\/\"},\"author\":{\"name\":\"Abhishek Singh\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/573e459f54796eb4195511990de4bfd0\"},\"headline\":\"Implement Adaptive Payments\",\"datePublished\":\"2013-08-28T07:58:40+00:00\",\"dateModified\":\"2024-02-23T07:18:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/implement-adaptive-payments\/\"},\"wordCount\":3,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"articleSection\":[\"Adaptive Payment\",\"paypal\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/implement-adaptive-payments\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/implement-adaptive-payments\/\",\"url\":\"https:\/\/webkul.com\/blog\/implement-adaptive-payments\/\",\"name\":\"Implement Adaptive Payments - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"datePublished\":\"2013-08-28T07:58:40+00:00\",\"dateModified\":\"2024-02-23T07:18:55+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/implement-adaptive-payments\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/implement-adaptive-payments\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/implement-adaptive-payments\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Implement Adaptive Payments\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/573e459f54796eb4195511990de4bfd0\",\"name\":\"Abhishek Singh\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d4ac7e0e671bf743359d7e3f140c262d1b16d71106f0a1aeaecca327a2805ae4?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d4ac7e0e671bf743359d7e3f140c262d1b16d71106f0a1aeaecca327a2805ae4?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Abhishek Singh\"},\"description\":\"Adobe Commerce certified Magento developer with over 12 years of experience at Webkul. Passionate about scalable Magento 2-based webshops, AI, and multi-channel integrations, Abhishek consistently delivers innovative and efficient e-commerce solutions that propel businesses forward.\",\"sameAs\":[\"http:\/\/webkul.com\"],\"url\":\"https:\/\/webkul.com\/blog\/author\/abhishek\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Implement Adaptive Payments - Webkul Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/implement-adaptive-payments\/","og_locale":"en_US","og_type":"article","og_title":"Implement Adaptive Payments - Webkul Blog","og_url":"https:\/\/webkul.com\/blog\/implement-adaptive-payments\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2013-08-28T07:58:40+00:00","article_modified_time":"2024-02-23T07:18:55+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png","type":"image\/png"}],"author":"Abhishek Singh","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Abhishek Singh"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/implement-adaptive-payments\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/implement-adaptive-payments\/"},"author":{"name":"Abhishek Singh","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/573e459f54796eb4195511990de4bfd0"},"headline":"Implement Adaptive Payments","datePublished":"2013-08-28T07:58:40+00:00","dateModified":"2024-02-23T07:18:55+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/implement-adaptive-payments\/"},"wordCount":3,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"articleSection":["Adaptive Payment","paypal"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/implement-adaptive-payments\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/implement-adaptive-payments\/","url":"https:\/\/webkul.com\/blog\/implement-adaptive-payments\/","name":"Implement Adaptive Payments - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"datePublished":"2013-08-28T07:58:40+00:00","dateModified":"2024-02-23T07:18:55+00:00","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/implement-adaptive-payments\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/implement-adaptive-payments\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/implement-adaptive-payments\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Implement Adaptive Payments"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/573e459f54796eb4195511990de4bfd0","name":"Abhishek Singh","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d4ac7e0e671bf743359d7e3f140c262d1b16d71106f0a1aeaecca327a2805ae4?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d4ac7e0e671bf743359d7e3f140c262d1b16d71106f0a1aeaecca327a2805ae4?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Abhishek Singh"},"description":"Adobe Commerce certified Magento developer with over 12 years of experience at Webkul. Passionate about scalable Magento 2-based webshops, AI, and multi-channel integrations, Abhishek consistently delivers innovative and efficient e-commerce solutions that propel businesses forward.","sameAs":["http:\/\/webkul.com"],"url":"https:\/\/webkul.com\/blog\/author\/abhishek\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/2222","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=2222"}],"version-history":[{"count":5,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/2222\/revisions"}],"predecessor-version":[{"id":423993,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/2222\/revisions\/423993"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=2222"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=2222"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=2222"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}