【发布时间】:2022-10-16 04:05:19
【问题描述】:
我正在尝试以authorize 为third party merchant 的意图对事务执行无效操作
import paypal from "@paypal/checkout-server-sdk";
...
const req = new paypal.payments.AuthorizationsVoidRequest(id);
const voidRequest = await client.execute(req);
const refundId = voidRequest.headers['paypal-debug-id'];
但我收到一个错误Authorization failed due to insufficient permissions. You do not have permission to access or perform operations on this resource.
根据this link 我需要获得商家的额外许可
Note:For three party transactions in which a partner is managing the API calls on behalf of a merchant, the partner must identify the merchant using either a PayPal-Auth-Assertion header or an access token with target_subject.
我如何从商家那里获得这些许可?我需要为我的商家添加connect with paypal 按钮吗?甚至有这样的事情吗?
或者我只需要添加PayPal-Auth-Assertion (也不知道该怎么做,我如何获得商家 access_token/client_id ?
...
req.headers['PayPal-Auth-Assertion'] = generateAuthAssertionHeader("XXXX@XXXX.com");
...
const generateAuthAssertionHeader = async email => {
const auth_1 = Buffer.from('{"alg":"none"}').toString('base64');
const auth_2 = Buffer.from(`{"email":"${email}","iss":"${PAYPAL_CLIENT_ID}"}`).toString('base64'); //my PAYPAL_CLIENT_ID or my merchant? how can I get the merchant PAYPAYL_CLIENT_ID
const auth_assertion_header = `${auth_1}.${auth_2}.`;
return auth_assertion_header;
};
【问题讨论】:
标签: paypal paypal-sandbox paypal-rest-sdk