paypal web experience 配置文件列表为空但无法创建新配置文件
paypal web experience profile list is empty but can't create new profile
我使用 PayPal REST API 在我的网上商店应用程序中创建结帐流程。几乎一切正常,但网络体验配置文件。
到目前为止,我尝试检查具有特定名称的配置文件是否已经存在(因为网络应用程序之前创建它):
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;
}
}
然后我得到一个空数组(没有错误)。我也在控制台上使用 "plain" curl (w/o 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 的 return 会失败:
{"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"}]}
有人知道那里发生了什么吗?
非常感谢!
附加测试运行和信息:
我知道配置文件名称必须是唯一的。 (但我不知道是否可以使用删除所有配置文件之前使用过的名称。)
于是我测试如下:
调用函数set_pp_profile(),但将第14行改成如下:
"name" => substr(md5("".time().rand()), 0, 12),
如预期的那样,结果是一个配置文件对象。
调用函数get_pp_profiles()。函数 return 是一个空数组。我用 var_dump 输出它,会得到:
数组(0) { }
我的结论是问题与唯一的配置文件名称无关。 PayPal 开发人员文档说配置文件将持续 3 小时或永远,具体取决于 "temporary" 参数。但这似乎不是真的。
您每次都需要使用唯一的体验资料名称。
已解决:问题是 PayPal developer manual。 API 通话
GET /v1/payment-experience/web-profiles
将 return 仅 个参数 "temporary" 设置为 "false" 的配置文件。但是,如果您使用 temporary == true 创建配置文件,它们也会存在(但隐藏)!这就是为什么您不能在 3 小时内创建具有相同名称的新配置文件的原因。相当糟糕的文档。
我使用 PayPal REST API 在我的网上商店应用程序中创建结帐流程。几乎一切正常,但网络体验配置文件。
到目前为止,我尝试检查具有特定名称的配置文件是否已经存在(因为网络应用程序之前创建它):
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;
}
}
然后我得到一个空数组(没有错误)。我也在控制台上使用 "plain" curl (w/o 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 的 return 会失败:
{"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"}]}
有人知道那里发生了什么吗?
非常感谢!
附加测试运行和信息:
我知道配置文件名称必须是唯一的。 (但我不知道是否可以使用删除所有配置文件之前使用过的名称。)
于是我测试如下:
调用函数set_pp_profile(),但将第14行改成如下:
"name" => substr(md5("".time().rand()), 0, 12),
如预期的那样,结果是一个配置文件对象。
调用函数get_pp_profiles()。函数 return 是一个空数组。我用 var_dump 输出它,会得到:
数组(0) { }
我的结论是问题与唯一的配置文件名称无关。 PayPal 开发人员文档说配置文件将持续 3 小时或永远,具体取决于 "temporary" 参数。但这似乎不是真的。
您每次都需要使用唯一的体验资料名称。
已解决:问题是 PayPal developer manual。 API 通话
GET /v1/payment-experience/web-profiles
将 return 仅 个参数 "temporary" 设置为 "false" 的配置文件。但是,如果您使用 temporary == true 创建配置文件,它们也会存在(但隐藏)!这就是为什么您不能在 3 小时内创建具有相同名称的新配置文件的原因。相当糟糕的文档。