paypal web experience profile list is empty but can't create new profile -
i use paypal rest api create checkout process in web shop application. works fine web experience profile.
so far, try check if profile specific name exists (because web application created befor):
function get_pp_profiles($pp_token) { $ct = curl_init(); // set url , 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; } }
i empty array (no error). tried on console "plain" curl (w/o php), - same result.
so, since there no profile, i'm supposed set new 1 this:
function set_pp_profile(&$pp_token) { $ct = curl_init(); $now = time(); // set url , 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; } }
but fail return 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 name exists"}]}
does know what's going on there?
thanks lot in advance!
additional test run , info:
i know profile name must unique. (but don't know if can use name had been used before deleting profiles.)
so tested follows:
call function set_pp_profile(), changed line 14 follows:
"name" => substr(md5("" . time() . rand()), 0, 12),
the result is, expected, profile object.
call function get_pp_profiles(). function returns empty array. put out var_dump , get:
array(0) { }
my conclusion problem has nothing unique profile names. paypal developer docs profile last 3 hours or forever, depending on "temporary"-parameter. seem not true.
solved: problem paypal developer manual. api call
get /v1/payment-experience/web-profiles
will return only profiles parameter "temporary" set "false". but, if created profiles temporary == true, exist, (but hidden)! that's why can't create new profile same name 3 hours. rather poor documentation.
Comments
Post a Comment