first commit

This commit is contained in:
2025-03-12 17:06:23 +01:00
commit 2241f7131f
13185 changed files with 1692479 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
all:
stPaypal:
api_endpoints:
live: "https://api-3t.paypal.com/nvp"
sandbox: "https://api-3t.sandbox.paypal.com/nvp"
beta-sandbox: "https://api-3t.beta-sandbox.paypal.com/nvp"
api_version: "60.0"
urls:
live: "https://www.paypal.com/webscr"
sandbox: "https://www.sandbox.paypal.com/webscr"
button_culture_locale:
at: de_DE
au: en_AU
be: en_US
c2: en_US
ch: de_DE
cn: zh_CN
de: de_DE
es: es_ES
fr: fr_FR
gb: en_GB
gf: fr_FR
gi: en_US
gp: fr_FR
ie: en_US
it: it_IT
jp: ja_JP
us: en_US
pl_PL: pl_PL
en_US: en_US
default: en_US

View File

@@ -0,0 +1,20 @@
<?php
stPluginHelper::addConfigValue('stPaymentType', 'stPaypalPlugin', array('name' => 'stPaypal', 'description' => 'Płatność przez serwis Paypal'));
if (SF_APP == 'frontend') {
stPluginHelper::addEnableModule('stPaypalFrontend', 'frontend');
stPluginHelper::addRouting('stPaypalDoExpressCheckout', '/paypal/do-express-checkout/:order_id/:order_hash', 'stPaypalFrontend', 'doExpressCheckout', 'frontend');
stPluginHelper::addRouting('stPaypalSetExpressCheckout', '/paypal/set-express-checkout/:order_id/:order_hash', 'stPaypalFrontend', 'setExpressCheckout', 'frontend');
stPluginHelper::addRouting('stPaypalIpn', '/paypal/ipn/:order_id/:order_hash', 'stPaypalFrontend', 'ipn', 'frontend');
stPluginHelper::addRouting('stPaypalBuyProduct', '/paypal/buy-product/:product_id', 'stPaypalFrontend', 'buyProduct', 'frontend');
stPluginHelper::addRouting('stPaypalCreateOrder', '/paypal/create-order', 'stPaypalFrontend', 'createOrder', 'frontend');
stPluginHelper::addRouting('stPaypalDoExpressCheckoutForProduct', '/paypal/do-express-checkout-for-product/:order_id/:order_hash/:token', 'stPaypalFrontend', 'doExpressCheckoutForProduct', 'frontend');
}
if (SF_APP == 'backend') {
stPluginHelper::addEnableModule('stPaypalBackend', 'backend');
stPluginHelper::addRouting('stPaypalPlugin', '/paypal', 'stPaypalBackend', 'config', 'backend');
stPluginHelper::addRouting('stPaypalActionPlugin', '/paypal/:action/*', 'stPaypalBackend', null, 'backend');
stConfiguration::addModule('stPaypalPlugin', 'group_3', 1);
}

View File

@@ -0,0 +1,12 @@
PaymentType:
PaymentType_20:
module_name: stPaypal
active: 0
culture: pl_PL
name: Paypal
PaymentTypeI18n:
PaymentTypeI18n_20:
id: PaymentType_20
culture: en_US
name: Paypal

View File

@@ -0,0 +1,74 @@
<?php
function st_paypal_checkout_express_add_link($namespace, Product $product) {
$config = stConfig::getInstance('stPaypal');
if ($config->get('express') && $config->get('configuration_verified')) {
$context = sfContext::getInstance();
st_theme_use_stylesheet('stPaypal.css');
if ($message = $context->getUser()->getAttribute('express_checkout_error', null, 'stPaypal')) {
$context->getUser()->setAttribute('express_checkout_error', null, 'stPaypal');
$errorContent = <<<ERROR
<div id="paypal_express_checkout_error">
{$message}.
</div>
ERROR;
}
if ($product->getPriceBrutto() <= 0 || !stBasket::isEnabled($product) || stBasket::isHidden($product)) {
$context->getUser()->setAttribute('express_checkout_error', null, 'stPaypal');
if (!empty($message))
return $errorContent;
else
return false;
}
$id = $product->getId();
$url = st_url_for('@stPaypalBuyProduct?product_id='.$id);
$image_url = 'https://www.paypal.com/' . stPaypal::getButtonLocaleByCulture($context->getUser()->getCulture()).'/i/btn/btn_xpressCheckout.gif';
$image_alt = __('Zapłać w systemie PayPal', null, 'stPaypalFrontend');
$content =<<< HTML
<div id="paypal_express_checkout">
<a id="{$namespace}_{$id}_paypal_checkout_express" href="$url">
<img src="$image_url" alt="$image_alt" />
</a>
</div>
<script type="text/javascript">
//<![CDATA[
jQuery(function($) {
$('#{$namespace}_{$id}_paypal_checkout_express').click(function() {
var quantity = $('#{$namespace}_{$id}_quantity');
if (quantity.length && quantity.val() == 0) {
quantity.val(quantity.get(0).defaultValue);
}
var quantity_value = quantity.length ? quantity.val() : {$product->getMinQty()};
var serialized = $('#{$namespace}_$id').serialize();
if (!serialized && $("#st_update_product_options_form").length > 0) {
serialized = 'option_list='+$.map($('#st_update_product_options_form').serializeArray(), function(option) { return option.value;}).join('-');
}
if (serialized) {
serialized += '&quantity='+quantity_value;
} else {
serialized += 'quantity='+quantity_value;
}
var link = $(this);
var href = link.attr('href')+'?'+serialized;
link.attr('href', href);
});
});
//]]>
</script>
HTML;
return $errorContent.$content;
}
return false;
}

View File

