我有这个函数应该给我 cURL 中的访问令牌
curl -v https://api.sandbox.paypal.com/v1/oauth2/token \
-H "Accept: application/json" \
-H "Accept-Language: en_US" \
-u "client_id:secret" \
-d "grant_type=client_credentials"
Run Code Online (Sandbox Code Playgroud)
来源:https ://developer.paypal.com/docs/api/overview/#get-an-access-token
但是当我尝试在谷歌应用程序脚本中运行该函数(应该是相同的)时,错误始终是:“无效令牌”。我究竟做错了什么?
function lol(){
var request = UrlFetchApp.fetch("https://api.sandbox.paypal.com/v1/oauth2/token", {
"Accept": "application/json",
"Accept-Language": "en_US",
"CLIENT_ID":"SECRET",
"grant_type":"application/x-www-form-urlencoded"
})
Logger.log(request.getContentText());
}
Run Code Online (Sandbox Code Playgroud)
CLIENT_ID 和 SECRET 是个人的,是从我的 PayPal 帐户复制的。
我使用 Paypal 的智能支付按钮,代码如下:
window.paypal.Buttons({
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: this.price,
currency: "USD"
}
}]
});
},
...
}
Run Code Online (Sandbox Code Playgroud)
它工作得很好,除了它要求用户在结帐窗口上提供送货地址这一事实之外,我想摆脱它,因为这是一种数字商品而不是物理商品。我怎样才能做到这一点?我尝试过做no_shipping: 1类似的事情但无济于事。
我在paypal沙盒中创建了一个帐户并创建了2个帐户,其中一个帐户有一些钱用于付款.我使用我的java程序中的签名详细信息来获得付款.当用户点击pay with paypal按钮时,我们将从paypal获得一个令牌并将其传递给此URL:
https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token=
成功付款后,我无法在paypal沙盒帐户中看到任何交易?为什么会这样,我在做什么错?我正在使用Google App Engine java和jsp.请给我任何帮助完整的链接做"Pay With Paypal"
谢谢.
我准备在用户从我的网站购买后设置一个IPN脚本,但我只是想一想,如果他们注册到我网站的电子邮件地址与他们注册到PayPal的电子邮件地址有什么不同呢?
即他们使用forename.surname@domain.com注册我的网站,但他们的PayPal帐户登录名为surname.forename@domain.com.
PayPal IPN将发回surname.forename@domain.com,我无法确定谁刚刚购买了该产品.
我意识到在这个简单的情况下,有可能找到一个类似于数据库中的电子邮件地址,但在现实世界中,人们有疯狂的电子邮件地址,并不总是可能的.
有人解决过这个问题吗?
我一直在尝试使用Paypal Adaptive API解决以下问题.我已将Paypal Adaptive链式支付API与我的网站集成.当用户点击"pay with paypal"按钮时,需要向paypal网站付款.我的问题从这里开始
现在,我希望能够在用户成功付款时将各种付款信息列入我的数据库,并且在投入生产之前我没有正确的方法在开发中进行
我很惊讶像paypal这样的十亿美元公司可以为开发人员提供这样一个无用的代码来集成
我也看看这个答案,Adaptive Payments Paypal:没有数据的返回网址?.来自paypal的人说
当用户返回returnUrl端点时,您调用PaymentDetails API并检查状态并继续.
好吧问题是拨打PaymentDetails,我需要paytoken.我怎样才能从回归中获得收益?就像现在一样,返回URL没有任何查询参数.
我正在尝试使用PayPal Sandbox来测试自动信用卡处理,但遇到了问题.上周我的测试是"成功的",因为当发生验证错误时,API会窒息,但至少我知道发生了什么.清理我传递给API的代码后,我不再收到验证错误,只是内部服务错误,这已经发生了四天.
以下是日志文件显示的内容(此处删除了访问令牌,但它是在使用之前从API成功生成的):
2013-07-01 16:47:00,845 [32944] DEBUG PayPal.Manager.ConnectionManager [(null)] grant_type = client_credentials
2013-07-01 16:47:03,296 [32944] DEBUG PayPal.Manager.ConnectionManager [(null)]服务响应
2013-07-01 16:47:03296 [32944] DEBUG PayPal.Manager.ConnectionManager [(空)] { "范围":" https://api.paypal.com/v1/payments/*.https://开头api.paypal.com/v1/vault/credit-card https://api.paypal.com/v1/vault/credit-card/.* openid","access_token":"[生成的访问令牌]", "token_type":"Bearer","app_id":"[app ID]","expires_in":28800}
2013-07-01 16:47:05,069 [32944] DEBUG PayPal.PayPalResource [(null)] Content-Type:application/json
2013-07-01 16:47:05,069 [32944] DEBUG PayPal.PayPalResource [(null)]授权:持票人[访问代码]
2013-07-01 16:47:05,069 [32944] DEBUG PayPal.PayPalResource [(null)] User-Agent:PayPalSDK/rest-sdk-dotnet 0.7.1; lang = DOTNET; v = 4.0.30319.18046; bit = 64 ; os = Windows 8 6.2.9200.0;
2013-07-01 16:47:05,069 [32944] DEBUG PayPal.PayPalResource [(null)] PayPal-Request-Id:303be909-4268-4909-b1cb-b51b6dc7ea54
2013-07-01 16:47:05,365 [32944] DEBUG …
我试图根据他们的cURL示例使用REST API进行简单的测试:https: //developer.paypal.com/docs/integration/direct/make-your-first-call/
curl -v https://api.sandbox.paypal.com/v1/oauth2/token \
-H "Accept: application/json" \
-H "Accept-Language: en_US" \
-u "EOJ2S-Z6OoN_le_KS1d75wsZ6y0SFdVsY9183IvxFyZp:EClusMEUk8e9ihI7ZdVLF5cZ6y0SFdVsY9183IvxFyZp" \
-d "grant_type=client_credentials"
Run Code Online (Sandbox Code Playgroud)
我的C#:
var h = new HttpClientHandler();
h.Credentials = new NetworkCredential("client_id", "secret");
var client = new HttpClient();
client.BaseAddress = new Uri("https://api.sandbox.paypal.com/v1/oauth2/token");
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Add("Accept-Language", "en_US");
var requestContent = new FormUrlEncodedContent(new[] {
new KeyValuePair<string, string>("grant_type", "client_credentials"),
});
HttpRequestMessage req = new HttpRequestMessage(System.Net.Http.HttpMethod.Post, "https://api.sandbox.paypal.com/v1/oauth2/token");
req.Content = new StringContent("grant_type=client_credentials");
var r = client.SendAsync(req).Result;
Run Code Online (Sandbox Code Playgroud)
错误返回:
StatusCode: 415, ReasonPhrase: 'Unsupported Media Type', Version: 1.1, …Run Code Online (Sandbox Code Playgroud) 没有 react-paypal-button-v2 ~~~有 60KB 的开销
类似的问题在这里,但他们建议react-paypal-button-v2
我正在尝试制作一个 React PayPal 按钮来更改道具更改的账单金额。
我使用道具价格调用以下组件,每次价格更改时,我都想重新渲染按钮以更新实际价格。没有 react-paypal-button-v2
const PaypalForm = props => {
let paypalRef = useRef();
useEffect(() => {
window.paypal
.Buttons({
createOrder: (data, actions) => {
return actions.order.create({
purchase_units: [
{
description: "test",
amount: {
currency_code: "USD",
value: props.price
}
}
]
});
},
onApprove: async (data, actions) => {
const order = await actions.order.capture();
console.log(order);
},
onError: err => {
setError(err);
console.error(err);
}
})
.render(paypalRef.current);
}, [props.price]);
return ( …Run Code Online (Sandbox Code Playgroud) 我在这里想做的就是能够从后端 api 获取 paypal_api_key ,例如:
app.get("/api/keys/paypal", (req, res) => {
res.send(process.env.PAYPAL_CLIENT_ID || "sb");
});
Run Code Online (Sandbox Code Playgroud)
前端侧:
const loadPaypalScript = async () => {
const { data: clientId } = await axios.get("/api/keys/paypal", {
headers: { authorization: `Bearer ${userInfo.token}` },
});
paypalDispatch({
type: "resetOptions",
value: {
"client-id": clientId,
currency: "GBP",
},
});
paypalDispatch({ type: "setLoadingStatus", value: "pending" });
};
loadPaypalScript();
Run Code Online (Sandbox Code Playgroud)
错误:
Uncaught Error: Attempted to load sdk version 5.0.343 on page, but window.paypal at version undefined already loaded.
To load this sdk alongside …Run Code Online (Sandbox Code Playgroud)