带进度条的 Paypal 捐款跟踪

发布于 2024-12-10 09:39:13 字数 171 浏览 1 评论 0原文

我正在为非营利组织设计和构建一个网站。他们想要一个 PayPal 捐赠按钮,我希望能够展示他们迄今为止筹集了多少资金。

我对 PayPal API 还不够熟悉,甚至无法接近。因此,我需要知道的是如何获取作为整数值的捐赠总额,以便我可以将其除以所需的金额并获得百分比。

有人最熟悉如何做到这一点吗?

I am designing and building a website for a non-profit. They want a PayPal Donate button and I'd like to be able to show how much they've raised so far.

I am not familiar enough with the PayPal API to even get close. So all I need to know is how to get the total amount donated as an integer value so that I can divide that by the amount needed and get a percentage.

Is anyone the least bit familiar with how to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

没有你我更好 2024-12-17 09:39:13

PayPal 为此提供了一个“实验室”(测试版)小部件。看看https://giving.paypallabs.com/authenticate/review

PayPal has a 'labs' (beta) widget for this. Have a look at https://giving.paypallabs.com/authenticate/review

我ぃ本無心為│何有愛 2024-12-17 09:39:13

从未使用过 paypal API,但他们有代码示例:

Paypal 代码示例

这是他们的 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));
}

?>

Never played with paypal API, but they have code samples:

Paypal Code Samples

this is their getBalance code sample:

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));
}

?>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文