@@ -0,0 +1,240 @@
<?php
class stPayPalExpressCheckout {
public function addOrder($response, Product $product) {
$config = stConfig::getInstance('stPaypal');
$custom = $response->getPaymentRequest_0_Custom();
if (!empty($custom)) $custom = json_decode($custom, true);
/**
* User
**/
$c = new Criteria();
$c->add(sfGuardUserPeer::USERNAME, $response->getEmail());
$user = sfGuardUserPeer::doSelectOne($c);
$billingUserData = $this->getUserDataFromResponse($response, new UserData());
$deliveryUserData = clone $billingUserData;
if (is_null($user)) {
$user = stUser::addUser($response->getEmail());
$billingUserData->setSfGuardUserId($user->getId());
$billingUserData->setIsDefault(1);
$billingUserData->setIsBilling(1);
$billingUserData->save();
$deliveryUserData->setSfGuardUserId($user->getId());
$deliveryUserData->setIsDefault(1);
$deliveryUserData->setIsBilling(0);
$deliveryUserData->save();
} else {
$c = new Criteria();
$c->add(UserDataPeer::SF_GUARD_USER_ID, $user->getId());
$c->add(UserDataPeer::IS_BILLING, 1);
$c->add(UserDataPeer::IS_DEFAULT, 1);
$defaultBillingUserData = UserDataPeer::doSelectOne($c);
$c = new Criteria();
$c->add(UserDataPeer::SF_GUARD_USER_ID, $user->getId());
$c->add(UserDataPeer::IS_BILLING, 0);
$c->add(UserDataPeer::IS_DEFAULT, 1);
$defaultDeliveryUserData = UserDataPeer::doSelectOne($c);
$stUser = sfContext::getInstance()->getUser();
if (!$stUser->thisSameUserDataObject($defaultBillingUserData, $billingUserData)) {
$billingUserData->setSfGuardUserId($user->getId());
$billingUserData->setIsBilling(1);
$billingUserData->save();
stUser::setDefaultUserData($billingUserData->getId(), 1, $user->getId());
}
if (!$stUser->thisSameUserDataObject($defaultDeliveryUserData, $deliveryUserData)) {
$deliveryUserData->setSfGuardUserId($user->getId());
$deliveryUserData->save();
stUser::setDefaultUserData($deliveryUserData->getId(), 0, $user->getId());
}
}
/**
* Order
**/
$order = new Order();
$order->setClientCulture(sfContext::getInstance()->getUser()->getCulture());
$order->setHost(sfContext::getInstance()->getRequest()->getHost());
$order->setOrderStatus(OrderStatusPeer::retrieveDefaultPendingStatus());
/**
* User billing and delivery data for order
**/
$order->setGuardUser($user);
$orderBilling = $this->mirrorUserData($order->getOrderUserDataBilling(), $billingUserData);
$orderDelivery = $this->mirrorUserData($order->getOrderUserDataDelivery(), $deliveryUserData);
/**
* Order currency
**/
$orderCurrency = $order->getOrderCurrency();
$c = new Criteria();
$c->add(CurrencyPeer::SHORTCUT, $response->getPaymentRequest_0_CurrencyCode());
$currency = CurrencyPeer::doSelectOne($c);
$orderCurrency->setName($currency->getName());
$orderCurrency->setExchange($currency->getExchange());
$orderCurrency->setFrontSymbol($currency->getFrontSymbol());
$orderCurrency->setBackSymbol($currency->getBackSymbol());
$orderCurrency->setShortcut($currency->getShortcut());
$orderProduct = new OrderProduct();
$orderProduct->setProductId($product->getId());
$orderProduct->setQuantity($response->getL_PaymentRequest_0_Qty0());
$orderProduct->setCode($product->getCode());
$orderProduct->setName($product->getName());
$orderProduct->setBasePriceBrutto($response->getL_PaymentRequest_0_Amt0());
$orderProduct->setImage($product->getOptImage());
$orderProduct->setTax($product->getTax());
$orderProduct->setPointsEarn($product->getPointsEarn());
$priceModifiers = $product->getPriceModifiers();
if ($priceModifiers)
{
foreach ($priceModifiers as $index => $price_modifier)
{
$priceModifiers[$index]['value'] = null;
if (isset($priceModifiers[$index]['custom']['label']))
{
$priceModifiers[$index]['label'] = $priceModifiers[$index]['custom']['label'];
}
}
$orderProduct->setPriceModifiers($priceModifiers);
}
$order->addOrderProduct($orderProduct);
/**
* Order delivery
**/
$delivery = DeliveryPeer::retrieveByPK($config->get('express_delivery'));
$orderDelivery = $order->getOrderDelivery();
$orderDelivery->setName($delivery->getName());
$orderDelivery->setTaxId($delivery->getTaxId());
$orderDelivery->setDeliveryId($delivery->getId());
$orderDelivery->setCostBrutto($response->getPaymentRequest_0_ShippingAmt()*$currency->getExchange());
$orderDelivery->setOptTax($delivery->getTax()->getVat());
/**
* Confirm order
**/
if (stUser::isFullAccount($user)) {
$order->setIsConfirmed(1);
}
/**
* Save order
**/
$order->save();
/**
* Generate order number
**/
$dateFormat = new sfDateFormat();
$orderConfig = stConfig::getInstance('stOrder');
$format = $orderConfig->get('number_format');
$date = $dateFormat->getDate($order->getCreatedAt(), 'd');
$number = str_replace(array('{NUMER}', '{DZIEN}', '{MIESIAC}', '{ROK}'), array($order->getId(), $date['mday'], $date['mon'], $date['year']), $format);
$order->setNumber($number);
$order->save();
/**
* Payment
**/
$c = new Criteria();
$c->add(PaymentTypePeer::MODULE_NAME, 'stPaypal');
$paymentType = PaymentTypePeer::doSelectOne($c);
$stPayment = new stPayment();
$paymentId = $stPayment->add($user->getId(), $paymentType->getId(), stPayment::getUnpayedAmountByOrder($order));
$stPayment->addPaymentForOrder($order->getId(), $paymentId);
/**
* Invoice
**/
stInvoiceListener::crateInvoiceProforma($order);
return $order;
}
protected function getUserDataFromResponse(stPaypalCallerResponse $r, UserData $u) {
$u->setFullName($r->getPaymentRequest_0_ShipToName());
$u->setAddress($r->getPaymentRequest_0_ShipToStreet());
$u->setCode($r->getPaymentRequest_0_ShipToZip());
$u->setTown($r->getPaymentRequest_0_ShipToCity());
$u->setRegion($r->getPaymentRequest_0_ShipToState());
$c = new Criteria();
$c->add(CountriesPeer::ISO_A2, $r->getPaymentRequest_0_ShipToCountryCode());
$country = CountriesPeer::doSelectOne($c);
$u->setCountriesId(is_null($country) ? '36' : $country->getId());
return $u;
}
protected function mirrorUserData($target, $source) {
$attributes = array('countries', 'full_name', 'address', 'region', 'code', 'town');
foreach($attributes as $attribute) {
$setter = 'set'.sfInflector::camelize($attribute);
$getter = 'get'.sfInflector::camelize($attribute);
$target->$setter($source->$getter());
}
}
public static function validateProduct(Product $product, $quantity) {
$context = sfContext::getInstance();
$i18n = $context->getI18n();
if ($product->getPriceBrutto() <= 0)
return self::returnValidareProductError($i18n->__('Cena produktu musi być większa niż 0'));
if (!is_numeric($quantity) || empty($quantity))
return self::returnValidareProductError($i18n->__('Podana wartość musi być liczbą całkowitą...', null, 'stBasket'));
$minAmount = stConfig::getInstance('stOrder')->get('min_amount', 0);
if ($minAmount > 0 && $minAmount > $product->getPriceBrutto())
return self::returnValidareProductError($i18n->__('Minimalna wartość zamówienia wynosi %min_amount%', array('%min_amount%' => st_price($min_amount, true, true)), 'stOrder'));
$maxQuantity = $product->getStock();
if ($product->getStock() == null || !$product->getIsStockValidated())
$maxQuantity = stConfig::getInstance('stBasket')->get('max_quantity', 0);
$productMaxQty = $product->getMaxQty();
$max = $productMaxQty && $productMaxQty < $maxQuantity ? $productMaxQty : $maxQuantity;
if ($max < $quantity)
return self::returnValidareProductError($i18n->__('Brak wymaganej ilości towaru w magazynie', null, 'stBasket'));
return true;
}
public static function returnValidareProductError($message) {
sfContext::getInstance()->getUser()->setAttribute('express_checkout_error', $message, 'stPaypal');
return false;
}
}

View File

@@ -0,0 +1,35 @@
<?php
/**
* SOTESHOP/stPaypalPlugin
*
* Ten plik należy do aplikacji stPaypalPlugin opartej na licencji (Professional License SOTE).
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
*
* @package stPaypalPlugin
* @subpackage libs
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/sote (Professional License SOTE)
* @version $Id: stPaypal.class.php 5933 2010-07-01 11:11:44Z marcin $
* @author Marcin Butlak <marcin.butlak@sote.pl>
*/
class stPaypal
{
public static function getButtonLocaleByCulture($culture)
{
$culture_to_locale = sfConfig::get('app_stPaypal_button_culture_locale');
return isset($culture_to_locale[$culture]) ? $culture_to_locale[$culture] : $culture_to_locale['default'];
}
public function checkPaymentConfiguration()
{
$config = stConfig::getInstance(null, 'stPaypal');
return $config->get('enabled') && $config->get('configuration_verified');
}
}

View File

