/** * @param Gopay\PaymentButton $button */ public function submittedForm(Gopay\PaymentButton $button) { $this->gopay->successUrl = $this->link('//success'); $this->gopay->failureUrl = $this->link('//failure'); srand((double) microtime() * 1000000); $order = array('sum' => rand(10, 2000), 'variable' => date("Y") . date("m") . date("d") . date("H") . date("i") . date("s"), 'specific' => 0, 'productName' => "Test", 'customer' => array('firstName' => "Martin", 'lastName' => NULL, 'street' => NULL, 'city' => NULL, 'postalCode' => "55101", 'countryCode' => 'CZE', 'email' => "*****@*****.**", 'phoneNumber' => NULL)); $payment = $this->gopay->createPayment($order); $model = $this->gopayModel; try { $storeIdCallback = function ($paymentId) use($model, $order) { $record = array("paymentSessionID" => $paymentId, "variable" => $order['variable'], "sum" => $order['sum'], "name" => "Test"); $this->gopayModel->insert($record); }; //$gopay->denyChannel($gopay::METHOD_TRANSFER); $response = $this->gopay->pay($payment, $button->getChannel(), $storeIdCallback); $this->sendResponse($response); } catch (Gopay\GopayException $e) { echo "<br><br><br>"; echo $e->getMessage(); echo 'Platební služba Gopay bohužel momentálně nefunguje. Zkuste to prosím za chvíli.'; } }
/** * Registers 'addPaymentButtons' & 'addPaymentButton' methods to form * * @param Service */ public static function registerAddPaymentButtons(Service $service) { Nette\Forms\Container::extensionMethod('addPaymentButtons', function ($container, $callbacks) use($service) { $service->bindPaymentButtons($container, $callbacks); }); Nette\Forms\Container::extensionMethod('addPaymentButton', function ($container, $channel) use($service) { return $service->bindPaymentButton($channel, $container); }); }