Advertisement
Guest User

Untitled

a guest
Mar 15th, 2017
1,813
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.97 KB | None | 0 0
  1. Array
  2. (
  3. [0] => X-PAYPAL-SECURITY-USERID: developer_api1.gmail.com
  4. [1] => X-PAYPAL-SECURITY-PASSWORD: xxxxxxxx
  5. [2] => X-PAYPAL-SECURITY-SIGNATURE: xxxxxxxxx
  6. [3] => X-PAYPAL-SECURITY-SUBJECT: subject
  7. [4] => X-PAYPAL-REQUEST-DATA-FORMAT: XML
  8. [5] => X-PAYPAL-RESPONSE-DATA-FORMAT: XML
  9. [6] => X-PAYPAL-APPLICATION-ID: APP-80W284485P519543T
  10. [7] => X-PAYPAL-DEVICE-ID:
  11. [8] => X-PAYPAL-DEVICE-IPADDRESS: http://192.168.1.9:8888
  12. [9] => X-PAYPAL-SANDBOX-EMAIL-ADDRESS: [email protected]
  13. )
  14.  
  15. /**
  16. * Timezone Setting
  17. * List of Supported Timezones: http://www.php.net/manual/en/timezones.php
  18. */
  19. date_default_timezone_set('America/Chicago');
  20.  
  21. /**
  22. * Enable Sessions
  23. * Checks to see if a session_id exists. If not, a new session is started.
  24. */
  25. if(!session_id()) session_start();
  26.  
  27. /**
  28. * Sandbox Mode - TRUE/FALSE
  29. * Check the domain of the current page and set $sandbox accordingly.
  30. * This allows you to automatically use Sandbox or Live credentials throughout
  31. * your application based on what server the app is running from.
  32. *
  33. * I like to do this so I don't forget to update Sandbox credentials to Live
  34. * prior to uploading files to a production server.
  35. *
  36. * In this case, it's checking to see if the current URL is http://sandbox.domain.*
  37. * If so, $sandbox is true and the PayPal sandbox will be used throughout. If not,
  38. * we'll assume it must be a live transaction and will use live credentials throughout.
  39. *
  40. * Following this pattern will allow you to create your own http://sandbox.domain.com test server,
  41. * and then any time your code runs from that server, PayPal's sandbox will be used automatically.
  42. *
  43. * If you would rather just set $sandbox to true/false on your own that's fine,
  44. * but you have to make sure your live server always uses false and your test server
  45. * always uses true. It's easy to forget this and up with real customers processing
  46. * payments from your live site on the PayPal sandbox.
  47. */
  48. $host_split = explode('.',$_SERVER['HTTP_HOST']);
  49. $sandbox = $host_split[0] == 'sandbox' && $host_split[1] == 'domain' ? TRUE : FALSE;
  50. $sandbox=TRUE;
  51. $domain = $sandbox ? 'http://192.168.1.9:8888' : 'http://www.realurl.com/';
  52.  
  53. $cancel_url="http://192.168.1.9:8888";
  54. $return_url="http://192.168.1.9:8888";
  55.  
  56. /**
  57. * Enable error reporting if running in sandbox mode.
  58. */
  59. if($sandbox)
  60. {
  61. error_reporting(E_ALL|E_STRICT);
  62. ini_set('display_errors', '1');
  63. }
  64.  
  65. /**
  66. * PayPal API Version
  67. * ------------------
  68. * The library is currently using PayPal API version 109.0.
  69. * You may adjust this value here and then pass it into the PayPal object when you create it within your scripts to override if necessary.
  70. */
  71. $api_version = '119.0'; // Released 11.05.2014
  72.  
  73. /**
  74. * PayPal Application ID
  75. * --------------------------------------
  76. * The application is only required with Adaptive Payments applications.
  77. * You obtain your application ID but submitting it for approval within your
  78. * developer account at http://developer.paypal.com
  79. *
  80. * We're using shorthand if/else statements here to set both Sandbox and Production values.
  81. * Your sandbox values go on the left and your live values go on the right.
  82. * The sandbox value included here is a global value provided for developrs to use in the PayPal sandbox.
  83. */
  84. $application_id = $sandbox ? 'APP-80W284485P519543T' : '';
  85.  
  86. /**
  87. * PayPal Developer Account Email Address
  88. * This is the email address that you use to sign in to http://developer.paypal.com
  89. */
  90. $developer_account_email = '[email protected]';
  91.  
  92. /**
  93. * PayPal Gateway API Credentials
  94. * ------------------------------
  95. * These are your PayPal API credentials for working with the PayPal gateway directly.
  96. * These are used any time you're using the parent PayPal class within the library.
  97. *
  98. * We're using shorthand if/else statements here to set both Sandbox and Production values.
  99. * Your sandbox values go on the left and your live values go on the right.
  100. *
  101. * You may obtain these credentials by logging into the following with your PayPal account: https://www.paypal.com/us/cgi-bin/webscr?cmd=_login-api-run
  102. */
  103. $api_username = $sandbox ? 'developer_api1.gmail.com' : 'developer_api1.gmail.com';
  104. $api_password = $sandbox ? 'xxxxxxxxxxxxxxxxxxxxxxxxxx' : 'xxxxxxxxxxxxxxxxxxxxxxxxxx';
  105. $api_signature = $sandbox ? 'xxxxxxxxxxxxxxxxxxxxxxxxxx' : 'xxxxxxxxxxxxxxxxxxxxxxxxxx';
  106.  
  107. /**
  108. * Payflow Gateway API Credentials
  109. * ------------------------------
  110. * These are the credentials you use for your PayPal Manager: http://manager.paypal.com
  111. * These are used when you're working with the PayFlow child class.
  112. *
  113. * We're using shorthand if/else statements here to set both Sandbox and Production values.
  114. * Your sandbox values go on the left and your live values go on the right.
  115. *
  116. * You may use the same credentials you use to login to your PayPal Manager,
  117. * or you may create API specific credentials from within your PayPal Manager account.
  118. */
  119. $payflow_username = $sandbox ? 'SANDBOX_PAYFLOW_USERNAME' : 'LIVE_PAYFLOW_USERNAME';
  120. $payflow_password = $sandbox ? 'SANDBOX_PAYFLOW_PASSWORD' : 'LIVE_PAYFLOW_PASSWORD';
  121. $payflow_vendor = $sandbox ? 'SANDBOX_PAYFLOW_VENDOR' : 'LIVE_PAYFLOW_VENDOR';
  122. $payflow_partner = $sandbox ? 'SANDBOX_PAYFLOW_PARTNER' : 'LIVE_PAYFLOW_PARTNER';
  123.  
  124. /**
  125. * PayPal REST API Credentials
  126. * ---------------------------
  127. * These are the API credentials used for the PayPal REST API.
  128. * These are used any time you're working with the REST API child class.
  129. *
  130. * You may obtain these credentials from within your account at http://developer.paypal.com
  131. */
  132. $rest_client_id = $sandbox ? 'SANDBOX_CLIENT_ID' : 'LIVE_CLIENT_ID';
  133. $rest_client_secret = $sandbox ? 'SANDBOX_SECRET_ID' : 'LIVE_SECRET_ID';
  134.  
  135. /**
  136. * PayPal Finance Portal API
  137. * -------------------------
  138. * These are credentials used for obtaining a PublisherID used in Bill Me Later Banner code.
  139. * As of now, these are specialized API's and you must obtain credentials directly from a PayPal rep.
  140. */
  141. $finance_access_key = $sandbox ? 'SANDBOX_ACCESS_KEY' : 'LIVE_ACCESS_KEY';
  142. $finance_client_secret = $sandbox ? 'SANDBOX_CLIENT_SECRET' : 'LIVE_CLIENT_SECRET';
  143.  
  144. /**
  145. * Third Party User Values
  146. * These can be setup here or within each caller directly when setting up the PayPal object.
  147. */
  148. $api_subject = 'soggetto'; // If making calls on behalf a third party, their PayPal email address or account ID goes here.
  149. $device_id = '';
  150. $device_ip_address = $_SERVER['REMOTE_ADDR'];
  151.  
  152. /**
  153. * Enable Headers
  154. * Option to print headers to screen when dumping results or not.
  155. */
  156. $print_headers = true;
  157.  
  158. /**
  159. * Enable Logging
  160. * Option to log API requests and responses to log file.
  161. */
  162. $log_results = false;
  163. $log_path = $_SERVER['DOCUMENT_ROOT'].'/logs/';
  164.  
  165. <?php
  166. // Include required library files.
  167. require_once('includes/config.php');
  168. require_once('autoload.php');
  169.  
  170. //phpinfo();
  171. // Create PayPal object.
  172. $PayPalConfig = array(
  173. 'Sandbox' => $sandbox,
  174. 'DeveloperAccountEmail' => $developer_account_email,
  175. 'ApplicationID' => $application_id,
  176. 'DeviceID' => $device_id,
  177. 'IPAddress' => "http://192.168.1.9:8888",
  178. 'APIUsername' => $api_username,
  179. 'APIPassword' => $api_password,
  180. 'APISignature' => $api_signature,
  181. 'APISubject' => $api_subject,
  182. 'PrintHeaders' => $print_headers,
  183. 'LogResults' => $log_results,
  184. 'LogPath' => $log_path,
  185. );
  186.  
  187. $PayPal = new angelleyePayPalAdaptive($PayPalConfig);
  188.  
  189. // Prepare request arrays
  190. $PayRequestFields = array(
  191. 'ActionType' => 'PAY_PRIMARY', // Required. Whether the request pays the receiver or whether the request is set up to create a payment request, but not fulfill the payment until the ExecutePayment is called. Values are: PAY, CREATE, PAY_PRIMARY
  192. 'CancelURL' => $cancel_url, // Required. The URL to which the sender's browser is redirected if the sender cancels the approval for the payment after logging in to paypal.com. 1024 char max.
  193. 'CurrencyCode' => 'EUR', // Required. 3 character currency code.
  194. 'FeesPayer' => 'SECONDARYONLY', // The payer of the fees. Values are: SENDER, PRIMARYRECEIVER, EACHRECEIVER, SECONDARYONLY
  195. 'IPNNotificationURL' => 'http://192.168.1.9:8888/ipn/', // The URL to which you want all IPN messages for this payment to be sent. 1024 char max.
  196. 'Memo' => '', // A note associated with the payment (text, not HTML). 1000 char max
  197. 'Pin' => '', // The sener's personal id number, which was specified when the sender signed up for the preapproval
  198. 'PreapprovalKey' => '', // The key associated with a preapproval for this payment. The preapproval is required if this is a preapproved payment.
  199. 'ReturnURL' => $return_url, // Required. The URL to which the sener's browser is redirected after approvaing a payment on paypal.com. 1024 char max.
  200. 'ReverseAllParallelPaymentsOnError' => '', // Whether to reverse paralel payments if an error occurs with a payment. Values are: TRUE, FALSE
  201. 'SenderEmail' => '', // Sender's email address. 127 char max.
  202. 'TrackingID' => 'trackpasy234234' // Unique ID that you specify to track the payment. 127 char max.
  203. );
  204.  
  205. $ClientDetailsFields = array(
  206. 'CustomerID' => '345', // Your ID for the sender 127 char max.
  207. 'CustomerType' => '34', // Your ID of the type of customer. 127 char max.
  208. 'GeoLocation' => '', // Sender's geographic location
  209. 'Model' => '', // A sub-identification of the application. 127 char max.
  210. 'PartnerName' => '' // Your organization's name or ID
  211. );
  212.  
  213. $FundingTypes = array('ECHECK', 'BALANCE', 'CREDITCARD'); // Funding constrainigs require advanced permissions levels.
  214.  
  215. $Receivers = array();
  216. $Receiver = array(
  217. 'Amount' => '500.00', // Required. Amount to be paid to the receiver.
  218. 'Email' => '[email protected]', // Receiver's email address. 127 char max.
  219. 'InvoiceID' => '', // The invoice number for the payment. 127 char max.
  220. 'PaymentType' => 'GOODS', // Transaction type. Values are: GOODS, SERVICE, PERSONAL, CASHADVANCE, DIGITALGOODS
  221. 'PaymentSubType' => '', // The transaction subtype for the payment.
  222. 'AccountID' => '',
  223. 'Phone' => array('CountryCode' => '', 'PhoneNumber' => '', 'Extension' => ''), // Receiver's phone number. Numbers only.
  224. 'Primary' => 'true' // Whether this receiver is the primary receiver. Values are boolean: TRUE, FALSE
  225. );
  226. array_push($Receivers,$Receiver);
  227.  
  228. $Receiver = array(
  229. 'Amount' => '50.00', // Required. Amount to be paid to the receiver.
  230. 'Email' => '[email protected]', // Receiver's email address. 127 char max.
  231. 'InvoiceID' => '', // The invoice number for the payment. 127 char max.
  232. 'PaymentType' => 'GOODS', // Transaction type. Values are: GOODS, SERVICE, PERSONAL, CASHADVANCE, DIGITALGOODS
  233. 'PaymentSubType' => '', // The transaction subtype for the payment.
  234. 'AccountID' => '',
  235. 'Phone' => array('CountryCode' => '', 'PhoneNumber' => '', 'Extension' => ''), // Receiver's phone number. Numbers only.
  236. 'Primary' => 'false' // Whether this receiver is the primary receiver. Values are boolean: TRUE, FALSE
  237. );
  238. array_push($Receivers,$Receiver);
  239.  
  240.  
  241.  
  242. $SenderIdentifierFields = array(
  243. 'UseCredentials' => '' // If TRUE, use credentials to identify the sender. Default is false.
  244. );
  245.  
  246. $AccountIdentifierFields = array(
  247. 'Email' => '', // Sender's email address. 127 char max.
  248. 'Phone' => array('CountryCode' => '', 'PhoneNumber' => '', 'Extension' => '') // Sender's phone number. Numbers only.
  249. );
  250.  
  251. $PayPalRequestData = array(
  252. 'PayRequestFields' => $PayRequestFields,
  253. 'ClientDetailsFields' => $ClientDetailsFields,
  254. //'FundingTypes' => $FundingTypes,
  255. 'Receivers' => $Receivers,
  256. 'SenderIdentifierFields' => $SenderIdentifierFields,
  257. 'AccountIdentifierFields' => $AccountIdentifierFields
  258. );
  259.  
  260.  
  261. // Pass data into class for processing with PayPal and load the response array into $PayPalResult
  262. $PayPalResult = $PayPal->Pay($PayPalRequestData);
  263.  
  264. // Write the contents of the response array to the screen for demo purposes.
  265. echo '<pre />';
  266. print_r($PayPalResult);
  267. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement