Inheritance: extends yii\db\ActiveRecord
コード例 #1
0
 public function columns()
 {
     return [['invoice_number', function ($model) {
         if (!Auth::user()->can('viewByOwner', [ENTITY_INVOICE, $model->invoice_user_id])) {
             return $model->invoice_number;
         }
         return link_to("invoices/{$model->invoice_public_id}/edit", $model->invoice_number, ['class' => Utils::getEntityRowClass($model)])->toHtml();
     }], ['client_name', function ($model) {
         if (!Auth::user()->can('viewByOwner', [ENTITY_CLIENT, $model->client_user_id])) {
             return Utils::getClientDisplayName($model);
         }
         return $model->client_public_id ? link_to("clients/{$model->client_public_id}", Utils::getClientDisplayName($model))->toHtml() : '';
     }, !$this->hideClient], ['transaction_reference', function ($model) {
         return $model->transaction_reference ? $model->transaction_reference : '<i>' . trans('texts.manual_entry') . '</i>';
     }], ['payment_type', function ($model) {
         return $model->payment_type && !$model->last4 ? $model->payment_type : ($model->account_gateway_id ? $model->gateway_name : '');
     }], ['payment_type_id', function ($model) {
         $code = str_replace(' ', '', strtolower($model->payment_type));
         $card_type = trans('texts.card_' . $code);
         if ($model->payment_type_id != PAYMENT_TYPE_ACH) {
             if ($model->last4) {
                 $expiration = Utils::fromSqlDate($model->expiration, false)->format('m/y');
                 return '<img height="22" src="' . URL::to('/images/credit_cards/' . $code . '.png') . '" alt="' . htmlentities($card_type) . '">&nbsp; &bull;&bull;&bull;' . $model->last4 . ' ' . $expiration;
             } elseif ($model->email) {
                 return $model->email;
             }
         } elseif ($model->last4) {
             if ($model->bank_name) {
                 $bankName = $model->bank_name;
             } else {
                 $bankData = PaymentMethod::lookupBankData($model->routing_number);
                 if ($bankData) {
                     $bankName = $bankData->name;
                 }
             }
             if (!empty($bankName)) {
                 return $bankName . '&nbsp; &bull;&bull;&bull;' . $model->last4;
             } elseif ($model->last4) {
                 return '<img height="22" src="' . URL::to('/images/credit_cards/ach.png') . '" alt="' . htmlentities($card_type) . '">&nbsp; &bull;&bull;&bull;' . $model->last4;
             }
         }
     }], ['amount', function ($model) {
         return Utils::formatMoney($model->amount, $model->currency_id, $model->country_id);
     }], ['payment_date', function ($model) {
         if ($model->is_deleted) {
             return Utils::dateToString($model->payment_date);
         } else {
             return link_to("payments/{$model->public_id}/edit", Utils::dateToString($model->payment_date))->toHtml();
         }
     }], ['payment_status_name', function ($model) {
         return self::getStatusLabel($model);
     }]];
 }
コード例 #2
0
 /**
  * Fungsi untuk menghapus data metode pembayaran
  * @param  [type] $id [description]
  * @return [type]     [description]
  */
 public function destroy($id)
 {
     $payment_method = PaymentMethod::find($id);
     if ($payment_method) {
         if ($payment_method->delete()) {
             return ['status' => 'success', 'message' => 'Metode pembayaran berhasil dihapus'];
         } else {
             return ['status' => 'failed', 'message' => 'Metode pembayaran gagal dihapus.'];
         }
     } else {
         return ['status' => 'failed', 'message' => 'Metode pembayaran tidak ditemukan.'];
     }
 }
コード例 #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = PaymentMethod::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created_by' => $this->created_by, 'created_at' => $this->created_at, 'updated_by' => $this->updated_by, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'type', $this->type]);
     return $dataProvider;
 }
コード例 #4
0
 /**
  * Finds the PaymentMethod model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return PaymentMethod the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = PaymentMethod::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #5
0
 /**
  * @param $routingNumber
  * @return \Illuminate\Http\JsonResponse
  */
 public function getBankInfo($routingNumber)
 {
     if (strlen($routingNumber) != 9 || !preg_match('/\\d{9}/', $routingNumber)) {
         return response()->json(['message' => 'Invalid routing number'], 400);
     }
     $data = PaymentMethod::lookupBankData($routingNumber);
     if (is_string($data)) {
         return response()->json(['message' => $data], 500);
     } elseif (!empty($data)) {
         return response()->json($data);
     }
     return response()->json(['message' => 'Bank not found'], 404);
 }
コード例 #6
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;
 }
コード例 #7
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/');
 }
コード例 #8
0
ファイル: _form.php プロジェクト: asimzeeshan/AliExpressOTS
    ?>

    <?php 
    echo $form->field($model, 'delivery_date')->widget(\yii\jui\DatePicker::classname(), ['options' => ['class' => 'form-control'], 'dateFormat' => 'yyyy-MM-dd']);
    ?>

    <?php 
}
?>

    <?php 
echo $form->field($model, 'arrived_in')->hiddenInput()->label(false);
?>

    <?php 
$allPaymentMethods = ArrayHelper::map(\app\models\PaymentMethod::find()->orderBy('id')->all(), 'id', 'name');
?>
    <?php 
