Well, finally it turned out that the response of the BMUpdateButton API returns HTML to create the form, and also returns other data also in the returned array.
Once you make a request, it will return an array with three keys according to the BMUpdateButton Response section of the API page linked above.
It:
WEBSITECODE
HTML for web pages
This is what I was looking for; simple link that you can redirect users to
Button ID
When changing the contents of a hosted button, you need to transfer all the details of the button, as when creating it; so, for example, if you do not pass the item name to it, the item name will be blank and Paypal will allow the user to set it.
In addition, the important note is that when updating the button information, it is not just updated for this user session, it updates it in your PayPal account, so the new name / price, etc. will affect all users who try to use it.
If you still want to update the button information, you can do this with the help of below:
I personally started with this class:
<?php class Paypal { /** * Last error message(s) * @var array */ protected $_errors = array(); /** * API Credentials * Use the correct credentials for the environment in use (Live / Sandbox) * @var array */ protected $_credentials = array( 'USER' => 'seller_1297608781_biz_api1.lionite.com', 'PWD' => '1297608792', 'SIGNATURE' => 'A3g66.FS3NAf4mkHn3BDQdpo6JD.ACcPc4wMrInvUEqO3Uapovity47p', ); /** * API endpoint * Live - https://api-3t.paypal.com/nvp * Sandbox - https://api-3t.sandbox.paypal.com/nvp * @var string */ protected $_endPoint = 'https://api-3t.sandbox.paypal.com/nvp'; /** * API Version * @var string */ protected $_version = '74.0'; /** * Make API request * * @param string $method string API method to request * @param array $params Additional request parameters * @return array / boolean Response array / boolean false on failure */ public function request($method, $params = array()) { $this->_errors = array(); if (empty($method)) { //Check if API method is not empty $this->_errors = array('API method is missing'); return false; } //Our request parameters $requestParams = array( 'METHOD' => $method, 'VERSION' => $this->_version ) + $this->_credentials; //Building our NVP string $request = http_build_query($requestParams + $params); //cURL settings $curlOptions = array( CURLOPT_URL => $this->_endPoint, CURLOPT_VERBOSE => 1, CURLOPT_SSL_VERIFYPEER => true, CURLOPT_SSL_VERIFYHOST => 2, CURLOPT_CAINFO => dirname(__FILE__) . '/cacert.pem', //CA cert file CURLOPT_RETURNTRANSFER => 1, CURLOPT_POST => 1, CURLOPT_POSTFIELDS => $request ); $ch = curl_init(); curl_setopt_array($ch, $curlOptions); //Sending our request - $response will hold the API response $response = curl_exec($ch); //Checking for cURL errors if (curl_errno($ch)) { $this->_errors = curl_error($ch); curl_close($ch); return false; //Handle errors } else { curl_close($ch); $responseArray = array(); parse_str($response, $responseArray); // Break the NVP string to an array return $responseArray; } } } ?>
Credit: https://www.smashingmagazine.com/2011/09/getting-started-with-the-paypal-api/
Then I did the following:
include(dirname(__FILE__) . '/includes/paypal.class.php'); $paypal = new Paypal(); // Set our method $method = 'BMUpdateButton'; // Set our params $params = array( 'HOSTEDBUTTONID' => 'your_button_id', 'BUTTONTYPE' => 'BUYNOW', 'BUTTONSUBTYPE' => 'SERVICES', 'L_BUTTONVAR0' => 'item_name=Your Description', 'L_BUTTONVAR1' => 'amount=999.00', 'L_BUTTONVAR2' => 'currency_code=AUD', 'L_BUTTONVAR3' => 'cancel_return=http://www.example.com/cancel.html', 'L_BUTTONVAR4' => 'return=http://www.example.com/success.html' ); // Make request to change button details $result = $paypal->request($method, $params);
Please note that although Paypal says BUTTONSUBTYPE is optional, you will most likely receive an error message if you do not enable it.