@@ -0,0 +1,466 @@
<?php
/**
* SOTESHOP/stPaypalPlugin
*
* Ten plik należy do aplikacji stPaypalPlugin opartej na licencji (Professional License SOTE).
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
*
* @package stPaypalPlugin
* @subpackage libs
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/sote (Professional License SOTE)
* @version $Id: $
* @author Marcin Butlak <marcin.butlak@sote.pl>
*/
/**
*
* Klasa obsługi wyjątków z stPaypalCallerService
*
* @package stPaypalPlugin
* @subpackage libs
*/
class stPaypalCallerException extends sfException
{
}
/**
*
* Podstawowa klasa upraszczająca tworzenie i pobieranie parametrów Paypal NVP API
*
* @package stPaypalPlugin
* @subpackage libs
*/
abstract class stPaypalCallerBase
{
protected $parameters = array('_ITEMS' => array());
public function __toString()
{
$tmp = array();
foreach($this->parameters as $name => $value)
{
if (is_array($value))
{
$tmp = array_merge($tmp, $value);
}
else
{
$tmp[] = strtoupper($name) . '=' . urlencode($value);
}
}
return implode('&', $tmp);
}
public function addItem(stPaypalCallerBase $item)
{
$this->parameters['_ITEMS'][] = $item;
}
public function getItems()
{
return $this->parameters['_ITEMS'];
}
public function setItems($items)
{
$this->parameters['_ITEMS'] = $items;
}
public function __set($name, $value)
{
$name = strtoupper($name);
$this->parameters[$name] = is_bool($value) ? intval($value) : $value;
}
public function __get($name)
{
$name = strtoupper($name);
return array_key_exists($name, $this->parameters) ? $this->parameters[$name] : null;
}
public function __call($name, $arguments)
{
if (strpos($name, 'set') === 0)
{
$name = substr($name, 3);
$this->$name = current($arguments);
return $this;
}
elseif (strpos($name, 'get') === 0)
{
$name = substr($name, 3);
return $this->$name;
}
}
}
/**
*
* Klasa upraszczająca definiowanie parametrów Paypal NVP API typu "List"
*
* @package stPaypalPlugin
* @subpackage libs
*/
class stPaypalCallerItem extends stPaypalCallerBase
{
private $id = 0;
public function __construct($id, $parameters = array())
{
$this->parameters = $parameters;
$this->id = $id;
}
public function setItemId($id)
{
$this->id = $id;
}
public function __toString()
{
$tmp = array();
foreach($this->parameters as $name => $value)
{
$tmp[] = 'L_' . strtoupper($name). $this->id . '=' . urlencode($value);
}
return implode('&', $tmp);
}
}
/**
*
* Klasa upraszczająca odbieranie odpowiedzi od Paypal NVP API
*
* @package stPaypalPlugin
* @subpackage libs
*/
class stPaypalCallerResponse extends stPaypalCallerBase
{
public function __construct($nvp)
{
$this->deformatNVP($nvp);
}
public function isSuccessful()
{
return $this->getAck() == 'Success' || $this->getAck() == 'SuccessWithWarning';
}
public function hasFailed()
{
return !$this->isSuccessful();
}
public function hasError($error_code)
{
foreach ($this->getItems() as $error)
{
if ($error->getErrorCode() == $error_code)
{
return true;
}
}
return false;
}
protected function deformatNVP($nvp)
{
$items = array();
$item_index = 0;
$parameters = explode('&', $nvp);
foreach ($parameters as $parameter)
{
list($name, $value) = explode('=', $parameter);
$tmp = array();
if (preg_match('/L_([A-Z]+)([0-9]+)/i', $name, $tmp))
{
if (isset($items[$item_index][$tmp[2]][$tmp[1]]) &&$tmp[2] == 0)
{
$item_index++;
}
$items[$item_index][$tmp[2]][$tmp[1]] = urldecode($value);
}
else
{
$this->parameters[$name] = urldecode($value);
}
}
foreach ($items as $item)
{
foreach ($item as $id => $params)
{
$this->addItem(new stPaypalCallerItem($id, $params));
}
}
unset($list_params);
}
}
/**
*
* Klasa upraszczająca tworzenie żądań do Paypal NVP API
*
* @package stPaypalPlugin
* @subpackage libs
*/
class stPaypalCallerRequest extends stPaypalCallerBase
{
public function __construct($parameters = array())
{
foreach($this->parameters as $name => $value)
{
if (is_array($value))
{
foreach ($value as $id => $params)
{
$this->addItem(new stPaypalCallerItem($id, $params));
}
}
else
{
$this->$name = $value;
}
}
}
}
/**
*
* Klasa upraszczająca kominukację z Paypal NVP API
*
* Przykład zapytania o aktualny bilans konta Paypal we wszystkich dostępnych walutach (zgodnie z specyfikacją ):
* $paypal = stPaypalCallerService::getInstance();
* $paypal->initialize('uzytkownik_api', 'haslo_api', 'podpis_api', 'sandbox|live');
* $request = new stPaypalCallerRequest();
* $request->setReturnAllCurrencies(1);
* $response = $paypal->getBalance($request);
* foreach ($response->getItems() as $item)
* {
* echo $item->getAmt() . " " . $item->getCurrencyCode() . "<br />";
* }
*
* @package stPaypalPlugin
* @subpackage libs
*/
class stPaypalCallerService
{
private $apiUsername = null;
private $apiPassword = null;
private $apiSignature = null;
private $apiEnvironment = self::ENV_LIVE;
private $apiVersion = null;
private $baseResponseClass = self::BASE_RESPONSE_CLASS;
protected static $instance = null;
const ENV_LIVE = 'live';
const ENV_SANDBOX = 'sandbox';
const BASE_RESPONSE_CLASS = 'stPaypalCallerResponse';
/**
*
* Pobiera instancję stPaypalCallerService
*
* @param string $base_caller_class Nazwy klasy rozszerzającej stPaypalCallerService (wymagane wyłącznie podczas rozszerzania stPaypalCallerService)
* @return stPaypalCallerService
*/
public static function getInstance($base_caller_class = null)
{
if (is_null(self::$instance))
{
$class = $base_caller_class ? $base_caller_class : __CLASS__;
self::$instance = new $class();
}
return self::$instance;
}
public function __construct()
{
$this->apiVersion = sfConfig::get('app_stPaypal_api_version');
}
public function initialize($username, $password, $signature, $params = array())
{
$this->apiUsername = $username;
$this->apiPassword = $password;
$this->apiSignature = $signature;
if (isset($params['environment']))
{
$this->apiEnvironment = $params['environment'];
}
if (isset($params['base_response_class']))
{
$this->baseResponseClass = $params['base_response_class'];
}
}
public function setApiUsername($username)
{
$this->apiUsername = $username;
}
public function setApiPassword($password)
{
$this->apiPassword = $password;
}
public function setApiSignature($signature)
{
$this->apiSignature = $signature;
}
public function setApiEnvironment($environment)
{
$this->apiEnvironment = $environment;
}
public function setApiVersion($apiVersion) {
$this->apiVersion = $apiVersion;
}
public function getExpressCheckoutUrl($token)
{
$urls = sfConfig::get('app_stPaypal_urls');
return $urls[$this->apiEnvironment] . '?cmd=_express-checkout&useraction=commit&token=' . $token;
}
/**
*
* Zmienia klase pełniącą rolę odpowiedzi od Paypal NVP API
*
* @param string $class_name Nazwa klasy
*/
public function setBaseResponseClass($class_name)
{
$this->baseResponseClass = $class_name;
}
/**
*
* Wykonuje żądanie za pośrednictwem Paypal NVP API
*
* @param string $method Nazwa metody Paypal API
* @param stPaypalCallerRequest $request Parametry żądania
* @return stPaypalCallerResponse
*/
public function __call($name, $arguments)
{
if (is_array($arguments[0]))
{
$request = new stPaypalCallerRequest($arguments[0]);
}
elseif (is_object($arguments[0]) && $arguments[0] instanceof stPaypalCallerRequest)
{
$request = clone $arguments[0];
}
else
{
throw new stPaypalCallerException('You must pass a stPaypalCallerRequest object or an array of Paypal parameters');
}
$request->setMethod($name);
$request->setUser($this->apiUsername);
$request->setPwd($this->apiPassword);
$request->setSignature($this->apiSignature);
$request->setVersion($this->apiVersion);
$endpoints = sfConfig::get('app_stPaypal_api_endpoints');
if (!isset($endpoints[$this->apiEnvironment]))
{
throw new stPaypalCallerException(sprintf('There is no "%s" environment, available enviroments: "%s"', $this->apiEnvironment, implode(", ",array_flip($endpoints))));
}
$response = self::curlCall($endpoints[$this->apiEnvironment], strval($request));
$responseObject = new $this->baseResponseClass($response);
if (sfConfig::get('sf_debug') && $responseObject->hasFailed())
{
sfLogger::getInstance()->err('{Paypal} '.var_export($responseObject->getItems(), true));
}
return $responseObject;
}
/**
*
* Metoda pomocnicza do obsługi żądań metodą POST
*
* @param string $url Adres żądania
* @param string $postfields Parametry POST żądania
* @return string Odpowiedź
*/
public static function curlCall($url, $postfields)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_VERBOSE, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
// curl_setopt($ch, CURLOPT_SSLVERSION, 3);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
$response = curl_exec($ch);
if (curl_errno($ch))
{
throw new stPaypalCallerException(curl_error($ch), curl_errno($ch));
}
curl_close($ch);
return $response;
}
}

View File

@@ -0,0 +1,230 @@
<?php
class stPaypalBackendActions extends stActions
{
protected $paymentConfigurartionVerified = false;
public function executeSave()
{
return $this->forward('stPaypalBackend', 'config');
}
public function executeConfig()
{
$this->config = stConfig::getInstance('stPaypal');
$this->labels = $this->getConfigLabels();
$this->deliveries = DeliveryPeer::doSelect(new Criteria());
if ($this->getRequest()->getMethod() == sfRequest::POST)
{
$this->config->set('configuration_verified', $this->paymentConfigurartionVerified);
$this->updateConfigRequest();
$this->config->save();
$this->setFlash('notice', 'Twoje zmiany zostały zapisane');
$this->redirect('stPaypalBackend/config');
}
}
public function executeAjaxPaypalPendingPayments()
{
$this->setLayout(false);
$this->config = stConfig::getInstance('stPaypal');
$paypal = $this->getPaypalCallerService();
$request = new stPaypalCallerRequest();
$timestamp_end = time();
$timestamp_start = $timestamp_end - 86400 * 7;
$request->setStartDate(date('Y-m-d\TH:i:s\Z', $timestamp_start));
$request->setEndDate(date('Y-m-d\TH:i:s\Z', $timestamp_end));
$request->setTransactionClass('Received');
$request->setStatus('Pending');
$this->paypal_response = $paypal->transactionSearch($request);
}
public function executeAjaxPaypalAccountBalance()
{
$this->setLayout(false);
$this->config = stConfig::getInstance('stPaypal');
$paypal = $this->getPaypalCallerService();
$request = new stPaypalCallerRequest();
$request->setReturnAllCurrencies(true);
$this->paypal_response = $paypal->getBalance($request);
}
protected function getPaypalCallerService()
{
$paypal = stPaypalCallerService::getInstance();
if ($this->config->get('test_mode'))
{
$username = $this->config->get('sandbox_api_username');
$password = $this->config->get('sandbox_api_password');
$signature = $this->config->get('sandbox_api_signature');
$environment = 'sandbox';
}
else
{
$username = $this->config->get('live_api_username');
$password = $this->config->get('live_api_password');
$signature = $this->config->get('live_api_signature');
$environment = 'live';
}
$paypal->initialize($username, $password, $signature, array('environment' => $environment));
return $paypal;
}
protected function updateConfigRequest()
{
$request = $this->getRequestParameter('config');
foreach ($request as $name => $value)
{
$this->config->set($name, trim($value));
}
$this->config->set('enabled', isset($request['enabled']));
$this->config->set('test_mode', isset($request['test_mode']));
$this->config->set('show_shipping_info', isset($request['show_shipping_info']));
$this->config->set('express', isset($request['express']));
}
public function handleErrorConfig()
{
$this->config = stConfig::getInstance('stPaypal');
$this->labels = $this->getConfigLabels();
$this->deliveries = DeliveryPeer::doSelect(new Criteria());
if ($this->getRequest()->getMethod() == sfRequest::POST)
{
$this->updateConfigRequest();
}
return sfView::SUCCESS;
}
public function validateConfig()
{
if ($this->getRequest()->getMethod() == sfRequest::POST)
{
stAuthUsersListener::checkModificationCredentials($this, $this->getRequest(), $this->getModuleName());
$i18n = $this->getContext()->getI18n();
$request = $this->getRequestParameter('config');
if (isset($request['enabled']))
{
if (isset($request['test_mode']))
{
if (empty($request['sandbox_api_username']))
{
$this->getRequest()->setError('config{sandbox_api_username}', 'Musisz podać nazwę użytkownika API');
}
if (empty($request['sandbox_api_password']))
{
$this->getRequest()->setError('config{sandbox_api_password}', 'Musisz podać hasło API');
}
if (empty($request['sandbox_api_signature']))
{
$this->getRequest()->setError('config{sandbox_api_signature}', 'Musisz podać podpis API');
}
}
else
{
if (empty($request['live_api_username']))
{
$this->getRequest()->setError('config{live_api_username}', 'Musisz podać nazwę użytkownika API');
}
if (empty($request['live_api_password']))
{
$this->getRequest()->setError('config{live_api_password}', 'Musisz podać hasło API');
}
if (empty($request['live_api_signature']))
{
$this->getRequest()->setError('config{live_api_signature}', 'Musisz podać podpis API');
}
}
if (!$this->getRequest()->hasErrors())
{
$paypal = stPaypalCallerService::getInstance();
if (isset($request['test_mode']))
{
$paypal->initialize(trim($request['sandbox_api_username']), trim($request['sandbox_api_password']), trim($request['sandbox_api_signature']), array('environment' => 'sandbox'));
}
else
{
$paypal->initialize(trim($request['live_api_username']), trim($request['live_api_password']), trim($request['live_api_signature']));
}
$paypal_response = $paypal->getBalance(new stPaypalCallerRequest());
if ($paypal_response->hasFailed())
{
$errors = array();
foreach ($paypal_response->getItems() as $error)
{
$errors[] = $error->getErrorCode().': '.$error->getLongMessage();
}
$this->getRequest()->setError('send_error', $i18n->__('Weryfikacja dostępu do API zakończyła się niepowodzeniem (%errors%)', array('%errors%' => implode(", ", $errors))));
}
else
{
$this->setFlash('notice', $i18n->__('Weryfikacja dostępu do API zakończona powodzeniem. Twoje zmiany zostały zapisane'));
$this->paymentConfigurartionVerified = true;
}
}
}
}
return !$this->getRequest()->hasErrors();
}
protected function getConfigLabels()
{
$i18n = $this->getContext()->getI18N();
return array(
'config{sandbox_api_username}' => $i18n->__('Nazwa użytkownika API'),
'config{sandbox_api_password}' => $i18n->__('Hasło API'),
'config{sandbox_api_signature}' => $i18n->__('Podpis API'),
'config{live_api_username}' => $i18n->__('Nazwa użytkownika API'),
'config{live_api_password}' => $i18n->__('Hasło API'),
'config{live_api_signature}' => $i18n->__('Podpis API'),
'send_error' => 'Paypal',
);
}
}

