Jump to content

gutterboy

Members
  • Posts

    284
  • Joined

  • Last visited

Everything posted by gutterboy

  1. Slight edit to the errors method above, this would probably be the best way to handle it actually.. public function errors() { $response = $this->formatResponse(); if (isset($response->errors) or $this->response_error) { if (isset($response->errors)) return $response->errors; else { $error = new stdClass(); $error->error = $this->response_error; return $error; } } return false; }
  2. Aren't subscriptions different to automatic payments? Subscriptions are only for recurring services no?
  3. I can't seem to find the option to do this - only other payment methods?
  4. I've been using the Blesta API in conjunction with the SDK; however I have recently noticed that the error handling it does with cURL is incorrect. For example we have this code in blesta_api.php private function submit($model, $method, array $args = array(), $action = "POST") { $url = $this->url . $model . "/" . $method . "." . self::$format; $this->last_request = array( 'url' => $url, 'args' => $args ); if ($action == "GET") { $url .= "?" . http_build_query($args); $args = null; } $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $action); curl_setopt($ch, CURLOPT_URL, $url); if ($args) { curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($args)); } curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_USERPWD, $this->user . ":" . $this->key); //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); $response = curl_exec($ch); $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); return new BlestaResponse($response, $response_code); } Then we have this code inside blesta_response.php /** * @var string The raw response from the API */ private $raw; /** * @var int The HTTP response code from the API */ private $response_code; /** * Initializes the Blesta Response * * @param string $response The raw response data from an API request * @param int $response_code The HTTP response code for the request */ public function __construct($response, $response_code) { $this->raw = $response; $this->response_code = $response_code; } /** * Returns the response from the request * * @return mixed A stdClass object representing the response returned from the request, null if no response returned */ public function response() { $response = $this->formatResponse(); if (isset($response->response)) return $response->response; return null; } /** * Returns the HTTP response code * * @return int The HTTP response code for the request */ public function responseCode() { return $this->response_code; } /** * Returns the raw response * * @return string The raw response */ public function raw() { return $this->raw; } /** * Returns all errors contained in the response * * @return stdClass A stdClass object representing the errors in the response, false if invalid response */ public function errors() { if ($this->response_code != 200) { $response = $this->formatResponse(); if (isset($response->errors)) return $response->errors; else { $error = new stdClass(); $error->error = $response; return $error; } } return false; } /** * Formats the raw response into a stdClass object * * @return stdClass A stdClass object representing the resposne */ private function formatResponse() { return json_decode($this->raw); } Giving particular notice to the errors method, first off it does this: if ($this->response_code != 200) { Just because the response code is != 200 doesn't mean there was an error, a response code of `301` will still return a valid response and shouldn't be treated as a possible error. Secondly, if there is an error it is not going to be contained within $this->raw; this will simply contain boolean false. The correct way to get errors would be via the function curl_error(). So with the above in mind, shouldn't it be done similar to: Add the below line to the submit method in blesta_api.php $response_error = curl_error($ch); CHANGE: return new BlestaResponse($response, $response_code); TO: return new BlestaResponse($response, $response_error, $response_code); Then update blesta_response.php ADD: /** * @var int The cURL error (if any) from the API */ private $response_error; UPDATE the constructor.. public function __construct($response, $response_error, $response_code) { $this->raw = $response; $this->response_error = $response_error; $this->response_code = $response_code; } Then changing the errors method to something like this: public function errors() { if ($this->response_code != 200 or $this->response_error) { $response = $this->formatResponse(); if (isset($response->errors)) return $response->errors; else { $error = new stdClass(); $error->error = ($response) ? $response : $this->response_error; return $error; } } return false; } I had to allow for Blesta errors, which aren't cURL errors so I left in some of the code.
  5. I'm trying to find out how much the user is in debit OR credit via the API. I know I can use the Invoices::amountDue() to get how much they owe, but what about if they are in credit? Is there a method that will return the actual status number? Like if they are in credit it will return a negative number? If not, what is a method I can use to check if they are in credit?
  6. Ahh haha........ that can do it to ya. Now I remember that happened to me once before too some time back.
  7. Regarding this plugin........ is there anyway to control if cookies are set or not when they are logged in?
  8. Are you sure Paypal IPN's can get through!? Like your site isn't password protected by .htaccess or something. This happened to me with some other software where I had it locked down by .,htaccess and I was wondering why my IPN notifications weren't getting through lol...... then I realized
  9. Not sure if it would cause that but maybe check to make sure that the account you paid it to is set as a business account in your sandbox and the account you paid with is set as personal? Also make sure they have enough funds - may have gone through as echeck - not sure haha
  10. Well as like you in that thread I don't want to hack the core files nor do anything outside the MVC scope; I can hard code the data but I really don't want to do that as that means I would have to have 3 separate files for dev, staging and production.
  11. I've been customizing the templates files (header/footer) by making a new template etc but I need to pass in some constants that contain the root url to our site - is there a way to make data available to the template files? If so, how?
  12. I only see a "Make Payment" and "Manage" button in that image haha....... but it doesn't matter too much; all good.
  13. Ahh ok gotcha. Although not sure where this add credit button is? Can't say I have seen it?
  14. Yep, I was also a bit clueless the first time I went to the page too.... the Paypal button just showed cards; considering I'm a seasoned web user I'm sure many others would get confused also.
  15. It would be nice if we could set a minimum payment account (ideal if it could be set either globally OR per payment type / gateway) as if somebody owes you something like $0.80 then if they pay by Paypal you will end up losing about 50% of the payment. The need for per payment type is because some payment types won't have fees such as bank deposit, so it would be fine for them to pay any amount; and other gateways or CC processors fees will obviously differ and hence you may want to set different minimums for each gateway. Thanks for your consideration.
  16. Nothing to see here. Move along..... had the incorrect paypal address set for the sandbox account.
  17. Well our system will automatically create a blesta account for said users on our site; so with the way it works at the moment we would have to restrict users on our main system from creating an account with the same username as we setup staff Blesta accounts for, otherwise we wouldn't be able to create a Blesta account for them (as our system wouldn't know the username has already been taken in Blesta) and hence would let them create the account unless we put controls in to disallow the usage of admin usernames in Blesta. So if we setup our staff accounts to use an email as the login then it wouldn't matter about the username being duplicate?
  18. Oh ok, I misunderstood you. I thought you meant I should have different account names for clients as well as admins. I can see your point for admins though. But on that note, we do a lot more on actually preventing unauthorized users from actually accessing the admin login page so users knowing the possible admin usernames isn't as big a deal as it could be.
  19. I just for the first time tested out the Paypal payments and made a payment after logging in as a client via Paypal, which I have in test mode, so it went to the sandbox. When I got back to the site it said "Your payment is being processed"; however after about 5 minutes there is still no transaction showing for the payment.
  20. Because it is a SSO (single sign-on) system; don't think there are many sites that make you setup a separate user/pass so you can pay your bills.
  21. Ok thanks. That is a little annoying as now we have to make sure any usernames we used for staff accounts can't be used as usernames on the main site.
  22. As per the title this is not possible right? Since we are integrating it with our main site and I have a user account on the main site I obviously will need a user (client) account on Blesta with the same username; does this mean I have to have a separate staff account with a different username as client accounts can't be added as staff accounts as well?
×
×
  • Create New...