*/ public static function statusValues(): array { return [ null => '-', self::PENDING => __('Pending'), self::PAID => __('Paid'), self::FAILED => __('Cancelled'), ]; } /** * Generate order number for payment */ public function generateOrderNumber(): string { return date('dmyHis'); } /** * Payment provder */ public function paymentProvider(PaymentProviderContract $provider): self { $this->provider = $provider; return $this; } /** * If payment has been successfull */ public function successful(): bool { return $this->successful; } /** * If payment has been a failure */ public function failed(): bool { return $this->failed; } /** * Send request via provider */ public function sendRequest(): self { $response = $this->provider->sendRequest(); $this->failed = $response->failed(); $this->successful = $response->successful(); $this->response = $response; return $this; } /** * Payment link */ public function paymentLink(): string { return $this->paymentLink; } // public function payCardOrder() // { // if ($paymentResponse->failed()) { // return [ // 'status' => 'failed', // 'url' => '', // ]; // } // $onlinePaymentHistory = new OnlinePayment; // $onlinePaymentHistory->online_paymantable_id = $resource->really(); // $onlinePaymentHistory->online_paymantable_type = CardOrder::class; // $onlinePaymentHistory->amount = $resource->priceAmount(); // $onlinePaymentHistory->orderNumber = $orderNumber; // $onlinePaymentHistory->description = 'Kart tölegi'; // $onlinePaymentHistory->orderId = $paymentResponse['orderId']; // $onlinePaymentHistory->formUrl = $paymentResponse['formUrl']; // $onlinePaymentHistory->successUrl = route('online-payment-store'); // $onlinePaymentHistory->errorUrl = route('online-payment-store'); // $onlinePaymentHistory->api_client = 'billing_username'; // $onlinePaymentHistory->username = $resource->branch->billing_username; // $onlinePaymentHistory->paymentStatus = self::PENDING; // $onlinePaymentHistory->save(); // return [ // 'status' => 'success', // 'url' => $paymentResponse['formUrl'], // ]; // } }