2015-11-23 12:58:14 +01:00
var React = require ( 'react' ) ;
var ItemActions = require ( '../../actions/itemActions' ) ;
var NavigationActions = require ( '../../actions/navigationActions' ) ;
var NavigationStore = require ( '../../stores/navigationStore' ) ;
2016-01-11 08:53:03 +01:00
var CartStore = require ( '../../stores/cartStore' ) ;
var CartActions = require ( '../../actions/cartActions' ) ;
2015-11-23 12:58:14 +01:00
var Globals = require ( '../../globals' ) ;
var Router = require ( 'react-router' ) ;
2016-01-05 09:31:51 +01:00
var PaypalButton = React . createClass ( {
2015-11-23 12:58:14 +01:00
render : function ( ) {
2016-01-11 08:53:03 +01:00
var deliveryDestination = JSON . stringify (
{
'anonymous_id_string' : this . props . deliveryDestination . get ( 'anonymous_id_string' ) ,
'user_id' : this . props . deliveryDestination . get ( 'user_id' )
} ) ;
2016-01-07 09:06:54 +01:00
var amount = Globals . ConvertToEuro ( this . props . amount ) ;
var deliveryCost = Globals . ConvertToEuro ( this . props . deliveryCost ) ;
2016-01-07 09:19:25 +01:00
var notifyUrl = Globals . ApiUrl + "/payment/confirmation" ;
var root = location . protocol + '//' + location . host ;
2016-01-11 08:53:03 +01:00
var return _url = root + "/hvala" ;
var cancel _return _url = root + "/dostava" ;
2016-01-07 08:58:37 +01:00
return (
2016-01-11 08:53:03 +01:00
< button onClick = { this . _onPaypalClick } disabled = { this . props . disabled } type = "button" className = "btn mybutton payment-btn" > Pay with paypal
< form id = "paypal_form" className = "hidden" action = "https://www.paypal.com/cgi-bin/webscr" method = "post" target = "_top" >
2016-01-05 09:31:51 +01:00
< input type = "hidden" name = "cmd" value = "_xclick" / >
2016-01-07 09:19:25 +01:00
< input type = "hidden" name = "business" value = { Globals . PaypalId } / >
2016-01-05 09:31:51 +01:00
< input type = "hidden" name = "lc" value = "BA" / >
2016-01-11 08:53:03 +01:00
< input type = "hidden" name = "item_name" value = "Item" / >
2016-01-13 09:26:28 +01:00
< input type = "hidden" name = "item_number" value = { this . props . cartId } / >
2016-01-07 09:06:54 +01:00
< input type = "hidden" name = "amount" value = { amount } / >
2016-01-05 09:31:51 +01:00
< input type = "hidden" name = "currency_code" value = "EUR" / >
< input type = "hidden" name = "button_subtype" value = "services" / >
< input type = "hidden" name = "no_note" value = "0" / >
< input type = "hidden" name = "cn" value = "Napomena:" / >
< input type = "hidden" name = "no_shipping" value = "1" / >
< input type = "hidden" name = "rm" value = "1" / >
2016-01-07 09:19:25 +01:00
< input type = "hidden" name = "return" value = { return _url } / >
< input type = "hidden" name = "cancel_return" value = { cancel _return _url } / >
2016-01-07 09:06:54 +01:00
< input type = "hidden" name = "shipping" value = { deliveryCost } / >
2016-01-05 09:31:51 +01:00
< input type = "hidden" name = "bn" value = "PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted" / >
< input type = "image" src = "https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border = "0" name = "submit" alt = "PayPal - The safer, easier way to pay online!" / >
< img alt = "" border = "0" src = "https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width = "1" height = "1" / >
2016-01-07 09:19:25 +01:00
< input name = "notify_url" value = { notifyUrl } type = "hidden" / >
2016-01-07 08:58:37 +01:00
< input name = "custom" value = { deliveryDestination } type = "hidden" / >
2016-01-05 09:31:51 +01:00
< / f o r m >
2016-01-11 08:53:03 +01:00
< / b u t t o n >
2016-01-05 09:31:51 +01:00
) ;
2016-01-11 08:53:03 +01:00
} ,
_onPaypalClick : function ( e ) {
CartActions . changeDeliveryDestinationProperty ( 'payment_method' , 'paypal' ) ;
CartStore . saveDeliveryDestinationAnd ( function ( ) {
$ ( "#paypal_form" ) . submit ( ) ;
} ) ;
2015-11-23 12:58:14 +01:00
}
} ) ;
2016-01-05 09:31:51 +01:00
module . exports = PaypalButton ;