Executes payment via redirecting to GoPay payment gate
/** * Creates and redirect payment request to GoPay * * @param int $id * @param string $channel */ public function actionPay($id, $channel) { // setup success and failure callbacks $this->paymentService->setSuccessUrl($this->link('//success', ['orderId' => $id])); $this->paymentService->setFailureUrl($this->link('//failure', ['orderId' => $id])); // your custom communication with model $order = $this->model->findOrderById($id); // prepare data about customer) $customer = ['firstName' => $order->name, 'email' => $order->email]; // creation of payment $payment = $this->paymentService->createPayment(['sum' => $order->getPrice(), 'variable' => $order->varSymbol, 'specific' => $order->specSymbol, 'productName' => $order->product, 'customer' => $customer]); // to be able to connect our internal Order with Gopay Payment, // we have to store its generated ID (which will be created during // 'pay' method call - this callback will be provided in next step $storePaymentId = function ($paymentId) use($order) { $order->storePaymentId($paymentId); }; // here we communicate with Gopay Web Service (via soap) $toPayResponse = $this->paymentService->pay($payment, $channel, $storePaymentId); // redirect to Gopay Payment Gate $this->sendResponse($toPayResponse); }