echo $form->field($model, 'paid_with')->dropDownList($allPaymentMethods, ['prompt' => ' -- Select Payment Method --'])->label('Payment Method');
?>

    <?php 
if (!$model->isNewRecord) {
    ?>

    <?php 
    echo $form->field($model, 'is_disputed')->checkBox();
    ?>

    <?php 
    echo $form->field($model, 'refund_status')->dropDownList(['Not Applicable' => 'Not Applicable', 'In Progress' => 'In Progress', 'Fully Refunded' => 'Fully Refunded', 'Partially Refunded' => 'Partially Refunded', 'Escalated' => 'Escalated', 'Lost' => 'Lost']);
コード例 #9
0
ファイル: Payment.php プロジェクト: hillelcoren/invoice-ninja
 /**
  * @return mixed|null|\stdClass|string
  */
 public function getBankDataAttribute()
 {
     if (!$this->routing_number) {
         return null;
     }
     return PaymentMethod::lookupBankData($this->routing_number);
 }
コード例 #10
0
    /**
     * @return bool
     */
    public function requiresDelayedAutoBill()
    {
        return $this->payment_type_id == PAYMENT_TYPE_ACH;
    }
    /**
     * @return mixed
     */
    public function gatewayType()
    {
        if ($this->payment_type_id == PAYMENT_TYPE_ACH) {
            return GATEWAY_TYPE_BANK_TRANSFER;
        } elseif ($this->payment_type_id == PAYMENT_TYPE_PAYPAL) {
            return GATEWAY_TYPE_PAYPAL;
        } else {
            return GATEWAY_TYPE_TOKEN;
        }
    }
}
PaymentMethod::deleting(function ($paymentMethod) {
    $accountGatewayToken = $paymentMethod->account_gateway_token;
    if ($accountGatewayToken->default_payment_method_id == $paymentMethod->id) {
        $newDefault = $accountGatewayToken->payment_methods->first(function ($i, $paymentMethdod) use($accountGatewayToken) {
            return $paymentMethdod->id != $accountGatewayToken->default_payment_method_id;
        });
        $accountGatewayToken->default_payment_method_id = $newDefault ? $newDefault->id : null;
        $accountGatewayToken->save();
    }
});
コード例 #11
0
 public function handleWebHook($input)
 {
     $eventId = array_get($input, 'id');
     $eventType = array_get($input, 'type');
     $accountGateway = $this->accountGateway;
     $accountId = $accountGateway->account_id;
     if (!$eventId) {
         throw new Exception('Missing event id');
     }
     if (!$eventType) {
         throw new Exception('Missing event type');
     }
     $supportedEvents = ['charge.failed', 'charge.succeeded', 'charge.refunded', 'customer.source.updated', 'customer.source.deleted', 'customer.bank_account.deleted'];
     if (!in_array($eventType, $supportedEvents)) {
         return ['message' => 'Ignoring event'];
     }
     // Fetch the event directly from Stripe for security
     $eventDetails = $this->makeStripeCall('GET', 'events/' . $eventId);
     if (is_string($eventDetails) || !$eventDetails) {
         return false;
     }
     if ($eventType != $eventDetails['type']) {
         return false;
     }
     if (!$eventDetails['pending_webhooks']) {
         return false;
     }
     if ($eventType == 'charge.failed' || $eventType == 'charge.succeeded' || $eventType == 'charge.refunded') {
         $charge = $eventDetails['data']['object'];
         $transactionRef = $charge['id'];
         $payment = Payment::scope(false, $accountId)->where('transaction_reference', '=', $transactionRef)->first();
         if (!$payment) {
             return false;
         }
         if ($eventType == 'charge.failed') {
             if (!$payment->isFailed()) {
                 $payment->markFailed($charge['failure_message']);
                 $userMailer = app('App\\Ninja\\Mailers\\UserMailer');
                 $userMailer->sendNotification($payment->user, $payment->invoice, 'payment_failed', $payment);
             }
         } elseif ($eventType == 'charge.succeeded') {
             $payment->markComplete();
         } elseif ($eventType == 'charge.refunded') {
             $payment->recordRefund($charge['amount_refunded'] / 100 - $payment->refunded);
         }
     } elseif ($eventType == 'customer.source.updated' || $eventType == 'customer.source.deleted' || $eventType == 'customer.bank_account.deleted') {
         $source = $eventDetails['data']['object'];
         $sourceRef = $source['id'];
         $paymentMethod = PaymentMethod::scope(false, $accountId)->where('source_reference', '=', $sourceRef)->first();
         if (!$paymentMethod) {
             return false;
         }
         if ($eventType == 'customer.source.deleted' || $eventType == 'customer.bank_account.deleted') {
             $paymentMethod->delete();
         } elseif ($eventType == 'customer.source.updated') {
             //$this->paymentService->convertPaymentMethodFromStripe($source, null, $paymentMethod)->save();
         }
     }
     return 'Processed successfully';
 }
コード例 #12
0
ファイル: Package.php プロジェクト: asimzeeshan/AliExpressOTS
 /**
  * Relationship with PaymentMethod
  */
 public function getPaymentMethod()
 {
     return $this->hasOne(PaymentMethod::className(), ['id' => 'paid_with']);
 }