View File

@@ -0,0 +1,13 @@
<?php
class stPaypalBackendComponents extends sfComponents
{
public function executeListMenu()
{
}
}
?>

View File

@@ -0,0 +1,24 @@
<?php
use_helper('stAdminGenerator');
function st_paypal_order_link($paypal_txn_id)
{
$c = new Criteria();
$c->addJoin(OrderHasPaymentPeer::PAYMENT_ID, PaymentPeer::ID);
$c->addJoin(OrderHasPaymentPeer::ORDER_ID, OrderPeer::ID);
$c->add(PaymentPeer::HASH, 'PAYPAL-' . $paypal_txn_id);
$order = OrderPeer::doSelectOne($c);
if ($order)
{
return st_external_link_to($order->getNumber(), 'stOrder/edit?id=' . $order->getId());
}
else
{
return '-';
}
}

View File

@@ -0,0 +1,19 @@
<div class="list-menu">
<ul>
<li class="selected">
<?php echo link_to(__('PayPal'),'stPaypalBackend/config')?>
</li>
<li>
<?php if (sfContext::getInstance()->getUser()->getCulture() == 'pl_PL'): ?>
<a href="https://www.sote.pl/docs/paypal" target="_blank"><?php echo __('Dokumentacja'); ?></a>
<?php else: ?>
<a href="https://www.soteshop.com/docs/paypal" target="_blank"><?php echo __('Documentation'); ?></a>
<?php endif; ?>
</li>
</ul>
</div>
<div class="clr"></div>

View File

@@ -0,0 +1,27 @@
<?php use_helper('stPaypal') ?>
<?php if ($paypal_response->isSuccessful()): ?>
<?php $items = $paypal_response->getItems() ?>
<?php if (count($items) > 1): ?>
<table class="st_record_list" cellspacing="0">
<thead>
<tr>
<?php foreach ($items as $balance): ?>
<th><?php echo $balance->getCurrencyCode() ?></th>
<?php endforeach; ?>
</tr>
</thead>
<tbody>
<tr>
<?php foreach ($items as $balance): ?>
<td><?php echo $balance->getAmt() ?></td>
<?php endforeach; ?>
</tr>
</tbody>
</table>
<?php else: ?>
<?php echo $items[0]->getAmt() . ' ' . $items[0]->getCurrencyCode() ?>
<?php endif; ?>
<?php else: ?>
<?php echo __('Wystąpiły problemy podczas próby połączenia z Paypal') ?>
<?php endif; ?>

View File

@@ -0,0 +1,33 @@
<?php use_helper('stPaypal', 'stDate') ?>
<?php if ($paypal_response->isSuccessful() && count($paypal_response->getItems()) > 0): ?>
<table class="st_record_list" cellspacing="0">
<thead>
<tr>
<th><?php echo __('Numer zamówienia') ?></th>
<th><?php echo __('Data płatności') ?></th>
<th><?php echo __('Płacący') ?></th>
<th><?php echo __('Kwota płatności') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($paypal_response->getItems() as $transaction): ?>
<tr>
<td><?php echo st_paypal_order_link($transaction->getTransactionId()) ?></td>
<td><?php echo st_format_date($transaction->getTimestamp(), 'f') ?></td>
<td>
<?php echo $transaction->getName() ?><br />
<?php echo $transaction->getEmail() ?>
</td>
<td><?php echo $transaction->getAmt() ?> <?php echo $transaction->getCurrencyCode() ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php elseif ($paypal_response->isSuccessful()): ?>
<p><?php echo __('Brak oczekujących płatności') ?></p>
<?php else: ?>
<?php echo __('Wystąpiły problemy podczas próby połączenia z Paypal') ?>
<?php endif;

View File

