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

Insert Costum Data #273

Open
hrace009 opened this issue Sep 4, 2024 · 0 comments
Open

Insert Costum Data #273

hrace009 opened this issue Sep 4, 2024 · 0 comments

Comments

@hrace009
Copy link

hrace009 commented Sep 4, 2024

Hello, I have code like bellow:

public function postPaypalSubmit(Request $request)
    {
        $min = config('pw-config.payment.paypal.minimum');
        $max = config('pw-config.payment.paypal.maximum');
        $request->validate([
            'promo_code' => 'alpha_num',
        ]);
        $promo_code = $request->input('promo_code');

        if ( $request->dollars >= $min && $request->dollars <= $max ) {
            $transaction = $this->gateway->purchase([
                'amount' => number_format($request->dollars, 0, '.', ''),
                'currency' => config('pw-config.payment.paypal.currency'),
                'description' => __('donate.paypal.description', ['amount' => $request->tokens, 'currency' => config('pw-config.currency_name')]),
                'returnUrl' => route('app.donate.paypal.complete'),
                'cancelUrl' => route('app.donate.paypal'),
            ]);
            $response = $transaction->send();

            if ($response->isRedirect()) {
                $response->redirect();
            } else {
                echo $response->getMessage();
            }
        }
        else {
            return redirect()->back()->with('error', __('donate.paypal.transaction_range', ['min' => $min, 'max' => $max ]));
        }
    }

how i can insert $promo_code to $transaction?

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