├── .gitignore ├── CHANGELOG.md ├── LICENSE.md ├── README.EN.md ├── README.md ├── app ├── code │ └── community │ │ └── PayU │ │ └── Account │ │ ├── Block │ │ ├── Adminhtml │ │ │ └── Block │ │ │ │ └── System │ │ │ │ └── Config │ │ │ │ └── Form │ │ │ │ └── Fieldset.php │ │ ├── Form │ │ │ ├── Abstract.php │ │ │ ├── PayuAccount.php │ │ │ └── PayuCard.php │ │ └── UpdateInfo.php │ │ ├── Helper │ │ └── Data.php │ │ ├── Model │ │ ├── Config.php │ │ ├── CreateOrder.php │ │ ├── GetPayMethods.php │ │ └── Method │ │ │ ├── Abstract.php │ │ │ ├── PayuAccount.php │ │ │ └── PayuCard.php │ │ ├── controllers │ │ └── PaymentController.php │ │ └── etc │ │ ├── config.xml │ │ └── system.xml ├── design │ └── frontend │ │ └── base │ │ └── default │ │ └── template │ │ └── payu_account │ │ ├── card_form.phtml │ │ └── form.phtml ├── etc │ └── modules │ │ └── PayU_Account.xml └── locale │ └── pl_PL │ └── PayU_Account.csv ├── lib └── PayU │ ├── Cache │ ├── .htaccess │ └── index.php │ ├── OpenPayU │ ├── AuthType │ │ ├── AuthType.php │ │ ├── Basic.php │ │ ├── Oauth.php │ │ └── TokenRequest.php │ ├── Configuration.php │ ├── Http.php │ ├── HttpCurl.php │ ├── Oauth │ │ ├── Cache │ │ │ ├── OauthCacheFile.php │ │ │ ├── OauthCacheInterface.php │ │ │ └── OauthCacheMemcached.php │ │ ├── Oauth.php │ │ ├── OauthGrantType.php │ │ └── OauthResultClientCredentials.php │ ├── OpenPayU.php │ ├── OpenPayUException.php │ ├── OpenPayuOrderStatus.php │ ├── Result.php │ ├── ResultError.php │ ├── Util.php │ └── v2 │ │ ├── Order.php │ │ ├── Refund.php │ │ ├── Retrieve.php │ │ └── Token.php │ └── openpayu.php ├── modman ├── readme_images ├── methods.png └── methods_en.png └── skin ├── adminhtml └── default │ └── default │ └── images │ └── payu │ └── payu_logo.png └── frontend └── base └── default ├── css └── payu │ └── payu.css ├── images └── payu │ ├── payu_cards.png │ └── payu_logo.png └── js └── payu └── payu.js /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | bin/ 9 | tmp/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | 19 | # External tool builders 20 | .externalToolBuilders/ 21 | 22 | # Locally stored "Eclipse launch configurations" 23 | *.launch 24 | 25 | # CDT-specific 26 | .cproject 27 | 28 | # PDT-specific 29 | .buildpath 30 | 31 | 32 | ################# 33 | ## Visual Studio 34 | ################# 35 | 36 | ## Ignore Visual Studio temporary files, build results, and 37 | ## files generated by popular Visual Studio add-ons. 38 | 39 | # User-specific files 40 | *.suo 41 | *.user 42 | *.sln.docstates 43 | 44 | # Build results 45 | [Dd]ebug/ 46 | [Rr]elease/ 47 | *_i.c 48 | *_p.c 49 | *.ilk 50 | *.meta 51 | *.obj 52 | *.pch 53 | *.pdb 54 | *.pgc 55 | *.pgd 56 | *.rsp 57 | *.sbr 58 | *.tlb 59 | *.tli 60 | *.tlh 61 | *.tmp 62 | *.vspscc 63 | .builds 64 | *.dotCover 65 | 66 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 67 | #packages/ 68 | 69 | # Visual C++ cache files 70 | ipch/ 71 | *.aps 72 | *.ncb 73 | *.opensdf 74 | *.sdf 75 | 76 | # Visual Studio profiler 77 | *.psess 78 | *.vsp 79 | 80 | # ReSharper is a .NET coding add-in 81 | _ReSharper* 82 | 83 | # Installshield output folder 84 | [Ee]xpress 85 | 86 | # DocProject is a documentation generator add-in 87 | DocProject/buildhelp/ 88 | DocProject/Help/*.HxT 89 | DocProject/Help/*.HxC 90 | DocProject/Help/*.hhc 91 | DocProject/Help/*.hhk 92 | DocProject/Help/*.hhp 93 | DocProject/Help/Html2 94 | DocProject/Help/html 95 | 96 | # Click-Once directory 97 | publish 98 | 99 | # Others 100 | [Bb]in 101 | [Oo]bj 102 | sql 103 | TestResults 104 | *.Cache 105 | ClientBin 106 | stylecop.* 107 | ~$* 108 | *.dbmdl 109 | Generated_Code #added for RIA/Silverlight projects 110 | 111 | # Backup & report files from converting an old project file to a newer 112 | # Visual Studio version. Backup files are not needed, because we have git ;-) 113 | _UpgradeReport_Files/ 114 | Backup*/ 115 | UpgradeLog*.XML 116 | 117 | 118 | 119 | ############ 120 | ## Windows 121 | ############ 122 | 123 | # Windows image file caches 124 | Thumbs.db 125 | 126 | # Folder config file 127 | Desktop.ini 128 | 129 | 130 | ############# 131 | ## Python 132 | ############# 133 | 134 | *.py[co] 135 | 136 | # Packages 137 | *.egg 138 | *.egg-info 139 | dist 140 | build 141 | eggs 142 | parts 143 | bin 144 | var 145 | sdist 146 | develop-eggs 147 | .installed.cfg 148 | 149 | # Installer logs 150 | pip-log.txt 151 | 152 | # Unit test / coverage reports 153 | .coverage 154 | .tox 155 | 156 | #Translations 157 | *.mo 158 | 159 | #Mr Developer 160 | .mr.developer.cfg 161 | 162 | # Mac crap 163 | .DS_Store 164 | 165 | .idea 166 | _connect 167 | _screens -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 2.4.4 2 | * Moved payu.js to correct path 3 | 4 | ## 2.4.3 5 | * Update SDK 6 | 7 | ## 2.4.2 8 | * Fixed checkout when not show paymethods 9 | 10 | ## 2.4.1 11 | * Update private policy 12 | 13 | ## 2.4.0 14 | * Payment methods show on one step checkout 15 | 16 | ## 2.3.1 17 | * Fixed sandbox configuration for card 18 | 19 | ## 2.3.0 20 | * Separated card payment 21 | * Added sandbox 22 | 23 | ## 2.2.1 24 | * Fix customerIp and translate 25 | * Catch consumeNotification exception 26 | * Add email notification 27 | 28 | ## 2.2.0 29 | * Update SDK 30 | * Add Outh 31 | * Refactor 32 | * Cleanup unused code 33 | 34 | ## 2.1.10 35 | * Replace http to https for static resources 36 | 37 | ## 2.1.9 38 | * Add lang to redirectUri 39 | 40 | ## 2.1.3 41 | * microtime() added to extOrderId to avoid ORDER_NOT_UNIQUE error 42 | * fixed status update bug 43 | * API version fixed 44 | * not used status updates removed 45 | * _payuPayMethod from CARD to CARD_TOKEN changed 46 | 47 | ## 2.1.2 48 | * SDK version 2.1.2 included (SSL3 protocol dissabled) 49 | 50 | ## 2.1.1 51 | * API 2.1 compatible 52 | 53 | ## 2.0.2 54 | * Rounding numbers fixed 55 | 56 | ## 2.0.1 57 | * Refund functionality added 58 | * Added discounted price calculation 59 | * SDK 2.0.0 compatible 60 | * Fixed Self-return flow 61 | * Fix for coupon total amount and order summary 62 | * Fix for user rights and Accept/Cancel buttons 63 | 64 | 65 | ## 1.8.2 66 | * Changed order's statuses management 67 | * Fixed payment acceptance 68 | * Fixed shipping taxes 69 | 70 | ## 1.8.1 71 | * Fixed GrandTotal Amount to SubTotal 72 | * Fixed updatePaymentStatusCompleted for Self-Returns 73 | 74 | ## 1.8.0 75 | * SDK 1.9.2 compatible 76 | * Fixed PayU order cancelling 77 | * Fixed adding customer shipping address in orders that are not virtual 78 | * Fixed status changing for Payment Review after complete payment 79 | * Fixed updating customer data 80 | * Changed order number in PayU description 81 | 82 | ## 1.7.0 83 | * Fixed problem with accepting and cancelling order in PayU [Issue #6](https://github.com/PayU/plugin_magento_160/issues/6) 84 | * Removed PayU.php file 85 | * Changed type of license 86 | * Added license file 87 | 88 | ## 0.1.6.5.1 89 | * Fixed Email empty value in new order 90 | * Changed description labels in configuration 91 | * Updated order statuses list 92 | 93 | ## 0.1.6.5 94 | * Added customer and shipping information in order create 95 | 96 | ## 0.1.6.4 97 | * Fixed displaying a message when you add item to cart 98 | * Fixed advertisements localization 99 | * Added redirect after payment cancel 100 | 101 | ## 0.1.6.3.2 102 | * Fixed empty ShippingCostList in Checkout process 103 | 104 | ## 0.1.6.3.1 105 | * Fixed order status changes for Completed 106 | 107 | ## 0.1.6.3 108 | * Changed shopping process flow without authentication before summary 109 | * Fixed billing address for virtual order 110 | 111 | ## 0.1.6.2 112 | * Fixed shipping costs list for virtual order 113 | * Fixed product tax rates 114 | * Fixed order grand total value 115 | 116 | ## 0.1.6.1 117 | * Changed extension name: PayU_Account was PayU_PayU 118 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.EN.md: -------------------------------------------------------------------------------- 1 | [**Wersja polska**][ext0] 2 | # Warning: This plugin for Magento 1.6.0+ has been archived, it’s no longer maintained 3 | 4 | ## PayU account plugin for Magento 1.6.0+ 5 | ``This plugin is released under the GPL license.`` 6 | 7 | * If you are using Magento version 2.3, please use a [plugin for version 2.3][ext8] 8 | * If you are using Magento version 2.4, please use a [plugin for version 2.4][ext9] 9 | 10 | ## Table of Contents 11 | 12 | 1. [Features](#features) 13 | 1. [Prerequisites](#prerequisites) 14 | 1. [Installation](#installation) 15 | 1. [Configuration](#configuration) 16 | * [Parameters](#parameters) 17 | 18 | ## Features 19 | The PayU payments Magento plugin adds the PayU payment option and enables you to process the following operations in your e-shop: 20 | * Creating a payment order (with discounts included) 21 | * Receive or canceling a payment order (when auto-receive is disable) 22 | * Conducting a refund operation (for a whole or partial order) 23 | 24 | The module adds two payment methods: 25 | 26 | ![methods][img0] 27 | * **Pay with PayU** - redirection to PayU hosted paywall (with all available payment methods) 28 | * **Pay by card** - redirection to PayU hosted card payment form 29 | 30 | # Prerequisites 31 | 32 | **Important:** This plugin works only with REST API (checkout) points of sales (POS). If you do not already have PayU merchant account, [**please register in Production**][ext4] or [**please register in Sandbox**][ext5] 33 | 34 | The following PHP extensions are required: 35 | 36 | * [cURL][ext2] to connect and communicate to many different types of servers with many different types of protocols. 37 | * [hash][ext3] to process directly or incrementally the arbitrary length messages by using a variety of hashing algorithms. 38 | 39 | ## Installation 40 | 41 | ### Option 1 42 | **Intended for users with FTP access to Magento Installation** 43 | 44 | 1. Download the module from [repozytorium GitHub][ext3] as zip file. 45 | 1. Unzip the file. 46 | 1. Connect with your FTP server and copy `app`, `lib` and `skin` directories from the unzipped file to the main directory of your Magento installation. 47 | 1. Flush the cache to update the available plugins list: 48 | * Go to admin page of your Magento installation [http://shop-url/admin]. 49 | * Choose **System** > **Cache Management**. 50 | * Click **Flush Magento Cache** button. 51 | 52 | ### Option 2 53 | **Using modman script** 54 | 55 | PayU module includes configuration which makes it possible to install via `modman` script. 56 | Please refer to `modman` documentation for further details. 57 | 58 | #### WARNING 59 | If you are using compilation option, choose **System** > **Tools** > **Compilation** and click **Run Compilation Process** button. 60 | 61 | Additionally, if you update the module from an older version, you must delete from `includes/src` directory `OpenPayu` directory and all files that start with `OpenPayU` 62 | 63 | ## Configuration 64 | 65 | Independently of the installation method, the configuration looks the same: 66 | 67 | 1. Go to the Magento administration page [http://shop-url/admin]. 68 | 2. Go to **System** > **Configuration**. 69 | 3. From the **Configuration** menu on the left, in the **Sales** section, select **Payment Methods**. 70 | 4. In the list of available methods, click **PayU** or **PayU - cards** to expand the configuration form. 71 | 5. Click `Save config`. 72 | 73 | ### Parameters 74 | 75 | #### Main parameters 76 | 77 | | Parameter | Description | 78 | |---------|-----------| 79 | | Enable plugin? | Defines the availability of the payment method on the payment method list during checkout. | 80 | | Sandbox mode | Defines if payments will be created in PayU sandbox instead of production (live) environment. | 81 | 82 | #### POS parameters 83 | 84 | | Parameter | Description | 85 | |---------|-----------| 86 | |POS ID|Unique ID of the POS| 87 | |Second Key|MD5 key for securing communication| 88 | |OAuth - client_id|client_id for OAuth| 89 | |OAuth - client_secret|client_secret for OAuth| 90 | 91 | #### POS parameters - Sandbox mode 92 | Available when parameter `Sandbox mode` is set to `Yes`. 93 | 94 | | Parameter | Description | 95 | |---------|-----------| 96 | |POS ID|Unique ID of the POS| 97 | |Second Key|MD5 key for securing communication| 98 | |OAuth - client_id|client_id for OAuth| 99 | |OAuth - client_secret|client_secret for OAuth| 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | [ext0]: README.md 108 | [ext1]: https://github.com/PayU-EMEA/plugin_magento 109 | [ext2]: http://php.net/manual/en/book.curl.php 110 | [ext3]: http://php.net/manual/en/book.hash.php 111 | [ext4]: https://www.payu.pl/en/commercial-offer 112 | [ext5]: https://secure.snd.payu.com/boarding/#/form&pk_campaign=Plugin-Github&pk_kwd=Magento 113 | [ext8]: https://github.com/PayU-EMEA/plugin_magento_23 114 | [ext9]: https://github.com/PayU-EMEA/plugin_magento_24 115 | 116 | 117 | [img0]: readme_images/methods_en.png 118 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [**English version**][ext0] 2 | # Uwaga: Ta wtyczka dla Magento 1.6.0+ została zarchiwizowana i nie jest już wspierana 3 | 4 | # Moduł PayU dla Magento 1.6.0+ 5 | ``Moduł jest wydawany na licencji GPL.`` 6 | 7 | * Jeżeli używasz Magneto w wersji 2.3 proszę skorzystać z [pluginu dla wersji 2.3][ext9] 8 | * Jeżeli używasz Magneto w wersji 2.4 proszę skorzystać z [pluginu dla wersji 2.4][ext10] 9 | 10 | ## Spis treści 11 | 12 | 1. [Cechy](#cechy) 13 | 1. [Wymagania](#wymagania) 14 | 1. [Instalacja](#instalacja) 15 | 1. [Konfiguracja](#konfiguracja) 16 | * [Parametry](#parametry) 17 | 1. [Informacje o cechach](#informacje-o-cechach) 18 | * [Kolejność metod płatności](#kolejność-metod-płatności) 19 | 20 | ## Cechy 21 | Moduł płatności PayU dodaje do Magento opcję płatności PayU. 22 | 23 | Możliwe są następujące operacje: 24 | * Utworzenie płatności (wraz z rabatami) 25 | * Odebranie lub odrzucenie płatności (w przypadku wyłączonego autoodbioru) 26 | * Utworzenie zwrotu online (pełnego lub częściowego) 27 | 28 | Moduł dodaje dwie metody płatności: 29 | 30 | ![methods][img0] 31 | * **Zapłać przez PayU** - wybór metody płatności i przekierowanie do banku / formatkę kartową lub przekierowanie na stronę wyboru metod płatności w PayU 32 | * **Zapłać kartą** - bezpośrednie przekierowanie na formularz płatności kartą 33 | 34 | ## Wymagania 35 | 36 | **Ważne:** Moduł ten działa tylko z punktem płatności typu `REST API` (Checkout), jeżeli nie posiadasz jeszcze konta w systemie PayU [**zarejestruj się w systemie produkcyjnym**][ext4] lub [**zarejestruj się w systemie sandbox**][ext5] 37 | 38 | Do prawidłowego funkcjonowania modułu wymagane są następujące rozszerzenia PHP: [cURL][ext1] i [hash][ext2]. 39 | 40 | ## Instalacja 41 | 42 | ### Opcja 1 43 | **Przeznaczona dla użytkowników z dostępem poprzez FTP do instalacji Magento** 44 | 45 | 1. Pobierz moduł z [repozytorium GitHub][ext3] jako plik zip 46 | 1. Rozpakuj pobrany plik 47 | 1. Połącz się z serwerem ftp i skopiuj katalogi `app`, `lib` oraz `skin` z rozpakowanego pliku do katalogu głównego swojego sklepu Magento 48 | 1. W celu aktualizacji listy dostępnych wtyczek należy wyczyścić cache: 49 | * Przejdź do strony administracyjnej swojego sklepu Magento [http://adres-sklepu/admin]. 50 | * Przejdź do **System** > **Cache Management**. 51 | * Naciśnij przycisk **Flush Magento Cache**. 52 | 53 | ### Opcja 2 54 | **Z użyciem skryptu modman** 55 | 56 | Moduł PayU zawiera konfigurację umożliwiającą instalację poprzez skrypt `modman`. 57 | W celu instalcji z użyciem `modman` proszę skozystać z dokumentacji skryptu `modman`. 58 | 59 | #### UWAGA 60 | Jeżeli używasz opcji kompilacji po przejściu do **System** > **Tools** > **Compilation** należy nacisnąć przycisk **Run Compilation Process**. 61 | 62 | Dodatkowo jeżeli aktualizujesz moduł ze starszej wersji należy z katalogu `includes/src` usunąć katalog `OpenPayu` oraz wszystkie pliki zaczynające się na `OpenPayU` 63 | 64 | ## Konfiguracja 65 | 66 | 1. Przejdź do strony administracyjnej swojego sklepu Magento [http://adres-sklepu/admin]. 67 | 1. Przejdź do **System** > **Configuration**. 68 | 3. Na stronie **Configuration** w menu po lewej stronie w sekcji **Sales** wybierz **Payment Methods**. 69 | 4. Na liście dostępnych metod płatności należy wybrać **PayU** lub **PayU - karty** w celu konfiguracji parametrów wtyczki. 70 | 5. Naciśnij przycisk `Save config`. 71 | 72 | ### Parametry 73 | 74 | #### Główne parametry 75 | 76 | | Parameter | Opis | 77 | |---------|-----------| 78 | | Czy włączyć wtyczkę? | Określa czy metoda płatności będzie dostępna w sklepie na liście płatności. | 79 | | Tryb testowy (Sandbox) | Określa czy płatności będą realizowane na środowisku testowym (sandbox) PayU. | 80 | 81 | #### Parametry dla metody `Zapłać przez PayU` 82 | 83 | | Parameter | Opis | 84 | |---------|-----------| 85 | | Wyświetlaj metody płatności | Określa czy ma być wyświetlana lista bramek płatności podczas procesu zamówienia w Magento | 86 | | Kolejność metod płatności | Określa kolejnośc wyświetlanych metod płatności [więcej informacji](#kolejność-metod-płatności). | 87 | 88 | #### Parametry punktu płatności (POS) 89 | 90 | | Parameter | Opis | 91 | |---------|-----------| 92 | | Id punktu płatności| Identyfikator POS-a z systemu PayU | 93 | | Drugi klucz MD5 | Drugi klucz MD5 z systemu PayU | 94 | | OAuth - client_id | client_id dla protokołu OAuth z systemu PayU | 95 | | OAuth - client_secret | client_secret for OAuth z systemu PayU | 96 | 97 | #### Parametry punktu płatności (POS) - Tryb testowy (Sandbox) 98 | Dostępne gdy parametr `Tryb testowy (Sandbox)` jest ustawiony na `Tak`. 99 | 100 | | Parameter | Opis | 101 | |---------|-----------| 102 | | Id punktu płatności| Identyfikator POS-a z systemu PayU | 103 | | Drugi klucz MD5 | Drugi klucz MD5 z systemu PayU | 104 | | OAuth - client_id | client_id dla protokołu OAuth z systemu PayU | 105 | | OAuth - client_secret | client_secret for OAuth z systemu PayU | 106 | 107 | ## Informacje o cechach 108 | 109 | ### Kolejność metod płatności 110 | W celu ustalenia kolejności wyświetlanych ikon matod płatności należy podać symbole metod płatności oddzielając je przecinkiem. [Lista metod płatności][ext7]. 111 | 112 | 113 | 114 | 115 | 116 | 117 | [ext0]: README.EN.md 118 | [ext1]: http://php.net/manual/en/book.curl.php 119 | [ext2]: http://php.net/manual/en/book.hash.php 120 | [ext3]: https://github.com/PayU-EMEA/plugin_magento 121 | [ext4]: https://www.payu.pl/oferta-handlowa 122 | [ext5]: https://secure.snd.payu.com/boarding/?pk_campaign=Plugin-Github&pk_kwd=Magento#/form 123 | [ext7]: http://developers.payu.com/pl/overview.html#paymethods 124 | [ext9]: https://github.com/PayU-EMEA/plugin_magento_23 125 | [ext10]: https://github.com/PayU-EMEA/plugin_magento_24 126 | 127 | 128 | [img0]: readme_images/methods.png 129 | -------------------------------------------------------------------------------- /app/code/community/PayU/Account/Block/Adminhtml/Block/System/Config/Form/Fieldset.php: -------------------------------------------------------------------------------- 1 | '; 17 | 18 | $html .= ' '; 19 | $html .= $element->getLegend(); 20 | 21 | $html .= ''; 22 | return $html; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/code/community/PayU/Account/Block/Form/Abstract.php: -------------------------------------------------------------------------------- 1 | getLayout()->getBlock('head')) { 19 | $head 20 | ->addCss('css/payu/payu.css') 21 | ->addItem('skin_js', 'js/payu/payu.js'); 22 | } 23 | return parent::_prepareLayout(); 24 | } 25 | 26 | /** 27 | * @return string 28 | */ 29 | protected function getPayuLogo() 30 | { 31 | return $this->getSkinUrl('images/payu/payu_logo.png'); 32 | } 33 | 34 | /** 35 | * @return string 36 | */ 37 | protected function getCardLogos() 38 | { 39 | return $this->getSkinUrl('images/payu/payu_cards.png'); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /app/code/community/PayU/Account/Block/Form/PayuAccount.php: -------------------------------------------------------------------------------- 1 | setMethodTitle($this->__('Pay with PayU')); 11 | $this->setMethodLabelAfterHtml(''); 12 | $this->setTemplate('payu_account/form.phtml'); 13 | 14 | } 15 | 16 | /** 17 | * @return array|null 18 | */ 19 | public function getPayMethods() 20 | { 21 | /** @var PayU_Account_Model_Config $payuConfig */ 22 | $payuConfig = Mage::getSingleton('payu/config', array('method' => PayU_Account_Model_Method_PayuAccount::CODE)); 23 | 24 | if (!$payuConfig->isShowPaytypes()) { 25 | return null; 26 | } 27 | 28 | /** @var PayU_Account_Model_GetPayMethods $getPayMetods */ 29 | $getPayMetods = Mage::getModel('payu/getPayMethods', array('method' => PayU_Account_Model_Method_PayuCard::CODE)); 30 | 31 | return $getPayMetods->execute(); 32 | } 33 | 34 | /** 35 | * @return bool 36 | */ 37 | public function isShowPayuConditions() 38 | { 39 | return substr(Mage::app()->getLocale()->getLocaleCode(), 0, 2) === 'pl'; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /app/code/community/PayU/Account/Block/Form/PayuCard.php: -------------------------------------------------------------------------------- 1 | setMethodTitle($this->__('Pay by card')); 11 | $this->setMethodLabelAfterHtml(''); 12 | $this->setTemplate('payu_account/card_form.phtml'); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /app/code/community/PayU/Account/Block/UpdateInfo.php: -------------------------------------------------------------------------------- 1 | ' . Mage::getModel('payu/config')->getPluginVersion() . ''; 18 | 19 | return $html; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/code/community/PayU/Account/Helper/Data.php: -------------------------------------------------------------------------------- 1 | storeId = $storeId; 41 | } else { 42 | $this->storeId = Mage::app()->getStore()->getId(); 43 | } 44 | 45 | $this->method = $params['method']; 46 | } 47 | 48 | /** 49 | * @param string $action 50 | * @param array $params 51 | * 52 | * @return string base module url 53 | */ 54 | public function getUrl($action, $params = array()) 55 | { 56 | $params['_secure'] = true; 57 | return Mage::getUrl('payu/payment/' . $action, $params); 58 | } 59 | 60 | /** 61 | * @return string 62 | */ 63 | public function getPluginVersion() 64 | { 65 | return self::PLUGIN_VERSION; 66 | } 67 | 68 | /** 69 | * Initialize PayU configuration 70 | */ 71 | public function initializeOpenPayUConfiguration() 72 | { 73 | OpenPayU_Configuration::setEnvironment($this->getEnvironment()); 74 | OpenPayU_Configuration::setMerchantPosId($this->getStoreConfig('pos_id')); 75 | OpenPayU_Configuration::setSignatureKey($this->getStoreConfig('signature_key')); 76 | OpenPayU_Configuration::setOauthClientId($this->getStoreConfig('oauth_client_id')); 77 | OpenPayU_Configuration::setOauthClientSecret($this->getStoreConfig('oauth_client_secret')); 78 | OpenPayU_Configuration::setOauthTokenCache(new OauthCacheFile(Mage::getBaseDir('cache'))); 79 | OpenPayU_Configuration::setSender('Magento ver ' . Mage::getVersion() . '/Plugin ver ' . $this->getPluginVersion()); 80 | } 81 | 82 | /** 83 | * @return string 84 | */ 85 | public function getMerchantPosId() 86 | { 87 | return \OpenPayU_Configuration::getMerchantPosId(); 88 | } 89 | 90 | /** 91 | * @return bool 92 | */ 93 | public function isShowPaytypes() 94 | { 95 | return (bool)Mage::getStoreConfig('payment/' . $this->method . '/paytypes', $this->storeId); 96 | } 97 | 98 | /** 99 | * @return bool 100 | */ 101 | public function isActive() 102 | { 103 | return (bool)Mage::getStoreConfig('payment/' . $this->method . '/active', $this->storeId); 104 | } 105 | 106 | /** 107 | * @return array 108 | */ 109 | public function getPaytypesOrder() { 110 | return explode( 111 | ',', 112 | str_replace( 113 | ' ', 114 | '', 115 | Mage::getStoreConfig('payment/' . $this->method . '/paytypes_order', $this->storeId) 116 | ) 117 | ); 118 | } 119 | 120 | /** 121 | * @return string 122 | */ 123 | private function getEnvironment() { 124 | return $this->isSandbox() ? self::ENVIRONMENT_SANBOX : self::ENVIRONMENT_SECURE; 125 | } 126 | 127 | /** 128 | * get Store Config variable 129 | * @param $name 130 | * @return string 131 | */ 132 | private function getStoreConfig($name) 133 | { 134 | return Mage::getStoreConfig('payment/' . $this->method . '/' . ($this->isSandbox() ? 'sandbox_' : '') . $name, $this->storeId); 135 | } 136 | 137 | /** 138 | * @return bool 139 | */ 140 | private function isSandbox() 141 | { 142 | return (bool)Mage::getStoreConfig('payment/' . $this->method . '/sandbox', $this->storeId); 143 | } 144 | 145 | } 146 | -------------------------------------------------------------------------------- /app/code/community/PayU/Account/Model/CreateOrder.php: -------------------------------------------------------------------------------- 1 | payuConfig = Mage::getSingleton('payu/config', array('method' => $method)); 15 | } 16 | 17 | /** 18 | * @param array $orderData 19 | * @return object 20 | * @throws Mage_Core_Exception 21 | */ 22 | public function execute($orderData) 23 | { 24 | $this->payuConfig->initializeOpenPayUConfiguration(); 25 | 26 | $orderData['merchantPosId'] = $this->payuConfig->getMerchantPosId(); 27 | 28 | try { 29 | /** @var \OpenPayU_Result $result */ 30 | $result = \OpenPayU_Order::create($orderData); 31 | 32 | if ($result->getStatus() == \OpenPayU_Order::SUCCESS) { 33 | return $result->getResponse(); 34 | } else { 35 | Mage::log($result); 36 | 37 | Mage::throwException(Mage::helper('payu') 38 | ->__('There was a problem with the payment initialization, please contact system administrator.')); 39 | } 40 | } catch (\OpenPayU_Exception $e) { 41 | Mage::log($e->getMessage()); 42 | 43 | Mage::throwException(Mage::helper('payu') 44 | ->__('There was a problem with the payment initialization, please contact system administrator.')); 45 | 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /app/code/community/PayU/Account/Model/GetPayMethods.php: -------------------------------------------------------------------------------- 1 | payuConfig = Mage::getSingleton('payu/config', array('method' => $method)); 36 | } 37 | 38 | public function execute() 39 | { 40 | $this->payuConfig->initializeOpenPayUConfiguration(); 41 | 42 | try { 43 | $response = \OpenPayU_Retrieve::payMethods()->getResponse(); 44 | if (isset($response->payByLinks)) { 45 | $this->result = $response->payByLinks; 46 | $this->removeTestPayment(); 47 | $this->removeCreditCard(); 48 | $this->sortPaymentMethods($this->payuConfig->getPaytypesOrder()); 49 | 50 | } 51 | } catch (\OpenPayU_Exception $exception) { 52 | Mage::log(__METHOD__ . ': ' . $exception->getMessage()); 53 | } 54 | 55 | return $this->result; 56 | } 57 | 58 | /** 59 | * Remove test payment when disabled 60 | * 61 | * @return void 62 | */ 63 | private function removeTestPayment() 64 | { 65 | $this->result = array_filter( 66 | $this->result, 67 | function ($payByLink) { 68 | return !($payByLink->value === self::TEST_PAYMENT_CODE && $payByLink->status !== self::PAYMETHOD_STATUS_ENABLED); 69 | } 70 | ); 71 | } 72 | 73 | /** 74 | * Remove test payment when disabled 75 | * 76 | * @return void 77 | */ 78 | private function removeCreditCard() 79 | { 80 | /** 81 | * @var $payuCardConfig PayU_Account_Model_Config 82 | */ 83 | $payuCardConfig = Mage::getModel('payu/config', array('method' => PayU_Account_Model_Method_PayuCard::CODE)); 84 | if ($payuCardConfig->isActive()) { 85 | $this->result = array_filter( 86 | $this->result, 87 | function ($payByLink) { 88 | return $payByLink->value !== self::CREDIT_CARD_CODE; 89 | } 90 | ); 91 | } 92 | } 93 | 94 | 95 | /** 96 | * Card first, sort by admin, disabled last 97 | * 98 | * @param array $paymentMethodsOrder 99 | * @return void 100 | */ 101 | private function sortPaymentMethods($paymentMethodsOrder) 102 | { 103 | if (count($this->result) < 1) { 104 | return; 105 | } 106 | 107 | array_walk( 108 | $this->result, 109 | function ($item, $key, $paymentMethodsOrder) { 110 | if ($item->value == self::CREDIT_CARD_CODE) { 111 | $item->sort = 0; 112 | } else if ($item->status !== self::PAYMETHOD_STATUS_ENABLED) { 113 | $item->sort = $key + 200; 114 | } else if (array_key_exists($item->value, $paymentMethodsOrder)) { 115 | $item->sort = $paymentMethodsOrder[$item->value] - 100; 116 | } else { 117 | $item->sort = $key + 100; 118 | } 119 | }, 120 | array_flip($paymentMethodsOrder) 121 | ); 122 | 123 | usort( 124 | $this->result, 125 | function ($a, $b) { 126 | return $a->sort - $b->sort; 127 | } 128 | ); 129 | } 130 | 131 | } 132 | -------------------------------------------------------------------------------- /app/code/community/PayU/Account/Model/Method/Abstract.php: -------------------------------------------------------------------------------- 1 | _payuConfig = Mage::getSingleton('payu/config', array('method' => $this->_code)); 58 | $this->_payuConfig->initializeOpenPayUConfiguration(); 59 | } 60 | 61 | /** 62 | * @return PayU_Account_Helper_Data 63 | */ 64 | protected function _helper() 65 | { 66 | return Mage::helper('payu'); 67 | } 68 | 69 | /** 70 | * @param string $extOrderId 71 | */ 72 | protected function _setOrderByOrderId($extOrderId) 73 | { 74 | $this->_order = Mage::getModel('sales/order')->load($extOrderId); 75 | } 76 | 77 | /** 78 | * @return Mage_Sales_Model_Order 79 | */ 80 | public function getOrder() 81 | { 82 | return $this->_order; 83 | } 84 | 85 | /** 86 | * @param Mage_Sales_Model_Order $order 87 | */ 88 | public function setOrder(Mage_Sales_Model_Order $order) 89 | { 90 | $this->_order = $order; 91 | } 92 | 93 | /** 94 | * Redirection url 95 | * 96 | * @return string 97 | */ 98 | public function getOrderPlaceRedirectUrl() 99 | { 100 | return Mage::getUrl('payu/payment/new', array('_secure' => true)); 101 | } 102 | 103 | /** 104 | * Get current quote 105 | * 106 | * @return Mage_Sales_Model_Quote 107 | */ 108 | public function getQuote() 109 | { 110 | return $this->getCheckoutSession()->getQuote(); 111 | } 112 | 113 | /** 114 | * Get checkout session namespace 115 | * 116 | * @return Mage_Checkout_Model_Session 117 | */ 118 | public function getCheckoutSession() 119 | { 120 | return Mage::getSingleton('checkout/session'); 121 | } 122 | 123 | /** 124 | * Create order 125 | * 126 | * @param Mage_Sales_Model_Order 127 | * @return array 128 | * @throws Mage_Core_Exception 129 | * @throws Varien_Exception 130 | * @throws Exception 131 | */ 132 | public function orderCreateRequest(Mage_Sales_Model_Order $order) 133 | { 134 | 135 | $orderData = $this->prepareOrderData($order); 136 | $response = null; 137 | 138 | /** @var PayU_Account_Model_CreateOrder $createOrder */ 139 | $createOrder = Mage::getModel('payu/createOrder', array('method' => $this->_code)); 140 | 141 | $result = $createOrder->execute($orderData); 142 | 143 | $payuOrderId = $result->orderId; 144 | 145 | Mage::getSingleton('core/session')->setPayUSessionId($payuOrderId); 146 | 147 | $payment = $order->getPayment(); 148 | $payment->setAdditionalInformation('payu_payment_status', OpenPayuOrderStatus::STATUS_NEW) 149 | ->save(); 150 | 151 | $this->_updatePaymentStatusNew($payment, $payuOrderId); 152 | 153 | $response = array( 154 | 'redirectUri' => $result->redirectUri 155 | ); 156 | 157 | try { 158 | $order->sendNewOrderEmail()->save(); 159 | } catch (\Exception $e) { 160 | Mage::log($e->getMessage()); 161 | } 162 | 163 | return $response; 164 | } 165 | 166 | 167 | /** 168 | * @param Mage_Sales_Model_Order $order 169 | * @return array 170 | */ 171 | private function prepareOrderData($order) { 172 | $orderData = array( 173 | 'description' => $this->_helper()->__('Order #%s', $order->getRealOrderId()), 174 | 'products' => array( 175 | array( 176 | 'quantity' => 1, 177 | 'name' => $this->_helper()->__('Order #%s', $order->getRealOrderId()), 178 | 'unitPrice' => $this->_toAmount($order->getGrandTotal()) 179 | ) 180 | ), 181 | 'customerIp' => trim(strtok(Mage::app()->getFrontController()->getRequest()->getClientIp(), ',')), 182 | 'notifyUrl' => $this->_payuConfig->getUrl('orderNotifyRequest', array('method' => $this->_code)), 183 | 'continueUrl' => $this->_payuConfig->getUrl('continuePayment'), 184 | 'currencyCode' => $order->getOrderCurrencyCode(), 185 | 'totalAmount' => $this->_toAmount($order->getGrandTotal()), 186 | 'extOrderId' => uniqid($order->getId() . self::DELIMITER, true), 187 | 'settings' => array( 188 | 'invoiceDisabled' => true 189 | ) 190 | ); 191 | 192 | $billingAddress = $order->getBillingAddress(); 193 | if ($billingAddress) { 194 | $orderData['buyer'] = array( 195 | 'email' => $billingAddress->getEmail(), 196 | 'phone' => $billingAddress->getTelephone(), 197 | 'firstName' => $billingAddress->getFirstname(), 198 | 'lastName' => $billingAddress->getLastname(), 199 | 'language' => $this->_getLanguageCode() 200 | ); 201 | } 202 | 203 | 204 | if ($this->_code === 'payu_card') { 205 | $payType = PayU_Account_Model_GetPayMethods::CREDIT_CARD_CODE; 206 | } else { 207 | $payType = $order->getPayment()->getMethodInstance()->getInfoInstance()->getAdditionalInformation(PayU_Account_Model_Method_PayuAccount::PAY_TYPE); 208 | } 209 | 210 | if ($payType) { 211 | $orderData['payMethods'] = array( 212 | 'payMethod' => array( 213 | 'type' => 'PBL', 214 | 'value' => $payType 215 | ) 216 | ); 217 | } 218 | 219 | return $orderData; 220 | } 221 | 222 | /** 223 | * @param Mage_Payment_Model_Info $payment 224 | * @return bool 225 | */ 226 | public function acceptPayment(Mage_Payment_Model_Info $payment) 227 | { 228 | parent::acceptPayment($payment); 229 | $sessionId = $payment->getLastTransId(); 230 | 231 | if (empty($sessionId)) { 232 | return false; 233 | } 234 | 235 | if (!$this->_orderStatusUpdateRequest(OpenPayuOrderStatus::STATUS_COMPLETED, $sessionId)) { 236 | return false; 237 | } 238 | 239 | return true; 240 | } 241 | 242 | /** 243 | * 244 | * @param Mage_Payment_Model_Info $payment 245 | * @return bool 246 | */ 247 | public function denyPayment(Mage_Payment_Model_Info $payment) 248 | { 249 | parent::denyPayment($payment); 250 | $sessionId = $payment->getLastTransId(); 251 | 252 | if (empty($sessionId)) { 253 | return false; 254 | } 255 | 256 | if (!$this->_orderStatusUpdateRequest(OpenPayuOrderStatus::STATUS_CANCELED, $sessionId)) { 257 | return false; 258 | } 259 | 260 | return true; 261 | } 262 | 263 | /** 264 | * Refund payment 265 | * 266 | * @param Varien_Object $payment 267 | * @param float $amount 268 | * @return $this 269 | */ 270 | public function refund(Varien_Object $payment, $amount) 271 | { 272 | /** @var Mage_Sales_Model_Order $order */ 273 | $order = $payment->getOrder(); 274 | 275 | try { 276 | $result = OpenPayU_Refund::create($order->getPayment()->getLastTransId(), $this->_helper()->__('Refund for order: %s', $order->getIncrementId()), $this->_toAmount($amount)); 277 | 278 | $comment = $this->_helper()->__('Payu refund - amount: %s, status: %s', $amount, $result->getStatus()); 279 | 280 | $order->addStatusHistoryComment($comment) 281 | ->save(); 282 | 283 | if ($result->getStatus() == OpenPayU_Order::SUCCESS) { 284 | return $this; 285 | } 286 | 287 | } catch (OpenPayU_Exception $e) { 288 | $comment = $this->_helper()->__('Payu refund - amount: %s, status: %s', $amount, $e->getMessage()); 289 | 290 | Mage::throwException($comment); 291 | } 292 | 293 | } 294 | 295 | public function orderNotifyRequest() 296 | { 297 | $body = file_get_contents('php://input'); 298 | $data = trim($body); 299 | 300 | try { 301 | $result = OpenPayU_Order::consumeNotification($data); 302 | } catch (Exception $e) { 303 | header('X-PHP-Response-Code: 500', true, 500); 304 | die($e->getMessage()); 305 | } 306 | $response = $result->getResponse(); 307 | $orderRetrieved = $response->order; 308 | 309 | if (isset($orderRetrieved) && is_object($orderRetrieved) && $orderRetrieved->orderId) { 310 | $this->_transactionId = $orderRetrieved->orderId; 311 | $extOrderIdExploded = explode(self::DELIMITER, $orderRetrieved->extOrderId); 312 | $orderId = array_shift($extOrderIdExploded); 313 | 314 | $this->_setOrderByOrderId($orderId); 315 | $this->_updatePaymentStatus($orderRetrieved->status); 316 | 317 | header("HTTP/1.1 200 OK"); 318 | } 319 | exit; 320 | } 321 | 322 | /** 323 | * Update payment status 324 | * 325 | * @param $paymentStatus 326 | */ 327 | protected function _updatePaymentStatus($paymentStatus) 328 | { 329 | $payment = $this->getOrder()->getPayment(); 330 | 331 | $currentState = $payment->getAdditionalInformation('payu_payment_status'); 332 | 333 | if ($currentState != OpenPayuOrderStatus::STATUS_COMPLETED && $currentState != $paymentStatus) { 334 | try { 335 | switch ($paymentStatus) { 336 | 337 | case OpenPayuOrderStatus::STATUS_PENDING: 338 | //nothing to do 339 | break; 340 | 341 | case OpenPayuOrderStatus::STATUS_CANCELED: 342 | $this->_updatePaymentStatusCanceled($payment); 343 | break; 344 | 345 | case OpenPayuOrderStatus::STATUS_WAITING_FOR_CONFIRMATION: 346 | case OpenPayuOrderStatus::STATUS_REJECTED: 347 | $this->_updatePaymentStatusRejected($payment); 348 | break; 349 | 350 | case OpenPayuOrderStatus::STATUS_COMPLETED: 351 | $this->_updatePaymentStatusCompleted($payment); 352 | break; 353 | } 354 | 355 | $payment->setAdditionalInformation('payu_payment_status', $paymentStatus) 356 | ->save(); 357 | 358 | } catch (Exception $e) { 359 | Mage::logException($e); 360 | } 361 | } 362 | } 363 | 364 | /** 365 | * Update payment status to new 366 | * 367 | * @param Mage_Sales_Model_Order_Payment $payment 368 | * @param string $orderId 369 | */ 370 | protected function _updatePaymentStatusNew(Mage_Sales_Model_Order_Payment $payment, $orderId) 371 | { 372 | $comment = $this->_helper()->__('New transaction started.'); 373 | 374 | $payment->setTransactionId($orderId) 375 | ->setPreparedMessage($comment) 376 | ->setCurrencyCode($payment->getOrder()->getBaseCurrencyCode()) 377 | ->setIsTransactionApproved(false) 378 | ->setIsTransactionClosed(false) 379 | ->save(); 380 | 381 | $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER, null, false, $comment) 382 | ->save(); 383 | 384 | $payment->getOrder() 385 | ->save(); 386 | 387 | } 388 | 389 | /** 390 | * Change the status to canceled 391 | * 392 | * @param Mage_Sales_Model_Order_Payment $payment 393 | */ 394 | protected function _updatePaymentStatusCanceled(Mage_Sales_Model_Order_Payment $payment) 395 | { 396 | $comment = $this->_helper()->__('The transaction has been canceled.'); 397 | 398 | $payment->setTransactionId($this->_transactionId) 399 | ->setPreparedMessage($comment) 400 | ->setIsTransactionApproved(true) 401 | ->setIsTransactionClosed(true) 402 | ->save(); 403 | 404 | $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER, null, false, $comment) 405 | ->save(); 406 | 407 | $payment->getOrder() 408 | ->sendOrderUpdateEmail(true, $comment) 409 | ->cancel() 410 | ->save(); 411 | 412 | } 413 | 414 | /** 415 | * Change the status to rejected 416 | * 417 | * @param Mage_Sales_Model_Order_Payment $payment 418 | */ 419 | protected function _updatePaymentStatusRejected(Mage_Sales_Model_Order_Payment $payment) 420 | { 421 | $comment = $this->_helper()->__('The transaction is to be accepted or rejected.'); 422 | 423 | $payment->setTransactionId($this->_transactionId) 424 | ->setPreparedMessage($comment) 425 | ->save(); 426 | 427 | $payment->getOrder() 428 | ->setState(Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, true, $comment) 429 | ->save(); 430 | } 431 | 432 | /** 433 | * Update payment status to complete 434 | * 435 | * @param Mage_Sales_Model_Order_Payment $payment 436 | */ 437 | protected function _updatePaymentStatusCompleted(Mage_Sales_Model_Order_Payment $payment) 438 | { 439 | 440 | $comment = $this->_helper()->__('The transaction completed successfully.'); 441 | 442 | $payment->setTransactionId($this->_transactionId) 443 | ->setPreparedMessage($comment) 444 | ->setCurrencyCode($payment->getOrder()->getBaseCurrencyCode()) 445 | ->setIsTransactionApproved(true) 446 | ->setIsTransactionClosed(true) 447 | ->registerCaptureNotification($this->getOrder()->getTotalDue(), true) 448 | ->save(); 449 | 450 | $this->getOrder() 451 | ->save(); 452 | 453 | if ($invoice = $payment->getCreatedInvoice()) { 454 | $comment = $this->_helper()->__('Notified customer about invoice #%s.', $invoice->getIncrementId()); 455 | $this->getOrder() 456 | ->queueNewOrderEmail() 457 | ->addStatusHistoryComment($comment) 458 | ->setIsCustomerNotified(true) 459 | ->save(); 460 | } 461 | 462 | } 463 | 464 | /** 465 | * @param $status 466 | * @param $sessionId 467 | * @return bool OpenPayU_Result 468 | */ 469 | protected function _orderStatusUpdateRequest($status, $sessionId) 470 | { 471 | if (empty($sessionId)) { 472 | $sessionId = $this->getOrder()->getPayment()->getLastTransId(); 473 | } 474 | 475 | if (empty($sessionId)) { 476 | Mage::log("PayU sessionId empty: " . $this->getId()); 477 | return false; 478 | } 479 | 480 | if ($status == OpenPayuOrderStatus::STATUS_CANCELED) { 481 | $result = OpenPayU_Order::cancel($sessionId); 482 | } elseif ($status == OpenPayuOrderStatus::STATUS_COMPLETED) { 483 | $status_update = array( 484 | "orderId" => $sessionId, 485 | "orderStatus" => OpenPayuOrderStatus::STATUS_COMPLETED 486 | ); 487 | $result = OpenPayU_Order::statusUpdate($status_update); 488 | } else { 489 | return false; 490 | } 491 | 492 | if ($result->getStatus() == OpenPayU_Order::SUCCESS) { 493 | return true; 494 | } else { 495 | Mage::log("PayU error while updating status: " . $result->getError()); 496 | return false; 497 | } 498 | } 499 | 500 | /** 501 | * Returns amount in PayU acceptable format 502 | * 503 | * @param $val 504 | * @return int 505 | */ 506 | protected function _toAmount($val) 507 | { 508 | return $this->_helper()->toAmount($val); 509 | } 510 | 511 | /** 512 | * Returns current language code 513 | * 514 | * @return string 515 | */ 516 | protected function _getLanguageCode() 517 | { 518 | return substr(Mage::app()->getLocale()->getLocaleCode(), 0, 2); 519 | } 520 | 521 | } 522 | -------------------------------------------------------------------------------- /app/code/community/PayU/Account/Model/Method/PayuAccount.php: -------------------------------------------------------------------------------- 1 | _payuConfig->isShowPaytypes()) { 30 | 31 | if (!($data instanceof Varien_Object)) { 32 | $data = new Varien_Object($data); 33 | } 34 | $info = $this->getInfoInstance(); 35 | 36 | $info 37 | ->setAdditionalInformation(self::PAY_TYPE, $data->getData(self::PAY_TYPE)) 38 | ->setAdditionalInformation(self::PAYU_CONDITION, $data->getData(self::PAYU_CONDITION)); 39 | } 40 | 41 | return $result; 42 | } 43 | 44 | public function validate() 45 | { 46 | parent::validate(); 47 | 48 | if ($this->_payuConfig->isShowPaytypes()) { 49 | $info = $this->getInfoInstance(); 50 | $errorMsg = false; 51 | 52 | $paytype = $info->getAdditionalInformation(self::PAY_TYPE); 53 | $payuCondition = $info->getAdditionalInformation(self::PAYU_CONDITION); 54 | 55 | if (!$paytype) { 56 | $errorMsg = Mage::helper('payu')->__('Please choose a payment method'); 57 | } else if ($this->_getLanguageCode() === 'pl' && !$payuCondition) { 58 | $errorMsg = Mage::helper('payu')->__('You must accept the "Terms and Conditions of the single transaction in of PayU"'); 59 | } 60 | 61 | if ($errorMsg) { 62 | Mage::throwException($errorMsg); 63 | } 64 | } 65 | 66 | return $this; 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /app/code/community/PayU/Account/Model/Method/PayuCard.php: -------------------------------------------------------------------------------- 1 | _getCheckout(); 36 | 37 | $order = Mage::getModel('sales/order'); 38 | $order->loadByIncrementId($session->getLastRealOrderId()); 39 | 40 | if (!$order->getId()) { 41 | Mage::throwException($this->__('No order for processing found')); 42 | } 43 | 44 | $redirectData = $this->getPayuModel($order->getPayment()->getMethod())->orderCreateRequest($order); 45 | 46 | $this->_redirectUrl($redirectData['redirectUri']); 47 | 48 | return; 49 | 50 | } catch (Exception $e) { 51 | Mage::logException($e); 52 | Mage::getSingleton('core/session')->addError($e->getMessage()); 53 | } 54 | 55 | $this->_redirectAction('failure'); 56 | } 57 | 58 | /** 59 | * Processes PayU OrderNotifyRequest 60 | */ 61 | public function orderNotifyRequestAction() 62 | { 63 | try { 64 | $this->getPayuModel($this->getRequest()->getParam('method'))->orderNotifyRequest(); 65 | } catch (Exception $e) { 66 | Mage::logException($e); 67 | } 68 | } 69 | 70 | /** 71 | * Continue payment action 72 | */ 73 | public function continuePaymentAction() 74 | { 75 | try { 76 | $this->_getCheckout()->getQuote()->setIsActive(false)->save(); 77 | } catch (Exception $e) { 78 | Mage::logException($e); 79 | } 80 | 81 | $this->_redirectAction($this->getRequest()->getParam('error') ? 'failure' : 'success'); 82 | 83 | } 84 | 85 | /** 86 | * @param string $action 87 | */ 88 | private function _redirectAction($action) 89 | { 90 | $this->_redirect('checkout/onepage/' . $action, array('_secure' => true)); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /app/code/community/PayU/Account/etc/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 2.4.4 6 | 7 | 8 | 9 | 10 | 11 | PayU_Account_Model 12 | 13 | 14 | 15 | 16 | PayU_Account_Helper 17 | 18 | 19 | 20 | 21 | PayU_Account_Block 22 | 23 | 24 | 25 | 26 | PayU 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | PayU_Account.csv 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | standard 45 | 46 | PayU_Account 47 | payu 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | PayU_Account.csv 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 0 65 | 0 66 | 1 67 | PayU 68 | payu/method_payuAccount 69 | payu 70 | 71 | 72 | 0 73 | 0 74 | PayU - Cards 75 | payu/method_payuCard 76 | payu 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /app/code/community/PayU/Account/etc/system.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | text 9 | 680 10 | 1 11 | 1 12 | 1 13 | please register in Production or please register in Sandbox]]> 14 | payu/adminhtml_block_system_config_form_fieldset 15 | 16 | 17 | 18 | adminhtml/system_config_form_field_heading 19 | 0 20 | 1 21 | 1 22 | 1 23 | 24 | 25 | 26 | select 27 | adminhtml/system_config_source_yesno 28 | 10 29 | 1 30 | 1 31 | 1 32 | 33 | 34 | 35 | select 36 | adminhtml/system_config_source_yesno 37 | 20 38 | 1 39 | 1 40 | 1 41 | 42 | 43 | 44 | Payment methods displayed on checkout page 45 | select 46 | adminhtml/system_config_source_yesno 47 | 22 48 | 1 49 | 1 50 | 1 51 | 52 | 53 | 54 | List of payment methods]]> 55 | text 56 | 24 57 | 1 58 | 1 59 | 1 60 | 61 | 62 | 63 | adminhtml/system_config_form_field_heading 64 | 70 65 | 1 66 | 1 67 | 1 68 | 69 | 70 | 71 | text 72 | 80 73 | 1 74 | 1 75 | 1 76 | 77 | 78 | 79 | text 80 | 90 81 | 1 82 | 1 83 | 1 84 | 85 | 86 | 87 | text 88 | 100 89 | 1 90 | 1 91 | 1 92 | 93 | 94 | 95 | text 96 | 110 97 | 1 98 | 1 99 | 1 100 | 101 | 102 | 103 | 1 104 | adminhtml/system_config_form_field_heading 105 | 120 106 | 1 107 | 1 108 | 1 109 | 110 | 111 | 112 | 1 113 | text 114 | 130 115 | 1 116 | 1 117 | 1 118 | 119 | 120 | 121 | 1 122 | text 123 | 140 124 | 1 125 | 1 126 | 1 127 | 128 | 129 | 130 | 1 131 | text 132 | 150 133 | 1 134 | 1 135 | 1 136 | 137 | 138 | 139 | 1 140 | text 141 | 160 142 | 1 143 | 1 144 | 1 145 | 146 | 147 | 148 | adminhtml/system_config_form_field_heading 149 | 230 150 | 1 151 | 0 152 | 0 153 | 154 | 155 | 156 | multiline 157 | payu/updateInfo 158 | 240 159 | 1 160 | 0 161 | 0 162 | 163 | 164 | 165 | 166 | 167 | text 168 | 681 169 | 1 170 | 1 171 | 1 172 | please register in Production or please register in Sandbox]]> 173 | payu/adminhtml_block_system_config_form_fieldset 174 | 175 | 176 | 177 | adminhtml/system_config_form_field_heading 178 | 0 179 | 1 180 | 1 181 | 1 182 | 183 | 184 | 185 | select 186 | adminhtml/system_config_source_yesno 187 | 10 188 | 1 189 | 1 190 | 1 191 | 192 | 193 | 194 | select 195 | adminhtml/system_config_source_yesno 196 | 20 197 | 1 198 | 1 199 | 1 200 | 201 | 202 | 203 | adminhtml/system_config_form_field_heading 204 | 70 205 | 1 206 | 1 207 | 1 208 | 209 | 210 | 211 | text 212 | 80 213 | 1 214 | 1 215 | 1 216 | 217 | 218 | 219 | text 220 | 90 221 | 1 222 | 1 223 | 1 224 | 225 | 226 | 227 | text 228 | 100 229 | 1 230 | 1 231 | 1 232 | 233 | 234 | 235 | text 236 | 110 237 | 1 238 | 1 239 | 1 240 | 241 | 242 | 243 | 1 244 | adminhtml/system_config_form_field_heading 245 | 120 246 | 1 247 | 1 248 | 1 249 | 250 | 251 | 252 | 1 253 | text 254 | 130 255 | 1 256 | 1 257 | 1 258 | 259 | 260 | 261 | 1 262 | text 263 | 140 264 | 1 265 | 1 266 | 1 267 | 268 | 269 | 270 | 1 271 | text 272 | 150 273 | 1 274 | 1 275 | 1 276 | 277 | 278 | 279 | 1 280 | text 281 | 160 282 | 1 283 | 1 284 | 1 285 | 286 | 287 | 288 | adminhtml/system_config_form_field_heading 289 | 230 290 | 1 291 | 0 292 | 0 293 | 294 | 295 | 296 | multiline 297 | payu/updateInfo 298 | 240 299 | 1 300 | 0 301 | 0 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | -------------------------------------------------------------------------------- /app/design/frontend/base/default/template/payu_account/card_form.phtml: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /app/design/frontend/base/default/template/payu_account/form.phtml: -------------------------------------------------------------------------------- 1 | getPayMethods(); 4 | ?> 5 | 6 | 46 | -------------------------------------------------------------------------------- /app/etc/modules/PayU_Account.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | true 6 | community 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/locale/pl_PL/PayU_Account.csv: -------------------------------------------------------------------------------- 1 | "PayU","PayU" 2 | "PayU - Cards","PayU - karty" 3 | "Enable plugin?","Czy włączyć wtyczkę?" 4 | "Main parameters","Główne parametry" 5 | "POS parameters","Parametry punktu płatności (POS)" 6 | "POS ID (pos_id)","Id punktu płatności (pos_id)" 7 | "Second key (MD5)","Drugi klucz (MD5)" 8 | "OAuth protocol - client_id","Protokół OAuth - client_id" 9 | "OAuth protocol - client_secret","Protokół OAuth - client_secret" 10 | "PayU Plugin Information","Informacja o wtyczce PayU" 11 | "You are currently using version","Aktualnie zainstalowana wersja" 12 | "Yes","Tak" 13 | "No","Nie" 14 | "Display payment methods","Wyświetlaj metody płatności" 15 | "Payment methods displayed on checkout page","Wyświetlaj metody płatności podczas procesu zamówienia " 16 | "Payment Methods Order","Kolejność metod płatności" 17 | "Please choose a payment method","Proszę wybrać metodę płatności" 18 | "Enter payment methods values separated by comma. List of payment methods","Podawaj symbole metod płatności oddzielając je przecinkiem. Lista metod płatności" 19 | "If you do not already have PayU merchant account, please register in Production or please register in Sandbox","Jeżeli nie posiadasz jeszcze konta w systemie PayU zarejestruj się w systemie produkcyjnym lub zarejestruj się w systemie sandbox" 20 | "Payment order: Payment is processed by PayU SA; The recipient's data, the payment title and the amount are provided to PayU SA by the recipient; The order is sent for processing when PayU SA receives your payment. The payment is transferred to the recipient within 1 hour, not later than until the end of the next business day; PayU SA does not charge any service fees.","Zlecenie realizacji płatności: Zlecenie wykonuje PayU SA; Dane odbiorcy, tytuł oraz kwota płatności dostarczane są PayU SA przez odbiorcę; Zlecenie jest przekazywane do realizacji po otrzymaniu przez PayU SA Państwa wpłaty. Płatność udostępniana jest odbiorcy w ciągu 1 godziny, nie później niż do końca następnego dnia roboczego; PayU SA nie pobiera opłaty od realizacji usługi." 21 | "The controller of your personal data is PayU S.A. with its registered office in Poznan (60-166), at Grunwaldzka Street 182 (""PayU""). Your personal data will be processed for purposes of processing payment transaction, notifying You about the status of this payment, dealing with complaints and also in order to fulfill the legal obligations imposed on PayU.","Administratorem Twoich danych osobowych jest PayU S.A. z siedzibą w Poznaniu (60-166), przy ul. Grunwaldzkiej 182 (""PayU""). Twoje dane osobowe będą przetwarzane w celu realizacji transakcji płatniczej, powiadamiania Cię o statusie realizacji Twojej płatności, rozpatrywania reklamacji, a także w celu wypełnienia obowiązków prawnych ciążących na PayU." 22 | "The recipients of your personal data may be entities cooperating with PayU during processing the payment. Depending on the payment method you choose, these may include: banks, payment institutions, loan institutions, payment card organizations, payment schemes), as well as suppliers supporting PayU’s activity providing: IT infrastructure, payment risk analysis tools and also entities that are authorised to receive it under the applicable provisions of law, including relevant judicial authorities. Your personal data may be shared with merchants to inform them about the status of the payment.
You have the right to access, rectify, restrict or oppose the processing of data, not to be subject to automated decision making, including profiling, or to transfer and erase Your personal data. Providing personal data is voluntary however necessary for the processing the payment and failure to provide the data may result in the rejection of the payment. For more information on how PayU processes your personal data, please click Payu Privacy Policy.","Odbiorcami Twoich danych osobowych mogą być podmioty współpracujące z PayU w procesie realizacji płatności. W zależności od wybranej przez Ciebie metody płatności mogą to być: banki, instytucje płatnicze, instytucje pożyczkowe, organizacje kart płatniczych, schematy płatnicze), ponadto podmioty wspierające działalność PayU tj. dostawcy infrastruktury IT, dostawcy narzędzi do analizy ryzyka płatności a także podmiotom uprawnionym do ich otrzymania na mocy obowiązujących przepisów prawa, w tym właściwym organom wymiaru sprawiedliwości. Twoje dane mogą zostać udostępnione akceptantom celem poinformowania ich o statusie realizacji płatności.
Przysługuje Tobie prawo dostępu do danych, a także do ich sprostowania, ograniczenia ich przetwarzania, zgłoszenia sprzeciwu wobec ich przetwarzania, niepodlegania zautomatyzowanemu podejmowaniu decyzji w tym profilowania oraz do przenoszenia i usunięcia danych. Podanie danych jest dobrowolne jednak niezbędne do realizacji płatności, a brak podania danych może skutkować odrzuceniem płatności. Więcej informacji o zasadach przetwarzania Twoich danych osobowych przez PayU znajdziesz w Polityce Prywatności PayU." 23 | "I accept","Akceptuję" 24 | "Terms and Conditions of the single transaction in of PayU","Regulamin pojedynczej transakcji płatniczej PayU" 25 | "You must accept the ""Terms and Conditions of the single transaction in of PayU""","Musisz zaakceptować ""Regulamin pojedynczej transakcji płatniczej PayU""" 26 | "Pay with PayU","Zapłać przez PayU" 27 | "Pay by card","Zapłać kartą" 28 | "After submitting the order you will be redirected to secure form where you can enter your card details","Po złożeniu zamówienia zostaniesz przekierowany do bezpiecznego formularza gdzie podasz dane karty" 29 | "After placing the order you will be redirected to the chosen method in order to make the payment","Po złożeniu zamówienia zostaniesz przekierowany do wybranej metody w celu dokonia płatności" 30 | "Order #%s","Zamówienie #%s" 31 | "Discount","Rabat" 32 | "Shipping","Dostawa" 33 | "No order for processing found","Brak zamówienia do przetwarzania" 34 | "New transaction started.","Nowa transakcja została rozpoczęta" 35 | "The transaction has been canceled.","Transakcja została anulowana." 36 | "The transaction is to be accepted or rejected.","Transakcja może być zaakceptowana lub odrzucona." 37 | "The transaction completed successfully.","Transakcja zakończona pomyślnie." 38 | "There was a problem with the payment initialization - "%s", please contact system administrator.","Wystąpił problem podczas inicjalizacji płatności - %s, prosimy o kontakt z obsługą sklepu." 39 | "Refund for order: %s","Zwrot do zamówienia %s" 40 | "Payu refund - amount: %s, status: %s","Zwrot Payu - kwota: %s, status: %s" 41 | "You will be redirected to PayU after submitting the order.","Po złożeniu zamówienia zostaniesz przekierowany do PayU w celu dokonania płatności" 42 | "Sandbox mode","Tryb testowy (Sandbox)" 43 | "POS parameters - Sandbox mode","Parametry punktu płatności (POS) - Tryb testowy (Sandbox)" 44 | -------------------------------------------------------------------------------- /lib/PayU/Cache/.htaccess: -------------------------------------------------------------------------------- 1 | order deny,allow 2 | deny from all -------------------------------------------------------------------------------- /lib/PayU/Cache/index.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PayU-EMEA/plugin_magento/6b84a2fd3a7f5a7c7c70c25c2e0bef6579a41c94/lib/PayU/Cache/index.php -------------------------------------------------------------------------------- /lib/PayU/OpenPayU/AuthType/AuthType.php: -------------------------------------------------------------------------------- 1 | authBasicToken = base64_encode($posId . ':' . $signatureKey); 22 | } 23 | 24 | public function getHeaders() 25 | { 26 | return array( 27 | 'Content-Type: application/json', 28 | 'Accept: application/json', 29 | 'Authorization: Basic ' . $this->authBasicToken 30 | ); 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /lib/PayU/OpenPayU/AuthType/Oauth.php: -------------------------------------------------------------------------------- 1 | oauthResult = OpenPayU_Oauth::getAccessToken(); 23 | } catch (OpenPayU_Exception $e) { 24 | throw new OpenPayU_Exception('Oauth error: [code=' . $e->getCode() . '], [message=' . $e->getMessage() . ']'); 25 | } 26 | 27 | } 28 | 29 | 30 | public function getHeaders() 31 | { 32 | return array( 33 | 'Content-Type: application/json', 34 | 'Accept: */*', 35 | 'Authorization: Bearer ' . $this->oauthResult->getAccessToken() 36 | ); 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /lib/PayU/OpenPayU/AuthType/TokenRequest.php: -------------------------------------------------------------------------------- 1 | version) && isset($composerData->extra[0]->engine)) { 410 | return sprintf("%s %s", $composerData->extra[0]->engine, $composerData->version); 411 | } 412 | } 413 | 414 | return self::DEFAULT_SDK_VERSION; 415 | } 416 | 417 | /** 418 | * @return string 419 | */ 420 | private static function getComposerFilePath() 421 | { 422 | return realpath(dirname(__FILE__)) . '/../../' . self::COMPOSER_JSON; 423 | } 424 | } 425 | -------------------------------------------------------------------------------- /lib/PayU/OpenPayU/Http.php: -------------------------------------------------------------------------------- 1 | getResponse(); 86 | $statusDesc = isset($response->status->statusDesc) ? $response->status->statusDesc : ''; 87 | 88 | switch ($statusCode) { 89 | case 400: 90 | throw new OpenPayU_Exception_Request($message, $message->getStatus().' - '.$statusDesc, $statusCode); 91 | break; 92 | 93 | case 401: 94 | case 403: 95 | throw new OpenPayU_Exception_Authorization($message->getStatus().' - '.$statusDesc, $statusCode); 96 | break; 97 | 98 | case 404: 99 | throw new OpenPayU_Exception_Network($message->getStatus().' - '.$statusDesc, $statusCode); 100 | break; 101 | 102 | case 408: 103 | throw new OpenPayU_Exception_ServerError('Request timeout', $statusCode); 104 | break; 105 | 106 | case 500: 107 | throw new OpenPayU_Exception_ServerError('PayU system is unavailable or your order is not processed. 108 | Error: 109 | [' . $statusDesc . ']', $statusCode); 110 | break; 111 | 112 | case 503: 113 | throw new OpenPayU_Exception_ServerMaintenance('Service unavailable', $statusCode); 114 | break; 115 | 116 | default: 117 | throw new OpenPayU_Exception_Network('Unexpected HTTP code response', $statusCode); 118 | break; 119 | 120 | } 121 | } 122 | 123 | /** 124 | * @param $statusCode 125 | * @param ResultError $resultError 126 | * @throws OpenPayU_Exception 127 | * @throws OpenPayU_Exception_Authorization 128 | * @throws OpenPayU_Exception_Network 129 | * @throws OpenPayU_Exception_ServerError 130 | * @throws OpenPayU_Exception_ServerMaintenance 131 | */ 132 | public static function throwErrorHttpStatusException($statusCode, $resultError) 133 | { 134 | switch ($statusCode) { 135 | case 400: 136 | throw new OpenPayU_Exception($resultError->getError().' - '.$resultError->getErrorDescription(), $statusCode); 137 | break; 138 | 139 | case 401: 140 | case 403: 141 | throw new OpenPayU_Exception_Authorization($resultError->getError().' - '.$resultError->getErrorDescription(), $statusCode); 142 | break; 143 | 144 | case 404: 145 | throw new OpenPayU_Exception_Network($resultError->getError().' - '.$resultError->getErrorDescription(), $statusCode); 146 | break; 147 | 148 | case 408: 149 | throw new OpenPayU_Exception_ServerError('Request timeout', $statusCode); 150 | break; 151 | 152 | case 500: 153 | throw new OpenPayU_Exception_ServerError('PayU system is unavailable. Error: [' . $resultError->getErrorDescription() . ']', $resultError); 154 | break; 155 | 156 | case 503: 157 | throw new OpenPayU_Exception_ServerMaintenance('Service unavailable', $statusCode); 158 | break; 159 | 160 | default: 161 | throw new OpenPayU_Exception_Network('Unexpected HTTP code response', $statusCode); 162 | break; 163 | 164 | } 165 | } 166 | 167 | } 168 | -------------------------------------------------------------------------------- /lib/PayU/OpenPayU/HttpCurl.php: -------------------------------------------------------------------------------- 1 | getHeaders()); 39 | curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'OpenPayU_HttpCurl::readHeader'); 40 | if ($data) { 41 | curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 42 | } 43 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 44 | curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); 45 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); 46 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 47 | curl_setopt($ch, CURLOPT_TIMEOUT, 60); 48 | 49 | if ($proxy = self::getProxy()) { 50 | curl_setopt($ch, CURLOPT_PROXY, $proxy); 51 | if ($proxyAuth = self::getProxyAuth()) { 52 | curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyAuth); 53 | } 54 | } 55 | 56 | $response = curl_exec($ch); 57 | $httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE); 58 | 59 | if($response === false) { 60 | throw new OpenPayU_Exception_Network(curl_error($ch)); 61 | } 62 | curl_close($ch); 63 | 64 | return array('code' => $httpStatus, 'response' => trim($response)); 65 | } 66 | 67 | /** 68 | * @param array $headers 69 | * 70 | * @return mixed 71 | */ 72 | public static function getSignature($headers) 73 | { 74 | foreach($headers as $name => $value) 75 | { 76 | if(preg_match('/X-OpenPayU-Signature/i', $name) || preg_match('/OpenPayu-Signature/i', $name)) 77 | return $value; 78 | } 79 | 80 | return null; 81 | } 82 | 83 | /** 84 | * @param resource $ch 85 | * @param string $header 86 | * @return int 87 | */ 88 | public static function readHeader($ch, $header) 89 | { 90 | if( preg_match('/([^:]+): (.+)/m', $header, $match) ) { 91 | self::$headers[$match[1]] = trim($match[2]); 92 | } 93 | 94 | return strlen($header); 95 | } 96 | 97 | private static function getProxy() 98 | { 99 | return OpenPayU_Configuration::getProxyHost() != null ? OpenPayU_Configuration::getProxyHost() 100 | . (OpenPayU_Configuration::getProxyPort() ? ':' . OpenPayU_Configuration::getProxyPort() : '') : false; 101 | } 102 | 103 | private static function getProxyAuth() 104 | { 105 | return OpenPayU_Configuration::getProxyUser() != null ? OpenPayU_Configuration::getProxyUser() 106 | . (OpenPayU_Configuration::getProxyPassword() ? ':' . OpenPayU_Configuration::getProxyPassword() : '') : false; 107 | } 108 | 109 | } 110 | -------------------------------------------------------------------------------- /lib/PayU/OpenPayU/Oauth/Cache/OauthCacheFile.php: -------------------------------------------------------------------------------- 1 | directory = $directory . (substr($directory, -1) != '/' ? '/' : ''); 22 | } 23 | 24 | public function get($key) 25 | { 26 | $cache = @file_get_contents($this->directory . md5($key)); 27 | return $cache === false ? null : unserialize($cache); 28 | } 29 | 30 | public function set($key, $value) 31 | { 32 | return @file_put_contents($this->directory . md5($key), serialize($value)); 33 | } 34 | 35 | public function invalidate($key) 36 | { 37 | return @unlink($this->directory . md5($key)); 38 | } 39 | 40 | } -------------------------------------------------------------------------------- /lib/PayU/OpenPayU/Oauth/Cache/OauthCacheInterface.php: -------------------------------------------------------------------------------- 1 | memcached = new Memcached('PayU'); 20 | $this->memcached->addServer($host, $port, $weight); 21 | $stats = $this->memcached->getStats(); 22 | if ($stats[$host . ':' . $port]['pid'] == -1) { 23 | throw new OpenPayU_Exception_Configuration('Problem with connection to memcached server [host=' . $host . '] [port=' . $port . '] [weight=' . $weight . ']'); 24 | } 25 | } 26 | 27 | public function get($key) 28 | { 29 | $cache = $this->memcached->get($key); 30 | return $cache === false ? null : unserialize($cache); 31 | } 32 | 33 | public function set($key, $value) 34 | { 35 | return $this->memcached->set($key, serialize($value)); 36 | } 37 | 38 | public function invalidate($key) 39 | { 40 | return $this->memcached->delete($key); 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /lib/PayU/OpenPayU/Oauth/Oauth.php: -------------------------------------------------------------------------------- 1 | get($cacheKey); 29 | 30 | if ($tokenCache instanceof OauthResultClientCredentials && !$tokenCache->hasExpire()) { 31 | return $tokenCache; 32 | } 33 | 34 | self::$oauthTokenCache->invalidate($cacheKey); 35 | $response = self::retrieveAccessToken($clientId, $clientSecret); 36 | self::$oauthTokenCache->set($cacheKey, $response); 37 | 38 | return $response; 39 | } 40 | 41 | /** 42 | * @param $clientId 43 | * @param $clientSecret 44 | * @return OauthResultClientCredentials 45 | * @throws OpenPayU_Exception_ServerError 46 | */ 47 | private static function retrieveAccessToken($clientId, $clientSecret) 48 | { 49 | $authType = new AuthType_TokenRequest(); 50 | 51 | $oauthUrl = OpenPayU_Configuration::getOauthEndpoint(); 52 | $data = array( 53 | 'grant_type' => OpenPayU_Configuration::getOauthGrantType(), 54 | 'client_id' => $clientId ? $clientId : OpenPayU_Configuration::getOauthClientId(), 55 | 'client_secret' => $clientSecret ? $clientSecret : OpenPayU_Configuration::getOauthClientSecret() 56 | ); 57 | 58 | if (OpenPayU_Configuration::getOauthGrantType() === OauthGrantType::TRUSTED_MERCHANT) { 59 | $data['email'] = OpenPayU_Configuration::getOauthEmail(); 60 | $data['ext_customer_id'] = OpenPayU_Configuration::getOauthExtCustomerId(); 61 | } 62 | 63 | return self::parseResponse(OpenPayU_Http::doPost($oauthUrl, http_build_query($data, '', '&'), $authType)); 64 | } 65 | 66 | /** 67 | * Parse response from PayU 68 | * 69 | * @param array $response 70 | * @return OauthResultClientCredentials 71 | * @throws OpenPayU_Exception 72 | * @throws OpenPayU_Exception_Authorization 73 | * @throws OpenPayU_Exception_Network 74 | * @throws OpenPayU_Exception_ServerError 75 | * @throws OpenPayU_Exception_ServerMaintenance 76 | */ 77 | private static function parseResponse($response) 78 | { 79 | $httpStatus = $response['code']; 80 | 81 | if ($httpStatus == 500) { 82 | $result = new ResultError(); 83 | $result->setErrorDescription($response['response']); 84 | OpenPayU_Http::throwErrorHttpStatusException($httpStatus, $result); 85 | } 86 | 87 | $message = OpenPayU_Util::convertJsonToArray($response['response'], true); 88 | 89 | if (json_last_error() == JSON_ERROR_SYNTAX) { 90 | throw new OpenPayU_Exception_ServerError('Incorrect json response. Response: [' . $response['response'] . ']'); 91 | } 92 | 93 | if ($httpStatus == 200) { 94 | $result = new OauthResultClientCredentials(); 95 | $result->setAccessToken($message['access_token']) 96 | ->setTokenType($message['token_type']) 97 | ->setExpiresIn($message['expires_in']) 98 | ->setGrantType($message['grant_type']) 99 | ->calculateExpireDate(new \DateTime()); 100 | 101 | return $result; 102 | } 103 | 104 | $result = new ResultError(); 105 | $result->setError($message['error']) 106 | ->setErrorDescription($message['error_description']); 107 | 108 | OpenPayU_Http::throwErrorHttpStatusException($httpStatus, $result); 109 | 110 | } 111 | 112 | private static function getOauthTokenCache() 113 | { 114 | $oauthTokenCache = OpenPayU_Configuration::getOauthTokenCache(); 115 | 116 | if (!$oauthTokenCache instanceof OauthCacheInterface) { 117 | $oauthTokenCache = new OauthCacheFile(); 118 | OpenPayU_Configuration::setOauthTokenCache($oauthTokenCache); 119 | } 120 | 121 | self::$oauthTokenCache = $oauthTokenCache; 122 | } 123 | } -------------------------------------------------------------------------------- /lib/PayU/OpenPayU/Oauth/OauthGrantType.php: -------------------------------------------------------------------------------- 1 | accessToken; 34 | } 35 | 36 | /** 37 | * @param string $accessToken 38 | * @return OauthResultClientCredentials 39 | */ 40 | public function setAccessToken($accessToken) 41 | { 42 | $this->accessToken = $accessToken; 43 | return $this; 44 | } 45 | 46 | /** 47 | * @return string 48 | */ 49 | public function getTokenType() 50 | { 51 | return $this->tokenType; 52 | } 53 | 54 | /** 55 | * @param string $tokenType 56 | * @return OauthResultClientCredentials 57 | */ 58 | public function setTokenType($tokenType) 59 | { 60 | $this->tokenType = $tokenType; 61 | return $this; 62 | } 63 | 64 | /** 65 | * @return string 66 | */ 67 | public function getExpiresIn() 68 | { 69 | return $this->expiresIn; 70 | } 71 | 72 | /** 73 | * @param string $expiresIn 74 | * @return OauthResultClientCredentials 75 | */ 76 | public function setExpiresIn($expiresIn) 77 | { 78 | $this->expiresIn = $expiresIn; 79 | return $this; 80 | } 81 | 82 | /** 83 | * @return string 84 | */ 85 | public function getGrantType() 86 | { 87 | return $this->grantType; 88 | } 89 | 90 | /** 91 | * @param string $grantType 92 | * @return OauthResultClientCredentials 93 | */ 94 | public function setGrantType($grantType) 95 | { 96 | $this->grantType = $grantType; 97 | return $this; 98 | } 99 | 100 | /** 101 | * @return DateTime 102 | */ 103 | public function getExpireDate() 104 | { 105 | return $this->expireDate; 106 | } 107 | 108 | /** 109 | * @param DateTime $date 110 | */ 111 | public function calculateExpireDate($date) 112 | { 113 | $this->expireDate = $date->add(new DateInterval('PT' . ($this->expiresIn - 60) . 'S')); 114 | } 115 | 116 | public function hasExpire() 117 | { 118 | return ($this->expireDate <= new DateTime()); 119 | } 120 | 121 | } -------------------------------------------------------------------------------- /lib/PayU/OpenPayU/OpenPayU.php: -------------------------------------------------------------------------------- 1 | init($data); 23 | 24 | return $instance; 25 | } 26 | 27 | /** 28 | * @param $data 29 | * @param $incomingSignature 30 | * @throws OpenPayU_Exception_Authorization 31 | */ 32 | public static function verifyDocumentSignature($data, $incomingSignature) 33 | { 34 | $sign = OpenPayU_Util::parseSignature($incomingSignature); 35 | 36 | if (false === OpenPayU_Util::verifySignature( 37 | $data, 38 | $sign->signature, 39 | OpenPayU_Configuration::getSignatureKey(), 40 | $sign->algorithm) 41 | ) { 42 | throw new OpenPayU_Exception_Authorization('Invalid signature - ' . $sign->signature); 43 | } 44 | } 45 | 46 | /** 47 | * @return AuthType 48 | * @throws OpenPayU_Exception 49 | */ 50 | protected static function getAuth() 51 | { 52 | if (OpenPayU_Configuration::getOauthClientId() && OpenPayU_Configuration::getOauthClientSecret()) { 53 | $authType = new AuthType_Oauth(OpenPayU_Configuration::getOauthClientId(), OpenPayU_Configuration::getOauthClientSecret()); 54 | } else { 55 | $authType = new AuthType_Basic(OpenPayU_Configuration::getMerchantPosId(), OpenPayU_Configuration::getSignatureKey()); 56 | } 57 | 58 | return $authType; 59 | } 60 | 61 | 62 | } -------------------------------------------------------------------------------- /lib/PayU/OpenPayU/OpenPayUException.php: -------------------------------------------------------------------------------- 1 | originalResponseMessage = $originalResponseMessage; 24 | 25 | parent::__construct($message, $code, $previous); 26 | } 27 | 28 | /** @return null|stdClass */ 29 | public function getOriginalResponse() 30 | { 31 | return $this->originalResponseMessage; 32 | } 33 | } 34 | 35 | class OpenPayU_Exception_Configuration extends OpenPayU_Exception 36 | { 37 | 38 | } 39 | 40 | class OpenPayU_Exception_Network extends OpenPayU_Exception 41 | { 42 | 43 | } 44 | 45 | class OpenPayU_Exception_ServerError extends OpenPayU_Exception 46 | { 47 | 48 | } 49 | 50 | class OpenPayU_Exception_ServerMaintenance extends OpenPayU_Exception 51 | { 52 | 53 | } 54 | 55 | class OpenPayU_Exception_Authorization extends OpenPayU_Exception 56 | { 57 | 58 | } -------------------------------------------------------------------------------- /lib/PayU/OpenPayU/OpenPayuOrderStatus.php: -------------------------------------------------------------------------------- 1 | status; 30 | } 31 | 32 | /** 33 | * @access public 34 | * @param $value 35 | */ 36 | public function setStatus($value) 37 | { 38 | $this->status = $value; 39 | } 40 | 41 | /** 42 | * @access public 43 | * @return string 44 | */ 45 | public function getError() 46 | { 47 | return $this->error; 48 | } 49 | 50 | /** 51 | * @access public 52 | * @param $value 53 | */ 54 | public function setError($value) 55 | { 56 | $this->error = $value; 57 | } 58 | 59 | /** 60 | * @access public 61 | * @return int 62 | */ 63 | public function getSuccess() 64 | { 65 | return $this->success; 66 | } 67 | 68 | /** 69 | * @access public 70 | * @param $value 71 | */ 72 | public function setSuccess($value) 73 | { 74 | $this->success = $value; 75 | } 76 | 77 | /** 78 | * @access public 79 | * @return string 80 | */ 81 | public function getRequest() 82 | { 83 | return $this->request; 84 | } 85 | 86 | /** 87 | * @access public 88 | * @param $value 89 | */ 90 | public function setRequest($value) 91 | { 92 | $this->request = $value; 93 | } 94 | 95 | /** 96 | * @access public 97 | * @return string 98 | */ 99 | public function getResponse() 100 | { 101 | return $this->response; 102 | } 103 | 104 | /** 105 | * @access public 106 | * @param $value 107 | */ 108 | public function setResponse($value) 109 | { 110 | $this->response = $value; 111 | } 112 | 113 | /** 114 | * @access public 115 | * @return string 116 | */ 117 | public function getSessionId() 118 | { 119 | return $this->sessionId; 120 | } 121 | 122 | /** 123 | * @access public 124 | * @param $value 125 | */ 126 | public function setSessionId($value) 127 | { 128 | $this->sessionId = $value; 129 | } 130 | 131 | /** 132 | * @access public 133 | * @return string 134 | */ 135 | public function getMessage() 136 | { 137 | return $this->message; 138 | } 139 | 140 | /** 141 | * @access public 142 | * @param $value 143 | */ 144 | public function setMessage($value) 145 | { 146 | $this->message = $value; 147 | } 148 | 149 | /** 150 | * @access public 151 | * @return string 152 | */ 153 | public function getCountryCode() 154 | { 155 | return $this->countryCode; 156 | } 157 | 158 | /** 159 | * @access public 160 | * @param $value 161 | */ 162 | public function setCountryCode($value) 163 | { 164 | $this->countryCode = $value; 165 | } 166 | 167 | /** 168 | * @access public 169 | * @return string 170 | */ 171 | public function getReqId() 172 | { 173 | return $this->reqId; 174 | } 175 | 176 | /** 177 | * @access public 178 | * @param $value 179 | */ 180 | public function setReqId($value) 181 | { 182 | $this->reqId = $value; 183 | } 184 | 185 | public function init($attributes) 186 | { 187 | $attributes = OpenPayU_Util::parseArrayToObject($attributes); 188 | 189 | if (!empty($attributes)) { 190 | foreach ($attributes as $name => $value) { 191 | $this->set($name, $value); 192 | } 193 | } 194 | } 195 | 196 | public function set($name, $value) 197 | { 198 | $this->{$name} = $value; 199 | } 200 | 201 | public function __get($name) 202 | { 203 | if (isset($this->{$name})) 204 | return $this->name; 205 | 206 | return null; 207 | } 208 | 209 | public function __call($methodName, $args) { 210 | if (preg_match('~^(set|get)([A-Z])(.*)$~', $methodName, $matches)) { 211 | $property = strtolower($matches[2]) . $matches[3]; 212 | if (!property_exists($this, $property)) { 213 | throw new Exception('Property ' . $property . ' not exists'); 214 | } 215 | switch($matches[1]) { 216 | case 'get': 217 | $this->checkArguments($args, 0, 0, $methodName); 218 | return $this->get($property); 219 | case 'default': 220 | throw new Exception('Method ' . $methodName . ' not exists'); 221 | } 222 | } 223 | } 224 | } -------------------------------------------------------------------------------- /lib/PayU/OpenPayU/ResultError.php: -------------------------------------------------------------------------------- 1 | error; 29 | } 30 | 31 | /** 32 | * @param string $error 33 | * @return ResultError 34 | */ 35 | public function setError($error) 36 | { 37 | $this->error = $error; 38 | return $this; 39 | } 40 | 41 | /** 42 | * @return string 43 | */ 44 | public function getErrorDescription() 45 | { 46 | return $this->errorDescription; 47 | } 48 | 49 | /** 50 | * @param string $errorDescription 51 | * @return ResultError 52 | */ 53 | public function setErrorDescription($errorDescription) 54 | { 55 | $this->errorDescription = $errorDescription; 56 | return $this; 57 | } 58 | 59 | } -------------------------------------------------------------------------------- /lib/PayU/OpenPayU/Util.php: -------------------------------------------------------------------------------- 1 | $value) { 37 | $contentForSign .= $key . '=' . urlencode($value) . '&'; 38 | } 39 | 40 | if (in_array($algorithm, array('SHA-256', 'SHA'))) { 41 | $hashAlgorithm = 'sha256'; 42 | $algorithm = 'SHA-256'; 43 | } else if ($algorithm == 'SHA-384') { 44 | $hashAlgorithm = 'sha384'; 45 | $algorithm = 'SHA-384'; 46 | } else if ($algorithm == 'SHA-512') { 47 | $hashAlgorithm = 'sha512'; 48 | $algorithm = 'SHA-512'; 49 | } 50 | 51 | $signature = hash($hashAlgorithm, $contentForSign . $signatureKey); 52 | 53 | $signData = 'sender=' . $merchantPosId . ';algorithm=' . $algorithm . ';signature=' . $signature; 54 | 55 | return $signData; 56 | } 57 | 58 | /** 59 | * Function returns signature data object 60 | * 61 | * @param string $data 62 | * 63 | * @return null|object 64 | */ 65 | public static function parseSignature($data) 66 | { 67 | if (empty($data)) { 68 | return null; 69 | } 70 | 71 | $signatureData = array(); 72 | 73 | $list = explode(';', rtrim($data, ';')); 74 | if (empty($list)) { 75 | return null; 76 | } 77 | 78 | foreach ($list as $value) { 79 | $explode = explode('=', $value); 80 | if (count($explode) != 2) { 81 | return null; 82 | } 83 | $signatureData[$explode[0]] = $explode[1]; 84 | } 85 | 86 | return (object)$signatureData; 87 | } 88 | 89 | /** 90 | * Function returns signature validate 91 | * 92 | * @param string $message 93 | * @param string $signature 94 | * @param string $signatureKey 95 | * @param string $algorithm 96 | * 97 | * @return bool 98 | */ 99 | public static function verifySignature($message, $signature, $signatureKey, $algorithm = 'MD5') 100 | { 101 | if (isset($signature)) { 102 | if ($algorithm === 'MD5') { 103 | $hash = md5($message . $signatureKey); 104 | } else if (in_array($algorithm, array('SHA', 'SHA1', 'SHA-1'))) { 105 | $hash = sha1($message . $signatureKey); 106 | } else { 107 | $hash = hash('sha256', $message . $signatureKey); 108 | } 109 | 110 | if (strcmp($signature, $hash) == 0) { 111 | return true; 112 | } 113 | } 114 | 115 | return false; 116 | } 117 | 118 | /** 119 | * Function builds OpenPayU Json Document 120 | * 121 | * @param string $data 122 | * @param string $rootElement 123 | * 124 | * @return null|string 125 | */ 126 | public static function buildJsonFromArray($data, $rootElement = '') 127 | { 128 | if (!is_array($data)) { 129 | return null; 130 | } 131 | 132 | if (!empty($rootElement)) { 133 | $data = array($rootElement => $data); 134 | } 135 | 136 | $data = self::setSenderProperty($data); 137 | 138 | return json_encode($data); 139 | } 140 | 141 | /** 142 | * @param string $data 143 | * @param bool $assoc 144 | * @return mixed|null 145 | */ 146 | public static function convertJsonToArray($data, $assoc = false) 147 | { 148 | if (empty($data)) { 149 | return null; 150 | } 151 | 152 | return json_decode($data, $assoc); 153 | } 154 | 155 | /** 156 | * @param array $array 157 | * @return bool|stdClass 158 | */ 159 | public static function parseArrayToObject($array) 160 | { 161 | if (!is_array($array)) { 162 | return $array; 163 | } 164 | 165 | if (self::isAssocArray($array)) { 166 | $object = new stdClass(); 167 | } else { 168 | $object = array(); 169 | } 170 | 171 | if (is_array($array) && count($array) > 0) { 172 | foreach ($array as $name => $value) { 173 | $name = trim($name); 174 | if (isset($name)) { 175 | if (is_numeric($name)) { 176 | $object[] = self::parseArrayToObject($value); 177 | } else { 178 | $object->$name = self::parseArrayToObject($value); 179 | } 180 | } 181 | } 182 | return $object; 183 | } 184 | 185 | return false; 186 | } 187 | 188 | /** 189 | * @return mixed 190 | */ 191 | public static function getRequestHeaders() 192 | { 193 | if (!function_exists('apache_request_headers')) { 194 | $headers = array(); 195 | foreach ($_SERVER as $key => $value) { 196 | if (substr($key, 0, 5) == 'HTTP_') { 197 | $headers[str_replace(' ', '-', ucwords(str_replace('_', ' ', strtolower(substr($key, 5)))))] = $value; 198 | } 199 | } 200 | return $headers; 201 | } else { 202 | return apache_request_headers(); 203 | } 204 | 205 | } 206 | 207 | /** 208 | * @param $array 209 | * @param string $namespace 210 | * @param array $outputFields 211 | * @return string 212 | */ 213 | public static function convertArrayToHtmlForm($array, $namespace = "", &$outputFields) 214 | { 215 | $i = 0; 216 | $htmlOutput = ""; 217 | $assoc = self::isAssocArray($array); 218 | 219 | foreach ($array as $key => $value) { 220 | 221 | if ($namespace && $assoc) { 222 | $key = $namespace . '.' . $key; 223 | } elseif ($namespace && !$assoc) { 224 | $key = $namespace . '[' . $i++ . ']'; 225 | } 226 | 227 | if (is_array($value)) { 228 | $htmlOutput .= self::convertArrayToHtmlForm($value, $key, $outputFields); 229 | } else { 230 | $htmlOutput .= sprintf("\n", $key, $value); 231 | $outputFields[$key] = $value; 232 | } 233 | } 234 | return $htmlOutput; 235 | } 236 | 237 | /** 238 | * @param $arr 239 | * @return bool 240 | */ 241 | public static function isAssocArray($arr) 242 | { 243 | $arrKeys = array_keys($arr); 244 | sort($arrKeys, SORT_NUMERIC); 245 | return $arrKeys !== range(0, count($arr) - 1); 246 | } 247 | 248 | /** 249 | * @param $namespace 250 | * @param $key 251 | * @return string 252 | */ 253 | public static function changeFormFieldFormat($namespace, $key) 254 | { 255 | 256 | if ($key === $namespace && $key[strlen($key) - 1] == 's') { 257 | return substr($key, 0, -1); 258 | } 259 | return $key; 260 | } 261 | 262 | /** 263 | * @param array $data 264 | * @return array 265 | */ 266 | private static function setSenderProperty($data) 267 | { 268 | $data['properties'][0] = array( 269 | 'name' => 'sender', 270 | 'value' => OpenPayU_Configuration::getFullSenderName() 271 | ); 272 | return $data; 273 | } 274 | 275 | public static function statusDesc($response) 276 | { 277 | 278 | $msg = ''; 279 | 280 | switch ($response) { 281 | case 'SUCCESS': 282 | $msg = 'Request has been processed correctly.'; 283 | break; 284 | case 'DATA_NOT_FOUND': 285 | $msg = 'Data indicated in the request is not available in the PayU system.'; 286 | break; 287 | case 'WARNING_CONTINUE_3_DS': 288 | $msg = '3DS authorization required.Redirect the Buyer to PayU to continue the 3DS process by calling OpenPayU.authorize3DS().'; 289 | break; 290 | case 'WARNING_CONTINUE_CVV': 291 | $msg = 'CVV/CVC authorization required. Call OpenPayU.authorizeCVV() method.'; 292 | break; 293 | case 'ERROR_SYNTAX': 294 | $msg = 'BIncorrect request syntax. Supported formats are JSON or XML.'; 295 | break; 296 | case 'ERROR_VALUE_INVALID': 297 | $msg = 'One or more required values are incorrect.'; 298 | break; 299 | case 'ERROR_VALUE_MISSING': 300 | $msg = 'One or more required values are missing.'; 301 | break; 302 | case 'BUSINESS_ERROR': 303 | $msg = 'PayU system is unavailable. Try again later.'; 304 | break; 305 | case 'ERROR_INTERNAL': 306 | $msg = 'PayU system is unavailable. Try again later.'; 307 | break; 308 | case 'GENERAL_ERROR': 309 | $msg = 'Unexpected error. Try again later.'; 310 | break; 311 | } 312 | 313 | return $msg; 314 | } 315 | 316 | } 317 | -------------------------------------------------------------------------------- /lib/PayU/OpenPayU/v2/Order.php: -------------------------------------------------------------------------------- 1 | '', 26 | 'formId' => 'payu-payment-form', 27 | 'submitClass' => '', 28 | 'submitId' => '', 29 | 'submitContent' => '', 30 | 'submitTarget' => '_blank' 31 | ); 32 | 33 | /** 34 | * Creates new Order 35 | * - Sends to PayU OrderCreateRequest 36 | * 37 | * @param array $order A array containing full Order 38 | * @return object $result Response array with OrderCreateResponse 39 | * @throws OpenPayU_Exception 40 | */ 41 | public static function create($order) 42 | { 43 | $data = OpenPayU_Util::buildJsonFromArray($order); 44 | 45 | if (empty($data)) { 46 | throw new OpenPayU_Exception('Empty message OrderCreateRequest'); 47 | } 48 | 49 | try { 50 | $authType = self::getAuth(); 51 | } catch (OpenPayU_Exception $e) { 52 | throw new OpenPayU_Exception($e->getMessage(), $e->getCode()); 53 | } 54 | 55 | $pathUrl = OpenPayU_Configuration::getServiceUrl() . self::ORDER_SERVICE; 56 | 57 | $result = self::verifyResponse(OpenPayU_Http::doPost($pathUrl, $data, $authType), 'OrderCreateResponse'); 58 | 59 | return $result; 60 | } 61 | 62 | /** 63 | * Retrieves information about the order 64 | * - Sends to PayU OrderRetrieveRequest 65 | * 66 | * @param string $orderId PayU OrderId sent back in OrderCreateResponse 67 | * @return OpenPayU_Result $result Response array with OrderRetrieveResponse 68 | * @throws OpenPayU_Exception 69 | */ 70 | public static function retrieve($orderId) 71 | { 72 | if (empty($orderId)) { 73 | throw new OpenPayU_Exception('Empty value of orderId'); 74 | } 75 | 76 | try { 77 | $authType = self::getAuth(); 78 | } catch (OpenPayU_Exception $e) { 79 | throw new OpenPayU_Exception($e->getMessage(), $e->getCode()); 80 | } 81 | 82 | $pathUrl = OpenPayU_Configuration::getServiceUrl() . self::ORDER_SERVICE . $orderId; 83 | 84 | $result = self::verifyResponse(OpenPayU_Http::doGet($pathUrl, $authType), 'OrderRetrieveResponse'); 85 | 86 | return $result; 87 | } 88 | 89 | /** 90 | * Retrieves information about the order transaction 91 | * - Sends to PayU TransactionRetrieveRequest 92 | * 93 | * @param string $orderId PayU OrderId sent back in OrderCreateResponse 94 | * @return OpenPayU_Result $result Response array with TransactionRetrieveResponse 95 | * @throws OpenPayU_Exception 96 | */ 97 | public static function retrieveTransaction($orderId) 98 | { 99 | if (empty($orderId)) { 100 | throw new OpenPayU_Exception('Empty value of orderId'); 101 | } 102 | 103 | try { 104 | $authType = self::getAuth(); 105 | } catch (OpenPayU_Exception $e) { 106 | throw new OpenPayU_Exception($e->getMessage(), $e->getCode()); 107 | } 108 | 109 | $pathUrl = OpenPayU_Configuration::getServiceUrl() . self::ORDER_SERVICE . $orderId . '/' . self::ORDER_TRANSACTION_SERVICE; 110 | 111 | $result = self::verifyResponse(OpenPayU_Http::doGet($pathUrl, $authType), 'TransactionRetrieveResponse'); 112 | 113 | return $result; 114 | } 115 | 116 | /** 117 | * Cancels Order 118 | * - Sends to PayU OrderCancelRequest 119 | * 120 | * @param string $orderId PayU OrderId sent back in OrderCreateResponse 121 | * @return OpenPayU_Result $result Response array with OrderCancelResponse 122 | * @throws OpenPayU_Exception 123 | */ 124 | public static function cancel($orderId) 125 | { 126 | if (empty($orderId)) { 127 | throw new OpenPayU_Exception('Empty value of orderId'); 128 | } 129 | 130 | try { 131 | $authType = self::getAuth(); 132 | } catch (OpenPayU_Exception $e) { 133 | throw new OpenPayU_Exception($e->getMessage(), $e->getCode()); 134 | } 135 | 136 | $pathUrl = OpenPayU_Configuration::getServiceUrl() . self::ORDER_SERVICE . $orderId; 137 | 138 | $result = self::verifyResponse(OpenPayU_Http::doDelete($pathUrl, $authType), 'OrderCancelResponse'); 139 | return $result; 140 | } 141 | 142 | /** 143 | * Updates Order status 144 | * - Sends to PayU OrderStatusUpdateRequest 145 | * 146 | * @param string $orderStatusUpdate A array containing full OrderStatus 147 | * @return OpenPayU_Result $result Response array with OrderStatusUpdateResponse 148 | * @throws OpenPayU_Exception 149 | */ 150 | public static function statusUpdate($orderStatusUpdate) 151 | { 152 | if (empty($orderStatusUpdate)) { 153 | throw new OpenPayU_Exception('Empty order status data'); 154 | } 155 | 156 | try { 157 | $authType = self::getAuth(); 158 | } catch (OpenPayU_Exception $e) { 159 | throw new OpenPayU_Exception($e->getMessage(), $e->getCode()); 160 | } 161 | 162 | $data = OpenPayU_Util::buildJsonFromArray($orderStatusUpdate); 163 | $pathUrl = OpenPayU_Configuration::getServiceUrl() . self::ORDER_SERVICE . $orderStatusUpdate['orderId'] . '/status'; 164 | 165 | $result = self::verifyResponse(OpenPayU_Http::doPut($pathUrl, $data, $authType), 'OrderStatusUpdateResponse'); 166 | 167 | return $result; 168 | } 169 | 170 | /** 171 | * Consume notification message 172 | * 173 | * @access public 174 | * @param $data string Request array received from with PayU OrderNotifyRequest 175 | * @return null|OpenPayU_Result Response array with OrderNotifyRequest 176 | * @throws OpenPayU_Exception 177 | */ 178 | public static function consumeNotification($data) 179 | { 180 | if (empty($data)) { 181 | throw new OpenPayU_Exception('Empty value of data'); 182 | } 183 | 184 | $headers = OpenPayU_Util::getRequestHeaders(); 185 | $incomingSignature = OpenPayU_HttpCurl::getSignature($headers); 186 | 187 | self::verifyDocumentSignature($data, $incomingSignature); 188 | 189 | return OpenPayU_Order::verifyResponse(array('response' => $data, 'code' => 200), 'OrderNotifyRequest'); 190 | } 191 | 192 | /** 193 | * Verify response from PayU 194 | * 195 | * @param string $response 196 | * @param string $messageName 197 | * @return null|OpenPayU_Result 198 | * @throws OpenPayU_Exception 199 | * @throws OpenPayU_Exception_Authorization 200 | * @throws OpenPayU_Exception_Network 201 | * @throws OpenPayU_Exception_ServerError 202 | * @throws OpenPayU_Exception_ServerMaintenance 203 | */ 204 | public static function verifyResponse($response, $messageName) 205 | { 206 | $data = array(); 207 | $httpStatus = $response['code']; 208 | 209 | $message = OpenPayU_Util::convertJsonToArray($response['response'], true); 210 | 211 | $data['status'] = isset($message['status']['statusCode']) ? $message['status']['statusCode'] : null; 212 | 213 | if (json_last_error() == JSON_ERROR_SYNTAX) { 214 | $data['response'] = $response['response']; 215 | } elseif (isset($message[$messageName])) { 216 | unset($message[$messageName]['Status']); 217 | $data['response'] = $message[$messageName]; 218 | } elseif (isset($message)) { 219 | $data['response'] = $message; 220 | unset($message['status']); 221 | } 222 | 223 | $result = self::build($data); 224 | 225 | if ($httpStatus == 200 || $httpStatus == 201 || $httpStatus == 422 || $httpStatus == 301 || $httpStatus == 302) { 226 | return $result; 227 | } 228 | 229 | OpenPayU_Http::throwHttpStatusException($httpStatus, $result); 230 | } 231 | 232 | /** 233 | * Generate a form body for hosted order 234 | * 235 | * @access public 236 | * @param array $order an array containing full Order 237 | * @param array $params an optional array with form elements' params 238 | * @return string Response html form 239 | * @throws OpenPayU_Exception_Configuration 240 | */ 241 | public static function hostedOrderForm($order, $params = array()) 242 | { 243 | $orderFormUrl = OpenPayU_Configuration::getServiceUrl() . 'orders'; 244 | 245 | $formFieldValuesAsArray = array(); 246 | $htmlFormFields = OpenPayU_Util::convertArrayToHtmlForm($order, '', $formFieldValuesAsArray); 247 | 248 | $signature = OpenPayU_Util::generateSignData( 249 | $formFieldValuesAsArray, 250 | OpenPayU_Configuration::getHashAlgorithm(), 251 | OpenPayU_Configuration::getMerchantPosId(), 252 | OpenPayU_Configuration::getSignatureKey() 253 | ); 254 | 255 | $formParams = array_merge(self::$defaultFormParams, $params); 256 | 257 | $htmlOutput = sprintf("
\n", $orderFormUrl, $formParams['formId'], $formParams['formClass']); 258 | $htmlOutput .= $htmlFormFields; 259 | $htmlOutput .= sprintf("", $signature); 260 | $htmlOutput .= sprintf("", $formParams['submitTarget'], $formParams['submitId'], $formParams['submitClass'], $formParams['submitContent']); 261 | $htmlOutput .= "
\n"; 262 | 263 | return $htmlOutput; 264 | } 265 | 266 | } 267 | -------------------------------------------------------------------------------- /lib/PayU/OpenPayU/v2/Refund.php: -------------------------------------------------------------------------------- 1 | $orderId, 33 | 'refund' => array('description' => $description) 34 | ); 35 | 36 | if (!empty($amount)) { 37 | $refund['refund']['amount'] = (int)$amount; 38 | } 39 | 40 | try { 41 | $authType = self::getAuth(); 42 | } catch (OpenPayU_Exception $e) { 43 | throw new OpenPayU_Exception($e->getMessage(), $e->getCode()); 44 | } 45 | 46 | $pathUrl = OpenPayU_Configuration::getServiceUrl().'orders/'. $refund['orderId'] . '/refund'; 47 | 48 | $data = OpenPayU_Util::buildJsonFromArray($refund); 49 | 50 | $result = self::verifyResponse(OpenPayU_Http::doPost($pathUrl, $data, $authType), 'RefundCreateResponse'); 51 | 52 | return $result; 53 | } 54 | 55 | /** 56 | * @param string $response 57 | * @param string $messageName 58 | * @return OpenPayU_Result 59 | */ 60 | public static function verifyResponse($response, $messageName='') 61 | { 62 | $data = array(); 63 | $httpStatus = $response['code']; 64 | 65 | $message = OpenPayU_Util::convertJsonToArray($response['response'], true); 66 | 67 | $data['status'] = isset($message['status']['statusCode']) ? $message['status']['statusCode'] : null; 68 | 69 | if (json_last_error() == JSON_ERROR_SYNTAX) { 70 | $data['response'] = $response['response']; 71 | } elseif (isset($message[$messageName])) { 72 | unset($message[$messageName]['Status']); 73 | $data['response'] = $message[$messageName]; 74 | } elseif (isset($message)) { 75 | $data['response'] = $message; 76 | unset($message['status']); 77 | } 78 | 79 | $result = self::build($data); 80 | 81 | if ($httpStatus == 200 || $httpStatus == 201 || $httpStatus == 422 || $httpStatus == 302) { 82 | return $result; 83 | } else { 84 | OpenPayU_Http::throwHttpStatusException($httpStatus, $result); 85 | } 86 | } 87 | } -------------------------------------------------------------------------------- /lib/PayU/OpenPayU/v2/Retrieve.php: -------------------------------------------------------------------------------- 1 | getMessage(), $e->getCode()); 30 | } 31 | 32 | if (!$authType instanceof AuthType_Oauth) { 33 | throw new OpenPayU_Exception_Configuration('Retrieve works only with OAuth'); 34 | } 35 | 36 | $pathUrl = OpenPayU_Configuration::getServiceUrl() . self::PAYMETHODS_SERVICE; 37 | if ($lang !== null) { 38 | $pathUrl .= '?lang=' . $lang; 39 | } 40 | 41 | $response = self::verifyResponse(OpenPayU_Http::doGet($pathUrl, $authType)); 42 | 43 | return $response; 44 | } 45 | 46 | /** 47 | * @param string $response 48 | * @return null|OpenPayU_Result 49 | */ 50 | public static function verifyResponse($response) 51 | { 52 | $data = array(); 53 | $httpStatus = $response['code']; 54 | 55 | $message = OpenPayU_Util::convertJsonToArray($response['response'], true); 56 | 57 | $data['status'] = isset($message['status']['statusCode']) ? $message['status']['statusCode'] : null; 58 | 59 | if (json_last_error() == JSON_ERROR_SYNTAX) { 60 | $data['response'] = $response['response']; 61 | } elseif (isset($message)) { 62 | $data['response'] = $message; 63 | unset($message['status']); 64 | } 65 | 66 | $result = self::build($data); 67 | 68 | if ($httpStatus == 200 || $httpStatus == 201 || $httpStatus == 422 || $httpStatus == 302 || $httpStatus == 400 || $httpStatus == 404) { 69 | return $result; 70 | } else { 71 | OpenPayU_Http::throwHttpStatusException($httpStatus, $result); 72 | } 73 | 74 | } 75 | } -------------------------------------------------------------------------------- /lib/PayU/OpenPayU/v2/Token.php: -------------------------------------------------------------------------------- 1 | getMessage(), $e->getCode()); 30 | } 31 | 32 | if (!$authType instanceof AuthType_Oauth) { 33 | throw new OpenPayU_Exception_Configuration('Delete token works only with OAuth'); 34 | } 35 | 36 | if (OpenPayU_Configuration::getOauthGrantType() !== OauthGrantType::TRUSTED_MERCHANT) { 37 | throw new OpenPayU_Exception_Configuration('Token delete request is available only for trusted_merchant'); 38 | } 39 | 40 | $pathUrl = OpenPayU_Configuration::getServiceUrl() . self::TOKENS_SERVICE . '/' . $token; 41 | 42 | $response = self::verifyResponse(OpenPayU_Http::doDelete($pathUrl, $authType)); 43 | 44 | return $response; 45 | } 46 | 47 | /** 48 | * @param string $response 49 | * @return null|OpenPayU_Result 50 | */ 51 | public static function verifyResponse($response) 52 | { 53 | $data = array(); 54 | $httpStatus = $response['code']; 55 | 56 | $message = OpenPayU_Util::convertJsonToArray($response['response'], true); 57 | 58 | $data['status'] = isset($message['status']['statusCode']) ? $message['status']['statusCode'] : null; 59 | 60 | if (json_last_error() == JSON_ERROR_SYNTAX) { 61 | $data['response'] = $response['response']; 62 | } elseif (isset($message)) { 63 | $data['response'] = $message; 64 | unset($message['status']); 65 | } 66 | 67 | $result = self::build($data); 68 | 69 | if ($httpStatus == 204) { 70 | return $result; 71 | } else { 72 | OpenPayU_Http::throwHttpStatusException($httpStatus, $result); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /lib/PayU/openpayu.php: -------------------------------------------------------------------------------- 1 |