@@ -0,0 +1,189 @@
<?php use_helper('Object', 'Validation', 'ObjectAdmin', 'I18N', 'Date', 'VisualEffect', 'stAdminGenerator') ?>
<?php echo st_get_admin_head('stPaypalPlugin', __('PayPal'), null,array('stPayment')) ?>
<?php st_view_slot_start('application-menu') ?>
<?php st_include_component('stPaypalBackend', 'listMenu') ?>
<?php st_view_slot_end() ?>
<?php st_include_partial('stAdminGenerator/message', array('labels' => $labels, 'i18n_catalogue' => 'stPaypalBackend')) ?>
<?php echo form_tag('stPaypalBackend/save', array('id' => 'sf_admin_config_form', 'name' => 'sf_admin_config_form', 'class' => 'admin_form')) ?>
<fieldset id="sf_fieldset-paypal-live">
<div class="content">
<div class="row">
<?php echo st_admin_get_form_field('config[enabled]', __('Aktywuj'), 1, 'checkbox_tag', array('checked' => $config->get('enabled'), 'class' => 'st_paypal-live-field', 'size' => '60')) ?>
<div class="clr"></div>
</div>
<div class="form-row">
<?php echo label_for('config_live_api_username', __('Nazwa użytkownika API'), array('class' => 'required')) ?>
<div class="content<?php if ($sf_request->hasError('config{live_api_username}')): ?> form-error<?php endif; ?>">
<?php if ($sf_request->hasError('config{live_api_username}')): ?>
<?php echo form_error('config{live_api_username}', array('class' => 'form-error-msg')) ?>
<?php endif; ?>
<?php echo input_tag('config[live_api_username]', $config->get('live_api_username'), array('disabled' => $config->get('test_mode'), 'class' => 'st_paypal-live-field', 'size' => 60)) ?>
<br class="st_clear_all"/>
</div>
</div>
<div class="form-row">
<?php echo label_for('config_live_api_password', __('Hasło API'), array('class' => 'required')) ?>
<div class="content<?php if ($sf_request->hasError('config{live_api_password}')): ?> form-error<?php endif; ?>">
<?php if ($sf_request->hasError('config{live_api_password}')): ?>
<?php echo form_error('config{live_api_password}', array('class' => 'form-error-msg')) ?>
<?php endif; ?>
<?php echo input_password_tag('config[live_api_password]', $config->get('live_api_password'), array('disabled' => $config->get('test_mode'), 'class' => 'st_paypal-live-field', 'size' => 60)) ?>
<br class="st_clear_all"/>
</div>
</div>
<div class="form-row">
<?php echo label_for('config_live_api_signature', __('Podpis API'), array('class' => 'required')) ?>
<div class="content<?php if ($sf_request->hasError('config{live_api_signature}')): ?> form-error<?php endif; ?>">
<?php if ($sf_request->hasError('config{live_api_signature}')): ?>
<?php echo form_error('config{live_api_signature}', array('class' => 'form-error-msg')) ?>
<?php endif; ?>
<?php echo input_password_tag('config[live_api_signature]', $config->get('live_api_signature'), array('disabled' => $config->get('test_mode'), 'class' => 'st_paypal-live-field', 'size' => 60)) ?>
<br class="st_clear_all"/>
</div>
</div>
<?php if (SF_ENVIRONMENT == 'dev' || $sf_request->hasParameter('debug')): ?>
<div class="form-row">
<?php echo label_for('config_enabled', __('Włącz')) ?>
<div class="content">
<?php echo st_admin_checkbox_tag('config[enabled]', true, $config->get('enabled')) ?>
<br class="st_clear_all"/>
</div>
</div>
<div class="form-row">
<?php echo label_for('config_test_mode', __('Tryb testowy')) ?>
<div class="content">
<?php echo st_admin_checkbox_tag('config[test_mode]', true, $config->get('test_mode')) ?>
<br class="st_clear_all"/>
</div>
</div>
<?php endif ?>
<div class="form-row">
<?php echo label_for('config_show_shipping_info', __('Pokaż dane dostawy').' <a href="#" class="help" title="'.__('Wyświetla dane dostawy na stronie potwierdzenia płatności PayPal').'"></a>') ?>
<div class="content">
<?php echo st_admin_checkbox_tag('config[show_shipping_info]', true, $config->get('show_shipping_info')) ?>
<br class="st_clear_all"/>
</div>
</div>
</fieldset>
<fieldset id="sf_fieldset-paypal-live">
<h2><?php echo __('PayPal Express') ?></h2>
<div class="content">
<div class="form-row">
<?php echo label_for('config_express', __('Aktywuj płatność na karcie produktu')) ?>
<div class="content">
<?php echo st_admin_checkbox_tag('config[express]', true, $config->get('express')) ?>
<br class="st_clear_all"/>
</div>
</div>
<div class="form-row">
<?php echo label_for('config_show_shipping_info', __('Domyślna dostawa'));?>
<div class="content">
<?php echo select_tag('config[express_delivery]', objects_for_select($deliveries, 'getId', 'getName', $config->get('express_delivery')));?>
<br class="st_clear_all"/>
</div>
</div>
</div>
</fieldset>
<?php if (SF_ENVIRONMENT == 'dev' || $sf_request->hasParameter('debug')): ?>
<fieldset id="sf_fieldset-paypal-sandbox">
<h2><?php echo __('Konfiguracja API (tryb testowy)') ?></h2>
<div class="content">
<div class="form-row">
<?php echo label_for('config_sandbox_api_username', __('Nazwa użytkownika API'), array('class' => 'required')); ?>
<div class="content<?php if ($sf_request->hasError('config{sandbox_api_username}')): ?> form-error<?php endif; ?>">
<?php if ($sf_request->hasError('config{sandbox_api_username}')): ?>
<?php echo form_error('config{sandbox_api_username}', array('class' => 'form-error-msg')) ?>
<?php endif; ?>
<?php echo input_tag('config[sandbox_api_username]', $config->get('sandbox_api_username'), array('disabled' => !$config->get('test_mode'), 'class' => 'st_paypal-sandbox-field', 'size' => 60)) ?>
<br class="st_clear_all"/>
</div>
</div>
<div class="form-row">
<?php echo label_for('config_sandbox_api_password', __('Hasło API'), array('class' => 'required')) ?>
<div class="content<?php if ($sf_request->hasError('config{sandbox_api_password}')): ?> form-error<?php endif; ?>">
<?php if ($sf_request->hasError('config{sandbox_api_password}')): ?>
<?php echo form_error('config{sandbox_api_password}', array('class' => 'form-error-msg')) ?>
<?php endif; ?>
<?php echo input_password_tag('config[sandbox_api_password]', $config->get('sandbox_api_password'), array('disabled' => !$config->get('test_mode'), 'class' => 'st_paypal-sandbox-field', 'size' => 60)) ?>
<br class="st_clear_all"/>
</div>
</div>
<div class="form-row">
<?php echo label_for('config_sandbox_api_signature', __('Podpis API'), array('class' => 'required')) ?>
<div class="content<?php if ($sf_request->hasError('config{sandbox_api_signature}')): ?> form-error<?php endif; ?>">
<?php if ($sf_request->hasError('config{sandbox_api_signature}')): ?>
<?php echo form_error('config{sandbox_api_signature}', array('class' => 'form-error-msg')) ?>
<?php endif; ?>
<?php echo input_password_tag('config[sandbox_api_signature]', $config->get('sandbox_api_signature'), array('disabled' => !$config->get('test_mode'), 'class' => 'st_paypal-sandbox-field', 'size' => 60)) ?>
<br class="st_clear_all"/>
</div>
</div>
</div>
</fieldset>
<?php endif ?>
<?php if ($config->get('configuration_verified')): ?>
<fieldset id="sf_fieldset-paypal-account">
<h2><?php echo __('Informacje o koncie') ?></h2>
<div class="content">
<div class="form-row">
<div><?php echo __('Bilans konta') ?></div>
<div class="content" id="st_paypal-account-balance" style="margin-left: 15px;">
<?php echo image_tag('backend/stPaypalPlugin/ajax-loader.gif') ?>
</div>
</div>
<div class="form-row">
<div><?php echo __('Oczekujące płatności') ?>:</div>
<div class="content" id="st_paypal-pending-payments" style="margin-left: 15px;">
<?php echo image_tag('backend/stPaypalPlugin/ajax-loader.gif') ?>
</div>
</div>
</div>
</fieldset>
<?php endif ?>
<?php echo st_get_admin_actions(array(
array('type' => 'save', 'label' => __('Zapisz', null, 'stAdminGeneratorPlugin'))
)) ?>
</form>
<div class="clr"></div>
<?php echo st_get_admin_foot();?>
<script type="text/javascript">
jQuery(function($) {
$('#config_test_mode').on('change', function() {
var input = $(this);
if (input.prop('checked'))
{
$('.st_paypal-sandbox-field').prop('disabled', false);
$('.st_paypal-live-field').prop('disabled', true);
}
else
{
$('.st_paypal-sandbox-field').prop('disabled', true);
$('.st_paypal-live-field').prop('disabled', false);
}
});
$.get('<?php echo url_for('stPaypalBackend/ajaxPaypalAccountBalance') ?>', function(response) {
$('#st_paypal-account-balance').html(response);
});
$.get('<?php echo url_for('stPaypalBackend/ajaxPaypalPendingPayments') ?>', function(response) {
$('#st_paypal-pending-payments').html(response);
});
});
</script>

View File

