<?php
namespace Website\Widgets\PaypalButton; use Moto; class Widget extends Moto\System\Widgets\AbstractWidget { protected $_name = 'paypal_button'; protected static $_defaultProperties = array( 'preset' => 'default', 'animation' => '', 'align' => array( 'desktop' => 'left', 'tablet' => '', 'mobile-v' => '', 'mobile-h' => '', ), 'spacing' => array( 'top' => 'auto', 'right' => 'auto', 'bottom' => 'auto', 'left' => 'auto', ), 'buttonConfig' => array( 'linkTarget' => '_blank', 'businessID' => '', 'itemName' => '', 'itemID' => '', 'currency' => 'USD', 'locale' => 'en_US', 'displayType' => 'paypal', 'style' => 'default', 'payPalButtonType' => 'buynow', 'buynow' => array( 'amount' => '', 'shippingRate' => '', 'taxAmount' => '', 'text' => 'buynow' ), 'donate' => array( 'contributionAmountType' => 'own', 'contributionAmount' => '' ) ), 'customImageData' => array( 'id' => null, 'src' => '', 'alt' => '', 'title' => '', 'thumbnail' => '' ), 'themeButtonData' => array( 'label' => 'Buy Now', 'preset' => 'default', 'size' => 'medium' ) ); protected $_templateType = 'templates'; protected $_widgetId = true; public function getImageUrl() { $url = 'https://www.paypalobjects.com/'; $url .= $this->properties['buttonConfig']['locale']; $url .= '/i/btn/btn_'; if ($this->properties['buttonConfig']['payPalButtonType'] === 'buynow') { $url .= $this->properties['buttonConfig']['buynow']['text']; } else { $url .= $this->properties['buttonConfig']['payPalButtonType']; } if ($this->properties['buttonConfig']['style'] === 'default' ) { $url .= 'CC_LG'; } elseif ($this->properties['buttonConfig']['style'] === 'small') { $url .= '_SM'; } else { $url .= '_LG'; } $url .= '.gif'; return $url; } } 