mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 04:07:32 -05:00 
			
		
		
		
	Merge pull request #5683 from turbo124/v5-develop
Fixes for Stripe Connect
This commit is contained in:
		
						commit
						247cd08010
					
				@ -36,15 +36,8 @@ class StripeConnectController extends BaseController
 | 
				
			|||||||
        if(!is_array($request->getTokenContent()))
 | 
					        if(!is_array($request->getTokenContent()))
 | 
				
			||||||
            abort(400, 'Invalid token');
 | 
					            abort(400, 'Invalid token');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
        MultiDB::findAndSetDbByCompanyKey($request->getTokenContent()['company_key']);
 | 
					        MultiDB::findAndSetDbByCompanyKey($request->getTokenContent()['company_key']);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $data = [
 | 
					 | 
				
			||||||
            'type' => 'standard',
 | 
					 | 
				
			||||||
            'email' => $request->getContact()->email,
 | 
					 | 
				
			||||||
            'country' => $request->getCompany()->country()->iso_3166_2,
 | 
					 | 
				
			||||||
        ];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $company_gateway = CompanyGateway::query()
 | 
					        $company_gateway = CompanyGateway::query()
 | 
				
			||||||
            ->where('gateway_key', 'd14dd26a47cecc30fdd65700bfb67b34')
 | 
					            ->where('gateway_key', 'd14dd26a47cecc30fdd65700bfb67b34')
 | 
				
			||||||
            ->where('company_id', $request->getCompany()->id)
 | 
					            ->where('company_id', $request->getCompany()->id)
 | 
				
			||||||
@ -58,26 +51,15 @@ class StripeConnectController extends BaseController
 | 
				
			|||||||
                return render('gateways.stripe.connect.existing');
 | 
					                return render('gateways.stripe.connect.existing');
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
        $account = Account::create($data);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $link = Account::link($account->id, $token);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if(!$company_gateway)
 | 
					 | 
				
			||||||
            $company_gateway = CompanyGatewayFactory::create($request->getCompany()->id, $request->getContact()->id);
 | 
					            $company_gateway = CompanyGatewayFactory::create($request->getCompany()->id, $request->getContact()->id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $company_gateway->fill([
 | 
					 | 
				
			||||||
            'gateway_key' => 'd14dd26a47cecc30fdd65700bfb67b34',
 | 
					 | 
				
			||||||
            'fees_and_limits' => [],
 | 
					 | 
				
			||||||
            'config' => encrypt(json_encode(['account_id' => $account->id]))
 | 
					 | 
				
			||||||
        ]);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        /* Set Credit Card To Enabled */
 | 
					        /* Set Credit Card To Enabled */
 | 
				
			||||||
        $gateway_types = $company_gateway->driver(new Client)->gatewayTypes();
 | 
					        $gateway_types = $company_gateway->driver(new Client)->gatewayTypes();
 | 
				
			||||||
 | 
					 | 
				
			||||||
        $fees_and_limits = new \stdClass;
 | 
					        $fees_and_limits = new \stdClass;
 | 
				
			||||||
        $fees_and_limits->{$gateway_types[0]} = new FeesAndLimits;
 | 
					        $fees_and_limits->{$gateway_types[0]} = new FeesAndLimits;
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
 | 
					        $company_gateway->gateway_key = 'd14dd26a47cecc30fdd65700bfb67b34';
 | 
				
			||||||
        $company_gateway->fees_and_limits = $fees_and_limits;
 | 
					        $company_gateway->fees_and_limits = $fees_and_limits;
 | 
				
			||||||
        $company_gateway->save();
 | 
					        $company_gateway->save();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -93,6 +75,16 @@ class StripeConnectController extends BaseController
 | 
				
			|||||||
            return render('gateways.stripe.connect.existing');
 | 
					            return render('gateways.stripe.connect.existing');
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $data = [
 | 
				
			||||||
 | 
					            'type' => 'standard',
 | 
				
			||||||
 | 
					            'email' => $request->getContact()->email,
 | 
				
			||||||
 | 
					            'country' => $request->getCompany()->country()->iso_3166_2,
 | 
				
			||||||
 | 
					        ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $account = Account::create($data);
 | 
				
			||||||
 | 
					        $link = Account::link($account->id, $token);
 | 
				
			||||||
 | 
					        $company_gateway->config = encrypt(json_encode(['account_id' => $account->id]));
 | 
				
			||||||
 | 
					        $company_gateway->save();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return redirect($link['url']);
 | 
					        return redirect($link['url']);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user