Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function()
- {
- var paypalButtonData;
- var returnPaypalButton = function( buttonData )
- {
- return '<form method="post" action="https://www.paypal.com/cgi-bin/webscr" class="paypal-button" target="_top" style="opacity: 1;">' +
- '<input type="hidden" name="button" value="buynow">' +
- '<input type="hidden" name="business" value="'+ buttonData.account +'">' +
- '<input type="hidden" name="item_name" value="'+ buttonData.itemName +'">' +
- '<input type="hidden" name="quantity" value="1">' +
- '<input type="hidden" name="amount" value="'+ buttonData.cost +'">' +
- '<input type="hidden" name="currency_code" value="'+ buttonData.currency +'">' +
- '<input type="hidden" name="no_shipping" value="' + buttonData.shipping + '">' +
- '<input type="hidden" name="shipping" value="'+ buttonData.shippingRate +'">' +
- '<input type="hidden" name="tax" value="">' +
- '<input type="hidden" name="return" value="http://' + window.location.hostname + '/paypal/checkout' + '">' +
- '<input type="hidden" name="cancel_return" value="http://' + window.location.hostname + '/paypal/checkout' + '">' +
- '<input type="hidden" name="notify_url" value="http://' + window.location.hostname + '/paypal/ipn' + '">' +
- '<input type="hidden" name="cmd" value="_xclick">' +
- '<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted">' +
- '<input type="image" src="https://www.paypalobjects.com/en_US/GB/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_GB/i/scr/pixel.gif" width="1" height="1">' +
- '</form>';
- };
- CKEDITOR.dialog.add( 'paypalCreateSingleButton', function( editor )
- {
- var lang = editor.lang.paypal;
- return {
- title : CKEDITOR.env.ie ? lang.dlgTitle : lang.title,
- minWidth : 300,
- minHeight : 250,
- contents : [
- {
- id: 'paypal1',
- label: '',
- title: '',
- expand: false,
- padding: 0,
- elements: [
- {
- type: 'text',
- id: 'CKpaypal-merchantEmail',
- label: lang.labelMerchantEmail + ' *',
- validate: function()
- {
- if( !this.getValue() )
- {
- document.getElementById( 'CKpaypal-validationMessages' ).innerHTML = lang.validateMerchantEmail;
- return false;
- };
- },
- commit: function()
- {
- paypalButtonData.account = this.getValue();
- }
- },
- {
- type: 'text',
- id: 'CKpaypal-itemName',
- label: lang.labelitemName + ' *',
- commit: function()
- {
- paypalButtonData.itemName = this.getValue();
- }
- },
- {
- type: 'select',
- id: 'CKpaypal-currency',
- label: lang.labelcurrency + ' *',
- items: [ ['Please select one:'],['CAD'],['EUR'],['GBP'],['NZD'],['USD'] ],
- validate: function()
- {
- if( this.getValue() === 'Please select one:' )
- {
- document.getElementById( 'CKpaypal-validationMessages' ).innerHTML = lang.validatecurrency;
- return false;
- };
- },
- commit: function()
- {
- paypalButtonData.currency = this.getValue();
- }
- },
- {
- type: 'text',
- id: 'CKpaypal-price',
- label: lang.labelprice + ' *',
- labelStyle: 'margin-top:10px;float:left',
- inputStyle: 'float:left',
- commit: function()
- {
- paypalButtonData.cost = this.getValue();
- }
- },
- {
- type: 'select',
- id: 'CKpaypal-shipping',
- label: lang.labelshipping + '*',
- items: [ ['Please select one:'],['yes'],['no'] ],
- validate: function()
- {
- if( this.getValue() === 'Please select one:' )
- {
- document.getElementById( 'CKpaypal-validationMessages' ).innerHTML = lang.validateshipping;
- return false;
- };
- },
- commit: function()
- {
- var shippingValue = this.getValue();
- paypalButtonData.shipping = ( this.getValue() === 'yes' ? 2 : 1 );
- }
- },
- {
- type: 'text',
- id: 'CKpaypal-shippingRate',
- label: lang.labelshippingRate + ' *',
- labelStyle: 'margin-top:10px;float:left',
- inputStyle: 'float:left',
- commit: function()
- {
- paypalButtonData.shippingRate = ( this.getValue() ? this.getValue() : 0 );
- }
- },
- {
- type: 'html',
- html: '<div id="CKpaypal-validationMessages" style="color:red;font-weight:bold;margin-top:20px;"></div>'
- }
- ]
- }
- ],
- onOk: function()
- {
- this.commitContent();
- var paypalButton = returnPaypalButton( paypalButtonData );
- editor.insertHtml(paypalButton);
- return;
- },
- onShow: function()
- {
- paypalButtonData = {};
- document.getElementById( 'CKpaypal-validationMessages' ).innerHTML = '';
- return;
- }
- };
- });
- })();
Add Comment
Please, Sign In to add comment