@@ -0,0 +1,768 @@
<?php
class stPaypalFrontendActions extends stActions
{
protected $order = null;
protected $paypalCaller = null;
protected $orderPayment = null;
public function executeSetExpressCheckout()
{
$this->smarty = new stSmarty('stPaypalFrontend');
$config = stConfig::getInstance('stPaypal');
$order = $this->getOrder();
$controller = $this->getController();
$paypal = $this->getPaypalCallerService();
$request = new stPaypalCallerRequest();
$request->setPaymentAction('Sale');
$request->setLandingPage('Billing');
$request->setSolutionType('Sole');
$request->setAllowNote(false);
$request->setAddrOverride(false);
$request->setReqConfirmShipping(false);
$request->setNoShipping(!$config->get('show_shipping_info'));
$request->setReturnUrl($controller->genUrl('@stPaypalDoExpressCheckout?order_id=' . $order->getId() . '&order_hash=' . $order->getHashCode(), true));
$request->setCancelUrl($controller->genUrl('@stOrderSummary?id=' . $order->getId() . '&hash_code=' . $order->getHashCode(), true));
$culture = $order->getClientCulture();
if ($culture == 'pl_PL')
{
$culture = 'PL';
}
elseif ($culture == 'en_US')
{
$culture = 'US';
}
$request->setLocaleCode(strtoupper($culture));
$request->setCurrencyCode($order->getOrderCurrency()->getShortcut());
$this->processOrderBillingAddress($request);
$this->processOrderSummary($request);
$this->paypal_response = $paypal->setExpressCheckout($request);
$this->postExecute();
if ($this->paypal_response->isSuccessful())
{
$this->redirect($paypal->getExpressCheckoutUrl($this->paypal_response->getToken()));
}
else
{
if (sfConfig::get('sf_debug'))
{
throw new stPaypalCallerException(var_export($this->paypal_response->getItems(), true));
}
$content = 'SetExpressCheckout - '.$order->getId(). ":\n" . var_export($this->paypal_response->getItems(), true);
file_put_contents(sfConfig::get('sf_root_dir').'/log/paypal.txt', '['.date('d-m-Y H:i:s').'] '.$content."\n\n", FILE_APPEND);
}
}
/**
*
* @return <type>
*/
public function executeIpn()
{
$request = $this->getRequest();
$parameters = $request->getParameterHolder()->getAll();
unset($parameters['module']);
unset($parameters['action']);
unset($parameters['order_id']);
unset($parameters['order_hash']);
try
{
if (isset($parameters['test_ipn']) && $parameters['test_ipn'])
{
$response = stPaypalCallerService::curlCall('https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_notify-validate', $parameters);
}
else
{
$response = stPaypalCallerService::curlCall('https://www.paypal.com/cgi-bin/webscr?cmd=_notify-validate', $parameters);
}
if ($response == 'VERIFIED')
{
if ($parameters['payment_status'] == 'Completed')
{
$order = $this->getOrder();
if ($this->validatePayment($order, $parameters['mc_gross']))
{
$order_payment = $this->getOrderPaymentByPaymentHash('PAYPAL-' . $parameters['txn_id']);
if ($order_payment && !$order_payment->getStatus())
{
$order_payment->setStatus(true);
$order_payment->save();
}
}
}
}
}
catch(stPaypalCallerException $e)
{
file_put_contents(sfConfig::get('sf_root_dir').'/log/paypal_ipn.txt', '['.date('d-m-Y H:i:s').'] '.$e->getMessage(). '('.$e->getCode().')' ."\n".var_export($parameters, true)."\n\n", FILE_APPEND);
throw $e;
}
return sfView::HEADER_ONLY;
}
/**
*
* Finalizacja płatności Paypal Express Checkout
*
*/
public function executeDoExpressCheckout()
{
$this->smarty = new stSmarty('stPaypalFrontend');
$this->order_id = $this->getRequestParameter('order_id');
$this->hash_code = $this->getRequestParameter('order_hash');
$token = $this->getRequestParameter('token');
$controller = $this->getController();
$paypal = $this->getPaypalCallerService();
$response = $this->getExpressCheckoutDetails($token);
$request = new stPaypalCallerRequest();
$request->setPayerId($response->getPayerId());
$request->setToken($token);
$request->setPaymentAction('Sale');
$request->setButtonSource('Sote_ShoppingCart_EC_PL');
$request->setCurrencyCode($response->getCurrencyCode());
$request->setNotifyUrl($controller->genUrl('@stPaypalIpn?order_id=' . $this->order_id . '&order_hash=' . $this->hash_code, true));
$request->setAmt($response->getAmt());
$request->setItemAmt($response->getItemAmt());
$request->setItems($response->getItems());
$this->paypal_response = $paypal->doExpressCheckoutPayment($request);
if ($this->paypal_response->isSuccessful())
{
$order = OrderPeer::retrieveByIdAndHashCode($this->order_id, $this->hash_code);
$order_payment = $order->getOrderPayment();
if ($this->paypal_response->getPaymentStatus() == 'Completed')
{
$order_payment->setStatus(true);
}
$order_payment->setHash('PAYPAL-' . $this->paypal_response->getTransactionId());
$order_payment->save();
}
else
{
if (sfConfig::get('sf_debug'))
{
throw new stPaypalCallerException($response->getItemAmt() . ':' . $response->getShippingAmt() . ':' . $response->getAmt() . var_export($this->paypal_response->getItems(), true));
}
$content = 'DoExpressCheckout - '.$this->order_id. ":\n" . var_export($this->paypal_response->getItems(), true);
file_put_contents(sfConfig::get('sf_root_dir').'/log/paypal.txt', '['.date('d-m-Y H:i:s').'] '.$content."\n\n", FILE_APPEND);
}
}
/**
*
* Wykonuje żądanie o szczegółowe informacje transakcji Paypal
*
* @param string $token Unikalny klucz otrzymany z Paypal
* @return stPaypalCallerResponse Odpowiedź
*/
protected function getExpressCheckoutDetails($token)
{
$paypal = $this->getPaypalCallerService();
$request = new stPaypalCallerRequest();
$request->setToken($token);
return $paypal->getExpressCheckoutDetails($request);
}
/**
*
* Uzupełnia żądanie o dane produktów z zamówienia
*
* @param stPaypalCallerRequest $request Żądanie API
*/
protected function processOrderProducts($request)
{
$order_products = $this->getOrder()->getOrderProducts();
foreach ($order_products as $index => $order_product)
{
$item = new stPaypalCallerItem($index);
$item->setName($order_product->getName());
$item->setNumber($order_product->getCode());
$item->setAmt($order_product->getPrice(false, true));
$item->setQty($order_product->getQuantity());
$item->setTaxAmt($order_product->getTaxAmount(true));
if ($order_product->getOptions())
{
$item->setDesc(implode(', ', $order_product->getOptions(true)));
}
$request->addItem($item);
$this->itemAmount += $order_product->getTotalAmount(false, true);
$this->itemTaxAmount += $order_product->getTotalTaxAmount(true);
}
}
/**
*
* Uzupełnia żądanie o dane podsumowania z zamówienia
*
* @param stPaypalCallerRequest $request Żądanie API
*/
protected function processOrderSummary($request)
{
$order = $this->getOrder();
$item = new stPaypalCallerItem(0);
$item->setName($this->getContext()->getI18N()->__('Zamówienie numer %number%', array('%number%' => $order->getNumber()), 'stOrder'));
$item->setAmt($order->getUnpaidAmount());
$item->setQty(1);
$request->addItem($item);
$unpaid_amount = $order->getUnpaidAmount();
$request->setAmt($unpaid_amount);
$request->setItemAmt($unpaid_amount);
}
/**
*
* Uzupełnia żądanie o dane billingowe z zamówienia
*
* @param stPaypalCallerRequest $request Żądanie API
*/
protected function processOrderBillingAddress($request)
{
$billing = $this->order->getOrderUserDataBilling();
$request->setEmail($this->order->getGuardUser()->getUsername());
if ($billing)
{
$request->setShipToName($billing->getFullName());
$request->setShipToStreet($billing->getAddress());
if ($billing->getAddressMore())
{
$request->setShipToStreet2($billing->getAddressMore());
}
$request->setShipToCity($billing->getTown());
$request->setShipToZip($billing->getCode());
$request->setShipToPhoneNum($billing->getPhone());
$request->setShipToCountryCode($billing->getCountry()->getIsoA2());
}
}
/**
* Aktualizuje status płatności
*/
protected function updatePaymentStatus($paypal_status, $payment_hash)
{
$payment = $this->getOrderPaymentByPaymentHash($payment_hash);
if ($paypal_status == 'Completed' && $payment->getStatus() == false)
{
$payment->setStatus(true);
$payment->save();
}
}
protected function validatePayment($order, $pay_amount)
{
$pay_amount = stCurrency::round($pay_amount);
$order_amount = stCurrency::round(stPayment::getUnpayedAmountByOrder($order));
return $order_amount == $pay_amount;
}
/**
*
* Pobiera aktualne zamówienie
*
* @return Order
*/
protected function getOrder()
{
if (is_null($this->order))
{
$this->order = OrderPeer::retrieveByIdAndHashCode($this->getRequestParameter('order_id'), $this->getRequestParameter('order_hash'));
}
return $this->order;
}
/**
*
* Pobiera płatność dla zamówienia
*
* @param int $payment_hash Unikalny kod płatności
* @return Payment
*/
protected function getOrderPaymentByOrder($order_id, $order_hash)
{
$c = new Criteria();
$c->add(OrderPeer::ID, $this->getRequestParameter('order_id', $order_id));
$c->add(OrderPeer::HASH_CODE, $this->getRequestParameter('order_hash', $order_hash));
$c->addJoin(OrderHasPaymentPeer::PAYMENT_ID, PaymentPeer::ID);
$c->addJoin(OrderHasPaymentPeer::ORDER_ID, OrderPeer::ID);
return PaymentPeer::doSelectOne($c);
}
protected function getOrderPaymentByPaymentHash($payment_hash)
{
$c = new Criteria();
$c->add(PaymentPeer::HASH, $payment_hash);
return PaymentPeer::doSelectOne($c);
}
/**
*
* Pobiera instancje stPaypalCallerService
*
* @return stPaypalCallerService
*/
protected function getPaypalCallerService()
{
if (is_null($this->paypalCaller))
{
$config = stConfig::getInstance($this->getContext(), 'stPaypal');
$this->paypalCaller = stPaypalCallerService::getInstance();
if ($config->get('test_mode'))
{
$this->paypalCaller->setApiUsername($config->get('sandbox_api_username'));
$this->paypalCaller->setApiPassword($config->get('sandbox_api_password'));
$this->paypalCaller->setApiSignature($config->get('sandbox_api_signature'));
$this->paypalCaller->setApiEnvironment('sandbox');
}
else
{
$this->paypalCaller->setApiUsername($config->get('live_api_username'));
$this->paypalCaller->setApiPassword($config->get('live_api_password'));
$this->paypalCaller->setApiSignature($config->get('live_api_signature'));
}
}
return $this->paypalCaller;
}
public function executeBuyProduct() {
$quantity = $this->getRequestParameter('quantity', 1);
$options = $this->getRequestParameter('option_list', null);
$config = stConfig::getInstance('stPaypal');
$controller = $this->getController();
if (!$config->get('express'))
return $this->redirect($controller->genUrl('@homepage', true));
$paypal = $this->getPaypalCallerService();
$paypal->setApiVersion(108);
/**
* @var Product $product
*/
$product = ProductPeer::retrieveByPK($this->getRequestParameter('product_id', null));
$delivery = DeliveryPeer::retrieveByPK($config->get('express_delivery'));
if (is_object($product) && is_object($delivery)) {
$request = new stPaypalCallerRequest();
$request->setPaymentRequest_0_PaymentAction('Sale');
$request->setLandingPage('Billing');
$request->setSolutionType('Sole');
$request->setAllowNote(true);
$request->setNoShipping(0);
$request->setAddrOverride(true);
$request->setReqConfirmShipping(false);
$request->setReturnUrl($controller->genUrl('@stPaypalCreateOrder', true));
$request->setCancelUrl($controller->genUrl('@stProductUrl?url='.$product->getUrl(), true));
$request->setLocaleCode($this->getUser()->getCulture());
$request->setPaymentRequest_0_CurrencyCode(stCurrency::getInstance($this->getContext())->get()->getShortcut());
if ($product->getOptHasOptions() > 1) {
// $selectedOption = $name = $cOptions = array();
// $ids = explode('-', $options);
// $options = ProductOptionsValuePeer::retrieveByPKs($ids);
// foreach ($ids as $ids) {
// $selectedOption[$option->getProductOptionsField()->getId()] = $option->getId();
// $name[$option->getProductOptionsField()->getId()] = $option->getProductOptionsField()->getName().': '.$option->getValue();
// $cOptions[$option->getId()] = $option->getValue();
// }
// ksort($selectedOption);
// ksort($name);
// $x = null;
// stNewProductOptions::updateProductRecursive($product, ProductOptionsValuePeer::doSelectByProduct($product), 'brutto', $selectedOption, $x);
$ids = explode('-', $options);
$selectedOptions = array();
foreach ($ids as $id)
{
$selectedOptions[] = ProductOptionsValuePeer::retrieveByPK($id);
}
stNewProductOptions::updateProductBySelectedOptions($product, $selectedOptions);
$option_label = array();
foreach ($product->getPriceModifiers() as $modifier)
{
$options_label[] = $modifier['custom']['field'].': '.$modifier['custom']['label'];
}
$name = $product->getName().' ('.implode(', ', $options_label).')';
} else {
$name = $product->getName();
}
if (!stPayPalExpressCheckout::validateProduct($product, $quantity)) {
return $this->redirect($controller->genUrl('@stProductUrl?url='.$product->getUrl(), true));
}
$item = new stPaypalCallerItem(0);
$item->setPaymentRequest_0_Name($name);
$item->setPaymentRequest_0_Amt($product->getPriceBrutto(true));
$item->setPaymentRequest_0_Number($product->getCode());
$item->setPaymentRequest_0_Qty($quantity);
$request->addItem($item);
$request->setPaymentRequest_0_ItemAmt($item->getPaymentRequest_0_Amt()*$quantity);
$type = $delivery->getSectionCostType();
switch ($type) {
case "ST_BY_ORDER_AMOUNT":
$value = $request->getPaymentRequest_0_ItemAmt();
break;
case "ST_BY_ORDER_QUANTITY":
$value = $quantity;
break;
case "ST_BY_ORDER_WEIGHT":
$value = ($product->getWeight()*$quantity);
break;
}
$additionalCost = 0;
if ($product->getDeliveryPrice())
{
$price_type = stConfig::getInstance('stProduct')->get('delivery_price_type', 'netto');
if ($price_type == 'netto')
{
$deliveryPrice = stPrice::calculate($product->getDeliveryPrice(), $delivery->getTax()->getVat());
}
else
{
$deliveryPrice = $product->getDeliveryPrice();
}
$additionalCost += $deliveryPrice;
}
if ($type) {
$c = new Criteria();
$c->add(DeliverySectionsPeer::VALUE_FROM, $value, Criteria::LESS_EQUAL);
$c->setLimit(1);
$c->addDescendingOrderByColumn(DeliverySectionsPeer::VALUE_FROM);
$tmp = $delivery->getDeliverySectionss($c);
if (isset($tmp[0]) && is_object($tmp[0])) {
$additionalCost = $tmp[0]->getCostBrutto(true);
}
}
if ($delivery->getFreeDelivery() && $request->getPaymentRequest_0_ItemAmt() >= $delivery->getFreeDelivery()) {
$delivery->setCostBrutto(0);
}
$request->setPaymentRequest_0_ShippingAmt($delivery->getCostBrutto(true) + $additionalCost);
$request->setPaymentRequest_0_Amt($request->getPaymentRequest_0_ItemAmt()+$request->getPaymentRequest_0_ShippingAmt());
$request->setPaymentRequest_0_Custom(json_encode(array('o' => $options)));
$this->paypalResponse = $paypal->setExpressCheckout($request);
$this->postExecute();
if ($this->paypalResponse->isSuccessful()) {
return $this->redirect($paypal->getExpressCheckoutUrl($this->paypalResponse->getToken()));
} else {
if (sfConfig::get('sf_debug'))
throw new stPaypalCallerException(var_export($this->paypalResponse->getItems(), true));
}
}
}
public function executeCreateOrder() {
$config = stConfig::getInstance('stPaypal');
$controller = $this->getController();
if (!$config->get('express'))
return $this->redirect($controller->genUrl('@homepage', true));
$paypal = $this->getPaypalCallerService();
$paypal->setApiVersion(108);
$token = $this->getRequestParameter('token');
$response = $this->getExpressCheckoutDetails($token);
if (!$response->getEmail())
return $this->redirect($controller->genUrl('@homepage', true));
$custom = $response->getPaymentRequest_0_Custom();
if (!empty($custom))
$custom = json_decode($custom, true);
else
$custom = array();
$c = new Criteria();
$c->add(ProductPeer::CODE, $response->getL_PaymentRequest_0_Number0());
$product = ProductPeer::doSelectOne($c);
if(is_object($product)) {
if ($product->getOptHasOptions() && $custom['o']) {
// $selectedOption = $ids = array();
$ids = explode("-", $custom['o']);
// $options = ProductOptionsValuePeer::retrieveByPKs($ids);
// foreach ($options as $option)
// $selectedOption[$option->getProductOptionsField()->getId()] = $option->getId();
// ksort($selectedOption);
// $x = null;
// stNewProductOptions::updateProductRecursive($product, ProductOptionsValuePeer::doSelectByProduct($product), 'brutto', $selectedOption, $x);
$selectedOptions = array();
foreach ($ids as $id)
{
$selectedOptions[] = ProductOptionsValuePeer::retrieveByPK($id);
}
stNewProductOptions::updateProductBySelectedOptions($product, $selectedOptions);
}
if (!stPayPalExpressCheckout::validateProduct($product, $response->getL_PaymentRequest_0_Qty0())) {
return $this->redirect($controller->genUrl('@stProductUrl?url='.$product->getUrl(), true));
}
} else {
return $this->redirect($controller->genUrl('@homepage', true));
}
$delivery = DeliveryPeer::retrieveByPK($config->get('express_delivery'));
$c = new Criteria();
$c->add(CountriesPeer::ISO_A2, $response->getPaymentRequest_0_ShipToCountryCode());
$country = CountriesPeer::doSelectOne($c);
if(is_object($delivery) && is_object($country)) {
$c = new Criteria();
$c->add(CountriesAreaHasCountriesPeer::COUNTRIES_ID, $country->getId());
$c->add(CountriesAreaHasCountriesPeer::COUNTRIES_AREA_ID, $delivery->getCountriesAreaId());
if (!CountriesAreaHasCountriesPeer::doCount($c)) {
stPayPalExpressCheckout::returnValidareProductError($this->getContext()->getI18N()->__('Dostawa nie jest możliwa do wskazanego kraju'));
return $this->redirect($controller->genUrl('@stProductUrl?url='.$product->getUrl(), true));
}
}
$ex = new stPayPalExpressCheckout();
$order = @$ex->addOrder($response, $product);
$this->sendMail($order);
if(is_object($order))
$this->redirect($controller->genUrl('@stPaypalDoExpressCheckoutForProduct?order_id='.$order->getId().'&order_hash='.$order->getHashCode().'&token='.$token, true));
else
throw new Exception('Order object don\'t exists.');
}
public function executeDoExpressCheckoutForProduct() {
$this->smarty = new stSmarty('stPaypalFrontend');
$this->order_id = $this->getRequestParameter('order_id');
$this->hash_code = $this->getRequestParameter('order_hash');
$token = $this->getRequestParameter('token');
$config = stConfig::getInstance('stPaypal');
$controller = $this->getController();
if (!$config->get('express'))
return $this->redirect($controller->genUrl('@homepage', true));
$paypal = $this->getPaypalCallerService();
$response = $this->getExpressCheckoutDetails($token);
$request = new stPaypalCallerRequest();
$request->setPayerId($response->getPayerId());
$request->setToken($token);
$request->setPaymentAction('Sale');
$request->setButtonSource('SOTE_Cart_Expresscheckout');
$request->setCurrencyCode($response->getCurrencyCode());
$request->setNotifyUrl($controller->genUrl('@stPaypalIpn?order_id=' . $this->order_id . '&order_hash=' . $this->hash_code, true));
$request->setAmt($response->getAmt());
$this->paypal_response = $paypal->doExpressCheckoutPayment($request);
if ($this->paypal_response->isSuccessful())
{
$order = OrderPeer::retrieveByIdAndHashCode($this->order_id, $this->hash_code);
$order_payment = $order->getOrderPayment();
if ($this->paypal_response->getPaymentStatus() == 'Completed')
{
$order_payment->setStatus(true);
}
$order_payment->setHash('PAYPAL-' . $this->paypal_response->getTransactionId());
$order_payment->save();
}
else
{
if (sfConfig::get('sf_debug'))
{
throw new stPaypalCallerException($response->getItemAmt() . ':' . $response->getShippingAmt() . ':' . $response->getAmt() . var_export($this->paypal_response->getItems(), true));
}
}
}
public function sendMail($order) {
$this->smarty = new stSmarty('stOrder');
$config_points = stConfig::getInstance('stPointsBackend');
$config_points->setCulture(sfContext::getInstance()->getUser()->getCulture());
$mail_config = stConfig::getInstance('stMailAccountBackend');
$mailHtmlHead = stMailer::getHtmlMailDescription("header");
$mailHtmlFoot = stMailer::getHtmlMailDescription("footer");
$mailHtmlHeadContent = stMailer::getHtmlMailDescription("top_order_confirm");
$mailHtmlFootContent = stMailer::getHtmlMailDescription("bottom_order_confirm");
$sendOrderToUserHtmlMailMessage = stMailTemplate::render('stOrder/sendOrderToUserHtml', array('order' => $order, 'head' => $mailHtmlHead, 'foot' => $mailHtmlFoot, 'head_content' => $mailHtmlHeadContent, 'foot_content' => $mailHtmlFootContent, 'smarty' => $this->smarty, 'config_points' => $config_points, 'mail_config' => $mail_config));
$sendOrderToUserPlainMailMessage = stMailTemplate::render('stOrder/sendOrderToUserPlain', array('order' => $order, 'smarty' => $this->smarty, 'config_points' => $config_points));
$mail = stMailer::getInstance();
$mail->setSubject($this->getRequest()->getHost().' - '.__('zamówienie numer', null, 'stOrder').': '.$order->getNumber())->setHtmlMessage($sendOrderToUserHtmlMailMessage)->setPlainMessage($sendOrderToUserPlainMailMessage)->setTo($order->getSfGuardUser()->getUsername())->sendToClient();
$user = $this->getContext()->getUser();
$culture = $user->getCulture();
$c = new Criteria();
$c->add(LanguagePeer::IS_DEFAULT_PANEL, 1);
$language = LanguagePeer::doSelectOne($c);
if (is_object($language))
$user->setCulture($language->getOriginalLanguage());
$sendOrderToAdminHtmlMailMessage = stMailTemplate::render('stOrder/sendOrderToAdminHtml', array('order' => $order, 'head' => $mailHtmlHead, 'foot' => $mailHtmlFoot, 'smarty' => $this->smarty, 'config_points' => $config_points, 'mail_config' => $mail_config));
$sendOrderToAdminPlainMailMessage = stMailTemplate::render('stOrder/sendOrderToAdminPlain', array('order' => $order, 'smarty' => $this->smarty, 'config_points' => $config_points));
$mail = stMailer::getInstance();
$mail->setSubject($this->getRequest()->getHost().' - '.__('złożono nowe zamówienie numer', null, 'stOrder').': '.$order->getNumber())->setHtmlMessage($sendOrderToAdminHtmlMailMessage)->setPlainMessage($sendOrderToAdminPlainMailMessage)->setReplyTo($order->getSfGuardUser()->getUsername());
stEventDispatcher::getInstance()->notify(new sfEvent($mail, 'stOrderActions.sendMailWithOrderToAdmin', array('order' => $order)));
$ret = $mail->sendToMerchant();
$user->setCulture($culture);
return $ret;
}
}

