mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-03 22:47:32 -05:00 
			
		
		
		
	
		
			
				
	
	
		
			55 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			55 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace App\Http\Requests;
 | 
						|
 | 
						|
use App\Models\Invitation;
 | 
						|
use App\Models\GatewayType;
 | 
						|
 | 
						|
class CreateOnlinePaymentRequest extends Request
 | 
						|
{
 | 
						|
    /**
 | 
						|
     * Determine if the user is authorized to make this request.
 | 
						|
     *
 | 
						|
     * @return bool
 | 
						|
     */
 | 
						|
    public function authorize()
 | 
						|
    {
 | 
						|
        return true;
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Get the validation rules that apply to the request.
 | 
						|
     *
 | 
						|
     * @return array
 | 
						|
     */
 | 
						|
    public function rules()
 | 
						|
    {
 | 
						|
        $account = $this->invitation->account;
 | 
						|
 | 
						|
        $paymentDriver = $account->paymentDriver($this->invitation, $this->gateway_type);
 | 
						|
 | 
						|
        return $paymentDriver->rules();
 | 
						|
    }
 | 
						|
 | 
						|
    public function sanitize()
 | 
						|
    {
 | 
						|
        $input = $this->all();
 | 
						|
 | 
						|
        $invitation = Invitation::with('invoice.invoice_items', 'invoice.client.currency', 'invoice.client.account.currency', 'invoice.client.account.account_gateways.gateway')
 | 
						|
            ->where('invitation_key', '=', $this->invitation_key)
 | 
						|
            ->firstOrFail();
 | 
						|
 | 
						|
        $input['invitation'] = $invitation;
 | 
						|
 | 
						|
        if ($gatewayTypeAlias = request()->gateway_type) {
 | 
						|
            $input['gateway_type'] = GatewayType::getIdFromAlias($gatewayTypeAlias);
 | 
						|
        } else {
 | 
						|
            $input['gateway_type'] = session($invitation->id . 'gateway_type');
 | 
						|
        }
 | 
						|
 | 
						|
        $this->replace($input);
 | 
						|
 | 
						|
        return $this->all();
 | 
						|
    }
 | 
						|
}
 |