{"id":387,"date":"2012-09-17T23:33:08","date_gmt":"2012-09-17T22:33:08","guid":{"rendered":"http:\/\/www.muratyaman.co.uk\/wp\/?p=387"},"modified":"2020-04-04T12:27:21","modified_gmt":"2020-04-04T11:27:21","slug":"just-another-reason-to-hate-using-others-code-paypal-sdk-for-php","status":"publish","type":"post","link":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/2012\/09\/just-another-reason-to-hate-using-others-code-paypal-sdk-for-php\/","title":{"rendered":"Just another reason to hate using others&#8217; code: Paypal SDK for PHP"},"content":{"rendered":"<p>Recently, I have downloaded <a href=\"https:\/\/www.x.com\/developers\/paypal\/documentation-tools\/paypal-sdk-index\" title=\"Paypal SDK downloads\">Paypal SDK<\/a> for PHP developers release 1.1.93 which is for &#8220;Express Checkout, Recurring Payments, Transaction Details, Mass Pay, Direct Payment, Payment Settlements, etc.&#8221;<\/p>\n<p>..and I have been trying to integrate it with my new web application which needs collecting credit card payments. I did not like the &#8220;Express Checkout&#8221; which is like 5 steps and customer is lead to Paypal&#8217;s website during the process; not really straight forward, and I must say, over the years, Paypal integration did not get any less confusing!<\/p>\n<p>The main problem is those so-called Paypal SDK developers clearly have released UNTESTED code:<\/p>\n<p><strong>1. Buggy XML preparation for input:<\/strong> If you care to skim over 25000 lines of code in file: lib\/PayPalAPIInterfaceService\/PayPalAPIInterfaceService.php you will see function toXMLString() in class <strong>SetExpressCheckoutRequestDetailsType<\/strong> and function toXMLString() in class <strong>PaymentDetailsType<\/strong> and both of them use class <strong>BasicAmountType<\/strong> and its function toXMLString(). The bug is when you are using a currency other than <strong>USD<\/strong>, it tries to create an attribute <strong>currencyID<\/strong> for tag <strong>ebl:OrderTotal<\/strong>. But the function injecting the result already closes the tag; therefore, the amount sent to Paypal is incorrect!<\/p>\n<p><strong>2. Redundant class OAuthException<\/strong> in lib\/auth\/PPAuth.php causes fatal error if PHP OAuth extension is already enabled in your server environment.<\/p>\n<p><strong>3. Default settings file config\/sdk_config.ini<\/strong> has incorrect SOAP service URL; it should be<\/p>\n<pre lang=\"ini\">\r\nservice.EndPoint=\"https:\/\/api-3t.sandbox.paypal.com\/2.0\/\"\r\n;service.EndPoint=\"https:\/\/api.sandbox.paypal.com\/2.0\/\"\r\n<\/pre>\n<p>There goes few sleepless nights! .. all because of some &#8220;cowboy&#8221; programmers!<\/p>\n<p>by the way, see: <a href=\"http:\/\/en.wikipedia.org\/wiki\/Cowboy_coding\" title=\"Cowboy coding\">http:\/\/en.wikipedia.org\/wiki\/Cowboy_coding<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently, I have downloaded Paypal SDK for PHP developers release 1.1.93 which is for &#8220;Express Checkout, Recurring Payments, Transaction Details, Mass Pay, Direct Payment, Payment Settlements, etc.&#8221;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[178,26,179,90],"class_list":["post-387","post","type-post","status-publish","format-standard","hentry","category-technology","tag-paypal","tag-php","tag-sdk","tag-soap"],"_links":{"self":[{"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/posts\/387","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=387"}],"version-history":[{"count":5,"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/posts\/387\/revisions"}],"predecessor-version":[{"id":972,"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/posts\/387\/revisions\/972"}],"wp:attachment":[{"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=387"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=387"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=387"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}