View File

@@ -0,0 +1,14 @@
<?php
class stPaypalFrontendComponents extends sfComponents
{
public function executeShowPayment()
{
$order = stPaymentType::getOrderInSummary();
$url = $this->getContext()->getController()->genUrl('@stPaypalSetExpressCheckout?order_id=' . $order->getId() . '&order_hash=' . $order->getHashCode());
$this->getContext()->getController()->redirect($url);
throw new sfStopException();
}
}

View File

@@ -0,0 +1,9 @@
<?php
st_theme_use_stylesheet('stPaypal.css');
$smarty->assign('successful', $paypal_response->isSuccessful());
$smarty->assign('already_payed', $paypal_response->hasError(10412) || $paypal_response->hasError(10415));
$smarty->assign('pending', $paypal_response->getPaymentStatus() == 'Pending');
$smarty->assign('paypal_button', link_to(image_tag('https://www.paypal.com/' . stPaypal::getButtonLocaleByCulture($sf_user->getCulture()) . '/i/btn/btn_xpressCheckout.gif', array('alt' => __('Zapłać w systemie PayPal'))), '@stPaypalSetExpressCheckout?order_id=' . $order_id . '&order_hash=' . $hash_code));
$smarty->display('paypal_return.html');

View File

@@ -0,0 +1,10 @@
<?php
st_theme_use_stylesheet('stPaypal.css');
$smarty->assign('successful', $paypal_response->isSuccessful());
$smarty->assign('already_payed', $paypal_response->hasError(10412) || $paypal_response->hasError(10415));
$smarty->assign('pending', $paypal_response->getPaymentStatus() == 'Pending');
$smarty->assign('paypal_button', link_to(image_tag('https://www.paypal.com/' . stPaypal::getButtonLocaleByCulture($sf_user->getCulture()) . '/i/btn/btn_xpressCheckout.gif', array('alt' => __('Zapłać w systemie PayPal'))), '@stPaypalSetExpressCheckout?order_id=' . $order_id . '&order_hash=' . $hash_code));
$smarty->display('paypal_return.html');
?>

