Ejemplo n.º 1
0
 public function redirectAction()
 {
     $order = Mage::helper('ipcpaygate')->getLastSessionOrder();
     $data = $order->getData();
     $orderId = $data['entity_id'];
     Mage::helper('ipcpaygate')->changeOrderState($order, 'pending_payment', true, 'Rozpoczęto proces płatności w inviPay.com.');
     $client = Mage::helper('ipcpaygate')->getApiClient();
     $request = new PaymentCreationData();
     $request->setReturnUrl(Mage::getUrl('ipcpaygate/payment/return', array('order' => $orderId)));
     $request->setStatusUrl(Mage::getUrl('ipcpaygate/payment/status', array()));
     $request->setStatusDataFormat(CallbackDataFormat::JSON);
     $request->setDocumentNumber($data['increment_id']);
     $request->setIssueDate(date('Y-m-d', strtotime($data['created_at'])));
     $request->setPriceGross($data['grand_total']);
     $request->setCurrency($data['base_currency_code']);
     $request->setIsInvoice(false);
     $request->setBuyerGovId(Mage::helper('ipcpaygate')->getNipFromOrder($order));
     $request->setBuyerEmail($data['customer_email']);
     // Any exception will be logged by Magento, so no try-catch here
     $result = $client->createPayment($request);
     $paymentId = $result->getPaymentId();
     $redirectUrl = $result->getRedirectUrl();
     $order->setInvipayPaymentId($paymentId);
     $order->setInvipayCompleted(false);
     $order->setInvipayDeliveryConfirmed(false);
     $order->save();
     $this->loadLayout();
     $block = $this->getLayout()->createBlock('Invipay_Ipcpaygate_Block_Redirect', 'ipcpaygate');
     $block->setRedirectUrl($redirectUrl);
     $this->getLayout()->getBlock('content')->append($block);
     $this->renderLayout();
 }
Ejemplo n.º 2
0
<?php

require_once dirname(__FILE__) . "/../../PaygateApiClient.class.php";
require_once dirname(__FILE__) . "/../config.php";
$client = new PaygateApiClient(INVIPAY_API_URL, INVIPAY_API_KEY, INVIPAY_SIGNATURE_KEY);
Logger::info('Creating new payment');
$request = new PaymentCreationData();
$request->setReturnUrl("http://aeroapi.localhost/paygate/thankyou.htm");
$request->setStatusUrl("http://aeroapi.localhost/paygate/StatusListener.example.php");
$request->setDocumentNumber(uniqid('Paygate/'));
$request->setIssueDate(date('Y-m-d', time()));
$request->setDueDate(date('Y-m-d', time() + 14 * 24 * 60 * 60));
$request->setPriceGross(123.0);
$request->setCurrency("PLN");
$request->setNote("My note");
$request->setNoRisk(true);
$request->setIsInvoice(false);
$request->setBuyerGovId('8429067910');
$request->setBuyerEmail('*****@*****.**');
$result = $client->createPayment($request);
Logger::info('Result is: {0}', $result);
Ejemplo n.º 3
0
 public function startPaymentRequest($cart, $order)
 {
     $moduleId = Context::getContext()->controller->module->id;
     $client = $this->getApiClient();
     $currency = new Currency($order->id_currency);
     $customer = new Customer($order->id_customer);
     $address = new Address($order->id_address_invoice);
     $request = new PaymentCreationData();
     $request->setReturnUrl(Context::getContext()->link->getPageLink('order-confirmation') . '?id_cart=' . $cart->id . '&id_module=' . $moduleId . '&id_order=' . $order->id . '&key=' . $customer->secure_key);
     $request->setStatusUrl(Context::getContext()->link->getModuleLink('invipaypaygate', 'statuslistener'));
     $request->setStatusDataFormat(CallbackDataFormat::JSON);
     $request->setDocumentNumber($order->reference);
     $request->setIssueDate(date('Y-m-d', strtotime($order->date_add)));
     $request->setPriceGross($order->total_paid_tax_incl);
     $request->setCurrency($currency->iso_code);
     $request->setIsInvoice(false);
     $request->setBuyerGovId(preg_replace('/[^0-9]*/', '', !empty($address->vat_number) ? $address->vat_number : $address->dni));
     $request->setBuyerEmail($customer->email);
     $result = $client->createPayment($request);
     $paymentId = $result->getPaymentId();
     $redirectUrl = $result->getRedirectUrl();
     $paymentEntity = new InvipayPaymentRequest();
     $paymentEntity->id_cart = $cart->id;
     $paymentEntity->id_order = $order->id;
     $paymentEntity->payment_id = $paymentId;
     $paymentEntity->payment_status = PaymentRequestStatus::STARTED;
     $paymentEntity->save();
     return $redirectUrl;
 }