kemeris Posted September 7, 2016 Report Posted September 7, 2016 Hi, I am trying to get HTML markup for PayPal standard gateway via API. function bl_getBuildProcess($contact_info, $amount, $currency, $invoice_amounts, $options, $gateway_id) { require_once "blesta_api.php"; $api = new BlestaApi($config->bl_api_url, $config->bl_api_user, $config->bl_api_key); $response = $api->get("Payments", "getBuildProcess", array("contact_info" => $contact_info, "amount" => $amount, "currency" => $currency, "invoice_amounts" => $invoice_amounts, "options" => $options, "gateway_id" => $gateway_id)); return $response; } $return = bl_getBuildProcess( array(client_id => 2), 9.90, "EUR", array(40 => 9.90), array(), 2); I get empty $return->response() and $return ->errors() is stdClass Object ( [error] => ) any ideas what is wrong with my code? Quote
0 Tyson Posted September 10, 2016 Report Posted September 10, 2016 Where's $config defined? Are your API credentials correct? Do any other requests return valid responses? Quote
0 kemeris Posted September 10, 2016 Author Report Posted September 10, 2016 Other requests works fine, bl_getState function works but bl_getBuildProcess do not function bl_getState($country, $code) { $response = bl_API()->get("States", "get", array("country" => $country, "code" => $code)); if ($response->errors()) { return $response->errors(); } else { return $response->response(); } } function bl_getBuildProcess($contact_info, $amount, $currency, $invoice_amounts, $options, $gateway_id) { $response = bl_API()->get("Payments", "getBuildProcess", array("contact_info" => $contact_info, "amount" => $amount, "currency" => $currency, "invoice_amounts" => $invoice_amounts, "options" => $options, "gateway_id" => $gateway_id)); if ($response->errors()) { return $response->errors(); } else { return $response->response(); } } Here is my full code, I am defining variable values manually for now. $contact_info = array ( "id" => 1, "client_id" => 2, "user_id" => 3, "contact_type" => null, "contact_type_id" => null, "first_name" => "Tadas", "last_name" => "Blinda", "title" => null, "company" => null, "address1" => null, "address2" => null, "city" => null, "zip" => null, "country" => Array ( "alpha2" => "LT", "alpha3" => "LTU", "name" => "Lithuania", "alt_name" => "Lietuva" ), "state" => Array ( "country_alpha2" => "LT", "code" => "VL", "name" => "Vilniaus Apskritis" ) ); $amount = 9.90; $currency = "EUR"; $invoice_amounts = array( 67 => "9.90" ); $options = array( 'recur' => array( 'amount' => 9.90, 'term' => 1, 'period' => "month" ), 'description' => 'Invoice #PROFORMA-67', 'return_url' => 'http://xx.xx.x.xx/blesta/order/checkout/complete/xxxxx/57d297b657a49' ); $gateway_id = 1; $return = bl_getBuildProcess($contact_info, $amount, $currency, $invoice_amounts, $options, $gateway_id); print_r($return); Quote
0 Tyson Posted September 16, 2016 Report Posted September 16, 2016 If you can call "bl_getState" successfully, then I would expect you could call "bl_getBuildProcess" successfully too. Everything you have looks correct. There may be some other issue, or possibly a bug somewhere. You may need to debug Payments::getBuildProcess in Blesta to see why a blank error is being set. Quote
0 kemeris Posted October 4, 2016 Author Report Posted October 4, 2016 $return->response() and $return ->errors() are empty, but $return itself is not: header("Content-Type: text/plain"); print_r($return); BlestaResponse Object ( [raw:BlestaResponse:private] => <pre>Array ( [id] => 1 [client_id] => 2 [user_id] => 3 [first_name] => Tadas [last_name] => Blinda [country] => Array ( [alpha2] => LT [alpha3] => LTU [name] => Lithuania [alt_name] => Lietuva ) [state] => Array ( [country_alpha2] => LT [code] => VL [name] => Vilniaus Apskritis ) ) </pre><pre>9.9</pre><pre>EUR</pre><pre>Array ( [67] => 9.90 ) </pre><pre>Array ( [recur] => Array ( [amount] => 9.90 [term] => 1 [period] => month ) [description] => Invoice #PROFORMA-37 [return_url] => http://xx.xx.x.xx/blesta/order/checkout/complete/xxxxx/57d297b657a49 ) </pre><pre>1</pre>{"response":{"paypal_payments_standard":["\n\t<form method=\"post\" action=\"https:\/\/www.sandbox.paypal.com\/cgi-bin\/webscr\">\n<input type=\"hidden\" name=\"cmd\" value=\"_xclick\" \/>\n<input type=\"hidden\" name=\"business\" value=\"kemeri_1320439495_biz@asista.lt\" \/>\n<input type=\"hidden\" name=\"page_style\" value=\"\" \/>\n<input type=\"hidden\" name=\"item_name\" value=\"Invoice #PROFORMA-37\" \/>\n<input type=\"hidden\" name=\"amount\" value=\"9.9\" \/>\n<input type=\"hidden\" name=\"currency_code\" value=\"EUR\" \/>\n<input type=\"hidden\" name=\"notify_url\" value=\"http:\/\/localhost\/blesta\/callback\/gw\/1\/paypal_payments_standard\/?client_id=2\" \/>\n<input type=\"hidden\" name=\"return\" value=\"http:\/\/xx.xx.x.xx\/blesta\/order\/checkout\/complete\/xxxxx\/57d297b657a49\" \/>\n<input type=\"hidden\" name=\"rm\" value=\"2\" \/>\n<input type=\"hidden\" name=\"no_note\" value=\"1\" \/>\n<input type=\"hidden\" name=\"no_shipping\" value=\"1\" \/>\n<input type=\"hidden\" name=\"first_name\" value=\"Tadas\" \/>\n<input type=\"hidden\" name=\"last_name\" value=\"Blinda\" \/>\n<input type=\"hidden\" name=\"address1\" \/>\n<input type=\"hidden\" name=\"address2\" \/>\n<input type=\"hidden\" name=\"city\" \/>\n<input type=\"hidden\" name=\"country\" value=\"LT\" \/>\n<input type=\"hidden\" name=\"zip\" \/>\n<input type=\"hidden\" name=\"charset\" value=\"utf-8\" \/>\n<input type=\"hidden\" name=\"bn\" value=\"PhillipsData_SP\" \/>\n<input type=\"hidden\" name=\"custom\" value=\"67=9.90\" \/>\n<input type=\"image\" name=\"submit\" value=\"Pay with PayPal\" src=\"https:\/\/www.paypalobjects.com\/en_US\/i\/bnr\/horizontal_solution_PP.gif\" alt=\"Pay with PayPal\" \/>\n<\/form>\n","\n\t<form method=\"post\" action=\"https:\/\/www.sandbox.paypal.com\/cgi-bin\/webscr\">\n<input type=\"hidden\" name=\"cmd\" value=\"_xclick-subscriptions\" \/>\n<input type=\"hidden\" name=\"business\" value=\"kemeri_1320439495_biz@asista.lt\" \/>\n<input type=\"hidden\" name=\"page_style\" value=\"\" \/>\n<input type=\"hidden\" name=\"item_name\" value=\"Invoice #PROFORMA-37\" \/>\n<input type=\"hidden\" name=\"currency_code\" value=\"EUR\" \/>\n<input type=\"hidden\" name=\"notify_url\" value=\"http:\/\/localhost\/blesta\/callback\/gw\/1\/paypal_payments_standard\/?client_id=2\" \/>\n<input type=\"hidden\" name=\"return\" value=\"http:\/\/xx.xx.x.xx\/blesta\/order\/checkout\/complete\/xxxxx\/57d297b657a49\" \/>\n<input type=\"hidden\" name=\"rm\" value=\"2\" \/>\n<input type=\"hidden\" name=\"no_note\" value=\"1\" \/>\n<input type=\"hidden\" name=\"no_shipping\" value=\"1\" \/>\n<input type=\"hidden\" name=\"first_name\" value=\"Tadas\" \/>\n<input type=\"hidden\" name=\"last_name\" value=\"Blinda\" \/>\n<input type=\"hidden\" name=\"address1\" \/>\n<input type=\"hidden\" name=\"address2\" \/>\n<input type=\"hidden\" name=\"city\" \/>\n<input type=\"hidden\" name=\"country\" value=\"LT\" \/>\n<input type=\"hidden\" name=\"zip\" \/>\n<input type=\"hidden\" name=\"charset\" value=\"utf-8\" \/>\n<input type=\"hidden\" name=\"bn\" value=\"PhillipsData_SP\" \/>\n<input type=\"hidden\" name=\"custom\" \/>\n<input type=\"hidden\" name=\"a1\" value=\"9.9\" \/>\n<input type=\"hidden\" name=\"p1\" value=\"1\" \/>\n<input type=\"hidden\" name=\"t1\" value=\"M\" \/>\n<input type=\"hidden\" name=\"a3\" value=\"9.9\" \/>\n<input type=\"hidden\" name=\"p3\" value=\"1\" \/>\n<input type=\"hidden\" name=\"t3\" value=\"M\" \/>\n<input type=\"hidden\" name=\"modify\" value=\"0\" \/>\n<input type=\"hidden\" name=\"src\" value=\"1\" \/>\n<input type=\"image\" name=\"submit\" value=\"Pay with PayPal\" src=\"https:\/\/www.paypalobjects.com\/en_US\/i\/btn\/btn_subscribeCC_LG.gif\" alt=\"Pay with PayPal\" \/>\n<\/form>\n"]}} [response_code:BlestaResponse:private] => 200 ) I have tried to make payment for same invoice from Blesta, everything is fine there. Where I can find Blesta debug documentation? Quote
Question
kemeris
Hi, I am trying to get HTML markup for PayPal standard gateway via API.
I get empty $return->response() and $return ->errors() is
any ideas what is wrong with my code?
4 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.