Skip to content
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

fix getTargetUrl #9

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/RedirectionForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,16 @@ public function render() : string
return call_user_func_array($renderer, $data);
}

/**
* Returns the target URL.
*
* @return string target URL
*/
public function getTargetUrl(): string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this method? you can run toJson method and retrieve redirection form in JSON format.
as you know we sometimes we redirect to bank page using POST method, so getTargetUrl is not suitable here.
it's better to get JSON format and send the suitable POST or GET request according to it.

Copy link
Member

@khanzadimahdi khanzadimahdi Jul 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could use use render method to generate redirection form (i think you use laravel)

// in laravel controller, the below code renders a redirection form and pass it as Laravel's view
return $purchasedPayment->pay()->render();

for restful API you could use toJson method too

{
return $this->getAction() . '?' . http_build_query($this->getInputs());
}

/**
* Retrieve JSON format of redirection form.
*
Expand Down