View File

@@ -0,0 +1,4 @@
<?php
st_theme_use_stylesheet('stPaypal.css');
$smarty->display('paypal_set_express_checkout.html');
?>

View File

@@ -0,0 +1,22 @@
<div class="st_application">
<h1 class="st_title">
{__ text="Paypal"}
</h1>
{if $successful}
<p id="st_paypal-message-success">
{__ text="Dziękujemy za dokonanie płatności. Twoje zamówienie zostanie zrealizowane po otrzymaniu płatności."}
</p>
{elseif $already_payed}
<p id="st_paypal-message-failed">
{__ text="Zamówienie zostało już opłacone."}
</p>
{else}
<p id="st_paypal-message-failed">
{__ text="Wystąpił problem podczas realizowania płatności za pośrednictwem serwisu Paypal."}
</p>
<p id="st_paypal-checkout-button">
{$paypal_button}
</p>
{/if}
</div>

View File

@@ -0,0 +1,8 @@
<div class="st_application">
<h1 class="st_title">
{__ text="Paypal"}
</h1>
<p id="st_paypal-message-failed">
{__ text="Wystąpił problem podczas realizowania płatności za pośrednictwem serwisu Paypal."}
</p>
</div>

View File

@@ -0,0 +1,12 @@
<div class="st_application">
<h1 class="st_title">
{__ text="Paypal"}
</h1>
<p id="st_paypal-message-success">
{if $already_payed}
{__ text="Zamówienie zostało już opłacone."}
{else}
{$paypal_button}
{/if}
</p>
</div>

View File

@@ -0,0 +1,31 @@
<div id="stPayment_return" class="box roundies">
<div class="title">
<h2>
<img src="{image_path image='stPaypalPlugin/paypal_logo.png'}" alt="paypal" />
</h2>
</div>
<div class="content">
{if $successful}
<p id="st_paypal-message-success">
{__ text="Dziękujemy za dokonanie płatności. Twoje zamówienie zostanie zrealizowane po otrzymaniu płatności."}
</p>
<div class="buttons important">
<a class="important" href="/">{__ text="Przejdź do strony głównej" langCatalogue="stPaypalFrontend"}</a>
</div>
{elseif $already_payed}
<p id="st_paypal-message-failed">
{__ text="Zamówienie zostało już opłacone."}
</p>
<div class="buttons important">
<a class="important" href="/">{__ text="Przejdź do strony głównej" langCatalogue="stPaypalFrontend"}</a>
</div>
{else}
<p id="st_paypal-message-failed">
{__ text="Wystąpił problem podczas realizowania płatności za pośrednictwem serwisu Paypal."}
</p>
<p id="st_paypal-checkout-button">
{$paypal_button}
</p>
{/if}
</div>
</div>

View File

@@ -0,0 +1,3 @@
<p id="st_paypal-message-failed">
{__ text="Wystąpił problem podczas realizowania płatności za pośrednictwem serwisu Paypal."}
</p>

View File

@@ -0,0 +1,12 @@
<div id="st_box_payment">
<span>
{$description}
</span>
<p id="st_paypal-message-success">
{if $already_payed}
{__ text="Zamówienie zostało już opłacone."}
{else}
{$paypal_button}
{/if}
</p>
</div>

View File

@@ -0,0 +1,20 @@
{set layout="one_column"}
<div id="payment">
<div class="panel panel-default center-block">
<div class="panel-heading">
{__ text="PayPal"}
</div>
<div class="panel-body text-center">
{if $successful}
<p>{__ text="Dziękujemy za dokonanie płatności. Twoje zamówienie zostanie zrealizowane po otrzymaniu płatności."}</p>
<a href="/" class="btn btn-primary">{__ text="Wróć do zakupów" langCatalogue="stPayment"}</a>
{elseif $already_payed}
<p>{__ text="Zamówienie zostało już opłacone."}</p>
<a href="/" class="btn btn-primary">{__ text="Wróć do zakupów" langCatalogue="stPayment"}</a>
{else}
<p>{__ text="Wystąpił problem podczas realizowania płatności za pośrednictwem serwisu Paypal."}</p>
<p>{$paypal_button}</p>
{/if}
</div>
</div>
</div>

View File

@@ -0,0 +1,3 @@
<p id="st_paypal-message-failed">
{__ text="Wystąpił problem podczas realizowania płatności za pośrednictwem serwisu Paypal."}
</p>

View File

@@ -0,0 +1,12 @@
<div class="panel panel-default center-block">
<div class="panel-heading">
{__ text="PayPal"}
</div>
<div class="panel-body text-center">
{if $already_payed}
<p>{__ text="Zamówienie zostało już opłacone."}</p>
{else}
{$paypal_button}
{/if}
</div>
</div>