Example #1
0
 private function GeneratePayUForm($trainingLevel, $trainingType, User $user)
 {
     //$liveUpdate = new PayuLu('PAYUDEMO','P5@F8*3!m0+?^9s3&u8(');
     $liveUpdate = new PayuLu('OPU_TEST', 'SECRET_KEY');
     //Show all errors
     $liveUpdate->setDebug(PayuLu::DEBUG_ALL);
     //pname,pcode,pinfo,price,priceType,quantity,tax
     $pname = $trainingLevel . " Yelkencilik Egitimi";
     $pcode = "1112000112";
     $pinfo = "Yelkencilik Egitimi";
     $price = $this->_price;
     $priceType = "NET";
     $quantity = "1";
     $tax = "18";
     $product = new PayuProduct($pname, $pcode, $pinfo, $price, $priceType, $quantity, $tax);
     $liveUpdate->setOrderRef($this->user->GetPublicId());
     $liveUpdate->addProduct($product);
     //Billing adresi hash stringe dahil olmaz. Dolay?s?yla hash de?erinin
     //hesab?na bir etkisi yoktur.
     //Fakat billing bilgisinin gönderilmesi zorunludur.
     //Bundan dolay? billing için first name, last name ve email gönderilmelidir
     $billing = new PayuAddress();
     $billing->setFirstName($user->FirstName());
     $billing->setLastName($user->LastName());
     $billing->setEmail($user->EmailAddress());
     //$billing->setCity("Ka??thane"); //Ilce/Semt
     //$billing->setState("Istanbul"); //Sehir
     $billing->setCountryCode("TR");
     $liveUpdate->setBillingAddress($billing);
     $liveUpdate->setPaymentCurrency("TRY");
     $liveUpdate->setInstalments("3,4");
     $liveUpdate->setOrderShipping("");
     $liveUpdate->setBackRef("");
     $liveUpdate->setButtonName('Şimdi Öde');
     $t = $liveUpdate->renderPaymentForm();
     return $t;
 }
Example #2
0
 /**
  * @param CartCore $cart
  * @return string
  */
 public function getLuForm(CartCore $cart)
 {
     $merchant_id = Configuration::get('PAYU_EPAYMENT_MERCHANT');
     $secret_key = Configuration::get('PAYU_EPAYMENT_SECRET_KEY');
     $url = $this->getBusinessPartnerSetting('lu_url');
     if (empty($merchant_id) || empty($secret_key) || empty($url)) {
         return false;
     }
     $live_update = new PayuLu($merchant_id, $secret_key);
     $live_update->setQueryUrl($url);
     $this->validateOrder($cart->id, (int) Configuration::get('PAYU_PAYMENT_STATUS_PENDING'), $cart->getOrderTotal(true, Cart::BOTH), $this->displayName, null, null, (int) $cart->id_currency, false, $cart->secure_key, Context::getContext()->shop->id ? new Shop((int) Context::getContext()->shop->id) : null);
     $this->current_order = $this->{'currentOrder'};
     if (version_compare(_PS_VERSION_, '1.5', 'lt')) {
         $this->current_order_reference = '';
         $internal_reference = '#' . str_pad($this->current_order, 6, '0', STR_PAD_LEFT);
         $order_ref = $this->current_order . '|' . str_pad($this->current_order, 6, '0', STR_PAD_LEFT);
         $order_id = $this->current_order;
         $backref_url = $this->getModuleAddress() . 'backward_compatibility/return.php?order_ref=' . $this->current_order;
     } else {
         $this->current_order_reference = $this->{'currentOrderReference'};
         $internal_reference = $this->{'currentOrderReference'};
         $order_ref = $this->{'currentOrder'} . '|' . $this->{'currentOrderReference'};
         $order_id = $this->{'currentOrder'};
         $backref_url = Context::getContext()->link->getModuleLink('payu', 'return', array('order_ref' => $this->current_order));
     }
     $live_update->setBackRef($backref_url);
     $live_update->setOrderRef($order_ref);
     $currency = Currency::getCurrency($cart->id_currency);
     $default_lang = (int) Configuration::get('PS_LANG_DEFAULT');
     $lang_iso_code = Language::getIsoById($default_lang);
     $live_update->setPaymentCurrency($currency['iso_code']);
     $live_update->setLanguage(Tools::strtoupper($lang_iso_code));
     $payu_product = new PayuProduct();
     $payu_product->setName('Payment for order ' . $internal_reference);
     $payu_product->setCode($internal_reference);
     $payu_product->setPrice($cart->getOrderTotal(true, Cart::BOTH));
     $payu_product->setTax(0);
     $payu_product->setQuantity(1);
     $live_update->addProduct($payu_product);
     if (!empty($cart->id_customer)) {
         $customer = new Customer((int) $cart->id_customer);
         if ($customer->email) {
             if (!empty($cart->id_address_invoice) && Configuration::get('PS_INVOICE')) {
                 $address = new Address((int) $cart->id_address_invoice);
                 $country = new Country((int) $address->id_country);
                 $billing = new PayuAddress();
                 $billing->setFirstName($address->firstname);
                 $billing->setLastName($address->lastname);
                 $billing->setEmail($customer->email);
                 $billing->setPhone(!$address->phone ? $address->phone_mobile : $address->phone);
                 $billing->setAddress($address->address1);
                 $billing->setAddress2($address->address2);
                 $billing->setZipCode($address->postcode);
                 $billing->setCity($address->city);
                 $billing->setCountryCode(Tools::strtoupper($country->iso_code));
                 $live_update->setBillingAddress($billing);
             }
             if (!empty($cart->id_address_delivery)) {
                 $address = new Address((int) $cart->id_address_delivery);
                 $country = new Country((int) $address->id_country);
                 $delivery = new PayuAddress();
                 $delivery->setFirstName($address->firstname);
                 $delivery->setLastName($address->lastname);
                 $delivery->setEmail($customer->email);
                 $delivery->setPhone(!$address->phone ? $address->phone_mobile : $address->phone);
                 $delivery->setAddress($address->address1);
                 $delivery->setAddress2($address->address2);
                 $delivery->setZipCode($address->postcode);
                 $delivery->setCity($address->city);
                 $delivery->setCountryCode(Tools::strtoupper($country->iso_code));
                 $live_update->setDeliveryAddress($delivery);
             }
         }
     }
     $lu_form = $live_update->renderPaymentForm(null);
     $this->savePayuTransaction($order_id, $cart->getOrderTotal(true, Cart::BOTH), Currency::getCurrency($cart->id_currency));
     return $lu_form;
 }