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

calling return $payfast->paymentForm(true); #34

Open
ByronCoet opened this issue Jun 22, 2024 · 1 comment
Open

calling return $payfast->paymentForm(true); #34

ByronCoet opened this issue Jun 22, 2024 · 1 comment

Comments

@ByronCoet
Copy link

Hi there.
just a quick question.

when I call return $payfast->paymentForm(false); - it just does nothing - returns a blank screen
Am I missing a step? I thought this would just go straight to payfast forms.

calling return $payfast->paymentForm(true); - this returns a small ugly button "pay"

how do I make this into a better formatted form?

Regards
Byron

@ByronCoet
Copy link
Author

ByronCoet commented Jun 22, 2024

I think I found a way to resolve this by chucking a script on the form to auto-execute it.
Seems to work. Guess I can format it better here as well.
Is this the right way?

In the vendor source, in the payment.php file, replace the existing buildForm function with:

public function buildForm()
{
    $this->getHost();
    $htmlForm = '<form id="payfast-pay-form" name="pay" action="https://'.$this->host.'/eng/process" 
 method="post">';
    foreach($this->vars as $name => $value)
    {
        $htmlForm .= '<input type="hidden" name="'.$name.'" value="'.$value.'">';
    }

    $htmlForm .= '<button type="submit">'.$this->getSubmitButton().'</button>';

    $htmlForm .= '</form>';

    $htmlForm .= "<script type=\"text/javascript\"> document.pay.submit(); </script>";


    return $htmlForm;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant