[英]Paypal donation tracking with progress bar
我正在設計和建立非營利性網站。 他們想要一個PayPal捐贈按鈕,我希望能夠顯示他們到目前為止籌集的金額。
我對PayPal API的熟悉程度甚至不高。 因此,我需要知道的是如何將捐贈的總金額作為整數值,以便我可以將其除以所需的金額並獲得百分比。
是否有人對如何做到這一點最熟悉?
PayPal有一個'labs'(beta)小部件。 看看https://giving.paypallabs.com/authenticate/review
從未玩過paypal API,但他們有代碼示例:
這是他們的getBalance代碼示例:
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 = & ProfileHandler_Array::getInstance(array(
'username' => 'my_api_username',
'certificateFile' => null,
'subject' => null,
'environment' => $environment));
$pid = ProfileHandler::generateID();
$profile = & new APIProfile($pid, $handler);
$profile->setAPIUsername('my_api_username');
$profile->setAPIPassword('my_api_password');
$profile->setSignature('my_api_signature');
$profile->setCertificateFile('my_cert_file_path');
$profile->setEnvironment($environment);
//--------------------------------------------------
$balance_request =& PayPal::getType('GetBalanceRequestType');
$balance_request->setVersion("51.0");
$caller =& PayPal::getCallerServices($profile);
// Execute SOAP request
$response = $caller->GetBalance($get_balance_request);
switch($response->getAck()) {
case 'Success':
case 'SuccessWithWarning':
// Extract the GetBalance response parameters
$balance = $response->getBalance();
$balance_amt = $balance->_value;
$balance_currency_id = $balance->getattr('currencyID');
$balance_time_stamp = $response->getBalanceTimeStamp();
$balance_holdings = $response->getBalanceHoldings();
$balance_holdings_amt = $balance_holdings->_value;
$balance_holdings_currency_id = $balance_holdings->getattr('currencyID');
exit('GetBalance Completed Successfully: ' . print_r($response, true));
default:
exit('GetBalance failed: ' . print_r($response, true));
}
?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.