我正在尝试让PayPal REST API使用存储在保险库中的信用卡创建付款.但是,每当我尝试使用保险箱中的卡付款时,PayPal的API将挂起大约半分钟,然后给我以下500错误:
Exception: Got Http response code 500 when accessing https://api.sandbox.paypal.com/v1/payments/payment.
{"name":"INTERNAL_SERVICE_ERROR","message":"An internal service error has occurred","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#INTERNAL_SERVICE_ERROR","debug_id":"e3c779ea99f73"}
Run Code Online (Sandbox Code Playgroud)
这是我正在使用的代码(如果这里有太多信息,我很抱歉,我不知道哪些信息与我的问题有关)
<?php
include("bootstrap.php"); //Sample bootstrap file configured with my clientId and Secret, creates $apiContext
use PayPal\Api\CreditCard;
use PayPal\Api\Payer;
use PayPal\Api\FundingInstrument;
use PayPal\Api\Details;
use PayPal\Api\Amount;
use PayPal\Api\Transaction;
use PayPal\Api\Payment;
use PayPal\Api\Address;
use PayPal\Api\CreditCardToken;
$useVault = true;
$addr = new Address();
$addr->setLine1('52 N Main ST');
$addr->setCity('Johnstown');
$addr->setCountry_code('US');
$addr->setPostal_code('43210');
$addr->setState('OH');
$card = new CreditCard();
//Also used PayPal Sandbox account number here
$card->setNumber('4111111111111111');
$card->setExpire_month('03');
$card->setExpire_year('2019');
$card->setCvv2('123'); …Run Code Online (Sandbox Code Playgroud) 我正在使用沙盒凭证在使用卡进行PayPal付款时获得回复.
{
"client": {
"environment": "sandbox",
"paypal_sdk_version": "2.14.6",
"platform": "Android",
"product_name": "PayPal-Android-SDK"
},
"response": {
"create_time": "2017-01-31T08:12:40Z",
"id": "PAY-*************",
"intent": "sale",
"state": "created"
},
"response_type": "payment"
}
Run Code Online (Sandbox Code Playgroud)
然后,我试图通过支付ID使用rest API调用获取完整详细信息,并在付款响应中获得"DEAD"状态.请检查以下回复
{
"id": "PAY-*************",
"create_time": "2017-01-31T08:12:40Z",
"update_time": "2017-01-31T08:13:22Z",
"state": "DEAD",
"intent": "sale",
"payer": {
"payment_method": "credit_card",
"funding_instruments": [
{
"credit_card": {
"type": "visa",
"number": "xxxxxxxxxxxx1111",
"expire_month": "11",
"expire_year": "2025"
}
}
]
},
"transactions": [
{
"amount": {
"total": "2.00",
"currency": "USD",
"details": {
"subtotal": "2.00"
}
},
"description": "New Product",
"related_resources": …Run Code Online (Sandbox Code Playgroud) 这不是这篇文章的副本。
我从链接的帖子中引用:
截至 2017 年 6 月 29 日,我认为这不起作用。Paypal 再次改变了它的规则,我认为它不再接受表单提交中隐藏的 HTML 字段:它们必须在 Paypal 的按钮编辑器中设置。
Paypal 文档一团糟。一半的链接已断开,另一半链接指向文档索引。
有没有人知道如何实现 Paypal 付款按钮,我可以在其中动态设置价格?
在我的网络应用程序(PHP)中,用户应该能够连接他的paypal帐户,每次他从我们的目录中销售产品时,我们都会向他收取价格.由于用户可能会销售很多产品,我想自动制作付款部分,因此他不必批准每笔交易.
不幸的是,我找不到使用Paypal SDK做到这一点的方法.
目前,该应用正在使用OAuth流程,因此用户被重定向到Paypal,我从那里获得了access_token.
问题:为用户提供access_token如何在没有Paypal重定向的情况下创建(后台)付款?
谢谢
我能够成功执行以下 API
/v2/checkout/orders
/v2/checkout/orders/{order_id}/authorize
/v2/checkout/orders/{order_id}/capture
Run Code Online (Sandbox Code Playgroud)
为什么在执行此处所述的 PayPal 退款时会收到“NOT_AUTHORIZED”响应?- https://developer.paypal.com/docs/api/payments/v2/#captures_refund
POST 请求
https://api.sandbox.paypal.com/v2/payments/captures/<Capture ID I got from capture request>/refund
Run Code Online (Sandbox Code Playgroud)
回复
{
"name": "NOT_AUTHORIZED",
"message": "Authorization failed due to insufficient permissions.",
"debug_id": "6c6xxxxx6c",
"details": [
{
"issue": "PERMISSION_DENIED",
"field": "capture_id",
"value": "XXXXXXXXX",
"description": "You do not have permission to access or perform operations on this resource.",
"location": "path"
}
],
"links": [
{
"href": "https://developer.paypal.com/docs/api/v2/payments/#NOT_AUTHORIZED",
"rel": "information_link"
}
]
}
Run Code Online (Sandbox Code Playgroud) 在 Paypal 基本集成教程中,可以捕获基本上将付款提交给 Paypal 的订单客户端。一旦订单被捕获,教程将向您展示如何验证交易,这将确保您不提供服务或产品,除非贝宝订单得到验证。但是,有人可能会使用客户端 ID 恶意获取付款,而在验证失败时,paypal 会从客户那里提取资金。你怎么能防止这种情况?这安全吗?
[更新]
这些问题主要是出于好奇和缺乏使用 paypal 的经验。对此提供更多背景信息,并希望对其他人有所帮助;Paypal 基本集成只是一个 HTML 表单,因此它不会阻止任何人修改 HTML 表单并发送不同的金额以进行授权/捕获;假设订单的原始金额为 100,可能有人更改了该金额并提交了不同金额的授权;至少它会启动对可能更高的不同数量的授权/捕获。良好的做法要求在后端完成交易之前应验证金额和订单,但即使发现交易无效,资金也已被贝宝“冻结”,并可能在客户信用卡上.
这可能不是问题,因为如前所述,交易应该在后端验证;也不太明显(也许通过一些社会工程)某人将如何从中受益,而且很可能只是带来不便。
我是 PayPal 集成的新手,但我已成功使用客户端 JavaScript SDK 创建按钮并完成交易。我还添加了一个 webhook,用于侦听 PAYMENT.CAPTURE.* 事件并将返回数据记录到我自己的数据库中的交易表中。缺点是我无法跟踪交易针对的是哪个服务或客户。因此,我想知道如何在按钮中添加至少一个自定义字段,以便它在 webhook POST 中返回给我,以便我可以为该特定客户执行一些业务逻辑。
我最初的选择是发布数据返回onApprove:(data, actions)=>{},但如果在此之前发生灾难性事件(例如断电或一般客户端-服务器连接故障),我将没有恢复选项。
现在我的 JS 基本代码如下:
try{
paypal.Buttons({
// Set up the transaction
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: charge.amount,
currency_code:'USD'
}
}]
});
},
// Finalize the transaction
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
console.log(details);
if(details.status == "COMPLETED"){
localStorage.clear();
window.location.href = "thank-you";
}
//alert('Transaction completed by ' + details.payer.name.given_name + '!');
});
}
}).render('#paypal-button-container');
}catch(e){
console.error('PayPal not loaded!');
}
Run Code Online (Sandbox Code Playgroud) 我正在使用 PayPal API 将付款选项添加到我的网站。在他们的教程中,他们使用 JavaScript 在客户端完全渲染按钮并设置交易。这是示例代码:
<script>
paypal.Buttons({
createOrder: function(data, actions) {
// This function sets up the details of the transaction, including the amount and line item details.
return actions.order.create({
purchase_units: [{
amount: {
value: '0.01'
}
}]
});
},
onApprove: function(data, actions) {
// This function captures the funds from the transaction.
return actions.order.capture().then(function(details) {
// This function shows a transaction success message to your buyer.
alert('Transaction completed by ' + details.payer.name.given_name);
});
}
}).render('#paypal-button-container');
//This …Run Code Online (Sandbox Code Playgroud) 我正在创建 PayPal 结帐按钮,有什么方法可以自动填写借记卡或信用卡表单中的帐单地址吗?
我当前的代码:
paypal.Buttons({
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: '1'
}
}],
});
}
}).render('#paypal-button-container');
Run Code Online (Sandbox Code Playgroud) 几周前,我在捕获 PayPal 订单时收到错误。在沙箱中一切正常,但在生产环境中则不然。
按钮正确呈现并且贝宝窗口打开。我登录贝宝后,商店的控制台打印:
buttonCorrelationID: "f648506974719"
buttonSessionID: "xxx"
clientID: "xxx"
env: "production"
err: "Identitysecuretokenserv responded with status 401 for securityContext"
referer: "www.paypal.com"
sdkCorrelationID: "a156c1d6c1aa1"
sessionID: "xxx"
time: "1644485190845"
timestamp: "1644485190845"
token: "xxx"
user_id: "xxx"
Run Code Online (Sandbox Code Playgroud)
xxx 被替换,实际上它填充了正确的数据。
在贝宝窗口中我没有看到任何错误。即使当我更改地址并且调用回调“onShippingChange”时,我也会得到正确的运费。然后我没有收到任何错误。
单击“立即付款”后,贝宝弹出窗口关闭,我看到此错误:
Error: Api: /smart/api/order/xxx/capture
returned ack: permission_denied (Corr ID: f1924860b1e9c {
"ack":"permission_denied",
"message":"Insufficient privileges"
}
Run Code Online (Sandbox Code Playgroud)
正如我一开始所说,这只出现在生产环境中。沙箱运行良好。这个错误是几周前才出现的。在此之前,它在生产环境中也运行良好。我客户的所有网上商店都同时发生这种情况,并且都有不同的商家帐户。
有人知道出了什么问题吗?如果需要,我可以提供所有信息和代码。
谢谢并亲切的问候汉斯鲁格