/** * Handle the event. * * @param UnknownPayPalPaymentReceived $event */ public function handle(UnknownPayPalPaymentReceived $event) { $email = $event->emailAddress; $payment = $this->paymentRepository->getById($event->paymentId); $this->mailer->send('emails.paypal-donation', ['email' => $email, 'payment' => $payment], function ($m) use($email) { $m->to($email); $m->cc('*****@*****.**'); $m->subject('Unknown PayPal Payment Received'); }); }
private function updateSubPayment($paymentId, $userId, $status) { $payment = $this->paymentRepository->getById($paymentId); $subCharge = $this->subscriptionChargeRepository->findCharge($userId); if (!$subCharge) { \Log::warning('Subscription payment without a sub charge. Payment ID:' . $paymentId); return; } //The sub charge record id gets saved onto the payment if (empty($payment->reference)) { $payment->reference = $subCharge->id; $payment->save(); } else { if ($payment->reference != $subCharge->id) { throw new PaymentException('Attempting to update sub charge (' . $subCharge->id . ') but payment (' . $payment->id . ') doesn\'t match. Sub charge has an existing reference on it.'); } } if ($status == 'paid') { $this->subscriptionChargeRepository->markChargeAsPaid($subCharge->id); } else { if ($status == 'pending') { $this->subscriptionChargeRepository->markChargeAsProcessing($subCharge->id); } } //The amount isn't stored on the sub charge record until its paid or processing if ($payment->amount != $subCharge->amount) { $this->subscriptionChargeRepository->updateAmount($subCharge->id, $payment->amount); } }
/** * Remove the specified payment * * @param int $id * @return Illuminate\Http\RedirectResponse * @throws \BB\Exceptions\ValidationException */ public function destroy($id) { $payment = $this->paymentRepository->getById($id); //we can only allow some records to get deleted, only cash payments can be removed, everything else must be refunded off if ($payment->source != 'cash') { throw new \BB\Exceptions\ValidationException('Only cash payments can be deleted'); } if ($payment->reason != 'balance') { throw new \BB\Exceptions\ValidationException('Currently only payments to the members balance can be deleted'); } //The delete event will broadcast an event and allow related actions to occur $this->paymentRepository->delete($id); \Notification::success('Payment deleted'); return \Redirect::back(); }