我一直在搜索PayPal文档两个小时,找不到答案,甚至搜索过谷歌。
点击此处: https://developer.paypal.com/docs/api/#api-operations
我在Maven(REST API)中添加了PayPal的SDK,现在我不确定该怎么做。
我希望使用PayPal API(所有货币)获得帐户余额。
答案 0 :(得分:2)
因此,对于在此问题上苦苦挣扎的其他人,文档的“事务搜索”部分下有一个 API 端点,这完全没有意义。
GET /v1/reporting/balances
您将获得一份余额列表,其中包含您在帐户中维护的每种货币。
请参阅此处的文档:
https://developer.paypal.com/docs/api/transaction-search/v1/
答案 1 :(得分:1)
GetBalance来自Classsic API,目前尚未包含在REST API中,但您可以直接使用HTTPRequest实现NVP调用,
API端点:
https://api-3t.paypal.com/nvp
POST请求有效负载:
USER=seller_api1.paypal.com
&PWD=56A9R4JPVFPMER2X
&SIGNATURE=AFcWxV21C7fd0v3bYYYRCpSSRl31AociN2kspFBnMbzOGg6NdiC7ZXtg
&VERSION=109.0
&METHOD=GetBalance
&RETURNALLCURRENCIES=1
响应:
L_AMT0=265.17
L_CURRENCYCODE0=USD
TIMESTAMP=2015-08-09T14:21:25Z
CORRELATIONID=802b0b6666022
ACK=Success
VERSION=109.0
BUILD=000000
您也可以使用您喜欢的编程语言获取Classic API SDKs,这次选择“Merchant”SDK。
我的示例PHP代码可帮助您了解流程,
<?php
$version = "124";
$user = "API UserName";
$pwd = "API Password";
$signature = "API Signature";
$API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp";
$resArray = CallGetBalance ( $API_Endpoint, $version, $user, $pwd, $signature );
$ack = strtoupper ( $resArray ["ACK"] );
if ($ack == "SUCCESS") {
$balance = urldecode ( $resArray ["L_AMT0"] );
$currency = urldecode ( $resArray ["L_CURRENCYCODE0"] );
echo "Account Balance: " . $balance . " " . $currency;
}
function CallGetBalance($API_Endpoint, $version, $user, $pwd, $signature) {
// setting the curl parameters.
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, $API_Endpoint );
curl_setopt ( $ch, CURLOPT_VERBOSE, 1 );
curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt ( $ch, CURLOPT_SSL_VERIFYHOST, FALSE );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt ( $ch, CURLOPT_POST, 1 );
// NVPRequest for submitting to server
$nvpreq = "METHOD=GetBalance" . "&RETURNALLCURRENCIES=1" . "&VERSION=" . $version . "&PWD=" . $pwd . "&USER=" . $user . "&SIGNATURE=" . $signature;
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $nvpreq );
$response = curl_exec ( $ch );
$nvpResArray = deformatNVP ( $response );
curl_close ( $ch );
return $nvpResArray;
}
/*
* This function will take NVPString and convert it to an Associative Array and it will decode the response. It is usefull to search for a particular key and displaying arrays. @nvpstr is NVPString. @nvpArray is Associative Array.
*/
function deformatNVP($nvpstr) {
$intial = 0;
$nvpArray = array ();
while ( strlen ( $nvpstr ) ) {
// postion of Key
$keypos = strpos ( $nvpstr, '=' );
// position of value
$valuepos = strpos ( $nvpstr, '&' ) ? strpos ( $nvpstr, '&' ) : strlen ( $nvpstr );
/* getting the Key and Value values and storing in a Associative Array */
$keyval = substr ( $nvpstr, $intial, $keypos );
$valval = substr ( $nvpstr, $keypos + 1, $valuepos - $keypos - 1 );
// decoding the respose
$nvpArray [urldecode ( $keyval )] = urldecode ( $valval );
$nvpstr = substr ( $nvpstr, $valuepos + 1, strlen ( $nvpstr ) );
}
return $nvpArray;
}
?>
答案 2 :(得分:0)
此答案适用于那些正在寻找适用于节点js或没有任何SDK的REST API的人。
GetBalance(获取特定帐户的余额)
文档链接:https://developer.paypal.com/docs/limited-release/balance-accounts/v2/api/
REST API [GET]:https://api.sandbox.paypal.com/v2/wallet/balance-accounts
请求:
enter code he var excelWorkSheet = (Worksheet)excelWorkBook.Sheets["IT"];
// excelWorkSheet.dec();
Range range = excelWorkSheet.UsedRange;
int rows = range.Rows.Count + 1;
int cols = range.Columns.Count + 1;
start = excelWorkSheet.Cells[1, 1];
end = excelWorkSheet.Cells[rows, cols];
excelWorkSheet.Activate();
excelWorkSheet.Cells[6, 5].Value2 = "16/05/2020";
excelWorkSheet.Cells[7, 5].Value2 = "07/06/2018";
excelWorkSheet.Cells[8, 5].Value2 = "07/06/2018";
excelWorkSheet.Cells[9, 5].Value2 = "07/06/2018";
excelWorkBook.Save();
excelWorkBook.Close(true, null, null);
excelApp.Quit();
Marshal.ReleaseComObject(excelWorkBook);
Marshal.ReleaseComObject(excelApp);
RES:
curl -v -X GET https://api.sandbox.paypal.com/v2/wallet/balance-accounts \
-H "Content-Type: application/json" \
-H "Authorization: Bearer Access-Token"