gpt4 book ai didi

paypal web experience 配置文件列表为空但无法创建新配置文件

转载 作者:太空宇宙 更新时间:2023-11-03 15:54:26 26 4
gpt4 key购买 nike

我使用 PayPal REST API 在我的网上商店应用程序中创建结帐流程。几乎一切正常,但 Web 体验配置文件除外。

到目前为止,我尝试检查具有特定名称的配置文件是否已经存在(因为网络应用程序之前创建了它):

function get_pp_profiles($pp_token)
{
$ct = curl_init();

// set URL and other appropriate options
curl_setopt($ct, CURLOPT_URL, PP_PROFILE_ENDPOINT);
curl_setopt($ct, CURLOPT_HEADER, false);
curl_setopt($ct, CURLOPT_RETURNTRANSFER, true);

$curl_http_headers = array('Content-Type: application/json', 'Accept: application/json', 'Authorization: ' . $pp_token->token_type . ' ' . $pp_token->access_token);
curl_setopt($ct, CURLOPT_HTTPHEADER, $curl_http_headers);


if ( $out = curl_exec($ct) )
{
$profile_list = json_decode($out);
curl_close($ct);
return $profile_list;
} else
{
curl_close($ct);
return false;
}
}

然后我得到一个空数组(没有错误)。我也在控制台上使用“普通”curl(没有 PHP)尝试了这个 - 结果相同。

因此,由于没有配置文件,我应该像这样设置一个新的配置文件:

function set_pp_profile(&$pp_token)
{
$ct = curl_init();
$now = time();

// set URL and other appropriate options
curl_setopt($ct, CURLOPT_URL, PP_PROFILE_ENDPOINT);
curl_setopt($ct, CURLOPT_HEADER, false);
curl_setopt($ct, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ct, CURLOPT_POST, true);

$profile =
array(
"name" => PP_PROFILE_NAME,
"temporary" => true,
"presentation" => array(
"brand_name" => "My brand name",
"logo_image" => "http://sonedomain.com/whatever.png",
"locale_code" => "DE"
),
"input_fields" => array(
"no_shipping" => 1,
"address_override" => 1
),
"flow_config" => array(
"landing_page_type" => "billing",
"user_action" => "commit",
"bank_txn_pending_url" => "http://somedomain.com/some_path/"
)
);

$pdata = json_encode($profile, JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$curl_http_headers = array('Content-Type: application/json', 'Accept: application/json', 'Authorization: ' . $pp_token->token_type . ' ' . $pp_token->access_token, 'Content-length: ' . strlen($pdata));

curl_setopt($ct, CURLOPT_HTTPHEADER, $curl_http_headers);
curl_setopt($ct, CURLOPT_POSTFIELDS, $pdata);

if ( $out = curl_exec($ct) )
{
echo $out;
curl_close($ct);
$profile_object = json_decode($out);
return $profile_object;
} else
{
curl_close($ct);
return false;
}
}

但这将因 PayPal 的返回而失败:

{"name":"VALIDATION_ERROR","debug_id":"956cbce081ac2","message":"Invalid request - see details","information_link":"https://developer.paypal.com/webapps/developer/docs/api/","details":[{"field":"name","issue":"A profile with this name already exists"}]}

有人知道那里发生了什么吗?

提前致谢!

额外的测试运行和信息:

我知道配置文件名称必须是唯一的。 (但我不知道是否可以使用删除所有配置文件之前使用过的名称。)

所以我测试如下:

  1. 调用函数set_pp_profile(),但将第14行修改如下:

    "name"=> substr(md5("".time() .rand()), 0, 12),

如预期的那样,结果是一个配置文件对象。

  1. 调用函数 get_pp_profiles()。该函数返回一个空数组。我用 var_dump 把它拿出来,会得到:

    数组(0) { }

我的结论是问题与唯一的配置文件名称无关。 PayPal 开发人员文档说配置文件将持续 3 小时或永远,具体取决于“临时”参数。但这似乎不是真的。

最佳答案

已解决:问题是 PayPal developer manual . API调用

GET /v1/payment-experience/web-profiles

将返回参数“temporary”设置为“false”的配置文件。但是,如果您使用 temporary == true 创建配置文件,它们也会存在(但隐藏)!这就是为什么您不能在 3 小时内创建具有相同名称的新配置文件的原因。相当糟糕的文档。

关于paypal web experience 配置文件列表为空但无法创建新配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43251847/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com