Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.75 KB | None | 0 0
  1. object(PayPalExceptionPayPalConnectionException)#18 (9) {["url":"PayPalExceptionPayPalConnectionException":private]=>
  2. string(50) "https://api.sandbox.paypal.com/v1/payments/payment"
  3. ["data":"PayPalExceptionPayPalConnectionException":private]=>
  4. string(213) "{"name":"MALFORMED_REQUEST","message":"Incoming JSON request does not map to API request","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#MALFORMED_REQUEST","debug_id":"a963484dd5bd0"}"
  5. ["message":protected]=>
  6. string(93) "Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment."
  7. ["string":"Exception":private]=>
  8. string(0) ""
  9. ["code":protected]=>
  10. int(400)
  11. ["file":protected]=>
  12. string(146) "/home/nork/domains/nork.lt/public_html/cms/xxx/system/payments/PayPal-PHP-SDK/paypal/rest-api-sdk-php/lib/PayPal/Core/PayPalHttpConnection.php"
  13. ["line":protected]=>
  14. int(202)
  15. ["trace":"Exception":private]=>
  16. array(4) {
  17. [0]=>
  18. array(6) {
  19. ["file"]=>
  20. string(145) "/home/nork/domains/nork.lt/public_html/cms/xxx/system/payments/PayPal-PHP-SDK/paypal/rest-api-sdk-php/lib/PayPal/Transport/PayPalRestCall.php"
  21. ["line"]=>
  22. int(73)
  23. ["function"]=>
  24. string(7) "execute"
  25. ["class"]=>
  26. string(32) "PayPalCorePayPalHttpConnection"
  27. ["type"]=>
  28. string(2) "->"
  29. ["args"]=>
  30. array(1) {
  31. [0]=>
  32. string(235) "{"intent":"sale","payer":{"payment_method":"paypal"},"redirect_urls":{"return_url":"http://google.lt","cancel_url":"http://cancel.lt"},"transactions":{"amount":1.19,"description":"RuneScape 2007 Gold","invoice_number":"5977898964140"}}"
  33. }
  34. }
  35. [1]=>
  36. array(6) {
  37. ["file"]=>
  38. string(147) "/home/nork/domains/nork.lt/public_html/cms/xxx/system/payments/PayPal-PHP-SDK/paypal/rest-api-sdk-php/lib/PayPal/Common/PayPalResourceModel.php"
  39. ["line"]=>
  40. int(104)
  41. ["function"]=>
  42. string(7) "execute"
  43. ["class"]=>
  44. string(31) "PayPalTransportPayPalRestCall"
  45. ["type"]=>
  46. string(2) "->"
  47. ["args"]=>
  48. array(5) {
  49. [0]=>
  50. array(1) {
  51. [0]=>
  52. string(26) "PayPalHandlerRestHandler"
  53. }
  54. [1]=>
  55. string(20) "/v1/payments/payment"
  56. [2]=>
  57. string(4) "POST"
  58. [3]=>
  59. string(235) "{"intent":"sale","payer":{"payment_method":"paypal"},"redirect_urls":{"return_url":"http://google.lt","cancel_url":"http://cancel.lt"},"transactions":{"amount":1.19,"description":"RuneScape 2007 Gold","invoice_number":"5977898964140"}}"
  60. [4]=>
  61. NULL
  62. }
  63. }
  64. [2]=>
  65. array(6) {
  66. ["file"]=>
  67. string(132) "/home/nork/domains/nork.lt/public_html/cms/xxx/system/payments/PayPal-PHP-SDK/paypal/rest-api-sdk-php/lib/PayPal/Api/Payment.php"
  68. ["line"]=>
  69. int(577)
  70. ["function"]=>
  71. string(11) "executeCall"
  72. ["class"]=>
  73. string(33) "PayPalCommonPayPalResourceModel"
  74. ["type"]=>
  75. string(2) "::"
  76. ["args"]=>
  77. array(6) {
  78. [0]=>
  79. string(20) "/v1/payments/payment"
  80. [1]=>
  81. string(4) "POST"
  82. [2]=>
  83. string(235) "{"intent":"sale","payer":{"payment_method":"paypal"},"redirect_urls":{"return_url":"http://google.lt","cancel_url":"http://cancel.lt"},"transactions":{"amount":1.19,"description":"RuneScape 2007 Gold","invoice_number":"5977898964140"}}"
  84. [3]=>
  85. NULL
  86. [4]=>
  87. object(PayPalRestApiContext)#2 (2) {
  88. ["requestId":"PayPalRestApiContext":private]=>
  89. NULL
  90. ["credential":"PayPalRestApiContext":private]=>
  91. object(PayPalAuthOAuthTokenCredential)#3 (7) {
  92. ["clientId":"PayPalAuthOAuthTokenCredential":private]=>
  93. string(80) "AcAvvJw6aK8kEs_lTfv8TjuPiPzHX8Yk_Q9mvDO6AR3grRa09kOBrNVAZyvs-EpKrB9HP0A6UPZBgCrh"
  94. ["clientSecret":"PayPalAuthOAuthTokenCredential":private]=>
  95. string(80) "EIXpeAtUZVOf1syl-Jlt0I90lhx8oRMHPpmmRRRxuZ2hUF9LFQJK2fUFa6yz_rRuRaFMLGwJmXBk2cut"
  96. ["accessToken":"PayPalAuthOAuthTokenCredential":private]=>
  97. string(97) "A21AAGgcZ9Ls3UfzYYWU1q4ScO4WcX45JNbtYNJIosxP2kEq7i60yA0ZZrhHPI-anHRtaVATMjTDZKiNE-D0pSYSCkMk1VKHw"
  98. ["tokenExpiresIn":"PayPalAuthOAuthTokenCredential":private]=>
  99. int(32382)
  100. ["tokenCreateTime":"PayPalAuthOAuthTokenCredential":private]=>
  101. int(1501006218)
  102. ["cipher":"PayPalAuthOAuthTokenCredential":private]=>
  103. object(PayPalSecurityCipher)#4 (1) {
  104. ["secretKey":"PayPalSecurityCipher":private]=>
  105. string(80) "EIXpeAtUZVOf1syl-Jlt0I90lhx8oRMHPpmmRRRxuZ2hUF9LFQJK2fUFa6yz_rRuRaFMLGwJmXBk2cut"
  106. }
  107. ["_propMap":"PayPalCommonPayPalModel":private]=>
  108. array(0) {
  109. }
  110. }
  111. }
  112. [5]=>
  113. NULL
  114. }
  115. }
  116. [3]=>
  117. array(6) {
  118. ["file"]=>
  119. string(63) "/home/nork/domains/nork.lt/public_html/cms/xxx/checkout.php"
  120. ["line"]=>
  121. int(65)
  122. ["function"]=>
  123. string(6) "create"
  124. ["class"]=>
  125. string(18) "PayPalApiPayment"
  126. ["type"]=>
  127. string(2) "->"
  128. ["args"]=>
  129. array(1) {
  130. [0]=>
  131. object(PayPalRestApiContext)#2 (2) {
  132. ["requestId":"PayPalRestApiContext":private]=>
  133. NULL
  134. ["credential":"PayPalRestApiContext":private]=>
  135. object(PayPalAuthOAuthTokenCredential)#3 (7) {
  136. ["clientId":"PayPalAuthOAuthTokenCredential":private]=>
  137. string(80) "AcAvvJw6aK8kEs_lTfv8TjuPiPzHX8Yk_Q9mvDO6AR3grRa09kOBrNVAZyvs-EpKrB9HP0A6UPZBgCrh"
  138. ["clientSecret":"PayPalAuthOAuthTokenCredential":private]=>
  139. string(80) "EIXpeAtUZVOf1syl-Jlt0I90lhx8oRMHPpmmRRRxuZ2hUF9LFQJK2fUFa6yz_rRuRaFMLGwJmXBk2cut"
  140. ["accessToken":"PayPalAuthOAuthTokenCredential":private]=>
  141. string(97) "A21AAGgcZ9Ls3UfzYYWU1q4ScO4WcX45JNbtYNJIosxP2kEq7i60yA0ZZrhHPI-anHRtaVATMjTDZKiNE-D0pSYSCkMk1VKHw"
  142. ["tokenExpiresIn":"PayPalAuthOAuthTokenCredential":private]=>
  143. int(32382)
  144. ["tokenCreateTime":"PayPalAuthOAuthTokenCredential":private]=>
  145. int(1501006218)
  146. ["cipher":"PayPalAuthOAuthTokenCredential":private]=>
  147. object(PayPalSecurityCipher)#4 (1) {
  148. ["secretKey":"PayPalSecurityCipher":private]=>
  149. string(80) "EIXpeAtUZVOf1syl-Jlt0I90lhx8oRMHPpmmRRRxuZ2hUF9LFQJK2fUFa6yz_rRuRaFMLGwJmXBk2cut"
  150. }
  151. ["_propMap":"PayPalCommonPayPalModel":private]=>
  152. array(0) {
  153. }
  154. }
  155. }
  156. }
  157. }
  158. }
  159. ["previous":"Exception":private]=>
  160. NULL
  161. }
  162.  
  163. <?php
  164.  
  165. use PayPalApiPayer;
  166. use PayPalApiItem;
  167. use PayPalApiItemList;
  168. use PayPalApiDetails;
  169. use PayPalApiAmount;
  170. use PayPalApiTransaction;
  171. use PayPalApiRedirectUrls;
  172. use PayPalApiPayment;
  173.  
  174. if(isset($_GET['type']) && isset($_GET['amount']) && isset($_GET['gold']))
  175. {
  176. if($_GET['type'] == 'paypal') // If payment is PayPal
  177. {
  178. require 'system/payments/paypal.php';
  179.  
  180. $gold = $_GET['gold'];
  181. $amount = $_GET['amount'];
  182. $pricePerVnt = 0.00;
  183. $productName = '';
  184. $shipping = 0.00;
  185.  
  186. switch($gold)
  187. {
  188. case 'first':
  189. {
  190. $productName = 'first name';
  191. $pricePerVnt = 1.19;
  192. break;
  193. }
  194. case 'second':
  195. {
  196. $productName = 'second name';
  197. $pricePerVnt = 0.21;
  198. break;
  199. }
  200. }
  201. if(!$pricePerVnt) die();
  202.  
  203. $totalAmount = $amount * $pricePerVnt;
  204.  
  205. $payer = new Payer();
  206. $payer->setPaymentMethod('paypal');
  207.  
  208. $item = new Item();
  209. $item->setName($productName)->setCurrency('USD')->setQuantity('1')->setPrice($pricePerVnt);
  210.  
  211. $itemList = new ItemList();
  212. $itemList->setItems($item);
  213.  
  214. $amount = new Amount();
  215. $amount->setCurrency('USD')->setTotal($totalAmount);
  216.  
  217. $transaction = new Transaction();
  218. $transaction->setAmount($pricePerVnt)->setDescription($productName)->setInvoiceNumber(uniqid());
  219.  
  220. $redirectUrls = new RedirectUrls();
  221. $redirectUrls->setReturnUrl('http://google.lt')->setCancelUrl('http://cancel.lt');
  222.  
  223. $payment = new Payment();
  224. $payment->setIntent('sale')->setPayer($payer)->setRedirectUrls($redirectUrls)->setTransactions($transaction);
  225.  
  226. try {
  227. $payment->create($paypal);
  228. } catch (PayPalExceptionPayPalConnectionException $ex) {
  229. echo $ex->getCode(); // Prints the Error Code
  230. echo $ex->getData(); // Prints the detailed error message
  231. die($ex);
  232. } catch (Exception $ex) {
  233. die($ex);
  234. }
  235. //print_r($payment);
  236.  
  237. //echo $approvalUrl = $payment->getApprovalLink();
  238. //header('Location: {$approvalUrl}');
  239. }
  240. }
  241.  
  242. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement