Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Never played with paypal API, but they have code samples:</p> <p><a href="https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&amp;content_ID=developer/library_code" rel="nofollow">Paypal Code Samples</a></p> <p>this is their getBalance code sample: <pre><code>require_once 'PayPal.php'; require_once 'PayPal/Profile/Handler/Array.php'; require_once 'PayPal/Profile/API.php'; require_once 'PayPal/Type/GetBalanceRequestType.php'; require_once 'PayPal/Type/GetBalanceResponseType.php'; $environment = 'sandbox'; // or 'beta-sandbox' or 'live' //-------------------------------------------------- // PROFILE //-------------------------------------------------- /** * W A R N I N G * Do not embed plaintext credentials in your application code. * Doing so is insecure and against best practices. * * Your API credentials must be handled securely. Please consider * encrypting them for use in any production environment, and ensure * hat only authorized individuals may view or modify them. */ $handler = &amp; ProfileHandler_Array::getInstance(array( 'username' =&gt; 'my_api_username', 'certificateFile' =&gt; null, 'subject' =&gt; null, 'environment' =&gt; $environment)); $pid = ProfileHandler::generateID(); $profile = &amp; new APIProfile($pid, $handler); $profile-&gt;setAPIUsername('my_api_username'); $profile-&gt;setAPIPassword('my_api_password'); $profile-&gt;setSignature('my_api_signature'); $profile-&gt;setCertificateFile('my_cert_file_path'); $profile-&gt;setEnvironment($environment); //-------------------------------------------------- $balance_request =&amp; PayPal::getType('GetBalanceRequestType'); $balance_request-&gt;setVersion("51.0"); $caller =&amp; PayPal::getCallerServices($profile); // Execute SOAP request $response = $caller-&gt;GetBalance($get_balance_request); switch($response-&gt;getAck()) { case 'Success': case 'SuccessWithWarning': // Extract the GetBalance response parameters $balance = $response-&gt;getBalance(); $balance_amt = $balance-&gt;_value; $balance_currency_id = $balance-&gt;getattr('currencyID'); $balance_time_stamp = $response-&gt;getBalanceTimeStamp(); $balance_holdings = $response-&gt;getBalanceHoldings(); $balance_holdings_amt = $balance_holdings-&gt;_value; $balance_holdings_currency_id = $balance_holdings-&gt;getattr('currencyID'); exit('GetBalance Completed Successfully: ' . print_r($response, true)); default: exit('GetBalance failed: ' . print_r($response, true)); } ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload