コード例 #1
0
 public function setDefaultPaymentMethod()
 {
     if (!($contact = $this->getContact())) {
         return $this->returnError();
     }
     $client = $contact->client;
     $account = $client->account;
     $validator = Validator::make(Input::all(), ['source' => 'required']);
     if ($validator->fails()) {
         return Redirect::to($client->account->enable_client_portal_dashboard ? '/client/dashboard' : '/client/payment_methods/');
     }
     $paymentDriver = $account->paymentDriver(false, GATEWAY_TYPE_TOKEN);
     $paymentMethod = PaymentMethod::clientId($client->id)->wherePublicId(Input::get('source'))->firstOrFail();
     $customer = $paymentDriver->customer($client->id);
     $customer->default_payment_method_id = $paymentMethod->id;
     $customer->save();
     Session::flash('message', trans('texts.payment_method_set_as_default'));
     return redirect()->to($client->account->enable_client_portal_dashboard ? '/client/dashboard' : '/client/payment_methods/');
 }
コード例 #2
0
 public function createPaymentMethod($customer)
 {
     $paymentMethod = PaymentMethod::createNew($this->invitation);
     $paymentMethod->contact_id = $this->contact()->id;
     $paymentMethod->ip = Request::ip();
     $paymentMethod->account_gateway_token_id = $customer->id;
     $paymentMethod->setRelation('account_gateway_token', $customer);
     $paymentMethod = $this->creatingPaymentMethod($paymentMethod);
     // archive the old payment method
     $oldPaymentMethod = PaymentMethod::clientId($this->client()->id)->wherePaymentTypeId($paymentMethod->payment_type_id)->first();
     if ($oldPaymentMethod) {
         $oldPaymentMethod->delete();
     }
     if ($paymentMethod) {
         $paymentMethod->save();
     }
     return $paymentMethod;
 }
コード例 #3
0
 public function verifyBankAccount($client, $publicId, $amount1, $amount2)
 {
     $customer = $this->customer($client->id);
     $paymentMethod = PaymentMethod::clientId($client->id)->wherePublicId($publicId)->firstOrFail();
     // Omnipay doesn't support verifying payment methods
     // Also, it doesn't want to urlencode without putting numbers inside the brackets
     $result = $this->makeStripeCall('POST', 'customers/' . $customer->token . '/sources/' . $paymentMethod->source_reference . '/verify', 'amounts[]=' . intval($amount1) . '&amounts[]=' . intval($amount2));
     if (is_string($result)) {
         return $result;
     }
     $paymentMethod->status = PAYMENT_METHOD_STATUS_VERIFIED;
     $paymentMethod->save();
     if (!$customer->default_payment_method_id) {
         $customer->default_payment_method_id = $paymentMethod->id;
         $customer->save();
     }
     return true;
 }