diff --git a/.travis.yml b/.travis.yml index bad7f18eb66b..ac07484b66d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,7 +34,6 @@ install: # these providers require referencing git commit's which cause Travis to fail - sed -i '/mollie/d' composer.json - sed -i '/2checkout/d' composer.json - - sed -i '/omnipay-neteller/d' composer.json - travis_retry composer install --prefer-dist; before_script: diff --git a/app/Http/Controllers/AccountApiController.php b/app/Http/Controllers/AccountApiController.php index f36252bc8d16..a4d0e8aa3ca7 100644 --- a/app/Http/Controllers/AccountApiController.php +++ b/app/Http/Controllers/AccountApiController.php @@ -36,6 +36,7 @@ class AccountApiController extends BaseAPIController public function register(RegisterRequest $request) { + $account = $this->accountRepo->create($request->first_name, $request->last_name, $request->email, $request->password); $user = $account->users()->first(); diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index 8709d42cc0a0..91a27556924c 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -2,7 +2,11 @@ use Auth; use App\Http\Requests\Request; +use Illuminate\Http\Request as InputRequest; +use Illuminate\Support\Facades\Log; use Illuminate\Validation\Factory; +use App\Libraries\Utils; +use Response; class RegisterRequest extends Request { @@ -11,6 +15,13 @@ class RegisterRequest extends Request * * @return bool */ + + public function __construct(InputRequest $req) + { + $this->req = $req; + } + + public function authorize() { return true; @@ -23,6 +34,7 @@ class RegisterRequest extends Request */ public function rules() { + $rules = [ 'email' => 'required|unique:users', 'first_name' => 'required', @@ -32,4 +44,24 @@ class RegisterRequest extends Request return $rules; } + + public function response(array $errors) + { + /* If the user is not validating from a mobile app - pass through parent::response */ + if(!isset($this->req->api_secret)) + return parent::response($errors); + + /* If the user is validating from a mobile app - pass through first error string and return error */ + foreach($errors as $error) { + foreach ($error as $key => $value) { + + $message['error'] = ['message'=>$value]; + $message = json_encode($message, JSON_PRETTY_PRINT); + $headers = Utils::getApiHeaders(); + + return Response::make($message, 400, $headers); + } + } + } + } diff --git a/app/Listeners/SubscriptionListener.php b/app/Listeners/SubscriptionListener.php index 1098869c7748..cac483b4d309 100644 --- a/app/Listeners/SubscriptionListener.php +++ b/app/Listeners/SubscriptionListener.php @@ -1,82 +1,84 @@ account); + $transformer = new ClientTransformer($event->client->account); $this->checkSubscriptions(ACTIVITY_TYPE_CREATE_CLIENT, $event->client, $transformer); } + public function createdQuote(QuoteWasCreated $event) { - if ( ! Auth::check()) { - return; - } - $transformer = new InvoiceTransformer(Auth::user()->account); + $transformer = new InvoiceTransformer($event->quote->account); $this->checkSubscriptions(ACTIVITY_TYPE_CREATE_QUOTE, $event->quote, $transformer, ENTITY_CLIENT); } + public function createdPayment(PaymentWasCreated $event) { - if ( ! Auth::check()) { - return; - } - $transformer = new PaymentTransformer(Auth::user()->account); + $transformer = new PaymentTransformer($event->payment->account); $this->checkSubscriptions(ACTIVITY_TYPE_CREATE_PAYMENT, $event->payment, $transformer, [ENTITY_CLIENT, ENTITY_INVOICE]); } - public function createdCredit(CreditWasCreated $event) - { - if ( ! Auth::check()) { - return; - } - //$this->checkSubscriptions(ACTIVITY_TYPE_CREATE_CREDIT, $event->credit); - } + public function createdInvoice(InvoiceWasCreated $event) { - if ( ! Auth::check()) { - return; - } - $transformer = new InvoiceTransformer(Auth::user()->account); + $transformer = new InvoiceTransformer($event->invoice->account); $this->checkSubscriptions(ACTIVITY_TYPE_CREATE_INVOICE, $event->invoice, $transformer, ENTITY_CLIENT); } + + public function createdCredit(CreditWasCreated $event) + { + //$this->checkSubscriptions(ACTIVITY_TYPE_CREATE_CREDIT, $event->credit); + } + public function createdVendor(VendorWasCreated $event) { //$this->checkSubscriptions(ACTIVITY_TYPE_CREATE_VENDOR, $event->vendor); } + public function createdExpense(ExpenseWasCreated $event) { //$this->checkSubscriptions(ACTIVITY_TYPE_CREATE_EXPENSE, $event->expense); } + private function checkSubscriptions($activityTypeId, $entity, $transformer, $include = '') { $subscription = $entity->account->getSubscription($activityTypeId); + if ($subscription) { $manager = new Manager(); $manager->setSerializer(new ArraySerializer()); $manager->parseIncludes($include); + $resource = new Item($entity, $transformer, $entity->getEntityType()); $data = $manager->createData($resource)->toArray(); + // For legacy Zapier support if (isset($data['client_id'])) { $data['client_name'] = $entity->client->getDisplayName(); } + Utils::notifyZapier($subscription, $data); } } -} \ No newline at end of file +} diff --git a/app/Services/InvoiceService.php b/app/Services/InvoiceService.php index 839c6fa6adf3..c5d6f258e02c 100644 --- a/app/Services/InvoiceService.php +++ b/app/Services/InvoiceService.php @@ -79,7 +79,8 @@ class InvoiceService extends BaseService public function approveQuote($quote, $invitation = null) { - $account = Auth::user()->account; + $account = $quote->account; + if (!$quote->is_quote || $quote->quote_invoice_id) { return null; } diff --git a/database/seeds/PaymentLibrariesSeeder.php b/database/seeds/PaymentLibrariesSeeder.php index b657e66dd1b9..654ad9fe0e43 100644 --- a/database/seeds/PaymentLibrariesSeeder.php +++ b/database/seeds/PaymentLibrariesSeeder.php @@ -1,4 +1,5 @@ 'BeanStream', 'provider' => 'BeanStream', 'payment_library_id' => 2], ['name' => 'Psigate', 'provider' => 'Psigate', 'payment_library_id' => 2], @@ -46,6 +49,7 @@ class PaymentLibrariesSeeder extends Seeder ['name' => 'WeChat Express', 'provider' => 'WeChat_Express', 'payment_library_id' => 1], ['name' => 'WePay', 'provider' => 'WePay', 'payment_library_id' => 1], ]; + foreach ($gateways as $gateway) { $record = Gateway::where('name', '=', $gateway['name'])->first(); if ($record) { @@ -55,5 +59,6 @@ class PaymentLibrariesSeeder extends Seeder Gateway::create($gateway); } } + } -} \ No newline at end of file +} diff --git a/resources/lang/de/texts.php b/resources/lang/de/texts.php index 3c2ec0580feb..80289bfa29f0 100644 --- a/resources/lang/de/texts.php +++ b/resources/lang/de/texts.php @@ -1121,7 +1121,7 @@ return array( 'all_pages_header' => 'Show header on', 'all_pages_footer' => 'Show footer on', 'invoice_currency' => 'Rechnungs-Währung', - 'enable_https' => 'Wir empfehlen dringend HTTPS zu verwendne, um Kreditkarten online zu akzeptieren.', + 'enable_https' => 'Wir empfehlen dringend HTTPS zu verwenden, um Kreditkarten online zu akzeptieren.', 'quote_issued_to' => 'Quote issued to', 'show_currency_code' => 'Währungscode', 'trial_message' => 'Your account will receive a free two week trial of our pro plan.',