-
Notifications
You must be signed in to change notification settings - Fork 323
Up-to-date new functions for laravel-paystack #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This was implemented based on the PayStack documentation
Now, you can fetch the details of any plan based on its id or code
Now, you can update any plan’s details based on its id or code
Updated the setGetResponse function to accept an array of data to sent, as a second parameter
You can now create customers using the laravel package
You can now fetch all customers
You can fetch a customer’s details using its id or code
You can now update customer’s details based on their id or code
You can export all transactions, transactions between a certain period and export only settled or pending transactions
You can now create subscription now, yaay!
With this two functions, you can now disable a certain subscription and enable it later if needed.
Fetch the details of any subscription using the subscription id
You can now create pages that can be shared among users using its slug
Fetches all the pages the merchant has
You can fetch the details of a page using it slug or id
Update the details about a particular page using its page slug or id
//Edits by Funsho http://devfunsho.com | @iamfusnho - 22/05/2016 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is necessary. Please remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, will do that in the next commit
I have made all the necessary changes. |
@@ -127,9 +127,9 @@ public function setResponse($relativeUrl) | |||
return $this; | |||
} | |||
|
|||
private function setGetResponse($relativeUrl) | |||
private function setGetResponse($relativeUrl, $body = array()) | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the array short-form here like so: $body = []
]); | ||
|
||
return $this->response->getResponse(); | ||
return $this->setGetResponse("/plan", $data)->getResponse(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setGetResponse
method uses the get
method. How come you are using it here?...shouldn't this be a post request?
Created setPostResponse and setPutResponse to handle POST and PUT request respectively
|
||
$this->response = $this->setGetResponse('/customer', $data); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please explain how you are using a get method. Since you are trying to create a customer. shouldn't it be a post method?
$this->setRequestOptions(); | ||
|
||
return $this->setGetResponse('/page/'.$page_id, $data)->getResponse(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldnt this be a post method?
$this->setRequestOptions(); | ||
|
||
$this->response = $this->setGetResponse('/subscription', $data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldnt this be a post method?
Oga, I have updated the code to use appropriate set response functions, I totally forgot to change them |
|
||
private function setPutResponse($relativeUrl, $body = []) | ||
{ | ||
$this->response = $this->client->put($this->baseUrl . $relativeUrl, $body); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now all these 3 can be just one method. Right now, the three methods just makes it redundant. It can be like so:
private function setHttpResponse($relativeUrl, $method = null, $body = [])
{
if (is_null($method) {
// throw the isNull exception
}
$this->response = $this->client->{strtolower($method)}($this->baseUrl . $relativeUrl, $body);
return $this;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then replace the entire code base with the setHttpResponse and pass in the relevant get
or post
or put
or delete
methods.
…sponse() and setPutResponse()
Hope i'm not missing anything else |
|
||
return $this; | ||
} | ||
throw new isNullException("Empty method not allowed"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you including all these extra spaces?..Please remove them. All the other parts of the codebase dont have unnecessary space like this
|
||
use Exception; | ||
|
||
class isNullException extends Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't create a class with a small letter. Please start with capital letter and also replace the change everywhere you have used this exception
Oya boss, updated. When are we going to implement that stuff I shared with you on twitter for paystack. Gracias. |
Which stuff? |
"It will be lovely if you can add a limit to the number of times an amount is deducted per interval in a plan. For example, Ayo wants to pay N10,000 every month for six months." |
I have fully implemented plans, customers, export transactions, subscriptions and pages. Also, i modified setGetResponse() function to be more useful.
Once you have reviewed and it is ok, we will work on the README.md file to reflect the changes.
Gracias.