├── .gitignore
├── COPYING
├── COPYING.LESSER
├── README.md
├── index.js
├── lib
├── WebPay.js
├── WebPayOneClick.js
├── WebPayOneClickMall.js
└── WebPayUniqueAndSpecialNonStandardWSSecurityCert.js
├── package-lock.json
├── package.json
└── showcase
├── cert
├── normal.js
├── oneClick.js
└── oneClickMall.js
├── onError.js
├── testNormal.js
├── testOneclick.js
└── testOneclickMall.js
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
--------------------------------------------------------------------------------
/COPYING:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/COPYING.LESSER:
--------------------------------------------------------------------------------
1 | GNU LESSER 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 |
9 | This version of the GNU Lesser General Public License incorporates
10 | the terms and conditions of version 3 of the GNU General Public
11 | License, supplemented by the additional permissions listed below.
12 |
13 | 0. Additional Definitions.
14 |
15 | As used herein, "this License" refers to version 3 of the GNU Lesser
16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU
17 | General Public License.
18 |
19 | "The Library" refers to a covered work governed by this License,
20 | other than an Application or a Combined Work as defined below.
21 |
22 | An "Application" is any work that makes use of an interface provided
23 | by the Library, but which is not otherwise based on the Library.
24 | Defining a subclass of a class defined by the Library is deemed a mode
25 | of using an interface provided by the Library.
26 |
27 | A "Combined Work" is a work produced by combining or linking an
28 | Application with the Library. The particular version of the Library
29 | with which the Combined Work was made is also called the "Linked
30 | Version".
31 |
32 | The "Minimal Corresponding Source" for a Combined Work means the
33 | Corresponding Source for the Combined Work, excluding any source code
34 | for portions of the Combined Work that, considered in isolation, are
35 | based on the Application, and not on the Linked Version.
36 |
37 | The "Corresponding Application Code" for a Combined Work means the
38 | object code and/or source code for the Application, including any data
39 | and utility programs needed for reproducing the Combined Work from the
40 | Application, but excluding the System Libraries of the Combined Work.
41 |
42 | 1. Exception to Section 3 of the GNU GPL.
43 |
44 | You may convey a covered work under sections 3 and 4 of this License
45 | without being bound by section 3 of the GNU GPL.
46 |
47 | 2. Conveying Modified Versions.
48 |
49 | If you modify a copy of the Library, and, in your modifications, a
50 | facility refers to a function or data to be supplied by an Application
51 | that uses the facility (other than as an argument passed when the
52 | facility is invoked), then you may convey a copy of the modified
53 | version:
54 |
55 | a) under this License, provided that you make a good faith effort to
56 | ensure that, in the event an Application does not supply the
57 | function or data, the facility still operates, and performs
58 | whatever part of its purpose remains meaningful, or
59 |
60 | b) under the GNU GPL, with none of the additional permissions of
61 | this License applicable to that copy.
62 |
63 | 3. Object Code Incorporating Material from Library Header Files.
64 |
65 | The object code form of an Application may incorporate material from
66 | a header file that is part of the Library. You may convey such object
67 | code under terms of your choice, provided that, if the incorporated
68 | material is not limited to numerical parameters, data structure
69 | layouts and accessors, or small macros, inline functions and templates
70 | (ten or fewer lines in length), you do both of the following:
71 |
72 | a) Give prominent notice with each copy of the object code that the
73 | Library is used in it and that the Library and its use are
74 | covered by this License.
75 |
76 | b) Accompany the object code with a copy of the GNU GPL and this license
77 | document.
78 |
79 | 4. Combined Works.
80 |
81 | You may convey a Combined Work under terms of your choice that,
82 | taken together, effectively do not restrict modification of the
83 | portions of the Library contained in the Combined Work and reverse
84 | engineering for debugging such modifications, if you also do each of
85 | the following:
86 |
87 | a) Give prominent notice with each copy of the Combined Work that
88 | the Library is used in it and that the Library and its use are
89 | covered by this License.
90 |
91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license
92 | document.
93 |
94 | c) For a Combined Work that displays copyright notices during
95 | execution, include the copyright notice for the Library among
96 | these notices, as well as a reference directing the user to the
97 | copies of the GNU GPL and this license document.
98 |
99 | d) Do one of the following:
100 |
101 | 0) Convey the Minimal Corresponding Source under the terms of this
102 | License, and the Corresponding Application Code in a form
103 | suitable for, and under terms that permit, the user to
104 | recombine or relink the Application with a modified version of
105 | the Linked Version to produce a modified Combined Work, in the
106 | manner specified by section 6 of the GNU GPL for conveying
107 | Corresponding Source.
108 |
109 | 1) Use a suitable shared library mechanism for linking with the
110 | Library. A suitable mechanism is one that (a) uses at run time
111 | a copy of the Library already present on the user's computer
112 | system, and (b) will operate properly with a modified version
113 | of the Library that is interface-compatible with the Linked
114 | Version.
115 |
116 | e) Provide Installation Information, but only if you would otherwise
117 | be required to provide such information under section 6 of the
118 | GNU GPL, and only to the extent that such information is
119 | necessary to install and execute a modified version of the
120 | Combined Work produced by recombining or relinking the
121 | Application with a modified version of the Linked Version. (If
122 | you use option 4d0, the Installation Information must accompany
123 | the Minimal Corresponding Source and Corresponding Application
124 | Code. If you use option 4d1, you must provide the Installation
125 | Information in the manner specified by section 6 of the GNU GPL
126 | for conveying Corresponding Source.)
127 |
128 | 5. Combined Libraries.
129 |
130 | You may place library facilities that are a work based on the
131 | Library side by side in a single library together with other library
132 | facilities that are not Applications and are not covered by this
133 | License, and convey such a combined library under terms of your
134 | choice, if you do both of the following:
135 |
136 | a) Accompany the combined library with a copy of the same work based
137 | on the Library, uncombined with any other library facilities,
138 | conveyed under the terms of this License.
139 |
140 | b) Give prominent notice with the combined library that part of it
141 | is a work based on the Library, and explaining where to find the
142 | accompanying uncombined form of the same work.
143 |
144 | 6. Revised Versions of the GNU Lesser General Public License.
145 |
146 | The Free Software Foundation may publish revised and/or new versions
147 | of the GNU Lesser General Public License from time to time. Such new
148 | versions will be similar in spirit to the present version, but may
149 | differ in detail to address new problems or concerns.
150 |
151 | Each version is given a distinguishing version number. If the
152 | Library as you received it specifies that a certain numbered version
153 | of the GNU Lesser General Public License "or any later version"
154 | applies to it, you have the option of following the terms and
155 | conditions either of that published version or of any later version
156 | published by the Free Software Foundation. If the Library as you
157 | received it does not specify a version number of the GNU Lesser
158 | General Public License, you may choose any version of the GNU Lesser
159 | General Public License ever published by the Free Software Foundation.
160 |
161 | If the Library as you received it specifies that a proxy can decide
162 | whether future versions of the GNU Lesser General Public License shall
163 | apply, that proxy's public statement of acceptance of any version is
164 | permanent authorization for you to choose that version for the
165 | Library.
166 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # webpay-nodejs
3 |
4 | Módulo no oficial para integrar la API de WebPay, Anulaciones y OneClick de Transbank en
5 | Node.js, con soporte para promesas.
6 |
7 | # Instalación
8 |
9 | ```
10 | npm install webpay-nodejs
11 | ```
12 |
13 | # Transacción normal
14 |
15 | > Revisa el directorio /showcase para ver ejemplos funcionando
16 | > `$ node showcase/test`
17 |
18 | 1) Instanciar
19 |
20 | ```js
21 | const WebPay = require('webpay-nodejs');
22 |
23 | let wp = new WebPay({
24 | commerceCode: youCommerceCode,
25 | publicKey: youPublicKey, // .cert file
26 | privateKey: youPrivateKey, // .key file
27 | webpayKey: youWebpayKey, // .pem file
28 | env: WebPay.ENV.INTEGRACION
29 | });
30 | ```
31 |
32 | 2) Iniciar Transacción
33 |
34 | ```js
35 | wp.initTransaction({
36 | buyOrder: buyOrden,
37 | sessionId: req.sessionId,
38 | returnURL: url + '/verificar',
39 | finalURL: url + '/comprobante',
40 | amount: amount
41 | }).then((data) => {
42 | res.redirect(data.url + '?token_ws=' + data.token);
43 | })
44 | ```
45 |
46 | 3) Obtener datos de la transacción
47 |
48 | ```js
49 | wp.getTransactionResult(token).then((transaccion) => {
50 | // datos de la transaccion
51 | })
52 | ```
53 |
54 | 4) Aceptar la transacción
55 |
56 | ```js
57 | wp.acknowledgeTransaction(token)
58 | ```
59 |
60 |
61 | Opcionalmente, anular
62 | ```js
63 | wp.nullify({
64 | authorizationCode: '123',
65 | authorizedAmount: 2000,
66 | buyOrder: buyOrder
67 | })
68 | ```
69 |
70 | Para los métodos de OneClick, usar `wp.oneclick.*` y `wp.onclickmall.*` respectivamente.
71 |
72 | # Changelog
73 |
74 | # v1.4.0
75 | > Las versiones anteriores tienen problemas de seguridad en sus dependencias. Se recomienda actualizar
76 | > a ésta versión como punto mínimo.
77 |
78 | * Se agregaron dependencias faltantes (ejs). Notificado por [ffflabs](https://github.com/ffflabs) (#15).
79 | * Se agregó una versión propia de ursa, y actualización de soap. Ahora la instalación no tiene problemas de
80 | seguridad. Gracias [nicolaslopezj](https://github.com/nicolaslopezj) (#20).
81 | * Se corrigieron problemas en los ejemplos. Gracias [DiruzCode](https://github.com/DiruzCode) (#17),
82 | [Rubenazo](https://github.com/DiruzCode) (#9).
83 | * Agregado soporte parcial para pagos diferidos (Falta documentación). [BluebambooSRL](https://github.com/BluebambooSRL) (#11).
84 | * Se agregó más formalismo en la licencia (archivos COPYING, COPYING.LESEER). La licencia sigue siendo la misma, LGPL.
85 |
86 | ## v1.3.0
87 |
88 | * Se agregó soporte para WebPay OneClick Mall. Gracias [Alonso Gaete](https://github.com/alogaete)! (#6).
89 | * Correcciones menores internas al manejo de errores (no implica cambios en la API).
90 | * Los ejemplos ahora manejan los errores (solo a modo de demostración).
91 | * Se actualizaron los certificados de WebPay Normal.
92 | * Se eliminaron dependencias sin uso.
93 |
94 | ## v1.2.0
95 |
96 | * Se agregó soporte para WebPay OneClick
97 | * Gracias a la observación de [Joaquin Gumucio L.](https://github.com/jjgumucio), se reemplazó
98 | la dependencia de "ursa" por una versión pura en js "ursa-purejs", solucionando de esta forma
99 | problemas en algunos equipos productos de usar una librería nativa. Ahora el código es 100% js.
100 | * Se actualizaron los ejemplos, ahora están en el directorio showcase
101 |
102 | ## v1.0.0 (Breaking Changes)
103 |
104 | * getTransactionResult retornaba transaction.detailOutput como un array con un único objeto
105 | las propiedades, ahora transaction.detailOutput retorna directamente dicho objeto.
106 |
107 | * Ejemplo antes: transaction.detailOutput[0].amount
108 | * Ejemplo ahora: transaction.detailOutput.amount
109 |
110 |
111 | # Legalidades
112 |
113 | Agradecimientos a [FabianBravoA](https://github.com/FabianBravoA/tbk_node) por el algoritmo de verificación especial
114 | de Transbank.
115 |
116 | Agradecimientos a [Leonardo Gatica](https://github.com/lgaticaq/tbk-oneclick) por descubrir el significado de
117 | los códigos de respuesta de WebPay OneClick desde el número -8 al -1.
118 |
119 | Éste código se distribuye con la licencia libre LGPL. Revisar COPYING.LESSER para detalles.
120 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | //Unofficial WebPay SDK for Node.js
2 | //Copyright (C) 2017-2020 Rodrigo González Castillo , et al.
3 | //
4 | //This program is free software: you can redistribute it and/or modify
5 | //it under the terms of the GNU General Public License as published by
6 | //the Free Software Foundation, either version 3 of the License, or
7 | //(at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | //GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | //along with this program. If not, see .
16 |
17 |
18 | module.exports = require('./lib/WebPay');
--------------------------------------------------------------------------------
/lib/WebPay.js:
--------------------------------------------------------------------------------
1 | //Unofficial WebPay SDK for Node.js
2 | //Copyright (C) 2017-2020 Rodrigo González Castillo , et al.
3 | //
4 | //This program is free software: you can redistribute it and/or modify
5 | //it under the terms of the GNU General Public License as published by
6 | //the Free Software Foundation, either version 3 of the License, or
7 | //(at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | //GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | //along with this program. If not, see .
16 | "use strict";
17 |
18 | const soap = require('soap');
19 | const select = require('xml-crypto').xpath;
20 | const SignedXml = require('xml-crypto').SignedXml;
21 | const DOMParser = require('xmldom').DOMParser;
22 | const Decimal = require('decimal.js-light');
23 |
24 | const WebPayUniqueAndSpecialNonStandardWSSecurityCert = require('./WebPayUniqueAndSpecialNonStandardWSSecurityCert');
25 |
26 | const WebPayOneClick = require('./WebPayOneClick');
27 | const WebPayOneClickMall = require('./WebPayOneClickMall');
28 |
29 | const ENV = {
30 | INTEGRACION: {
31 | normal: 'https://webpay3gint.transbank.cl/WSWebpayTransaction/cxf/WSWebpayService?wsdl',
32 | nullify: 'https://webpay3gint.transbank.cl/WSWebpayTransaction/cxf/WSCommerceIntegrationService?wsdl',
33 | oneclick: 'https://webpay3gint.transbank.cl/webpayserver/wswebpay/OneClickPaymentService?wsdl',
34 | oneclickmall: 'https://webpay3gint.transbank.cl/WSWebpayTransaction/cxf/WSOneClickMulticodeService?wsdl'
35 | },
36 | CERTIFICACION: {
37 | normal: 'https://webpay3gint.transbank.cl/WSWebpayTransaction/cxf/WSWebpayService?wsdl',
38 | nullify: 'https://webpay3gint.transbank.cl/WSWebpayTransaction/cxf/WSCommerceIntegrationService?wsdl',
39 | oneclick: 'https://webpay3gint.transbank.cl/webpayserver/wswebpay/OneClickPaymentService?wsdl',
40 | oneclickmall: 'https://webpay3gint.transbank.cl/WSWebpayTransaction/cxf/WSOneClickMulticodeService?wsdl'
41 | },
42 | PRODUCCION: {
43 | normal: 'https://webpay3g.transbank.cl/WSWebpayTransaction/cxf/WSWebpayService?wsdl',
44 | nullify: 'https://webpay3g.transbank.cl/WSWebpayTransaction/cxf/WSCommerceIntegrationService?wsdl',
45 | oneclick: 'https://webpay3g.transbank.cl/webpayserver/wswebpay/OneClickPaymentService?wsdl',
46 | oneclickmall: 'https://webpay3g.transbank.cl/WSWebpayTransaction/cxf/WSOneClickMulticodeService?wsdl'
47 | }
48 | };
49 |
50 | class WebPay {
51 |
52 | /**
53 | * Página de transición según dicta Transbank.
54 | * @param urlRedirection obtenido de detailOutput al hacer getTransactionResult
55 | * @param token_ws
56 | * @param gifUrl? la url del gif de Transbank
57 | * @returns {string}
58 | */
59 | static getHtmlTransitionPage(urlRedirection, token_ws, gifUrl) {
60 | gifUrl = gifUrl || 'data:image/gif;base64,R0lGODlhZABkAMQAAAAAAP////z8/Pj4+PX19fHx8e7u7uvr6+fn5+Pj4+Dg4N3d3dra2tbW1tLS0s/Pz8zMzP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABEALAAAAABkAGQAAAX/ICSO5LgURwMpAmIcJdko40E8UIPHo1LELNXoQRMhYA3BIUEo8iAJxKiQeK6KCQMjIXCsAgtrTuAs3MSjAQP4qwkG4YdA9YiuxdERo81jCHB/EAcKC153PA0qSUUHCzs8D14rMDGPEA5wBAUzfGg0SUILBmIGVQEPgxClYg4Hc2MJTGhcKRADkmJLKy0EYWgLSrsICgNCJIUiDl2uRQW+fQQJroovliQPCAMJdQMolCUPVCIPtxB1b2gvCQMwDAcIuCMOAUo4WQ+aWd88ziJBaKoQLGDnb0CgGAwIEFgjTd4zaOMI7OOxhEsVNVCGoekngsArKw1+OCBAUEQsKywQ/5AzhiahiQATSyiLZEAbAYAjmOyIdhPlqIUMAoyCsEcMNiWdjJIRsSDbwxUFJOUh6tEJIgMGwhzQdgAGAZYyHTRsdUccGgcFAsQDl61KkiVfRYFLEGCbHFwKrMnoxSLMgpPkeCQooBLKgQdahuBMRkogQbEJVJyM4aAmAwVDAWad5MCXgnVWjSRgYKBLA4OhSww+sBZNyEskKWGzsQMs0QGWcTpTACOLv8gx1tVI+sQAAncfcWKGAFTopckiUAgOZmULEepTrRw4NS4AwAY9oRC34kAsDLJP8KXXmxOFiq1RzqA5YACHHDQPXI7wPouwvcOJWRFOaqwM4I8zTW0jk/99gxUGXxNiEAPBUuYIgAYCo5XmwGkURlgSTnssQBJd7EFxAwLH1YTDNBEm9pYCEFohnAgHjAdOjVXIcQhACBRQxAAlCkLScDTKx4MCARThwBE7UsSdOfwJ2ISIJlWxmAgMtCJFLk8+EKUuCPmT3GL02WdhJUPl8RoEGF5JYws4lVmhYjxIJKZt4LD0IIEQiBNFSHXoZMUJAS7W4Io28XmNnbu0RoIPJbD4RBKRBFAADqUEOdgWHaaTYU+uONqDEPhQ0iQPGJFA2zVOHCGMlWIc5EeQrOVwUzgNWHlqCf9UGNM1kvAWA5hvwlGhIm2i8WSfu5r0Q0K4TojnMTj0mor/jEqoUM41MmWyCaQAOaLKN18JiNEAxVQYpK1nsIDZlkat4w1AuqTUi2sKPYCPjy8cucNAY8ClqHiDnXECrJTlVtBB15hFjhfnGCgjFWbomwWBLAhgpTh1HKfsDqsaFQ2SVkFHQkILGeaQGE+GbAUcNRXCMEBdBmCkYFWckKQeNgqz0mI138wGVSjAC5B05hRgXC4JYFJHXdEhXAkCSC2GdDhLR1pYn54NoJYYJ6Sw72B5nTkpYjR8RipOaH39xDoqje3jfTKVRgMDEpszcBacOkBEAmGQVgmO0Skw0rrkTbzHDX8HnlkJCUVFLBqBDIJMRumW4KOIN7GQOSQ4Il4C/5DMVWxSNtOapATpNKNCwyqBWlNHG/hIDUk0JwhNnoUYykGA37GIjs3O1W3DTHRPgaOQCT3nBK9ZIJ4mwmZuMjax2Pn0i180TD0OSXZFGUVf4DeYHAOhzT6ByYF/aVSCEK1wnM/nFKXwkVxi+JhSOAEYHVwBnBoY5JwxomVpziuEIMAo8KE7EggqJcRI3exEkIT0kUBWM7uQj0TAukookHbcKxWXJOEOeIgsPMkSEASWBcDqZekdJ2ReRHZ1B5fhpHaiEUMSKkOu1D3BFf67nZXwZw4eKIMRDZTBI0qFgCQSpU37wsyv2lOrxaBCflSg36QoZIP5IEwOUxzBW8Zxsf/GIMeHQ5gSAaSwr3UpaAxFsOAlZraIs8FxMeBpj4DSJIWQOIAGD0BjyIIyML/RKDSnYU8TcVBHgOhHBFHiRxX+dKkkAASJOFhS8lSlsfLkjU4UOUMSNtkDEVCIblus1KWo8gvq2ABGpCRBK5AiwBnUQJRBAgYSlACj1BBhBK5KyTp8qI6SDCaWkZPEOZp3x+g4cVzrOA+TKPKGOLyiARgSFZZ6IkLXwIFqLNnEpBTBRXE9QT/dJI+3OHGlRy4AJulYQ4+SY75ksCgJsQjPOcPzzjDSqAr2iiU4KNQUY72sASfokwDWoCOEROOe1cAPQZ0CDoeVI2K/cM9bmIBQ70H/bkJeaMQO2MORXuFhACrZaFw8ijKGfKMzeNACF8oTC8nYrgFY8YVawpe/Z3jEh5uqGGRs+oT9adEKlSMExI4gNLQsICVsspToBMUcWbwMB5o4w2yceJQaAc11qqgCZBCSrAp+J6eC4IpXpqUMNm1DAL8bK0Daps0rCIJCHNkivFJoBb4IwC+A+SRCpKcKgSbOCi84zNi0p8OF5tAoYeANTFcAmvO5hyqBwgMK6goEGNTBALlynwywhNa3LFJKhBCWbyhrG1FsAQz8CyIJjHPGK0WBBSjQ5zXIMJKnaixg8foBdmTbgwCxQHR5dNaVEJOYkYBEAKsYwxoaeTsDwee0/ygBwwhSZpRHrrB6ECjEvZ67VyslshJ0kMgCEiQ6YkiiXCgx0CnNZkWSCFC6jy3i+V6BDwOi91EtYOyRXMTLGIGOCqIbAuFM+8w7maODR0oKyTxBvCUdIH21y12C8ZHAPsJJQLD6B3FJkKoejOlkDsZJdqCHptPlICqfCFJeGAWFEwPLHzEBVwwYZVI8wIunkswIoCwJtnrwGDhvy5YtWlOibrKgrp+4n0dl8Id5rNK7MSjmYRToXvzIqyuXJBWjLKhLYUSwEq2CgTCPqgduSgQVoE1PW3pgEMT1CozpWAJBSugoVxhLDshqmhjcCc/GDGQf9TRBtT5yrX1GxJ+XWP+njgEihyIUNJavGcmHgLyXdpEha9XhZ6G1A1BeGPZQKu2oT5jDgKAMhcXtKRgODkbpiRp0CBaFGBcEW4JSkOYmQ4WC7eRhnktceBxPaFmDsaGNgHGUiG1OWUOSgelbbcJKW9XLoQyDGDmucKQ2W5dxDv0c4CTaZ2x2aLReIdcSYIg0pkGNbmSjtBFnOjbjYGqQusrMNKRLDm7Mm1fD5R65lW3VzRlFu1mRFm3WYbpKYIIAtwNugPBtpo0jypSTUWz0gNfha9xSx7wtiPrMiXIrUurpjrptaXRbQKFzUypacRiQkNbke2pdKmAXvBi8W0McUlSGTWe1z8CEMOnhLV//SCepotLgeFw7KZEs/rxhT2qzK7A3dK00cBvOtiv6yh6kKd4dSoOv3+Bo9bb0WvZ/HsmzWQjtfUtupvnYLxQbr84A4NtYhpqtRLcVQG7xo6dE4cHTw0i3OWKOx9IqwcB7bK5uh8ZJQbqNz1ICHNERsSXw+DYMO3STeA1riyZ5XQ9FSnBGpmD1Cq1hM5IFvZvwMQChBysmk5MHFxvsYiw1bzBcU23enVVFQyl57cjeIhIhOwa8x6ABh2gCCyiRHR7Qtuk3/DKkoVAbCmGYLmlrwZlHJ3gV4A0V2sAuIsID/LMobAV1RomQdkBIkaFoKZgHggGmj4qc9W7Q+hRJQjRh/zlhdWW2KprkYxTUKU+gBuewDpy1AqZUBKj0NjmTFk7AadOjZzDwSuMlI3tFPHtxB/pRGdQxKMHwIpBHEU0DJHSxMbaDTnZyTI70ERjSBUAAXV6wQVhCTBx4CdPkGmjDWskHOaIGaZWBESnRI9gwbA/oNCDiZtt3RRtjOMtma7FUOxOWKwoiTupjBrDmaEwxak+wOcvjOakTNokQcSslIxdIPNiENIOGLqwwDliYHu2HQ7MgU10QbOcmCC34NFWwBaQnD6HWbKkGbYvCT/2WVMiQbSAxhGoDXmhwC+Tmh62nh4rIA6ewc2KVaFRYOIcDEgbAg1eyUJomG/pGQfaERXvDRC94ZVhm2DlvkDqn8VQfohxm0GrOsXDSoUYLlC8RAkhiF1wR0XpDQD0NJXPG1iz4UIrHaA40lmVgdzoCxEAyhFp59Yc/9HJSwogz9HbmEHfLxT3hlXcTRFV8hRPytj1DlBmANwyC10U6tETzI0FDklb5FCQ4ZYoQEAIAOw==';
61 | return `
64 |
65 | `;
66 | }
67 |
68 | /**
69 | *
70 | * @param {number} props.commerceCode
71 | * @param {string} props.publicKey
72 | * @param {string} props.privateKey
73 | * @param {string} props.webpayKey
74 | * @param {number} props.commerceCode el código del comercio
75 | * @param props.env una constante de WebPay.ENV.*, según sea integración, certificación o producción
76 | * @param {boolean} props.verbose
77 | *
78 | * Las propiedades siguientes se ocupan para el método calcFees solamente:
79 | *
80 | * @param {number} props.creditFeePerc el porcentaje de comisión de transbank para ventas con crédito. Por defecto
81 | * es 2.95
82 | * @param {number} props.debitFeePerc el porcenaje de comisión de transbank para ventas con débito. Por defecto
83 | * es 1.49
84 | * @param {number} props.ivaFactor el factor a multiplicar la comisión para determinar el iva. Por defecto es 0.19
85 | */
86 | constructor(props) {
87 |
88 | this.commerceCode = props.commerceCode;
89 | this.publicKey = props.publicKey;
90 | this.privateKey = props.privateKey;
91 | this.webpayKey = props.webpayKey;
92 | this.env = props.env || WebPay.ENV.INTEGRACION;
93 | this.creditFeePerc = props.creditFeePerc || 2.95;
94 | this.debitFeePerc = props.debitFeePerc || 1.49;
95 | this.ivaFactor = props.ivaFactor || 0.19;
96 | this.verbose = props.verbose || false;
97 |
98 | this._wsSecurity = new WebPayUniqueAndSpecialNonStandardWSSecurityCert(
99 | this.privateKey,
100 | this.publicKey,
101 | 'utf8',
102 | true);
103 |
104 | this.oneclick = new WebPayOneClick(this);
105 | this.oneclickmall = new WebPayOneClickMall(this);
106 | }
107 |
108 | _getClient(type) {
109 | if(type !== 'normal' && type !== 'nullify' && type !== 'oneclick' && type !== 'oneclickmall') {
110 | throw new Error('WebPay::_getClient invalid type parameter. Must be "normal", "nullify", "oneclick" or "oneclickmall"');
111 | }
112 | const transactionClientKey = '_transactionClient_' + type;
113 | if(!this[transactionClientKey]) {
114 | return new Promise((resolve, reject) => {
115 | let options = {
116 | ignoredNamespaces: {
117 | namespaces: [],
118 | override: true
119 | },
120 | endpoint:this.env[type].replace('?wsdl','')
121 | };
122 | soap.createClient(this.env[type], options, (err, client) => {
123 | if(err) {
124 | return reject(err);
125 | }
126 | this._wsSecurity.promise().then(() => {
127 | client.setSecurity(this._wsSecurity);
128 | this[transactionClientKey] = client;
129 | resolve(this[transactionClientKey]);
130 | });
131 | });
132 | });
133 | }
134 | return Promise.resolve(this[transactionClientKey]);
135 | }
136 |
137 | /**
138 | * Inicia ina transacción en WebPay
139 | *
140 | * @param {string} props.buyOrder Orden de compra de la tienda.
141 | * @param {string} props.sessionId Identificador de sesión, uso interno de comercio, este valor es
142 | * devuelto al final de la transacción.
143 | * @param {string} props.returnURL URL del comercio, a la cual Webpay redireccionará posterior al
144 | * proceso de autorización.
145 | * @param props.finalURL URL del comercio a la cual Webpay redireccionará posterior al
146 | * voucher de éxito de Webpay.
147 | * @param props.amount
148 | * @returns {Promise} { token, url }
149 | */
150 | initTransaction(props) {
151 | this.verbose && console.log('initTransaction:parameters', props);
152 | if(!props) {
153 | return Promise.reject(new Error('props param missing'));
154 | }
155 | let wsInitTransactionInput = {
156 | wSTransactionType: props.wsTransactionType || 'TR_NORMAL_WS',
157 | sessionId: props.sessionId,
158 | returnURL: props.returnURL,
159 | finalURL: props.finalURL,
160 | buyOrder: props.buyOrder,
161 | transactionDetails: {
162 | amount: props.amount,
163 | buyOrder: props.buyOrder,
164 | commerceCode: this.commerceCode
165 | }
166 | };
167 |
168 | return new Promise((resolve, reject) => {
169 | this._getClient('normal').then((client) => {
170 | client.WSWebpayServiceImplService.WSWebpayServiceImplPort.initTransaction({
171 | wsInitTransactionInput: wsInitTransactionInput
172 | }, (err, result, raw, soapHeader) => {
173 | if(err) {
174 | this.verbose && console.log('initTransaction:error!', err);
175 | return reject(err);
176 | }
177 | this.verbose && console.log('initTransaction:result:', result);
178 | if(this._verifySignature(raw)) {
179 | resolve(result.return);
180 | } else {
181 | this.verbose && console.log('initTransaction: result doesn\'t have a valid signature!');
182 | reject(new Error('Invalid signature response'));
183 | }
184 | });
185 | }).catch(reject);
186 | });
187 |
188 | }
189 |
190 | /**
191 | *
192 | * @param {string} token token de la transacción, viene como token_ws tipo POST
193 | * @returns {Promise} promesa con la siguiente información:
194 | * - buyOrder Orden de compra de la tienda.
195 | * - sessionId Identificador de sesión, uso interno de comercio, este valor es devuelto al
196 | * final de la transacción.
197 | * - cardDetails Objeto que representa los datos de la tarjeta de crédito del tarjeta habiente.
198 | * - cardDetails.cardNumber 4 últimos números de la tarjeta de crédito del tarjeta habiente.
199 | * Solo para comercios autorizados por Transbank se envía el número completo
200 | * - cardDetails.cardExpirationDate (Opcional) Fecha de expiración de la tarjeta de crédito del tarjetahabiente.
201 | * Formato YYMM Solo para comercios autorizados por Transbank.
202 | * - accoutingDate Fecha de la autorización.
203 | * - transactionDate Fecha y hora de la autorización.
204 | * - VCI Resultado de la autenticación para comercios Webpay Plus y/o 3D Secure,
205 | * los valores posibles son los siguientes:
206 | * -- TSY: Autenticación exitosa
207 | * -- TSN: autenticación fallida.
208 | * -- TO: Tiempo máximo excedido para autenticación.
209 | * -- ABO: Autenticación abortada por tarjetahabiente.
210 | * -- U3: Error interno en la autenticación.
211 | * -- Puede ser vacío si la transacción no se autentico.
212 | * - urlRedirection URL de redirección para visualización de voucher.
213 | * - detailsOutput detailsOutput Objeto que contiene el detalle de la transacción financiera.
214 | * - detailsOutput.authorizationCode Código de autorización de la transacción
215 | * - detailsOutput.paymentTypeCode Tipo de pago de la transacción.
216 | * -- VD = Venta Debito
217 | * -- VN = Venta Normal
218 | * -- VC = Venta en cuotas
219 | * -- SI = 3 cuotas sin interés
220 | * -- S2=2 cuotas sin interés
221 | * -- NC = N Cuotas sin interés
222 | * - detailsOutput.responseCode Código de respuesta de la autorización. Valores posibles:
223 | * -- 0 Transacción aprobada.
224 | * -- -1 Rechazo de transacción.
225 | * -- -2 Transacción debe reintentarse.
226 | * -- -3 Error en transacción.
227 | * -- -4 Rechazo de transacción.
228 | * -- -5 Rechazo por error de tasa.
229 | * -- -6 Excede cupo máximo mensual.
230 | * -- -7 Excede límite diario por transacción.
231 | * -- -8 Rubro no autorizado.
232 | * - Amount Monto de la transacción
233 | * - sharesNumber Cantidad de cuotas
234 | * - commerceCode Código comercio de la tienda
235 | * - buyOrder Orden de compra de la tienda.
236 | */
237 | getTransactionResult(token) {
238 | if(!token) {
239 | return Promise.reject(new Error('token missing'));
240 | }
241 | this.verbose && console.log('getTransactionResult:token:', token);
242 | return new Promise((resolve, reject) => {
243 | this._getClient('normal').then((client) => {
244 | client.WSWebpayServiceImplService.WSWebpayServiceImplPort.getTransactionResult({
245 | tokenInput: token
246 | }, (err, result, raw, soapHeader) => {
247 | if(err) {
248 | this.verbose && console.log('getTransactionResult:error!', err);
249 | return reject(err);
250 | }
251 | this.verbose && console.log('getTransactionResult:result:', result);
252 | if(this._verifySignature(raw)) {
253 | result.return.detailOutput = result.return.detailOutput[0];
254 | resolve(result.return);
255 | } else {
256 | this.verbose && console.log('getTransactionResult: result doesn\'t have a valid signature!');
257 | reject(new Error('Invalid signature response'));
258 | }
259 | });
260 | }).catch(reject);
261 | });
262 | }
263 |
264 | /**
265 | * Luego de recibir getTransactionResult, se debe llamar en no más de 30 segundos.
266 | * @param token Token de la transacción.
267 | * @returns {Promise}
268 | */
269 | acknowledgeTransaction(token) {
270 | return new Promise((resolve, reject) => {
271 | this.verbose && console.log('acknowledgeTransaction:token:', token);
272 | this._getClient('normal').then((client) => {
273 | client.WSWebpayServiceImplService.WSWebpayServiceImplPort.acknowledgeTransaction({
274 | tokenInput: token
275 | }, (err, result, raw, soapHeader) => {
276 | if (err) {
277 | this.verbose && console.log('acknowledgeTransaction:error!', err);
278 | return reject(err);
279 | }
280 | this.verbose && console.log('acknowledgeTransaction:result:', result);
281 | if (this._verifySignature(raw)) {
282 | resolve(result);
283 | } else {
284 | this.verbose && console.log('acknowledgeTransaction: result doesn\'t have a valid signature!');
285 | reject(new Error('Invalid signature response'));
286 | }
287 | });
288 | }).catch(reject);
289 | });
290 | }
291 |
292 | /**
293 | *
294 | * @param props
295 | *
296 | * @param {string} props.authorizationCode Código de autorización de la transacción que se requiere anular.
297 | * Para el caso que se esté anulando una transacción de captura en línea, este código
298 | * corresponde al código de autorización de la captura. (Máx 6 carácteres)
299 | *
300 | * @param {number} props.authorizedAmount Monto autorizado de la transacción que se requiere anular. Para el caso
301 | * que se esté anulando una transacción de captura en línea, este monto corresponde al monto de la captura.
302 | *
303 | * @param {string} props.buyOrder Orden de compra de la transacción que se requiere anular
304 | *
305 | * @param {string?} props.commerceId ódigo de comercio o tienda mall que realizó la transacción. Si se ignora se
306 | * usará el codigo de comercio según se indicó en el constructor (transacción normal).
307 | *
308 | * @param {number} props.nullifyAmount Monto que se desea anular de la transacción
309 | *
310 | * @return {*}
311 | * - Token
312 | * - authorizationCode
313 | * - authorizationDate
314 | * - Balance
315 | * - nullifiedAmount
316 | */
317 | nullify(props) {
318 | if(!props) {
319 | return Promise.reject(new Error('props param missing'));
320 | }
321 |
322 | props.commerceId = props.commerceId || this.commerceCode;
323 |
324 | this.verbose && console.log('nullify:parameters', props);
325 |
326 | return new Promise((resolve, reject) => {
327 | this._getClient('nullify').then((client) => {
328 | client.WSCommerceIntegrationServiceImplService.WSCommerceIntegrationServiceImplPort.nullify({
329 | nullificationInput : props
330 | }, (err, result, raw, soapHeader) => {
331 | if(err) {
332 | this.verbose && console.log('nullify:error!', err);
333 | return reject(err);
334 | }
335 | this.verbose && console.log('nullify:result:', result);
336 | if(this._verifySignature(raw)) {
337 | resolve(result.return);
338 | } else {
339 | this.verbose && console.log('nullify: result doesn\'t have a valid signature!');
340 | reject(new Error('Invalid signature response'));
341 | }
342 | });
343 | }).catch(reject);
344 | });
345 | }
346 |
347 | /**
348 | *
349 | * @param props
350 | *
351 | * @param {string} props.authorizationCode Código de autorización de la transacción que se requiere anular.
352 | * Para el caso que se esté anulando una transacción de captura en línea, este código
353 | * corresponde al código de autorización de la captura. (Máx 6 carácteres)
354 | *
355 | * @param {string} props.buyOrder Orden de compra de la transacción que se requiere anular
356 | *
357 | * @param {string?} props.commerceId ódigo de comercio o tienda mall que realizó la transacción. Si se ignora se
358 | * usará el codigo de comercio según se indicó en el constructor (transacción normal).
359 | *
360 | * @param {number} props.captureAmount Monto que se desea capturar de la transacción
361 | *
362 | * @return {*}
363 | * - Token
364 | * - authorizationCode
365 | * - authorizationDate
366 | * - captureAmount
367 | */
368 |
369 |
370 | capture(props) {
371 | if(!props) {
372 | return Promise.reject(new Error('props param missing'));
373 | }
374 |
375 | props.commerceId = props.commerceId || this.commerceCode;
376 |
377 | this.verbose && console.log('capture:parameters', props);
378 |
379 | return new Promise((resolve, reject) => {
380 | this._getClient('nullify').then((client) => {
381 | client.WSCommerceIntegrationServiceImplService.WSCommerceIntegrationServiceImplPort.capture({
382 | captureInput : props
383 | }, (err, result, raw, soapHeader) => {
384 | if(err) {
385 | this.verbose && console.log('capture:error!', err);
386 | return reject(err);
387 | }
388 | this.verbose && console.log('capture:result:', result);
389 | if(this._verifySignature(raw)) {
390 | resolve(result.return);
391 | } else {
392 | this.verbose && console.log('capture: result doesn\'t have a valid signature!');
393 | reject(new Error('Invalid signature response'));
394 | }
395 | });
396 | }).catch(reject);
397 | });
398 | }
399 |
400 |
401 |
402 | /**
403 | * @param transaction
404 | * @param {number} transaction.amount el monto cobrado en la transaccion
405 | * @param {string} transaction.tbkTypeCode el valor depaymentTypeCode (al hacer getTransactionResult),
406 | * si es DV es redcompra (Débito).
407 | * @param {boolean} noIvaLess180Clp true para no contabilizar el iva en el caso de que el monto sea menor a 180 CLP.
408 | * Teóricamente debería ser así si la empresa es persona natural (recibe boletas en vez de factura). Fuente:
409 | * https://www.chileatiende.gob.cl/fichas/ver/29234
410 | * @return {{clp: number, iva: number, total: number}}
411 | */
412 | calcFees(transaction, noIvaLess180Clp) {
413 |
414 | const amount = new Decimal(transaction.amount);
415 | const feePerc = transaction.tbkTypeCode.toUpperCase() === 'VD' ? this.debitFeePerc : this.creditFeePerc;
416 |
417 | // el 2.95 por ciento.. es decir, amount * (2.95/100)
418 | let feeWebpay = amount.mul(feePerc).div(100).toDecimalPlaces(0);
419 |
420 | let iva = 0;
421 |
422 | if((noIvaLess180Clp && feeWebpay.gte(180)) || !noIvaLess180Clp) {
423 | iva = feeWebpay.mul(this.ivaFactor).toDecimalPlaces(0).toNumber();
424 | }
425 |
426 | const total = feeWebpay.plus(iva);
427 |
428 | return {
429 | subtotal: feeWebpay.toNumber(),
430 | iva: iva,
431 | total: total.toNumber()
432 | };
433 |
434 | }
435 |
436 | _verifySignature(xml) {
437 | console.log('----------------', xml, '-------------------')
438 | try {
439 | let doc = new DOMParser().parseFromString(xml);
440 | let signature = select(doc, "//*[local-name(.)='Signature' and namespace-uri(.)='http://www.w3.org/2000/09/xmldsig#']")[0];
441 | let sig = new SignedXml();
442 | //Hack to check non-standard transbank SignedInfo node
443 | sig.validateSignatureValue = function () {
444 | let signedInfo = select(doc, "//*[local-name(.)='SignedInfo']");
445 | if (signedInfo.length === 0) throw new Error("could not find SignedInfo element in the message");
446 | let signedInfoCanon = this.getCanonXml([this.canonicalizationAlgorithm], signedInfo[0]);
447 | signedInfoCanon = signedInfoCanon.toString().replace("xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\"", "xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"");
448 | let signer = this.findSignatureAlgorithm(this.signatureAlgorithm);
449 | let res = signer.verifySignature(signedInfoCanon, this.signingKey, this.signatureValue);
450 | if (!res) this.validationErrors.push("invalid signature: the signature value " + this.signatureValue + " is incorrect");
451 | return res
452 | };
453 | let webpayKey = this.webpayKey;
454 | sig.keyInfoProvider = {
455 | getKeyInfo: function (key, prefix) {
456 | prefix = prefix || '';
457 | prefix = prefix ? prefix + ':' : prefix;
458 | return "<" + prefix + "X509Data>" + prefix + "X509Data>";
459 | },
460 | getKey: function (keyInfo) {
461 | return webpayKey
462 | }
463 | };
464 | sig.loadSignature(signature);
465 | let res = sig.checkSignature(xml);
466 | if (!res) {
467 | throw new Error(sig.validationErrors.join('; '));
468 | }
469 | return res;
470 | } catch (err) {
471 | console.log('SIGNATURE:::', err)
472 | return false;
473 | }
474 | }
475 |
476 | }
477 |
478 | WebPay.ENV = ENV;
479 |
480 | module.exports = WebPay;
481 |
--------------------------------------------------------------------------------
/lib/WebPayOneClick.js:
--------------------------------------------------------------------------------
1 | //Unofficial WebPay SDK for Node.js
2 | //Copyright (C) 2017-2020 Rodrigo González Castillo , et al.
3 | //
4 | //This program is free software: you can redistribute it and/or modify
5 | //it under the terms of the GNU General Public License as published by
6 | //the Free Software Foundation, either version 3 of the License, or
7 | //(at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | //GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | //along with this program. If not, see .
16 | const WebPay = require('./WebPay');
17 |
18 | // Gracias a https://github.com/lgaticaq/tbk-oneclick/blob/master/src/response.js#L8-L21 por ahorrar tipeo <3
19 | const AUTHORIZE_RESULT_CODE = {
20 | '0': 'Aprobado.',
21 | '-1': 'La transacción ha sido rechazada.',
22 | '-2': 'La transacción ha sido rechazada, por favor intente nuevamente.',
23 | '-3': 'Ha ocurrido un error al hacer la transacción.',
24 | '-4': 'La transacción ha sido rechazada.',
25 | '-5': 'La transacción ha sido rechazada porque la tasa es inválida.',
26 | '-6': 'Ha alcanzado el límite de transacciones mensuales.',
27 | '-7': 'Ha alcanzado el límite de transacciones diarias.',
28 | '-8': 'La transacción ha sido rechazada, el rubro es inválido.',
29 | '-97': 'Ha alcanzado el máximo monto diario de pagos.',
30 | '-98': 'La transacción ha sido rechazada porque ha excedido el máximo monto de pago.',
31 | '-99': 'La transacción ha sido rechazada porque ha excedido la máxima cantidad de pagos diarias.'
32 | };
33 |
34 | class WebPayOneClick {
35 |
36 | /**
37 | *
38 | * @param {WebPay} webpay
39 | */
40 | constructor(webpay) {
41 | this.webpay = webpay;
42 | this.verbose = webpay.verbose;
43 | }
44 |
45 | /**
46 | * Permite realizar la inscripción del tarjetahabiente e información de su
47 | * tarjeta de crédito. Retorna como respuesta un token que representa la
48 | * transacción de inscripción y una URL (UrlWebpay), que corresponde a la
49 | * URL de inscripción de One Click.
50 | * Una vez que se llama a este servicio Web, el usuario debe ser
51 | * redireccionado vía POST a urlWebpay con parámetro TBK_TOKEN igual al
52 | * token obtenido.
53 | *
54 | * @param {object} props
55 | * @param {string} props.username
56 | * @param {string} props.email
57 | * @param {string} props.responseUrl
58 | *
59 | * @return {Promise<{token, urlWebpay}>}
60 | */
61 | initInscription(props) {
62 | this.verbose && console.log('oneclick.initInscription:parameters', props);
63 | if(!props) {
64 | return Promise.reject(new Error('props param missing'));
65 | }
66 |
67 | return new Promise((resolve, reject) => {
68 | this.webpay._getClient('oneclick').then((client) => {
69 |
70 | client.initInscription({
71 | arg0: {
72 | username: props.username,
73 | email: props.email,
74 | responseURL: props.responseUrl
75 | }
76 | }, (err, result, raw, soapHeader) => {
77 | if(err) {
78 | this.verbose && console.log('oneclick.initInscription:error!', err);
79 | return reject(err);
80 | }
81 | this.verbose && console.log('oneclick.initInscription:result:', result);
82 | if(this.webpay._verifySignature(raw)) {
83 | resolve(result.return);
84 | } else {
85 | this.verbose && console.log('oneclick.initInscription: result doesn\'t have a valid signature!');
86 | reject(new Error('Invalid signature response'));
87 | }
88 | })
89 | }).catch(reject);
90 | });
91 | }
92 |
93 | /**
94 | * Permite finalizar el proceso de inscripción del tarjetahabiente en
95 | * Oneclick. Entre otras cosas, retorna el identificador del usuario en
96 | * Oneclick, el cual será utilizado para realizar las transacciones de pago.
97 | * Una vez terminado el flujo de inscripción en Transbank el usuario es
98 | * enviado a la URL de fin de inscripción que definió el comercio. En ese
99 | * instante el comercio debe llamar a finishInscription.
100 | *
101 | * @param {string} token el token TBK_TOKEN (post)
102 | *
103 | * @return {Promise<{responseCode, authCode, creditCardType, last4CardDigits, tbkUser}>}
104 | *
105 | * responseCode: Código de retorno del proceso de inscripción, donde 0 (cero) es aprobado.
106 | * authCode: Código que identifica la autorización de la inscripción.
107 | * creditCardType: Indica el tipo de tarjeta que fue inscrita por el cliente ( Visa, AmericanExpress, MasterCard, Diners, Magna)
108 | * last4CardDigits: Los últimos 4 dígitos de la tarjeta ingresada por el cliente en la inscripción.
109 | * tbkUser: Identificador único de la inscripción del cliente, este debe ser usado para realizar pagos, o borrar la inscripción.
110 | */
111 | finishInscription(token) {
112 | this.verbose && console.log('oneclick.finishInscription:parameters', token);
113 | if(!token) {
114 | return Promise.reject(new Error('props param missing'));
115 | }
116 |
117 | return new Promise((resolve, reject) => {
118 | this.webpay._getClient('oneclick').then((client) => {
119 |
120 | client.finishInscription({
121 | arg0: {
122 | token: token
123 | }
124 | }, (err, result, raw, soapHeader) => {
125 | if(err) {
126 | this.verbose && console.log('oneclick.finishInscription:error!', err);
127 | return reject(err);
128 | }
129 | this.verbose && console.log('oneclick.finishInscription:result:', result);
130 | if(this.webpay._verifySignature(raw)) {
131 | resolve(result.return);
132 | } else {
133 | this.verbose && console.log('oneclick.finishInscription: result doesn\'t have a valid signature!');
134 | reject(new Error('Invalid signature response'));
135 | }
136 | })
137 | }).catch(reject);
138 | });
139 | }
140 |
141 | /**
142 | * En el caso que el comercio requiera eliminar la inscripción de un usuario en Webpay OneClick ya sea
143 | * por la eliminación de un cliente en su sistema o por la solicitud de este para no operar con esta
144 | * forma de pago, el comercio deberá consumir un servicio web de Transbank con el identificador de
145 | * usuario entregado en la inscripción.
146 | *
147 | * @param {object} props
148 | * @param {string} props.tbkUser Identificador único de la inscripción del cliente.
149 | * @param {string} props.username Nombre de usuario, del cliente, en el sistema del comercio.
150 | *
151 | * @return {Promise} Retorno verdadero, si fue posible eliminar la inscripción. Falso de lo contrario.
152 | */
153 | removeUser(props) {
154 | this.verbose && console.log('oneclick.removeUser:parameters', props);
155 | if(!props) {
156 | return Promise.reject(new Error('props param missing'));
157 | }
158 |
159 | return new Promise((resolve, reject) => {
160 | this.webpay._getClient('oneclick').then((client) => {
161 |
162 | client.removeUser({
163 | arg0: {
164 | tbkUser: props.tbkUser,
165 | username: props.username
166 | }
167 | }, (err, result, raw, soapHeader) => {
168 | if(err) {
169 | this.verbose && console.log('oneclick.removeUser:error!', err);
170 | return reject(err);
171 | }
172 | this.verbose && console.log('oneclick.removeUser:result:', result);
173 | if(this.webpay._verifySignature(raw)) {
174 | resolve(result.return);
175 | } else {
176 | this.verbose && console.log('oneclick.removeUser: result doesn\'t have a valid signature!');
177 | reject(new Error('Invalid signature response'));
178 | }
179 | });
180 | }).catch(reject);
181 | });
182 | }
183 |
184 | /**
185 | * Permite realizar transacciones de pago. Retorna el resultado de la
186 | * autorización. Este método que debe ser ejecutado, cada vez que el
187 | * usuario selecciona pagar con Oneclick.
188 | *
189 | * @param {object} props
190 | * @param {number} props.amount Monto del pago en pesos.
191 | * @param {string} props.tbkUser
192 | * @param {string} props.username
193 | * @param {int} props.buyOrder Identificador único de la compra generado por el comercio. Debe ser
194 | * timestamp [yyyymmddhhMMss] + un correlativo de tres dígitos.
195 | * Ej: Para la tercera transacción realizada el día 15 de julio de 2011 a las
196 | * 11:55:50 la orden de compra sería: 20110715115550003. (.... lo sé ¬¬*)
197 | *
198 | * @return {Promise<{responseCode, authCode, last4CardDigits, creditCardType, transactionId}>}
199 | *
200 | * responseCode: Código de retorno del proceso de pago, donde:
201 | * 0 (cero) es aprobado.
202 | * -1 Rechazo
203 | * -2 Rechazo
204 | * -3 Rechazo
205 | * -4 Rechazo
206 | * -5 Rechazo
207 | * -6 Rechazo
208 | * -7 Rechazo
209 | * -8 Rechazo
210 | * -97 limites Oneclick, máximo monto diario de pago excedido
211 | * -98 limites Oneclick, máximo monto de pago excedido
212 | * -99 limites Oneclick, máxima cantidad de pagos diarios excedido
213 | * responseCodeLocaleSpanish: lo mismo que lo anterior, pero en palabras
214 | * authCode: Código de autorización de la transacción de pago.
215 | * last4CardDigits: Los últimos 4 dígitos de la tarjeta ingresada por el cliente en la inscripción.
216 | * creditCardType: Indica el tipo de tarjeta que fue inscrita por el cliente ( Visa, AmericanExpress, MasterCard, Diners, Magna)
217 | * transactionId: Identificador único de la transacción de pago, se utiliza para la reversa, si fuera necesario.
218 | */
219 | authorize(props) {
220 | this.verbose && console.log('oneclick.authorize:parameters', props);
221 | if(!props) {
222 | return Promise.reject(new Error('props param missing'));
223 | }
224 |
225 | return new Promise((resolve, reject) => {
226 | this.webpay._getClient('oneclick').then((client) => {
227 |
228 | client.authorize({
229 | arg0: {
230 | amount: props.amount,
231 | tbkUser: props.tbkUser,
232 | username: props.username,
233 | buyOrder: props.buyOrder
234 | }
235 | }, (err, result, raw, soapHeader) => {
236 | if(err) {
237 | this.verbose && console.log('oneclick.authorize:error!', err);
238 | return reject(err);
239 | }
240 | this.verbose && console.log('oneclick.authorize:result:', result);
241 | if(this.webpay._verifySignature(raw)) {
242 | result.return.responseCodeLocaleSpanish = AUTHORIZE_RESULT_CODE[result.return.responseCode];
243 | resolve(result.return);
244 | } else {
245 | this.verbose && console.log('oneclick.authorize: result doesn\'t have a valid signature!');
246 | reject(new Error('Invalid signature response'));
247 | }
248 | });
249 | }).catch(reject);
250 | });
251 | }
252 |
253 | /**
254 | *
255 | * Este proceso permite reversar una venta cuando esta no pudo concretarse, dentro del mismo día
256 | * contable, con la finalidad de anular un cargo realizado al cliente.
257 | * El comercio, en caso de requerir reversar un pago, debe consumir un servicio web publicado por
258 | * Transbank con el identificador del pago entregado en la respuesta de la autorización de la transacción
259 | *
260 | * Permite reversar una transacción de venta autorizada con anterioridad.
261 | * Este método retorna como respuesta un identificador único de la
262 | * transacción de reversa.
263 | *
264 | * @param {int} buyOrder
265 | *
266 | * @return {Promise<{reverseCode, reversed}>}
267 | * reverseCode: el código de la reversa. El código regresado por este método, es un identificador único de la transacción de reversa.
268 | * reversa: true si se hizo, false si no se hizo
269 | */
270 | codeReverseOneClick(buyOrder) {
271 | this.verbose && console.log('oneclick.codeReverseOneClick:parameters', buyOrder);
272 | if(!buyOrder) {
273 | return Promise.reject(new Error('props param missing'));
274 | }
275 |
276 | return new Promise((resolve, reject) => {
277 | this.webpay._getClient('oneclick').then((client) => {
278 |
279 | client.codeReverseOneClick({
280 | arg0: {
281 | buyorder: buyOrder
282 | }
283 | }, (err, result, raw, soapHeader) => {
284 | if(err) {
285 | this.verbose && console.log('oneclick.codeReverseOneClick:error!', err);
286 | return reject(err);
287 | }
288 | this.verbose && console.log('oneclick.codeReverseOneClick:result:', result);
289 | if(this.webpay._verifySignature(raw)) {
290 | resolve(result.return);
291 | } else {
292 | this.verbose && console.log('oneclick.codeReverseOneClick: result doesn\'t have a valid signature!');
293 | reject(new Error('Invalid signature response'));
294 | }
295 | });
296 | }).catch(reject);
297 | });
298 | }
299 |
300 | }
301 |
302 | module.exports = WebPayOneClick;
--------------------------------------------------------------------------------
/lib/WebPayOneClickMall.js:
--------------------------------------------------------------------------------
1 | //Unofficial WebPay SDK for Node.js
2 | //Copyright (C) 2017-2020 Rodrigo González Castillo , et al.
3 | //
4 | //This program is free software: you can redistribute it and/or modify
5 | //it under the terms of the GNU General Public License as published by
6 | //the Free Software Foundation, either version 3 of the License, or
7 | //(at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | //GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | //along with this program. If not, see .
16 | const WebPay = require('./WebPay');
17 |
18 | // Gracias a https://github.com/lgaticaq/tbk-oneclick/blob/master/src/response.js#L8-L21 por ahorrar tipeo <3
19 | const AUTHORIZE_RESULT_CODE = {
20 | '0': 'Aprobado.',
21 | '-1': 'La transacción ha sido rechazada.',
22 | '-2': 'La transacción ha sido rechazada, por favor intente nuevamente.',
23 | '-3': 'Ha ocurrido un error al hacer la transacción.',
24 | '-4': 'La transacción ha sido rechazada.',
25 | '-5': 'La transacción ha sido rechazada porque la tasa es inválida.',
26 | '-6': 'Ha alcanzado el límite de transacciones mensuales.',
27 | '-7': 'Ha alcanzado el límite de transacciones diarias.',
28 | '-8': 'La transacción ha sido rechazada, el rubro es inválido.',
29 | '-97': 'Ha alcanzado el máximo monto diario de pagos.',
30 | '-98': 'La transacción ha sido rechazada porque ha excedido el máximo monto de pago.',
31 | '-99': 'La transacción ha sido rechazada porque ha excedido la máxima cantidad de pagos diarias.'
32 | };
33 |
34 | class WebPayOneClickMall {
35 |
36 | /**
37 | *
38 | * @param {WebPay} webpay
39 | */
40 | constructor(webpay) {
41 | this.webpay = webpay;
42 | this.verbose = webpay.verbose;
43 | }
44 |
45 | /**
46 | * Permite realizar la inscripción del tarjetahabiente e información de su
47 | * tarjeta de crédito. Retorna como respuesta un token que representa la
48 | * transacción de inscripción y una URL (urlInscriptionForm), que corresponde a la
49 | * URL de inscripción de Oneclick Mall.
50 | * Una vez que se llama a este servicio Web, el usuario debe ser
51 | * redireccionado vía POST a urlInscriptionForm con parámetro TBK_TOKEN igual al
52 | * token obtenido.
53 | *
54 | * @param {object} props
55 | * @param {string} props.username
56 | * @param {string} props.email
57 | * @param {string} props.returnUrl
58 | *
59 | * @return {Promise<{token, urlInscriptionForm}>}
60 | *
61 | * token:
62 | * urlInscriptionForm:
63 | */
64 | initInscription(props) {
65 | this.verbose && console.log('oneclickmall.initInscription:parameters', props);
66 | if(!props) {
67 | return Promise.reject(new Error('props param missing'));
68 | }
69 |
70 | return new Promise((resolve, reject) => {
71 | this.webpay._getClient('oneclickmall').then((client) => {
72 |
73 | client.initInscription({
74 | input: {
75 | username: props.username,
76 | email: props.email,
77 | returnUrl: props.returnUrl
78 | }
79 | }, (err, result, raw, soapHeader) => {
80 | //console.log('lastrequest initInscription: ', client.lastRequest);
81 | if(err) {
82 | this.verbose && console.log('oneclickmall.initInscription:error!', err);
83 | return reject(err);
84 | }
85 | this.verbose && console.log('oneclickmall.initInscription:result:', result);
86 | if(this.webpay._verifySignature(raw)) {
87 | resolve(result.return);
88 | } else {
89 | this.verbose && console.log('oneclickmall.initInscription: result doesn\'t have a valid signature!');
90 | reject(new Error('Invalid signature response'));
91 | }
92 | });
93 | });
94 | });
95 | }
96 |
97 | /**
98 | * Permite finalizar el proceso de inscripción del tarjetahabiente en
99 | * Oneclick Mall. Entre otras cosas, retorna el identificador del usuario en
100 | * Oneclick Mall, el cual será utilizado para realizar las transacciones de pago.
101 | * Una vez terminado el flujo de inscripción en Transbank el usuario es
102 | * enviado a la URL de fin de inscripción que definió el comercio. En ese
103 | * instante el comercio debe llamar a finishInscription.
104 | *
105 | * @param {string} token el token TBK_TOKEN (post)
106 | *
107 | * @return {Promise<{responseCode, authorizationCode, cardType, cardNumber, cardExpirationDate, cardOrigin, tbkUser}>}
108 | *
109 | * responseCode: Código de retorno del proceso de inscripción, donde 0 (cero) es aprobado.
110 | * authorizationCode: Código que identifica la autorización de la inscripción.
111 | * cardType: Indica la marca de la tarjeta de crédito que fue inscrita por el cliente (Visa, AmericanExpress, MasterCard, Diners, Magna).
112 | * cardNumber: Indica los últimos 4 dígitos y/o BIN de la tarjeta de crédito utilizada.
113 | * cardExpirationDate: Indica la fecha de expiración de la tarjeta de crédito utilizada.
114 | * cardOrigin: Indica si la tarjeta de crédito utilizada es nacional (NATIONAL_CARD) o extranjera (FOREIGN_CARD).
115 | * tbkUser: Identificador único de la inscripción del cliente, este debe ser usado para realizar pagos, o borrar la inscripción.
116 | */
117 | finishInscription(token) {
118 | this.verbose && console.log('oneclickmall.finishInscription:parameters', token);
119 | if(!token) {
120 | return Promise.reject(new Error('props param missing'));
121 | }
122 |
123 | return new Promise((resolve, reject) => {
124 | this.webpay._getClient('oneclickmall').then((client) => {
125 |
126 | client.finishInscription({
127 | input: {
128 | token: token
129 | }
130 | }, (err, result, raw, soapHeader) => {
131 | //console.log('lastrequest finishInscription: ', client.lastRequest);
132 | if(err) {
133 | this.verbose && console.log('oneclickmall.finishInscription:error!', err);
134 | return reject(err);
135 | }
136 | this.verbose && console.log('oneclickmall.finishInscription:result:', result);
137 | if(this.webpay._verifySignature(raw)) {
138 | resolve(result.return);
139 | } else {
140 | this.verbose && console.log('oneclickmall.finishInscription: result doesn\'t have a valid signature!');
141 | reject(new Error('Invalid signature response'));
142 | }
143 | });
144 | }).catch(reject);
145 | });
146 | }
147 |
148 | /**
149 | * En el caso que el comercio requiera eliminar la inscripción de un usuario en Webpay Oneclick Mall, ya sea
150 | * por la eliminación de un cliente en su sistema o por la solicitud de este para no operar con esta
151 | * forma de pago, el comercio deberá consumir un servicio web de Transbank con el identificador de
152 | * usuario entregado en la inscripción.
153 | *
154 | * @param {object} props
155 | * @param {string} props.tbkUser Identificador único de la inscripción del cliente.
156 | * @param {string} props.username Nombre de usuario, del cliente, en el sistema del comercio.
157 | *
158 | * @return {Promise<{result}>}
159 | *
160 | * result: Es verdadero si fue posible eliminar la inscripción o falso en caso contrario.
161 | */
162 | removeInscription(props) {
163 | this.verbose && console.log('oneclickmall.removeInscription:parameters', props);
164 | if(!props) {
165 | return Promise.reject(new Error('props param missing'));
166 | }
167 |
168 | return new Promise((resolve, reject) => {
169 | this.webpay._getClient('oneclickmall').then((client) => {
170 |
171 | client.removeInscription({
172 | input: {
173 | tbkUser: props.tbkUser,
174 | username: props.username
175 | }
176 | }, (err, result, raw, soapHeader) => {
177 | //console.log('lastrequest removeInscription: ', client.lastRequest);
178 | if(err) {
179 | this.verbose && console.log('oneclickmall.removeInscription:error!', err);
180 | return reject(err);
181 | }
182 | this.verbose && console.log('oneclickmall.removeInscription:result:', result);
183 | if(this.webpay._verifySignature(raw)) {
184 | resolve(result.return);
185 | } else {
186 | this.verbose && console.log('oneclickmall.removeInscription: result doesn\'t have a valid signature!');
187 | reject(new Error('Invalid signature response'));
188 | }
189 | });
190 | }).catch(reject);
191 | });
192 | }
193 |
194 | /**
195 | * Permite realizar transacciones de pago. Retorna el resultado de la
196 | * autorización. Este método que debe ser ejecutado, cada vez que el
197 | * usuario selecciona pagar con Oneclick Mall.
198 | * Una autorización Webpay Oneclick Mall puede estar asociada a multiples comercios hijos.
199 | *
200 | * @param {object} props
201 | * @param {string} props.tbkUser
202 | * @param {string} props.username
203 | * @param {int} props.buyOrder Identificador único de la compra generado por el comercio padre. Debe ser
204 | * timestamp [yyyymmddhhMMss] + un correlativo de tres dígitos.
205 | * Ej: Para la tercera transacción realizada el día 15 de julio de 2011 a las
206 | * 11:55:50 la orden de compra sería: 20110715115550003. (.... lo sé ¬¬*)
207 | * @param {object} props.storesInput Lista de comercios hijos.
208 | * @param {number} props.storesInput.commerceId Código de comercio del comercio hijo.
209 | * @param {number} props.storesInput.buyOrder Identi cador único de la compra generado por el comercio
210 | * hijo (tienda). Debe ser timestamp [yyyymmddhhMMss] + un correlativo de tres dígitos.
211 | * @param {number} props.storesInput.amount Monto de la sub-transacción de pago. En pesos o dólares según
212 | * con guración comercio padre.
213 | * @param {number} props.storesInput.sharesNumber Cantidad de cuotas de la sub-transacción de pago.
214 | * Cualquier valor distinto de número, incluyendo letras, inexistencia del campo o nulo, será asumido
215 | * como cero, es decir “Sin cuotas”.
216 | *
217 | * @return {Promise<{commerceId, buyOrder, settlementDate, authorizationDate, storesOutput:[{commerceId, buyOrder, amount, paymentType, sharesNumber, shareAmount, authorizationCode, responseCode}, ... ]}>}
218 | *
219 | * commerceId: Código de comercio del comercio padre.
220 | * buyOrder: Orden de compra generada por el comercio padre.
221 | * settlementDate: Fecha contable de la autorización del pago.
222 | * authorizationDate: Fecha completa (timestamp) de la autorización del pago.
223 | * storesOutput: Lista de comercios hijos.
224 | * storesOutput.commerceId: Código de comercio del comercio hijo (tienda).
225 | * storesOutput.buyOrder: Orden de compra generada por el comercio hijo para la sub-transacción de pago.
226 | * storesOutput.amount: Monto de la sub-transacción de pago.
227 | * storesOutput.paymentType: Tipo (VC, NC, SI, etc.) de la sub-transacción de pago.
228 | * storesOutput.sharesNumber: Cantidad de cuotas de la sub-transacción de pago.
229 | * storesOutput.shareAmount: Monto por cuota de la sub-transacción de pago.
230 | * storesOutput.authorizationCode: Código de autorización de la sub-transacción de pago.
231 | * storesOutput.responseCode: Código de retorno del proceso de pago, donde:
232 | * 0 (cero) es aprobado.
233 | * -1 Rechazo.
234 | * -2 Rechazo.
235 | * -3 Rechazo.
236 | * -4 Rechazo.
237 | * -5 Rechazo.
238 | * -6 Rechazo.
239 | * -7 Rechazo.
240 | * -8 Rechazo.
241 | * -97 limites OneClick Mall: máximo monto acumulado de pagos diarios excedido.
242 | * -98 limites OneClick Mall: máximo monto unitario de pago excedido.
243 | * -99 limites OneClick Mall: máxima cantidad de transacciones diarias excedida.
244 | */
245 | authorize(props) {
246 | this.verbose && console.log('oneclickmall.authorize:parameters', props);
247 | if(!props) {
248 | return Promise.reject(new Error('props param missing'));
249 | }
250 | return new Promise((resolve, reject) => {
251 | this.webpay._getClient('oneclickmall').then((client) => {
252 |
253 | client.authorize({
254 | input: {
255 | username: props.username,
256 | tbkUser: props.tbkUser,
257 | buyOrder: props.buyOrder,
258 | storesInput: props.storesInput
259 | }
260 | }, (err, result, raw, soapHeader) => {
261 | //console.log('lastrequest authorize: ', client.lastRequest);
262 | if(err) {
263 | this.verbose && console.log('oneclickmall.authorize:error!', err);
264 | return reject(err);
265 | }
266 | this.verbose && console.log('oneclickmall.authorize:result:', result);
267 | if(this.webpay._verifySignature(raw)) {
268 | for (let i = 0, len = result.return.storesOutput.length; i < len; i++) {
269 | result.return.storesOutput[i].responseCodeLocaleSpanish = AUTHORIZE_RESULT_CODE[result.return.storesOutput[i].responseCode];
270 | }
271 | resolve(result.return);
272 | } else {
273 | this.verbose && console.log('oneclickmall.authorize: result doesn\'t have a valid signature!');
274 | reject(new Error('Invalid signature response'));
275 | }
276 | });
277 | }).catch(reject);
278 | });
279 | }
280 |
281 | /**
282 | *
283 | * Este proceso permitirá reversar un pago OneClick Mall cuando existan problemas operacionales
284 | * (lado comercio) o de comunicación entre comercio y Transbank que impidan recibir a tiempo la
285 | * respuesta de una autorización. Como en este último caso el comercio no conoce el resultado de
286 | * la autorización, debe intentar reversar la transacción de autorización para evitar un posible
287 | * descuadre entre comercio y Transbank.
288 | *
289 | * Para llevar a cabo la reversa, el comercio debe consumir un servicio web publicado por Transbank
290 | * con la orden de compra (generada por el comercio padre) del pago realizado.
291 | * Cabe destacar que la reversa siempre actuará sobre el listado completo bajo la orden de compra
292 | * padre.
293 | *
294 | * @param {int} buyOrder Orden de compra generada por el comercio padre, para la transacción de pago a reversar.
295 | *
296 | * @return {Promise<{storesReverse:[{commerceId, buyOrder, reversed, reverseCode}, ... ]}>}
297 | *
298 | * storesReverse: Lista de comercios hijos reversados.
299 | * storesReverse.commerceId: Código de comercio del comercio hijo (tienda).
300 | * storesReverse.buyOrder: Orden de compra generada por el comercio hijo para la sub-transacción de pago.
301 | * storesReverse.reversed: Boolean que indica si la reversa se realizó correctamente o no.
302 | * storesReverse.reverseCode: Identidficador único de la transacción de reversa.
303 | */
304 | reverse(buyOrder) {
305 | this.verbose && console.log('oneclickmall.reverse:parameters', buyOrder);
306 | if(!buyOrder) {
307 | return Promise.reject(new Error('props param missing'));
308 | }
309 |
310 | return new Promise((resolve, reject) => {
311 | this.webpay._getClient('oneclickmall').then((client) => {
312 |
313 | client.reverse({
314 | input: {
315 | buyOrder: buyOrder
316 | }
317 | }, (err, result, raw, soapHeader) => {
318 | if(err) {
319 | this.verbose && console.log('oneclickmall.reverse:error!', err);
320 | return reject(err);
321 | }
322 | this.verbose && console.log('oneclickmall.reverse:result:', result);
323 | if(this.webpay._verifySignature(raw)) {
324 | resolve(result.return);
325 | } else {
326 | this.verbose && console.log('oneclickmall.reverse: result doesn\'t have a valid signature!');
327 | reject(new Error('Invalid signature response'));
328 | }
329 | });
330 | }).catch(reject);
331 | });
332 | }
333 |
334 |
335 | /**
336 | *
337 | * Este proceso permitirá reversar un pago OneClick Mall cuando existan problemas operacionales
338 | *
339 | *
340 | * @param {int} buyOrder Orden de compra generada por el comercio hijo, para la sub-transacción de pago a anular.
341 | * @param {int} authorizedAmount Monto de la sub-transacción de pago a anular.
342 | * @param {int} authorizationCode Código de autorización de la sub-transacción de pago a anular.
343 | * @param {int} nullifyAmount Monto a anular de la sub-transacción de pago. Puede ser un monto parcial o monto total.
344 | *
345 | * @return {Promise<{token, buyOrder, commerceId, authorizationCode, authorizationDate, nullifiedAmount, balance}>}
346 | *
347 | * token: Identificador único de la transacción de anulación.
348 | * buyOrder: Orden de compra de la sub-transacción de pago anulada.
349 | * commerceId: Código de comercio del comercio hijo (tienda).
350 | * authorizationCode: Código de autorización de la transacción de anulación.
351 | * authorizationDate: Fecha de la autorización de la transacción de anulación.
352 | * nullifiedAmount: Monto anulado.
353 | * balance: Monto restante de la sub-transacción de pago original: monto inicial – monto anulado.
354 | */
355 | nullify(props) {
356 | this.verbose && console.log('oneclickmall.nullify:parameters', props);
357 | if(!props) {
358 | return Promise.reject(new Error('props param missing'));
359 | }
360 |
361 | return new Promise((resolve, reject) => {
362 | this.webpay._getClient('oneclickmall').then((client) => {
363 |
364 | client.nullify({
365 | input: {
366 | commerceId: props.commerceId,
367 | buyOrder: props.buyOrder,
368 | authorizedAmount: props.authorizedAmount,
369 | authorizationCode: props.authorizationCode,
370 | nullifyAmount: props.nullifyAmount
371 | }
372 | }, (err, result, raw, soapHeader) => {
373 | if(err) {
374 | this.verbose && console.log('oneclickmall.reverse:error!', err);
375 | return reject(err);
376 | }
377 | this.verbose && console.log('oneclickmall.reverse:result:', result);
378 | if(this.webpay._verifySignature(raw)) {
379 | resolve(result.return);
380 | } else {
381 | this.verbose && console.log('oneclickmall.reverse: result doesn\'t have a valid signature!');
382 | reject(new Error('Invalid signature response'));
383 | }
384 | });
385 | }).catch(reject);
386 | });
387 | }
388 |
389 |
390 | /**
391 | *
392 | * Este proceso permitirá reversar un pago OneClick Mall cuando existan problemas operacionales
393 | *
394 | * @param {int} buyOrder Orden de compra generada por el comercio hijo, para la sub-transacción de pago anulada.
395 | * @param {int} commerceId Código de comercio del comercio hijo (tienda).
396 | * @param {int} nullifyAmount Monto anulado en la transacción de anulación que se intenta reversar.
397 | *
398 | * @return {Promise<{reversed, reverseCode}>}
399 | *
400 | * reversed: Boolean que indica si la reversa se realizó correctamente o no.
401 | * reverseCode: Identificador único de la transacción de reversa.
402 | */
403 | reverseNullification(props) {
404 | this.verbose && console.log('oneclickmall.reverseNullification:parameters', props);
405 | if(!props) {
406 | return Promise.reject(new Error('props param missing'));
407 | }
408 |
409 | return new Promise((resolve, reject) => {
410 | this.webpay._getClient('oneclickmall').then((client) => {
411 |
412 | client.reverseNullification({
413 | input: {
414 | buyOrder: props.buyOrder,
415 | commerceId: props.commerceId,
416 | nullifyAmount: props.nullifyAmount
417 | }
418 | }, (err, result, raw, soapHeader) => {
419 | if(err) {
420 | this.verbose && console.log('oneclickmall.reverseNullification:error!', err);
421 | return reject(err);
422 | }
423 | this.verbose && console.log('oneclickmall.reverseNullification:result:', result);
424 | if(this.webpay._verifySignature(raw)) {
425 | resolve(result.return);
426 | } else {
427 | this.verbose && console.log('oneclickmall.reverseNullification: result doesn\'t have a valid signature!');
428 | reject(new Error('Invalid signature response'));
429 | }
430 | });
431 | }).catch(reject);
432 | });
433 | }
434 | }
435 |
436 | module.exports = WebPayOneClickMall;
437 |
--------------------------------------------------------------------------------
/lib/WebPayUniqueAndSpecialNonStandardWSSecurityCert.js:
--------------------------------------------------------------------------------
1 | //Unofficial WebPay SDK for Node.js
2 | //Copyright (C) 2017-2020 Rodrigo González Castillo , et al.
3 | //
4 | //This program is free software: you can redistribute it and/or modify
5 | //it under the terms of the GNU General Public License as published by
6 | //the Free Software Foundation, either version 3 of the License, or
7 | //(at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | //GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | //along with this program. If not, see .
16 | "use strict";
17 | /**
18 | * Clase basada en https://github.com/FabianBravoA/tbk_node
19 | */
20 |
21 | const ursa = require('ursa-purejs2020');
22 | const ejs = require('ejs');
23 | const SignedXml = require('xml-crypto').SignedXml;
24 | const uuid = require('uuid/v4');
25 | const pem = require('pem');
26 |
27 | const wsseSecurityHeader = `
28 |
29 |
30 |
31 |
32 | <%-issuerName%>
33 | <%-serialNumber%>
34 |
35 | <%-cert%>
36 |
37 |
38 |
39 | `;
40 |
41 | const wsSecurituToken = `
42 |
43 |
44 |
45 | <%-issuerName%>
46 | <%-serialNumber%>
47 |
48 | <%-cert%>
49 |
50 |
51 | `;
52 |
53 | const wsseSecurityHeaderTemplate = ejs.compile(wsseSecurityHeader);
54 | const wsseSecurityTokenTemplate = ejs.compile(wsSecurituToken);
55 |
56 | function insertStr(src, dst, pos) {
57 | return [dst.slice(0, pos), src, dst.slice(pos)].join('');
58 | }
59 |
60 | function generateId() {
61 | return uuid().replace(/-/gm, '');
62 | }
63 |
64 | class WebPayUniqueAndSpecialNonStandardWSSecurityCert {
65 |
66 | constructor(privatePEM, publicP12PEM, encoding) {
67 |
68 | this._instantiatePromise = new Promise((resolve, reject) => {
69 | if (!ursa) {
70 | throw reject(new Error('Module ursa must be installed to use WebPayUniqueAndSpecialNonStandardWSSecurityCert'));
71 | }
72 | this.privateKey = ursa.createPrivateKey(privatePEM, null, encoding);
73 | this.publicP12PEM = publicP12PEM.toString().replace('-----BEGIN CERTIFICATE-----', '').replace('-----END CERTIFICATE-----', '').replace(/(\r\n|\n|\r)/gm, '');
74 |
75 | this.signer = new SignedXml();
76 | this.signer.signingKey = this.privateKey.toPrivatePem();
77 | this.x509Id = "x509-" + generateId();
78 |
79 | pem.readCertificateInfo(publicP12PEM, (pemError, pemData) => {
80 | if(pemError) {
81 | return reject(pemError);
82 | }
83 |
84 | this.certSerial = "";
85 | if(!Number.isNaN(parseInt(pemData.serial.split(" ")[0])) && pemData.serial.indexOf(":") < 0) {
86 | this.certSerial = pemData.serial.split(" ")[0];
87 | } else {
88 | let tokens = pemData.serial.split(":");
89 | for(let i = 0; i < tokens.length; ++i) {
90 | this.certSerial += ""+parseInt("0x"+tokens[i]);
91 | }
92 | }
93 | this.issuer = "C="+pemData.issuer.country+",ST="+pemData.issuer.state+",O="+pemData.issuer.organization+",L="+pemData.issuer.locality+",CN="+pemData.commonName+",OU="+pemData.organizationUnit+",emailAddress="+pemData.emailAddress;
94 |
95 | let references = ["http://www.w3.org/2000/09/xmldsig#enveloped-signature",
96 | "http://www.w3.org/2001/10/xml-exc-c14n#"];
97 |
98 | this.signer.addReference("//*[local-name(.)='Body']", references);
99 |
100 | this.signer.keyInfoProvider = {};
101 | this.signer.keyInfoProvider.getKeyInfo = (key) => {
102 | return wsseSecurityTokenTemplate({
103 | cert: this.publicP12PEM,
104 | serialNumber: this.certSerial,
105 | issuerName: this.issuer
106 | });
107 | };
108 | resolve();
109 | });
110 |
111 | });
112 | }
113 |
114 | promise() {
115 | return this._instantiatePromise;
116 | }
117 |
118 | postProcess(xml) {
119 |
120 | let secHeader = wsseSecurityHeaderTemplate({
121 | cert: this.publicP12PEM,
122 | serialNumber: this.certSerial,
123 | issuerName: this.issuer
124 | });
125 |
126 | let xmlWithSec = insertStr(secHeader, xml, xml.indexOf(''));
127 |
128 | this.signer.computeSignature(xmlWithSec);
129 |
130 | return insertStr(this.signer.getSignatureXml(), xmlWithSec, xmlWithSec.indexOf(''));
131 | }
132 | }
133 |
134 | module.exports = WebPayUniqueAndSpecialNonStandardWSSecurityCert;
135 |
--------------------------------------------------------------------------------
/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "webpay-nodejs",
3 | "version": "1.3.0",
4 | "lockfileVersion": 1,
5 | "requires": true,
6 | "dependencies": {
7 | "@types/caseless": {
8 | "version": "0.12.2",
9 | "resolved": "https://registry.npmjs.org/@types/caseless/-/caseless-0.12.2.tgz",
10 | "integrity": "sha512-6ckxMjBBD8URvjB6J3NcnuAn5Pkl7t3TizAg+xdlzzQGSPSmBcXf8KoIH0ua/i+tio+ZRUHEXp0HEmvaR4kt0w=="
11 | },
12 | "@types/node": {
13 | "version": "13.5.0",
14 | "resolved": "https://registry.npmjs.org/@types/node/-/node-13.5.0.tgz",
15 | "integrity": "sha512-Onhn+z72D2O2Pb2ql2xukJ55rglumsVo1H6Fmyi8mlU9SvKdBk/pUSUAiBY/d9bAOF7VVWajX3sths/+g6ZiAQ=="
16 | },
17 | "@types/request": {
18 | "version": "2.48.4",
19 | "resolved": "https://registry.npmjs.org/@types/request/-/request-2.48.4.tgz",
20 | "integrity": "sha512-W1t1MTKYR8PxICH+A4HgEIPuAC3sbljoEVfyZbeFJJDbr30guDspJri2XOaM2E+Un7ZjrihaDi7cf6fPa2tbgw==",
21 | "requires": {
22 | "@types/caseless": "*",
23 | "@types/node": "*",
24 | "@types/tough-cookie": "*",
25 | "form-data": "^2.5.0"
26 | }
27 | },
28 | "@types/tough-cookie": {
29 | "version": "2.3.6",
30 | "resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-2.3.6.tgz",
31 | "integrity": "sha512-wHNBMnkoEBiRAd3s8KTKwIuO9biFtTf0LehITzBhSco+HQI0xkXZbLOD55SW3Aqw3oUkHstkm5SPv58yaAdFPQ=="
32 | },
33 | "accepts": {
34 | "version": "1.3.7",
35 | "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz",
36 | "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==",
37 | "dev": true,
38 | "requires": {
39 | "mime-types": "~2.1.24",
40 | "negotiator": "0.6.2"
41 | }
42 | },
43 | "ajv": {
44 | "version": "6.11.0",
45 | "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.11.0.tgz",
46 | "integrity": "sha512-nCprB/0syFYy9fVYU1ox1l2KN8S9I+tziH8D4zdZuLT3N6RMlGSGt5FSTpAiHB/Whv8Qs1cWHma1aMKZyaHRKA==",
47 | "requires": {
48 | "fast-deep-equal": "^3.1.1",
49 | "fast-json-stable-stringify": "^2.0.0",
50 | "json-schema-traverse": "^0.4.1",
51 | "uri-js": "^4.2.2"
52 | }
53 | },
54 | "array-flatten": {
55 | "version": "1.1.1",
56 | "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
57 | "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=",
58 | "dev": true
59 | },
60 | "asn1": {
61 | "version": "0.2.4",
62 | "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz",
63 | "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==",
64 | "requires": {
65 | "safer-buffer": "~2.1.0"
66 | }
67 | },
68 | "assert-plus": {
69 | "version": "1.0.0",
70 | "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
71 | "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU="
72 | },
73 | "asynckit": {
74 | "version": "0.4.0",
75 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
76 | "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
77 | },
78 | "aws-sign2": {
79 | "version": "0.7.0",
80 | "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz",
81 | "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg="
82 | },
83 | "aws4": {
84 | "version": "1.9.1",
85 | "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.9.1.tgz",
86 | "integrity": "sha512-wMHVg2EOHaMRxbzgFJ9gtjOOCrI80OHLG14rxi28XwOW8ux6IiEbRCGGGqCtdAIg4FQCbW20k9RsT4y3gJlFug=="
87 | },
88 | "bcrypt-pbkdf": {
89 | "version": "1.0.2",
90 | "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz",
91 | "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=",
92 | "requires": {
93 | "tweetnacl": "^0.14.3"
94 | }
95 | },
96 | "bluebird": {
97 | "version": "3.7.2",
98 | "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",
99 | "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg=="
100 | },
101 | "body-parser": {
102 | "version": "1.19.0",
103 | "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz",
104 | "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==",
105 | "dev": true,
106 | "requires": {
107 | "bytes": "3.1.0",
108 | "content-type": "~1.0.4",
109 | "debug": "2.6.9",
110 | "depd": "~1.1.2",
111 | "http-errors": "1.7.2",
112 | "iconv-lite": "0.4.24",
113 | "on-finished": "~2.3.0",
114 | "qs": "6.7.0",
115 | "raw-body": "2.4.0",
116 | "type-is": "~1.6.17"
117 | },
118 | "dependencies": {
119 | "debug": {
120 | "version": "2.6.9",
121 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
122 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
123 | "dev": true,
124 | "requires": {
125 | "ms": "2.0.0"
126 | }
127 | },
128 | "http-errors": {
129 | "version": "1.7.2",
130 | "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz",
131 | "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==",
132 | "dev": true,
133 | "requires": {
134 | "depd": "~1.1.2",
135 | "inherits": "2.0.3",
136 | "setprototypeof": "1.1.1",
137 | "statuses": ">= 1.5.0 < 2",
138 | "toidentifier": "1.0.0"
139 | }
140 | },
141 | "inherits": {
142 | "version": "2.0.3",
143 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
144 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
145 | "dev": true
146 | },
147 | "ms": {
148 | "version": "2.0.0",
149 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
150 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
151 | "dev": true
152 | },
153 | "qs": {
154 | "version": "6.7.0",
155 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
156 | "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==",
157 | "dev": true
158 | }
159 | }
160 | },
161 | "buffer-from": {
162 | "version": "1.1.1",
163 | "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
164 | "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A=="
165 | },
166 | "bytes": {
167 | "version": "3.1.0",
168 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
169 | "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==",
170 | "dev": true
171 | },
172 | "caseless": {
173 | "version": "0.12.0",
174 | "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz",
175 | "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw="
176 | },
177 | "charenc": {
178 | "version": "0.0.2",
179 | "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz",
180 | "integrity": "sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc="
181 | },
182 | "combined-stream": {
183 | "version": "1.0.8",
184 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
185 | "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
186 | "requires": {
187 | "delayed-stream": "~1.0.0"
188 | }
189 | },
190 | "concat-stream": {
191 | "version": "2.0.0",
192 | "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz",
193 | "integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==",
194 | "requires": {
195 | "buffer-from": "^1.0.0",
196 | "inherits": "^2.0.3",
197 | "readable-stream": "^3.0.2",
198 | "typedarray": "^0.0.6"
199 | }
200 | },
201 | "content-disposition": {
202 | "version": "0.5.3",
203 | "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz",
204 | "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==",
205 | "dev": true,
206 | "requires": {
207 | "safe-buffer": "5.1.2"
208 | },
209 | "dependencies": {
210 | "safe-buffer": {
211 | "version": "5.1.2",
212 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
213 | "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
214 | "dev": true
215 | }
216 | }
217 | },
218 | "content-type": {
219 | "version": "1.0.4",
220 | "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz",
221 | "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==",
222 | "dev": true
223 | },
224 | "cookie": {
225 | "version": "0.4.0",
226 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz",
227 | "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==",
228 | "dev": true
229 | },
230 | "cookie-signature": {
231 | "version": "1.0.6",
232 | "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
233 | "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=",
234 | "dev": true
235 | },
236 | "core-util-is": {
237 | "version": "1.0.2",
238 | "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
239 | "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
240 | },
241 | "crypt": {
242 | "version": "0.0.2",
243 | "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz",
244 | "integrity": "sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs="
245 | },
246 | "dashdash": {
247 | "version": "1.14.1",
248 | "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz",
249 | "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=",
250 | "requires": {
251 | "assert-plus": "^1.0.0"
252 | }
253 | },
254 | "debug": {
255 | "version": "4.1.1",
256 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
257 | "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
258 | "requires": {
259 | "ms": "^2.1.1"
260 | }
261 | },
262 | "decimal.js-light": {
263 | "version": "2.5.0",
264 | "resolved": "https://registry.npmjs.org/decimal.js-light/-/decimal.js-light-2.5.0.tgz",
265 | "integrity": "sha512-b3VJCbd2hwUpeRGG3Toob+CRo8W22xplipNhP3tN7TSVB/cyMX71P1vM2Xjc9H74uV6dS2hDDmo/rHq8L87Upg=="
266 | },
267 | "delayed-stream": {
268 | "version": "1.0.0",
269 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
270 | "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
271 | },
272 | "depd": {
273 | "version": "1.1.2",
274 | "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
275 | "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak="
276 | },
277 | "destroy": {
278 | "version": "1.0.4",
279 | "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
280 | "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
281 | },
282 | "ecc-jsbn": {
283 | "version": "0.1.2",
284 | "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz",
285 | "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=",
286 | "requires": {
287 | "jsbn": "~0.1.0",
288 | "safer-buffer": "^2.1.0"
289 | }
290 | },
291 | "ee-first": {
292 | "version": "1.1.1",
293 | "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
294 | "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
295 | },
296 | "ejs": {
297 | "version": "3.0.1",
298 | "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.0.1.tgz",
299 | "integrity": "sha512-cuIMtJwxvzumSAkqaaoGY/L6Fc/t6YvoP9/VIaK0V/CyqKLEQ8sqODmYfy/cjXEdZ9+OOL8TecbJu+1RsofGDw=="
300 | },
301 | "encodeurl": {
302 | "version": "1.0.2",
303 | "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
304 | "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k="
305 | },
306 | "es6-promisify": {
307 | "version": "6.0.2",
308 | "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-6.0.2.tgz",
309 | "integrity": "sha512-eO6vFm0JvqGzjWIQA6QVKjxpmELfhWbDUWHm1rPfIbn55mhKPiAa5xpLmQWJrNa629ZIeQ8ZvMAi13kvrjK6Mg=="
310 | },
311 | "escape-html": {
312 | "version": "1.0.3",
313 | "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
314 | "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg="
315 | },
316 | "etag": {
317 | "version": "1.8.1",
318 | "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
319 | "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc="
320 | },
321 | "express": {
322 | "version": "4.17.1",
323 | "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz",
324 | "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==",
325 | "dev": true,
326 | "requires": {
327 | "accepts": "~1.3.7",
328 | "array-flatten": "1.1.1",
329 | "body-parser": "1.19.0",
330 | "content-disposition": "0.5.3",
331 | "content-type": "~1.0.4",
332 | "cookie": "0.4.0",
333 | "cookie-signature": "1.0.6",
334 | "debug": "2.6.9",
335 | "depd": "~1.1.2",
336 | "encodeurl": "~1.0.2",
337 | "escape-html": "~1.0.3",
338 | "etag": "~1.8.1",
339 | "finalhandler": "~1.1.2",
340 | "fresh": "0.5.2",
341 | "merge-descriptors": "1.0.1",
342 | "methods": "~1.1.2",
343 | "on-finished": "~2.3.0",
344 | "parseurl": "~1.3.3",
345 | "path-to-regexp": "0.1.7",
346 | "proxy-addr": "~2.0.5",
347 | "qs": "6.7.0",
348 | "range-parser": "~1.2.1",
349 | "safe-buffer": "5.1.2",
350 | "send": "0.17.1",
351 | "serve-static": "1.14.1",
352 | "setprototypeof": "1.1.1",
353 | "statuses": "~1.5.0",
354 | "type-is": "~1.6.18",
355 | "utils-merge": "1.0.1",
356 | "vary": "~1.1.2"
357 | },
358 | "dependencies": {
359 | "debug": {
360 | "version": "2.6.9",
361 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
362 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
363 | "dev": true,
364 | "requires": {
365 | "ms": "2.0.0"
366 | }
367 | },
368 | "ms": {
369 | "version": "2.0.0",
370 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
371 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
372 | "dev": true
373 | },
374 | "qs": {
375 | "version": "6.7.0",
376 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
377 | "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==",
378 | "dev": true
379 | },
380 | "safe-buffer": {
381 | "version": "5.1.2",
382 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
383 | "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
384 | "dev": true
385 | }
386 | }
387 | },
388 | "extend": {
389 | "version": "3.0.2",
390 | "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
391 | "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g=="
392 | },
393 | "extsprintf": {
394 | "version": "1.3.0",
395 | "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz",
396 | "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU="
397 | },
398 | "fast-deep-equal": {
399 | "version": "3.1.1",
400 | "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.1.tgz",
401 | "integrity": "sha512-8UEa58QDLauDNfpbrX55Q9jrGHThw2ZMdOky5Gl1CDtVeJDPVrG4Jxx1N8jw2gkWaff5UUuX1KJd+9zGe2B+ZA=="
402 | },
403 | "fast-json-stable-stringify": {
404 | "version": "2.1.0",
405 | "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
406 | "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw=="
407 | },
408 | "finalhandler": {
409 | "version": "1.1.2",
410 | "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz",
411 | "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==",
412 | "dev": true,
413 | "requires": {
414 | "debug": "2.6.9",
415 | "encodeurl": "~1.0.2",
416 | "escape-html": "~1.0.3",
417 | "on-finished": "~2.3.0",
418 | "parseurl": "~1.3.3",
419 | "statuses": "~1.5.0",
420 | "unpipe": "~1.0.0"
421 | },
422 | "dependencies": {
423 | "debug": {
424 | "version": "2.6.9",
425 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
426 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
427 | "dev": true,
428 | "requires": {
429 | "ms": "2.0.0"
430 | }
431 | },
432 | "ms": {
433 | "version": "2.0.0",
434 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
435 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
436 | "dev": true
437 | }
438 | }
439 | },
440 | "forever-agent": {
441 | "version": "0.6.1",
442 | "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
443 | "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE="
444 | },
445 | "form-data": {
446 | "version": "2.5.1",
447 | "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz",
448 | "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==",
449 | "requires": {
450 | "asynckit": "^0.4.0",
451 | "combined-stream": "^1.0.6",
452 | "mime-types": "^2.1.12"
453 | }
454 | },
455 | "forwarded": {
456 | "version": "0.1.2",
457 | "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz",
458 | "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=",
459 | "dev": true
460 | },
461 | "fresh": {
462 | "version": "0.5.2",
463 | "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
464 | "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
465 | },
466 | "getpass": {
467 | "version": "0.1.7",
468 | "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz",
469 | "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=",
470 | "requires": {
471 | "assert-plus": "^1.0.0"
472 | }
473 | },
474 | "har-schema": {
475 | "version": "2.0.0",
476 | "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz",
477 | "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI="
478 | },
479 | "har-validator": {
480 | "version": "5.1.3",
481 | "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz",
482 | "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==",
483 | "requires": {
484 | "ajv": "^6.5.5",
485 | "har-schema": "^2.0.0"
486 | }
487 | },
488 | "http-errors": {
489 | "version": "1.7.3",
490 | "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.3.tgz",
491 | "integrity": "sha512-ZTTX0MWrsQ2ZAhA1cejAwDLycFsd7I7nVtnkT3Ol0aqodaKW+0CTZDQ1uBv5whptCnc8e8HeRRJxRs0kmm/Qfw==",
492 | "requires": {
493 | "depd": "~1.1.2",
494 | "inherits": "2.0.4",
495 | "setprototypeof": "1.1.1",
496 | "statuses": ">= 1.5.0 < 2",
497 | "toidentifier": "1.0.0"
498 | }
499 | },
500 | "http-signature": {
501 | "version": "1.2.0",
502 | "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz",
503 | "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=",
504 | "requires": {
505 | "assert-plus": "^1.0.0",
506 | "jsprim": "^1.2.2",
507 | "sshpk": "^1.7.0"
508 | }
509 | },
510 | "httpntlm": {
511 | "version": "1.7.6",
512 | "resolved": "https://registry.npmjs.org/httpntlm/-/httpntlm-1.7.6.tgz",
513 | "integrity": "sha1-aZHoNSg2AH1nEBuD247Q+RX5BtA=",
514 | "requires": {
515 | "httpreq": ">=0.4.22",
516 | "underscore": "~1.7.0"
517 | }
518 | },
519 | "httpreq": {
520 | "version": "0.4.24",
521 | "resolved": "https://registry.npmjs.org/httpreq/-/httpreq-0.4.24.tgz",
522 | "integrity": "sha1-QzX/2CzZaWaKOUZckprGHWOTYn8="
523 | },
524 | "iconv-lite": {
525 | "version": "0.4.24",
526 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
527 | "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
528 | "dev": true,
529 | "requires": {
530 | "safer-buffer": ">= 2.1.2 < 3"
531 | }
532 | },
533 | "inherits": {
534 | "version": "2.0.4",
535 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
536 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
537 | },
538 | "ipaddr.js": {
539 | "version": "1.9.0",
540 | "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz",
541 | "integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA==",
542 | "dev": true
543 | },
544 | "is-buffer": {
545 | "version": "1.1.6",
546 | "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
547 | "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w=="
548 | },
549 | "is-typedarray": {
550 | "version": "1.0.0",
551 | "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz",
552 | "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo="
553 | },
554 | "isexe": {
555 | "version": "2.0.0",
556 | "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
557 | "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA="
558 | },
559 | "isstream": {
560 | "version": "0.1.2",
561 | "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
562 | "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo="
563 | },
564 | "jsbn": {
565 | "version": "0.1.1",
566 | "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
567 | "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM="
568 | },
569 | "json-schema": {
570 | "version": "0.2.3",
571 | "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz",
572 | "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM="
573 | },
574 | "json-schema-traverse": {
575 | "version": "0.4.1",
576 | "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
577 | "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg=="
578 | },
579 | "json-stringify-safe": {
580 | "version": "5.0.1",
581 | "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
582 | "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus="
583 | },
584 | "jsprim": {
585 | "version": "1.4.1",
586 | "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz",
587 | "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=",
588 | "requires": {
589 | "assert-plus": "1.0.0",
590 | "extsprintf": "1.3.0",
591 | "json-schema": "0.2.3",
592 | "verror": "1.10.0"
593 | }
594 | },
595 | "lodash": {
596 | "version": "4.17.15",
597 | "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz",
598 | "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A=="
599 | },
600 | "md5": {
601 | "version": "2.2.1",
602 | "resolved": "https://registry.npmjs.org/md5/-/md5-2.2.1.tgz",
603 | "integrity": "sha1-U6s41f48iJG6RlMp6iP6wFQBJvk=",
604 | "requires": {
605 | "charenc": "~0.0.1",
606 | "crypt": "~0.0.1",
607 | "is-buffer": "~1.1.1"
608 | }
609 | },
610 | "media-typer": {
611 | "version": "0.3.0",
612 | "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
613 | "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=",
614 | "dev": true
615 | },
616 | "merge-descriptors": {
617 | "version": "1.0.1",
618 | "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
619 | "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=",
620 | "dev": true
621 | },
622 | "methods": {
623 | "version": "1.1.2",
624 | "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
625 | "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=",
626 | "dev": true
627 | },
628 | "mime": {
629 | "version": "1.6.0",
630 | "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
631 | "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg=="
632 | },
633 | "mime-db": {
634 | "version": "1.43.0",
635 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.43.0.tgz",
636 | "integrity": "sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ=="
637 | },
638 | "mime-types": {
639 | "version": "2.1.26",
640 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.26.tgz",
641 | "integrity": "sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ==",
642 | "requires": {
643 | "mime-db": "1.43.0"
644 | }
645 | },
646 | "ms": {
647 | "version": "2.1.2",
648 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
649 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
650 | },
651 | "negotiator": {
652 | "version": "0.6.2",
653 | "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz",
654 | "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==",
655 | "dev": true
656 | },
657 | "oauth-sign": {
658 | "version": "0.9.0",
659 | "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz",
660 | "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ=="
661 | },
662 | "on-finished": {
663 | "version": "2.3.0",
664 | "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",
665 | "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=",
666 | "requires": {
667 | "ee-first": "1.1.1"
668 | }
669 | },
670 | "os-tmpdir": {
671 | "version": "1.0.2",
672 | "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
673 | "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ="
674 | },
675 | "parseurl": {
676 | "version": "1.3.3",
677 | "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
678 | "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ=="
679 | },
680 | "path-to-regexp": {
681 | "version": "0.1.7",
682 | "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
683 | "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=",
684 | "dev": true
685 | },
686 | "pem": {
687 | "version": "1.14.4",
688 | "resolved": "https://registry.npmjs.org/pem/-/pem-1.14.4.tgz",
689 | "integrity": "sha512-v8lH3NpirgiEmbOqhx0vwQTxwi0ExsiWBGYh0jYNq7K6mQuO4gI6UEFlr6fLAdv9TPXRt6GqiwE37puQdIDS8g==",
690 | "requires": {
691 | "es6-promisify": "^6.0.0",
692 | "md5": "^2.2.1",
693 | "os-tmpdir": "^1.0.1",
694 | "which": "^2.0.2"
695 | }
696 | },
697 | "performance-now": {
698 | "version": "2.1.0",
699 | "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
700 | "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns="
701 | },
702 | "proxy-addr": {
703 | "version": "2.0.5",
704 | "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz",
705 | "integrity": "sha512-t/7RxHXPH6cJtP0pRG6smSr9QJidhB+3kXu0KgXnbGYMgzEnUxRQ4/LDdfOwZEMyIh3/xHb8PX3t+lfL9z+YVQ==",
706 | "dev": true,
707 | "requires": {
708 | "forwarded": "~0.1.2",
709 | "ipaddr.js": "1.9.0"
710 | }
711 | },
712 | "psl": {
713 | "version": "1.7.0",
714 | "resolved": "https://registry.npmjs.org/psl/-/psl-1.7.0.tgz",
715 | "integrity": "sha512-5NsSEDv8zY70ScRnOTn7bK7eanl2MvFrOrS/R6x+dBt5g1ghnj9Zv90kO8GwT8gxcu2ANyFprnFYB85IogIJOQ=="
716 | },
717 | "punycode": {
718 | "version": "2.1.1",
719 | "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
720 | "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
721 | },
722 | "qs": {
723 | "version": "6.5.2",
724 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz",
725 | "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA=="
726 | },
727 | "range-parser": {
728 | "version": "1.2.1",
729 | "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
730 | "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg=="
731 | },
732 | "raw-body": {
733 | "version": "2.4.0",
734 | "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz",
735 | "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==",
736 | "dev": true,
737 | "requires": {
738 | "bytes": "3.1.0",
739 | "http-errors": "1.7.2",
740 | "iconv-lite": "0.4.24",
741 | "unpipe": "1.0.0"
742 | },
743 | "dependencies": {
744 | "http-errors": {
745 | "version": "1.7.2",
746 | "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz",
747 | "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==",
748 | "dev": true,
749 | "requires": {
750 | "depd": "~1.1.2",
751 | "inherits": "2.0.3",
752 | "setprototypeof": "1.1.1",
753 | "statuses": ">= 1.5.0 < 2",
754 | "toidentifier": "1.0.0"
755 | }
756 | },
757 | "inherits": {
758 | "version": "2.0.3",
759 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
760 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
761 | "dev": true
762 | }
763 | }
764 | },
765 | "readable-stream": {
766 | "version": "3.5.0",
767 | "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.5.0.tgz",
768 | "integrity": "sha512-gSz026xs2LfxBPudDuI41V1lka8cxg64E66SGe78zJlsUofOg/yqwezdIcdfwik6B4h8LFmWPA9ef9X3FiNFLA==",
769 | "requires": {
770 | "inherits": "^2.0.3",
771 | "string_decoder": "^1.1.1",
772 | "util-deprecate": "^1.0.1"
773 | }
774 | },
775 | "request": {
776 | "version": "2.88.0",
777 | "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz",
778 | "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==",
779 | "requires": {
780 | "aws-sign2": "~0.7.0",
781 | "aws4": "^1.8.0",
782 | "caseless": "~0.12.0",
783 | "combined-stream": "~1.0.6",
784 | "extend": "~3.0.2",
785 | "forever-agent": "~0.6.1",
786 | "form-data": "~2.3.2",
787 | "har-validator": "~5.1.0",
788 | "http-signature": "~1.2.0",
789 | "is-typedarray": "~1.0.0",
790 | "isstream": "~0.1.2",
791 | "json-stringify-safe": "~5.0.1",
792 | "mime-types": "~2.1.19",
793 | "oauth-sign": "~0.9.0",
794 | "performance-now": "^2.1.0",
795 | "qs": "~6.5.2",
796 | "safe-buffer": "^5.1.2",
797 | "tough-cookie": "~2.4.3",
798 | "tunnel-agent": "^0.6.0",
799 | "uuid": "^3.3.2"
800 | },
801 | "dependencies": {
802 | "form-data": {
803 | "version": "2.3.3",
804 | "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz",
805 | "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==",
806 | "requires": {
807 | "asynckit": "^0.4.0",
808 | "combined-stream": "^1.0.6",
809 | "mime-types": "^2.1.12"
810 | }
811 | },
812 | "uuid": {
813 | "version": "3.4.0",
814 | "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
815 | "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="
816 | }
817 | }
818 | },
819 | "safe-buffer": {
820 | "version": "5.2.0",
821 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz",
822 | "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg=="
823 | },
824 | "safer-buffer": {
825 | "version": "2.1.2",
826 | "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
827 | "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
828 | },
829 | "sax": {
830 | "version": "1.2.4",
831 | "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
832 | "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
833 | },
834 | "send": {
835 | "version": "0.17.1",
836 | "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz",
837 | "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==",
838 | "requires": {
839 | "debug": "2.6.9",
840 | "depd": "~1.1.2",
841 | "destroy": "~1.0.4",
842 | "encodeurl": "~1.0.2",
843 | "escape-html": "~1.0.3",
844 | "etag": "~1.8.1",
845 | "fresh": "0.5.2",
846 | "http-errors": "~1.7.2",
847 | "mime": "1.6.0",
848 | "ms": "2.1.1",
849 | "on-finished": "~2.3.0",
850 | "range-parser": "~1.2.1",
851 | "statuses": "~1.5.0"
852 | },
853 | "dependencies": {
854 | "debug": {
855 | "version": "2.6.9",
856 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
857 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
858 | "requires": {
859 | "ms": "2.0.0"
860 | },
861 | "dependencies": {
862 | "ms": {
863 | "version": "2.0.0",
864 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
865 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
866 | }
867 | }
868 | },
869 | "ms": {
870 | "version": "2.1.1",
871 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
872 | "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg=="
873 | }
874 | }
875 | },
876 | "serve-static": {
877 | "version": "1.14.1",
878 | "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz",
879 | "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==",
880 | "requires": {
881 | "encodeurl": "~1.0.2",
882 | "escape-html": "~1.0.3",
883 | "parseurl": "~1.3.3",
884 | "send": "0.17.1"
885 | }
886 | },
887 | "setprototypeof": {
888 | "version": "1.1.1",
889 | "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz",
890 | "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw=="
891 | },
892 | "soap": {
893 | "version": "0.30.0",
894 | "resolved": "https://registry.npmjs.org/soap/-/soap-0.30.0.tgz",
895 | "integrity": "sha512-nPDbX8Y/EJNyMXog50BRONUa/S0oaDYvFO3IAegh7IoxOwGpWr6xoyUx+ZgAY9tvstZDnOHRPdfvxDhAVCVyAQ==",
896 | "requires": {
897 | "@types/request": "^2.48.1",
898 | "bluebird": "^3.5.0",
899 | "concat-stream": "^2.0.0",
900 | "debug": "^4.1.1",
901 | "httpntlm": "^1.5.2",
902 | "lodash": "^4.17.15",
903 | "request": ">=2.9.0",
904 | "sax": ">=0.6",
905 | "serve-static": "^1.11.1",
906 | "strip-bom": "^3.0.0",
907 | "uuid": "^3.1.0",
908 | "xml-crypto": "^1.4.0"
909 | },
910 | "dependencies": {
911 | "uuid": {
912 | "version": "3.4.0",
913 | "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
914 | "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="
915 | },
916 | "xml-crypto": {
917 | "version": "1.4.0",
918 | "resolved": "https://registry.npmjs.org/xml-crypto/-/xml-crypto-1.4.0.tgz",
919 | "integrity": "sha512-K8FRdRxICVulK4WhiTUcJrRyAIJFPVOqxfurA3x/JlmXBTxy+SkEENF6GeRt7p/rB6WSOUS9g0gXNQw5n+407g==",
920 | "requires": {
921 | "xmldom": "0.1.27",
922 | "xpath": "0.0.27"
923 | }
924 | },
925 | "xmldom": {
926 | "version": "0.1.27",
927 | "resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.27.tgz",
928 | "integrity": "sha1-1QH5ezvbQDr4757MIFcxh6rawOk="
929 | }
930 | }
931 | },
932 | "sshpk": {
933 | "version": "1.16.1",
934 | "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz",
935 | "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==",
936 | "requires": {
937 | "asn1": "~0.2.3",
938 | "assert-plus": "^1.0.0",
939 | "bcrypt-pbkdf": "^1.0.0",
940 | "dashdash": "^1.12.0",
941 | "ecc-jsbn": "~0.1.1",
942 | "getpass": "^0.1.1",
943 | "jsbn": "~0.1.0",
944 | "safer-buffer": "^2.0.2",
945 | "tweetnacl": "~0.14.0"
946 | }
947 | },
948 | "statuses": {
949 | "version": "1.5.0",
950 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
951 | "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow="
952 | },
953 | "string_decoder": {
954 | "version": "1.3.0",
955 | "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
956 | "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==",
957 | "requires": {
958 | "safe-buffer": "~5.2.0"
959 | }
960 | },
961 | "strip-bom": {
962 | "version": "3.0.0",
963 | "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz",
964 | "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM="
965 | },
966 | "toidentifier": {
967 | "version": "1.0.0",
968 | "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz",
969 | "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw=="
970 | },
971 | "tough-cookie": {
972 | "version": "2.4.3",
973 | "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz",
974 | "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==",
975 | "requires": {
976 | "psl": "^1.1.24",
977 | "punycode": "^1.4.1"
978 | },
979 | "dependencies": {
980 | "punycode": {
981 | "version": "1.4.1",
982 | "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz",
983 | "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4="
984 | }
985 | }
986 | },
987 | "tunnel-agent": {
988 | "version": "0.6.0",
989 | "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
990 | "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=",
991 | "requires": {
992 | "safe-buffer": "^5.0.1"
993 | }
994 | },
995 | "tweetnacl": {
996 | "version": "0.14.5",
997 | "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz",
998 | "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q="
999 | },
1000 | "type-is": {
1001 | "version": "1.6.18",
1002 | "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
1003 | "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
1004 | "dev": true,
1005 | "requires": {
1006 | "media-typer": "0.3.0",
1007 | "mime-types": "~2.1.24"
1008 | }
1009 | },
1010 | "typedarray": {
1011 | "version": "0.0.6",
1012 | "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
1013 | "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c="
1014 | },
1015 | "underscore": {
1016 | "version": "1.7.0",
1017 | "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.7.0.tgz",
1018 | "integrity": "sha1-a7rwh3UA02vjTsqlhODbn+8DUgk="
1019 | },
1020 | "unpipe": {
1021 | "version": "1.0.0",
1022 | "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
1023 | "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=",
1024 | "dev": true
1025 | },
1026 | "uri-js": {
1027 | "version": "4.2.2",
1028 | "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz",
1029 | "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==",
1030 | "requires": {
1031 | "punycode": "^2.1.0"
1032 | }
1033 | },
1034 | "ursa-purejs2020": {
1035 | "version": "0.0.4",
1036 | "resolved": "https://registry.npmjs.org/ursa-purejs2020/-/ursa-purejs2020-0.0.4.tgz",
1037 | "integrity": "sha512-ws5wJF0lC0NgC82jkVUJz9nGPXUT6KhVbAHkSHCbEAkkSIDbw/u6CbYHIZu3ZQv/z9/+86yXkPE9iTMKENgLlw==",
1038 | "requires": {
1039 | "node-rsa": "^1.0.7"
1040 | },
1041 | "dependencies": {
1042 | "node-rsa": {
1043 | "version": "1.0.7",
1044 | "resolved": "https://registry.npmjs.org/node-rsa/-/node-rsa-1.0.7.tgz",
1045 | "integrity": "sha512-idwRXma6scFufZmbaKkHpJoLL93yynRefP6yur13wZ5i9FR35ex451KCoF2OORDeJanyRVahmjjiwmUlCnTqJA==",
1046 | "requires": {
1047 | "asn1": "^0.2.4"
1048 | }
1049 | }
1050 | }
1051 | },
1052 | "util-deprecate": {
1053 | "version": "1.0.2",
1054 | "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
1055 | "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
1056 | },
1057 | "utils-merge": {
1058 | "version": "1.0.1",
1059 | "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
1060 | "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=",
1061 | "dev": true
1062 | },
1063 | "uuid": {
1064 | "version": "3.4.0",
1065 | "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
1066 | "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="
1067 | },
1068 | "vary": {
1069 | "version": "1.1.2",
1070 | "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
1071 | "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=",
1072 | "dev": true
1073 | },
1074 | "verror": {
1075 | "version": "1.10.0",
1076 | "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz",
1077 | "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=",
1078 | "requires": {
1079 | "assert-plus": "^1.0.0",
1080 | "core-util-is": "1.0.2",
1081 | "extsprintf": "^1.2.0"
1082 | }
1083 | },
1084 | "which": {
1085 | "version": "2.0.2",
1086 | "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
1087 | "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
1088 | "requires": {
1089 | "isexe": "^2.0.0"
1090 | }
1091 | },
1092 | "xml-crypto": {
1093 | "version": "0.8.5",
1094 | "resolved": "https://registry.npmjs.org/xml-crypto/-/xml-crypto-0.8.5.tgz",
1095 | "integrity": "sha1-K7z7PrM/OoKiGLgiv2craxwg5Tg=",
1096 | "requires": {
1097 | "xmldom": "=0.1.19",
1098 | "xpath.js": ">=0.0.3"
1099 | },
1100 | "dependencies": {
1101 | "xmldom": {
1102 | "version": "0.1.19",
1103 | "resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.19.tgz",
1104 | "integrity": "sha1-Yx/Ad3bv2EEYvyUXGzftTQdaCrw="
1105 | }
1106 | }
1107 | },
1108 | "xmldom": {
1109 | "version": "0.1.31",
1110 | "resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.31.tgz",
1111 | "integrity": "sha512-yS2uJflVQs6n+CyjHoaBmVSqIDevTAWrzMmjG1Gc7h1qQ7uVozNhEPJAwZXWyGQ/Gafo3fCwrcaokezLPupVyQ=="
1112 | },
1113 | "xpath": {
1114 | "version": "0.0.27",
1115 | "resolved": "https://registry.npmjs.org/xpath/-/xpath-0.0.27.tgz",
1116 | "integrity": "sha512-fg03WRxtkCV6ohClePNAECYsmpKKTv5L8y/X3Dn1hQrec3POx2jHZ/0P2qQ6HvsrU1BmeqXcof3NGGueG6LxwQ=="
1117 | },
1118 | "xpath.js": {
1119 | "version": "1.1.0",
1120 | "resolved": "https://registry.npmjs.org/xpath.js/-/xpath.js-1.1.0.tgz",
1121 | "integrity": "sha512-jg+qkfS4K8E7965sqaUl8mRngXiKb3WZGfONgE18pr03FUQiuSV6G+Ej4tS55B+rIQSFEIw3phdVAQ4pPqNWfQ=="
1122 | }
1123 | }
1124 | }
1125 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "webpay-nodejs",
3 | "version": "1.4.0",
4 | "description": "WebPay Plus implementation in Node.js",
5 | "main": "index.js",
6 | "dependencies": {
7 | "decimal.js-light": "^2.2.3",
8 | "uuid": "^3.4.0",
9 | "pem": "^1.9.4",
10 | "soap": "^0.30.0",
11 | "ursa-purejs2020": "0.0.4",
12 | "xml-crypto": "^0.8.5",
13 | "xmldom": "^0.1.27",
14 | "ejs": "^3.0.1"
15 | },
16 | "devDependencies": {
17 | "body-parser": "^1.16.0",
18 | "express": "^4.14.0"
19 | },
20 | "scripts": {
21 | "test": "echo \"Error: no test specified\" && exit 1"
22 | },
23 | "repository": {
24 | "type": "git",
25 | "url": "https://github.com/rgcl/webpay-nodejs.git"
26 | },
27 | "author": "Rodrigo González Castillo ",
28 | "license": "LGPL"
29 | }
30 |
--------------------------------------------------------------------------------
/showcase/cert/normal.js:
--------------------------------------------------------------------------------
1 | //Unofficial WebPay SDK for Node.js
2 | //Copyright (C) 2017-2020 Rodrigo González Castillo , et al.
3 | //
4 | //This program is free software: you can redistribute it and/or modify
5 | //it under the terms of the GNU General Public License as published by
6 | //the Free Software Foundation, either version 3 of the License, or
7 | //(at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | //GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | //along with this program. If not, see .
16 |
17 | module.exports.commerceCode = '597020000540';
18 |
19 | module.exports.env = "INTEGRACION";
20 |
21 | module.exports.publicKey =
22 | `-----BEGIN CERTIFICATE-----
23 | MIIDeDCCAmACCQDjtGVIe/aeCTANBgkqhkiG9w0BAQsFADB+MQswCQYDVQQGEwJj
24 | bDENMAsGA1UECAwEc3RnbzENMAsGA1UEBwwEc3RnbzEMMAoGA1UECgwDdGJrMQ0w
25 | CwYDVQQLDARjY3JyMRUwEwYDVQQDDAw1OTcwMjAwMDA1NDAxHTAbBgkqhkiG9w0B
26 | CQEWDmNjcnJAZ21haWwuY29tMB4XDTE4MDYwODEzNDYwNloXDTIyMDYwNzEzNDYw
27 | NlowfjELMAkGA1UEBhMCY2wxDTALBgNVBAgMBHN0Z28xDTALBgNVBAcMBHN0Z28x
28 | DDAKBgNVBAoMA3RiazENMAsGA1UECwwEY2NycjEVMBMGA1UEAwwMNTk3MDIwMDAw
29 | NTQwMR0wGwYJKoZIhvcNAQkBFg5jY3JyQGdtYWlsLmNvbTCCASIwDQYJKoZIhvcN
30 | AQEBBQADggEPADCCAQoCggEBAL7jYAcTADgZTSOxcObBxmNaegwehDCvN0i+G9WS
31 | C0ibP/PzAl/D5MrNwryZkiIilO351pIF3IRHalyVfrc4KBA/8vfbV4KDLLItJmvr
32 | vWLT76U+wWua5OR6S7mhTXrhN5fpqZFw2WShUmSdX1fx8p9wNWc/u/l9qohqwFln
33 | Y3hrCJM+K7rjBS0FXT1a3QMRFqA0cmxFIa2kCdZMJsfdhxX0ZbGzQJhJYxvZ4Mf/
34 | vySwNvHLPaFC8uPzO31VM4qCrASZo0SXerOKyNmCA6bpenZoJaFoBH83yzZwLGYS
35 | a8iTQa9lmxOgy+cf1Nl0HIY4rITGwyD45g4EtByyzI0QjKUCAwEAATANBgkqhkiG
36 | 9w0BAQsFAAOCAQEAhX2/fZ6+lyoY3jSU9QFmbL6ONoDS6wBU7izpjdihnWt7oIME
37 | a51CNssla7ZnMSoBiWUPIegischx6rh8M1q5SjyWYTvnd3v+/rbGa6d40yZW3m+W
38 | p/3Sb1e9FABJhZkAQU2KGMot/b/ncePKHvfSBzQCwbuXWPzrF+B/4ZxGMAkgxtmK
39 | WnWrkcr2qakpHzERn8irKBPhvlifW5sdMH4tz/4SLVwkek24Sp8CVmIIgQR3nyR9
40 | 8hi1+Iz4O1FcIQtx17OvhWDXhfEsG0HWygc5KyTqCkVBClVsJPRvoCSTORvukcuW
41 | 18gbYO3VlxwXnvzLk4aptC7/8Jq83XY8o0fn+A==
42 | -----END CERTIFICATE-----`;
43 |
44 | module.exports.privateKey =
45 | `-----BEGIN RSA PRIVATE KEY-----
46 | MIIEowIBAAKCAQEAvuNgBxMAOBlNI7Fw5sHGY1p6DB6EMK83SL4b1ZILSJs/8/MC
47 | X8Pkys3CvJmSIiKU7fnWkgXchEdqXJV+tzgoED/y99tXgoMssi0ma+u9YtPvpT7B
48 | a5rk5HpLuaFNeuE3l+mpkXDZZKFSZJ1fV/Hyn3A1Zz+7+X2qiGrAWWdjeGsIkz4r
49 | uuMFLQVdPVrdAxEWoDRybEUhraQJ1kwmx92HFfRlsbNAmEljG9ngx/+/JLA28cs9
50 | oULy4/M7fVUzioKsBJmjRJd6s4rI2YIDpul6dmgloWgEfzfLNnAsZhJryJNBr2Wb
51 | E6DL5x/U2XQchjishMbDIPjmDgS0HLLMjRCMpQIDAQABAoIBAEkSwa/zliHjjaQc
52 | SRwNEeT2vcHl7LS2XnN6Uy1uuuMQi2rXnBEM7Ii2O9X28/odQuXWvk0n8UKyFAVd
53 | NSTuWmfeEyTO0rEjhfivUAYAOH+coiCf5WtL4FOWfWaSWRaxIJcG2+LRUGc1WlUp
54 | 6VXBSR+/1LGxtEPN13phY0DWUz3FEfGBd4CCPLpzq7HyZWEHUvbaw89xZJSr/Zwh
55 | BDZZyTbuwSHc9X9LlQsbaDuW/EyOMmDvSxmSRJO10FRMxyg8qbE4edtUK4jd61i0
56 | kGFqdDu9sj5k8pDxOsN2F270SMlIwejZ1uunB87w9ezIcR9YLq9aa22cT8BZdOxb
57 | uZ3PAAECgYEA6xfgRtcvpJUBWBVNsxrSg6Ktx2848eQne9NnbWHdZuNjH8OyN7SW
58 | Fn0r4HsTw59/NJ1L5F3co5L5baEtRbRLWRpD72xjrXsQSsoKliCik1xgDIplMvOh
59 | teA2GdeSv9wglqnotGcj5B/8+vn3tEzMjy+UUsyFn0fIaDC3zK3W2qUCgYEAz90g
60 | va+FCcU8cnykb5Yn1u1izdK1c6S++v1bQFf6590ZMNy3p0uGrwAk/MzuBkJ421GK
61 | p4pInUvO/Mb2BCcoHtr3ON3v0DCLl6Ae2Gb7lG0dLgcZ1EK7MDpMvKCqNHAv8Qu8
62 | QBZOA08L8buVkkRt7jxJrPuOFDI5JAaWCmMOSgECgYEA3GvzfZgu9Go862B2DJL+
63 | hCuYMiCHTM01c/UfyT/z/Y7/ln2+8FniS02rQPtE6ar28tb0nDahM8EPGon/T5ae
64 | +vkUbzy6LKLxAJ501JPeurnm2Hs+LUqe+U8yioJD9p2m9Hx0UglOborLgGm0pRlI
65 | xou+zu8x7ci5D292NXNcun0CgYAVKV378bKJnBrbTPUwpwjHSMOWUK1IaK1IwCJa
66 | GprgoBHAd7f6wCWmC024ruRMntfO/C4xgFKEMQORmG/TXGkpOwGQOIgBme+cMCDz
67 | xwg1xCYEWZS3l1OXRVgqm/C4BfPbhmZT3/FxRMrigUZo7a6DYn/drH56b+KBWGpO
68 | BGegAQKBgGY7Ikdw288DShbEVi6BFjHKDej3hUfsTwncRhD4IAgALzaatuta7JFW
69 | NrGTVGeK/rE6utA/DPlP0H2EgkUAzt8x3N0MuVoBl/Ow7y5sqIQKfEI7h0aRdXH5
70 | ecefOL6iiJWQqX2+237NOd0fJ4E1+BCMu/+HnyCX+cFM2FgoE6tC
71 | -----END RSA PRIVATE KEY-----`;
72 |
73 | module.exports.webpayKey = `
74 | -----BEGIN CERTIFICATE-----
75 | MIIEDzCCAvegAwIBAgIJAMaH4DFTKdnJMA0GCSqGSIb3DQEBCwUAMIGdMQswCQYD
76 | VQQGEwJDTDERMA8GA1UECAwIU2FudGlhZ28xETAPBgNVBAcMCFNhbnRpYWdvMRcw
77 | FQYDVQQKDA5UUkFOU0JBTksgUy5BLjESMBAGA1UECwwJU2VndXJpZGFkMQswCQYD
78 | VQQDDAIyMDEuMCwGCSqGSIb3DQEJARYfc2VndXJpZGFkb3BlcmF0aXZhQHRyYW5z
79 | YmFuay5jbDAeFw0xODA4MjQxOTU2MDlaFw0yMTA4MjMxOTU2MDlaMIGdMQswCQYD
80 | VQQGEwJDTDERMA8GA1UECAwIU2FudGlhZ28xETAPBgNVBAcMCFNhbnRpYWdvMRcw
81 | FQYDVQQKDA5UUkFOU0JBTksgUy5BLjESMBAGA1UECwwJU2VndXJpZGFkMQswCQYD
82 | VQQDDAIyMDEuMCwGCSqGSIb3DQEJARYfc2VndXJpZGFkb3BlcmF0aXZhQHRyYW5z
83 | YmFuay5jbDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJN+OJgQQqMb
84 | iRZDb3x+JoTfSjyYsRc5k2CWvLpTPFxXuhDyp6mbdIpWIiNYEC4vufVZo5A3THar
85 | cbnJRlW/4NVv5QM3gHN9WJ4QeIsrTLtvcIPlfUJNPLNeDqy84zum2YqAFmX5LWsp
86 | SF1Ls6n7el8KNJAceaU+2ooN8QZdFZ3RnMc2vrHY7EU6wYGmf/VCEaDZCKqY6ElY
87 | mt6/9b2lkhpQLdBn01IqqFpGrD+5DLmYrQur4/1BDVtdNLggX0K7kPk/mkPDq4ME
88 | ytkc9/RI5HfJWoQ4EDQF6qcqPqxlMFDf5KEaoLVL230EdwOl0UyvlF25S9ubRyHy
89 | mKWIEFSSXe0CAwEAAaNQME4wHQYDVR0OBBYEFP3nYSPX3YKF11RArC09hxjEMMBv
90 | MB8GA1UdIwQYMBaAFP3nYSPX3YKF11RArC09hxjEMMBvMAwGA1UdEwQFMAMBAf8w
91 | DQYJKoZIhvcNAQELBQADggEBAFHqOPGeg5IpeKz9LviiBGsJDReGVkQECXHp1QP4
92 | 8RpWDdXBKQqKUi7As97wmVksweaasnGlgL4YHShtJVPFbYG9COB+ElAaaiOoELsy
93 | kjF3tyb0EgZ0Z3QIKabwxsxdBXmVyHjd13w6XGheca9QFane4GaqVhPVJJIH/zD2
94 | mSc1boVSpaRc1f0oiMtiZf/rcY1/IyMXA9RVxtOtNs87Wjnwq6AiMjB15fLHfT7d
95 | R48O6P0ZpWLlZwScyqDWcsg/4wNCL5Kaa5VgM03SKM6XoWTzkT7p0t0FPZVoGCyG
96 | MX5lzVXafBH/sPd545fBH2J3xAY3jtP764G4M8JayOFzGB0=
97 | -----END CERTIFICATE-----
98 | `;
99 |
--------------------------------------------------------------------------------
/showcase/cert/oneClick.js:
--------------------------------------------------------------------------------
1 | //Unofficial WebPay SDK for Node.js
2 | //Copyright (C) 2017-2020 Rodrigo González Castillo , et al.
3 | //
4 | //This program is free software: you can redistribute it and/or modify
5 | //it under the terms of the GNU General Public License as published by
6 | //the Free Software Foundation, either version 3 of the License, or
7 | //(at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | //GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | //along with this program. If not, see .
16 |
17 | module.exports.commerceCode = "597020000547";
18 |
19 | module.exports.env = "INTEGRACION";
20 |
21 | module.exports.publicKey = `
22 | -----BEGIN CERTIFICATE-----
23 | MIIDujCCAqICCQCFNCTEl24W2TANBgkqhkiG9w0BAQsFADCBnjELMAkGA1UEBhMC
24 | Q0wxETAPBgNVBAgMCFNhbnRpYWdvMRIwEAYDVQQKDAlUcmFuc2JhbmsxETAPBgNV
25 | BAcMCFNhbnRpYWdvMRUwEwYDVQQDDAw1OTcwMjAwMDA1NDcxFzAVBgNVBAsMDkNh
26 | bmFsZXNSZW1vdG9zMSUwIwYJKoZIhvcNAQkBFhZpbnRlZ3JhZG9yZXNAdmFyaW9z
27 | LmNsMB4XDTE2MDYyMzE2MzcxM1oXDTI0MDYyMTE2MzcxM1owgZ4xCzAJBgNVBAYT
28 | AkNMMREwDwYDVQQIDAhTYW50aWFnbzESMBAGA1UECgwJVHJhbnNiYW5rMREwDwYD
29 | VQQHDAhTYW50aWFnbzEVMBMGA1UEAwwMNTk3MDIwMDAwNTQ3MRcwFQYDVQQLDA5D
30 | YW5hbGVzUmVtb3RvczElMCMGCSqGSIb3DQEJARYWaW50ZWdyYWRvcmVzQHZhcmlv
31 | cy5jbDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAORastwv3YYHVbBp
32 | L+aeRi73fTsXjr/qaCuNc08SFFzi6RujRFvh2+UM9K05NUxFSVAklW9G1fJ37A9K
33 | B6JQ/+yFP877xFifMyOXGu1Wdrmduy7nngGrM0X0RlpCfE6kQfKhP0LhyFFSRIGP
34 | WMaRJg9uYRCJWVPeBUUUXB0qSdfvKNyvQ0qpG3vWlhhr7Pocc65U4TuPBwFMC9Bd
35 | qMjKsrEkIUamX33kmTKeKrCpRO4iK+aZPN+90Ki6328Jtn3OevkRtIFUOO0ik36T
36 | 8dkVTPZ2ydwKGLaaBHOB0WlJ1QieWIhmMuvQrFDST7I/WUy9Wr0ySul58oKFT6Jf
37 | Xe19dysCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAubHNHDzyMLXuNQwawdhrzJYf
38 | Cvi2NsAqVBKICp+VC94OqVsdWknrqm8+Wz+1DZV1ezTvoVgagiC/ZrfHvn9DEP45
39 | 7JttrOt2Sbr+F2Pj3oBl1RiQ2QkIXBRaSmipKaQB/cWRd0ZiO7uT5mP7eQtO5qFJ
40 | 4WST6dXtks2Oz4G7eMpqnctOfFiGBi1i6omD7LZg+qpbeTFWTEgZFcAUTrViRLl2
41 | PEhUMVAobvvY7zUmzeu2mAMlWVNoaJysl6sH7Gii3T/xbxHsbxV8bZgvgQwiwFVP
42 | +ffp06jqVndIhoeiTOz0MXgPIXIESaDraY2dgNTgEs2GwLNjy2cMB5pkjkAZ4g==
43 | -----END CERTIFICATE-----
44 | `;
45 |
46 | module.exports.privateKey = `
47 | -----BEGIN RSA PRIVATE KEY-----
48 | MIIEpAIBAAKCAQEA5Fqy3C/dhgdVsGkv5p5GLvd9OxeOv+poK41zTxIUXOLpG6NE
49 | W+Hb5Qz0rTk1TEVJUCSVb0bV8nfsD0oHolD/7IU/zvvEWJ8zI5ca7VZ2uZ27Luee
50 | AaszRfRGWkJ8TqRB8qE/QuHIUVJEgY9YxpEmD25hEIlZU94FRRRcHSpJ1+8o3K9D
51 | Sqkbe9aWGGvs+hxzrlThO48HAUwL0F2oyMqysSQhRqZffeSZMp4qsKlE7iIr5pk8
52 | 373QqLrfbwm2fc56+RG0gVQ47SKTfpPx2RVM9nbJ3AoYtpoEc4HRaUnVCJ5YiGYy
53 | 69CsUNJPsj9ZTL1avTJK6XnygoVPol9d7X13KwIDAQABAoIBAQDPB6/rUvYbIqE8
54 | nFESW+KziCwgm/4O3x1shwTI5lJR2GORbBd42i973aAjQJ+is5qBL3nP9j/YYYNC
55 | ZVLAhYFR1YkBRl9AHa3GkaOXE/H13RwsrU8ioi2NOadjA64humgT6r8pCvyLRfPY
56 | JrdM56HDEcassGmtULgkZg4RXxqtym6dcpPmuXtCHFZ7JEWVSKWH+STReAh7unwD
57 | TYOZlsnU5FuSzYlN2IC0OtZORviTSiEkI1XMyrDm97HQWOCkwa6OizKf/xFdvX5X
58 | xcksALubSX1I+2sUHqP0LbZ3rkxgG6VoaJGF3zZdsjUPfFHBy/IGnbpcMqe/YkZl
59 | AduyI4KhAoGBAP5iLhQr9k/vKUXNgl/9H5wMWBqf3WvOgH4WiApUZ5i5e5JkOgav
60 | 6LSsGdLYhEADYAKYgRUOpwDE6IBcWobTCwe6O0R7Us9r/c1ex3zEPcqiMqULyAxx
61 | LLu34O75t7ctPvhewKfNs16qzl751ZWYInBbQoZf8CkZMDSxsQGCbTIRAoGBAOXO
62 | LOutW0anleTsBbQwbR1k0hIPk6CwQnutq1BcsELYBSNKh6DIA16zBqyE9oFDsS34
63 | VLvXETZZKGEUoPju28DVH+Scic5E15CPNUaJie+Ief97fA/iPLJNJFSpcsJG/+Rd
64 | jB1hurkcvjzp67wNk9z+WJBxcMfAo/KwSxbkNtl7AoGBAKUitycBIvThHLnjny8Q
65 | 8uQqX0dpYCQL+f3gQo/yGw5Z2o494i1VJIuk7V6ij7e+eSU2OxWgXWlyajxpt5qu
66 | hgqOKstaA3gDcs9PJ9Em07YndRkPfN4W2iNCSxLXqRuQk8BIQmiscDSUTUP6i1yB
67 | Vln55EW3IgCMCW8rqux/7sMBAoGAHkrqUvrcIFkxAic2rUUA7TIAGw9gl3sEmIcR
68 | IRvGxFjzfG5zqHcVMqOIyq8QS4Pf1D569PPpue9QylNM0OOzphyyApG7/KvIeq7W
69 | CAFTZHbqFgpyFSnudFaE5oAbt45iZvkJ4kmisooebassPvLPPf9tL0U056/2LKSe
70 | kVrt/AcCgYAWmgeAtQ4H6mX3yPeEa4uDJevjaVKxlKYUPdd8kCD3OTjX9/Pig2GH
71 | XhI5UeVd2k4EBdrY1DRVr+cJ8/fEKzcjOKyrbs0XTld8XCBeVuQKAliYS7PpG70C
72 | 3/jXM8HZyqbPB+apW35Ucqo84ClgPN8LUOi/tE/aP11awxmgTk9F+w==
73 | -----END RSA PRIVATE KEY-----
74 | `;
75 |
76 | module.exports.webpayKey = `
77 | -----BEGIN CERTIFICATE-----
78 | MIIDKTCCAhECBFZl7uIwDQYJKoZIhvcNAQEFBQAwWTELMAkGA1UEBhMCQ0wxDjAMBgNVBAgMBUNo
79 | aWxlMREwDwYDVQQHDAhTYW50aWFnbzEMMAoGA1UECgwDa2R1MQwwCgYDVQQLDANrZHUxCzAJBgNV
80 | BAMMAjEwMB4XDTE1MTIwNzIwNDEwNloXDTE4MDkwMjIwNDEwNlowWTELMAkGA1UEBhMCQ0wxDjAM
81 | BgNVBAgMBUNoaWxlMREwDwYDVQQHDAhTYW50aWFnbzEMMAoGA1UECgwDa2R1MQwwCgYDVQQLDANr
82 | ZHUxCzAJBgNVBAMMAjEwMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAizJUWTDC7nfP
83 | 3jmZpWXFdG9oKyBrU0Bdl6fKif9a1GrwevThsU5Dq3wiRfYvomStNjFDYFXOs9pRIxqX2AWDybjA
84 | X/+bdDTVbM+xXllA9stJY8s7hxAvwwO7IEuOmYDpmLKP7J+4KkNH7yxsKZyLL9trG3iSjV6Y6SO5
85 | EEhUsdxoJFAow/h7qizJW0kOaWRcljf7kpqJAL3AadIuqV+hlf+Ts/64aMsfSJJA6xdbdp9ddgVF
86 | oqUl1M8vpmd4glxlSrYmEkbYwdI9uF2d6bAeaneBPJFZr6KQqlbbrVyeJZqmMlEPy0qPco1TIxrd
87 | EHlXgIFJLyyMRAyjX9i4l70xjwIDAQABMA0GCSqGSIb3DQEBBQUAA4IBAQBn3tUPS6e2USgMrPKp
88 | sxU4OTfW64+mfD6QrVeBOh81f6aGHa67sMJn8FE/cG6jrUmX/FP1/Cpbpvkm5UUlFKpgaFfHv+Kg
89 | CpEvgcRIv/OeIi6Jbuu3NrPdGPwzYkzlOQnmgio5RGb6GSs+OQ0mUWZ9J1+YtdZc+xTga0x7nsCT
90 | 5xNcUXsZKhyjoKhXtxJm3eyB3ysLNyuL/RHy/EyNEWiUhvt1SIePnW+Y4/cjQWYwNqSqMzTSW9TP
91 | 2QR2bX/W2H6ktRcLsgBK9mq7lE36p3q6c9DtZJE+xfA4NGCYWM9hd8pbusnoNO7AFxJZOuuvLZI7
92 | JvD7YLhPvCYKry7N6x3l
93 | -----END CERTIFICATE-----
94 | `;
95 |
--------------------------------------------------------------------------------
/showcase/cert/oneClickMall.js:
--------------------------------------------------------------------------------
1 | //Unofficial WebPay SDK for Node.js
2 | //Copyright (C) 2017-2020 Rodrigo González Castillo , et al.
3 | //
4 | //This program is free software: you can redistribute it and/or modify
5 | //it under the terms of the GNU General Public License as published by
6 | //the Free Software Foundation, either version 3 of the License, or
7 | //(at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | //GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | //along with this program. If not, see .
16 |
17 | module.exports.commerceCode = "597020000584";
18 |
19 | module.exports.env = "INTEGRACION";
20 |
21 | module.exports.publicKey = `
22 | -----BEGIN CERTIFICATE-----
23 | MIIDNDCCAhwCCQCwwMoltTfOszANBgkqhkiG9w0BAQUFADBcMQswCQYDVQQGEwJD
24 | TDETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0
25 | cyBQdHkgTHRkMRUwEwYDVQQDDAw1OTcwMjAwMDA1ODQwHhcNMTYwODE2MjIxNzA4
26 | WhcNMjAwODE1MjIxNzA4WjBcMQswCQYDVQQGEwJDTDETMBEGA1UECAwKU29tZS1T
27 | dGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMRUwEwYDVQQD
28 | DAw1OTcwMjAwMDA1ODQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDI
29 | cO22FdNOKKtLxOcgJFugyKFla0dM9e+fhavxv13K6bPc7FCPaYf9Iy2sHGrEEJga
30 | DmiH3CljtYC4cdyzURw9UwkY8I4hOsi2WY0sr592rxrRfdkEIZxyPe3u6Nss35xD
31 | 29aZeOkUiiXCfZYpedPrsfwxUT27KLRb9y1qJRuA7dadI4k4511d16gV7cZ+syWf
32 | G93rze4aaty/X3kXKT6jmAlQ+Y+IsnAX1Giya6i3gCCxJRhc27waTzT5FhaYrAch
33 | 2NkWB0hKFK7VudNft8sV5RHSbNKigIXh+CrKiadcSDvj20Lp2idk8lloYSYwwChA
34 | Q/8mJcVH8QIdSXnTZslDAgMBAAEwDQYJKoZIhvcNAQEFBQADggEBADjyRWD6HveD
35 | fDF166yPIcFGM/3YmUFVhOJSc+tlhBINZn6GuKouezSQeJY3snHZ5l06lQJIcW+s
36 | i+12J4xdvd/bStin0lkZCft2GWA5JvoUKxFIQXfsAN1jldwjiq604DLSIvhBNDyO
37 | Zc1IEq/dHCBDHtBVTjkWU8/m5HT574G5WQyDGBwwPdk68Zp6Gf5Up/BbEoaExl4U
38 | wf08Q8jMDZbOJIbQOs9lvJA6R+j5OPkH1oTfTST7eKfkzRtnb2hAO8PAE6G3Hd1D
39 | bIm99ZsMOo+q0FciiNAApYPNaFc2JoMqDhORKi40qlrW/v7HsRomNweO4xj2JuEp
40 | C5V/LBCeLP4=
41 | -----END CERTIFICATE-----
42 | `;
43 |
44 | module.exports.privateKey = `
45 | -----BEGIN RSA PRIVATE KEY-----
46 | MIIEpQIBAAKCAQEAyHDtthXTTiirS8TnICRboMihZWtHTPXvn4Wr8b9dyumz3OxQ
47 | j2mH/SMtrBxqxBCYGg5oh9wpY7WAuHHcs1EcPVMJGPCOITrItlmNLK+fdq8a0X3Z
48 | BCGccj3t7ujbLN+cQ9vWmXjpFIolwn2WKXnT67H8MVE9uyi0W/ctaiUbgO3WnSOJ
49 | OOddXdeoFe3GfrMlnxvd683uGmrcv195Fyk+o5gJUPmPiLJwF9Rosmuot4AgsSUY
50 | XNu8Gk80+RYWmKwHIdjZFgdIShSu1bnTX7fLFeUR0mzSooCF4fgqyomnXEg749tC
51 | 6donZPJZaGEmMMAoQEP/JiXFR/ECHUl502bJQwIDAQABAoIBAQCOVXLX3EPCuqp5
52 | EYe2kVrnn9DMPhPRmMriEn/5GRU3ZCEu/jhuvles7/AcyckfFVGNHzInV7WkclzH
53 | nUNFqpFNEsvhA+FJw36HzqurUcMA+nMm1CDpCB0aGtP81SnegaNrpI6NSQjqZvdN
54 | VvTs2vAb7LXTJ4eYgd0heTKsr1EKiZaJKCr/I3fl2Gl9zpz6C7ViwK+ctsRsLPW9
55 | UsPmzXqoDMEYVLvWTrkuIMmREyj1rr0jR1/BYsIiOAN4P4KtQTzhp3KaHqKWZmYF
56 | qjbQxNFjo9G7yDQDsZTVVpvBjovmsKIMIO6eMM07SZ+qNC8L9tRL757dlZSnxlFR
57 | 27MVy5ZxAoGBAPpsqKmJ75PWuANTt/yC8JMwBi2/zxpxxzQQBLJSQR/IYr1Xs86H
58 | jD4vYIH6J3Wz4VIK90ZTyNI3MrNtFBFB7DGKAeVYwakVqRrpBiahNAlG2mFOxGY+
59 | HzG1g/221dNpN0vTIzmYGA+VTajc9R/3cZcli4/N6NAwcCfdsGKvf5ClAoGBAMzn
60 | YWHAB3Kx13yXCeM9Z17a6Z/Fgwz71ogS/qm3RJfjplg2dEeKECOlIhUz91oOBMct
61 | yKzxv1BaKR2jcn9upUlOBBoYB5nfzN00/j35GeAPozA5lVjz2zyGmvZXoCu2+LrV
62 | p/Kd1qtjZGxQCQjaOvijQ4abVd0zFFM73ODIh6XHAoGBANQ/aCxZxn7tDAV13Yjd
63 | if2WRIZd/bCSIp5TvUdOQ/gmJNoKDVHMvOavzQIc/XjbPuwEc1ReCuVw9z3wA4Qk
64 | 9YV/TOAP/APNYgh23Em9c5cxQEIdOoTVviapi/dsEYsfsEhJ6Z8U87+xcaLfs7qm
65 | RNYwcjst8FcT1ttTH/5kdKApAoGAV9/bKZq7FvsiGPKFcQkCbfGgQ77m5wiSBqVu
66 | xcYtCp681hP0ZkHVjhPhvAofSGW+stT1vQWoMIOaInXYQsJm7DsjEzW+/MS4DR4O
67 | 8vEDoc3TBHmNjSp3mUt45bDKpjTAExBSCICcccAcbz8bwMomhD8wVGgFuOmRC+ke
68 | XuBhHD0CgYEAuWXTQcFF0pzblvlEA3hQjUXX8VK/BdhjgdY2fuoOoWqzMp6zwb2e
69 | lAZNMSTdAq9o9kgb+QapSJfdduuOomP/T5ch2XFHBS+0RVs6wcI2nLk0wqtVSntN
70 | d0iSG8GjR4Mx3f4GmKzdJP9yIenxTWSw6nDNgTPas3+HVmlqbBKiCGs=
71 | -----END RSA PRIVATE KEY-----
72 | `;
73 |
74 | module.exports.webpayKey = `
75 | -----BEGIN CERTIFICATE-----
76 | MIIDKTCCAhECBFZl7uIwDQYJKoZIhvcNAQEFBQAwWTELMAkGA1UEBhMCQ0wxDjAMBgNVBAgMBUNo
77 | aWxlMREwDwYDVQQHDAhTYW50aWFnbzEMMAoGA1UECgwDa2R1MQwwCgYDVQQLDANrZHUxCzAJBgNV
78 | BAMMAjEwMB4XDTE1MTIwNzIwNDEwNloXDTE4MDkwMjIwNDEwNlowWTELMAkGA1UEBhMCQ0wxDjAM
79 | BgNVBAgMBUNoaWxlMREwDwYDVQQHDAhTYW50aWFnbzEMMAoGA1UECgwDa2R1MQwwCgYDVQQLDANr
80 | ZHUxCzAJBgNVBAMMAjEwMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAizJUWTDC7nfP
81 | 3jmZpWXFdG9oKyBrU0Bdl6fKif9a1GrwevThsU5Dq3wiRfYvomStNjFDYFXOs9pRIxqX2AWDybjA
82 | X/+bdDTVbM+xXllA9stJY8s7hxAvwwO7IEuOmYDpmLKP7J+4KkNH7yxsKZyLL9trG3iSjV6Y6SO5
83 | EEhUsdxoJFAow/h7qizJW0kOaWRcljf7kpqJAL3AadIuqV+hlf+Ts/64aMsfSJJA6xdbdp9ddgVF
84 | oqUl1M8vpmd4glxlSrYmEkbYwdI9uF2d6bAeaneBPJFZr6KQqlbbrVyeJZqmMlEPy0qPco1TIxrd
85 | EHlXgIFJLyyMRAyjX9i4l70xjwIDAQABMA0GCSqGSIb3DQEBBQUAA4IBAQBn3tUPS6e2USgMrPKp
86 | sxU4OTfW64+mfD6QrVeBOh81f6aGHa67sMJn8FE/cG6jrUmX/FP1/Cpbpvkm5UUlFKpgaFfHv+Kg
87 | CpEvgcRIv/OeIi6Jbuu3NrPdGPwzYkzlOQnmgio5RGb6GSs+OQ0mUWZ9J1+YtdZc+xTga0x7nsCT
88 | 5xNcUXsZKhyjoKhXtxJm3eyB3ysLNyuL/RHy/EyNEWiUhvt1SIePnW+Y4/cjQWYwNqSqMzTSW9TP
89 | 2QR2bX/W2H6ktRcLsgBK9mq7lE36p3q6c9DtZJE+xfA4NGCYWM9hd8pbusnoNO7AFxJZOuuvLZI7
90 | JvD7YLhPvCYKry7N6x3l
91 | -----END CERTIFICATE-----
92 | `;
93 |
--------------------------------------------------------------------------------
/showcase/onError.js:
--------------------------------------------------------------------------------
1 | //Unofficial WebPay SDK for Node.js
2 | //Copyright (C) 2017-2020 Rodrigo González Castillo , et al.
3 | //
4 | //This program is free software: you can redistribute it and/or modify
5 | //it under the terms of the GNU General Public License as published by
6 | //the Free Software Foundation, either version 3 of the License, or
7 | //(at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | //GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | //along with this program. If not, see .
16 |
17 | module.exports = (res) => {
18 |
19 | return function (err) {
20 | console.log('ERROR', err)
21 | res.send(`
22 |
23 |
24 |
25 | ERROR
26 |
27 | ${err.stack}
28 |
29 |
30 |
31 | `)
32 | }
33 |
34 | };
35 |
--------------------------------------------------------------------------------
/showcase/testNormal.js:
--------------------------------------------------------------------------------
1 | //Unofficial WebPay SDK for Node.js
2 | //Copyright (C) 2017-2020 Rodrigo González Castillo , et al.
3 | //
4 | //This program is free software: you can redistribute it and/or modify
5 | //it under the terms of the GNU General Public License as published by
6 | //the Free Software Foundation, either version 3 of the License, or
7 | //(at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | //GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | //along with this program. If not, see .
16 | "use strict";
17 |
18 | const WebPay = require('../lib/WebPay');
19 | const express = require('express');
20 | const bodyParser = require('body-parser');
21 | const onError = require('./onError');
22 |
23 | let transactions = {};
24 | let transactionsByToken = {};
25 | let app = express();
26 | app.use(bodyParser.urlencoded({ extended: true }));
27 |
28 | const cert = require('./cert/normal');
29 |
30 | /**
31 | * 1. Instanciamos la clase WebPay.
32 | *
33 | * Notar que los certificados son simples strings, no buffer de archivos ni nada esotérico o místico.
34 | *
35 | * @type {WebPay}
36 | */
37 | let wp = new WebPay({
38 | commerceCode: cert.commerceCode,
39 | publicKey: cert.publicKey,
40 | privateKey: cert.privateKey,
41 | webpayKey: cert.webpayKey,
42 | verbose: true,
43 | env: WebPay.ENV.INTEGRACION
44 | });
45 |
46 | app.get('/', (req, res) => {
47 | res.send(`
48 |
49 |
50 |
51 | Test webpay-nodejs
52 |
53 |
54 | Test webpay-nodejs
55 |
59 |
60 | `);
61 | });
62 |
63 | app.post('/pagar', (req, res) => {
64 |
65 | let buyOrden = Date.now();
66 | let amount = req.body.amount;
67 | transactions[buyOrden] = { amount: amount};
68 | let url = 'http://' + req.get('host');
69 |
70 | /**
71 | * 2. Enviamos una petición a Transbank para que genere
72 | * una transacción, como resultado tendremos un token y una url.
73 | *
74 | * Nuestra misión es redireccionar al usuario a dicha url y token.
75 | */
76 | wp.initTransaction({
77 | buyOrder: buyOrden,
78 | sessionId: req.sessionId,
79 | returnURL: url + '/verificar',
80 | finalURL: url + '/comprobante',
81 | amount: amount
82 | }).then((data) => {
83 | // Al ser un ejemplo, se está usando GET.
84 | // Transbank recomienda POST, el cual se debe hacer por el lado del cliente, obteniendo
85 | // esta info por AJAX... al final es lo mismo, así que no estresarse.
86 | res.redirect(data.url + '?token_ws=' + data.token);
87 | }).catch(onError(res));
88 |
89 | });
90 |
91 | app.post('/verificar', (req, res) => {
92 |
93 | let token = req.body.token_ws;
94 | let transaction;
95 |
96 | // Si toodo está ok, Transbank realizará esta petición para que le vuelvas a confirmar la transacción.
97 |
98 | /**
99 | * 3. Cuando el usuario ya haya pagado con el banco, Transbank realizará una petición a esta url,
100 | * porque así se definió en initTransaction
101 | */
102 | console.log('pre token', token);
103 | wp.getTransactionResult(token).then((transactionResult) => {
104 | transaction = transactionResult;
105 | transactions[transaction.buyOrder] = transaction;
106 | transactionsByToken[token] = transactions[transaction.buyOrder];
107 |
108 | console.log('transaction', transaction);
109 | /**
110 | * 4. Como resultado, obtendras transaction, que es un objeto con la información de la transacción.
111 | * Independiente de si la transacción fue correcta o errónea, debes siempre
112 | * hacer un llamado a acknowledgeTransaction con el token... Cosas de Transbank.
113 | *
114 | * Tienes 30 amplios segundos para hacer esto, sino la transacción se reversará.
115 | */
116 | console.log('re acknowledgeTransaction', token)
117 | return wp.acknowledgeTransaction(token);
118 |
119 | }).then((result2) => {
120 | console.log('pos acknowledgeTransaction', result2);
121 | // Si llegas aquí, entonces la transacción fue confirmada.
122 | // Este es un buen momento para guardar la información y actualizar tus registros (disminuir stock, etc).
123 |
124 | // Por reglamento de Transbank, debes retornar una página en blanco con el fondo
125 | // psicodélico de WebPay. Debes usar este gif: https://webpay3g.transbank.cl/webpayserver/imagenes/background.gif
126 | // o bien usar la librería.
127 | res.send(WebPay.getHtmlTransitionPage(transaction.urlRedirection, token));
128 | }).catch(onError(res));
129 |
130 | });
131 |
132 | app.post('/comprobante', (req, res) => {
133 | console.log('Mostrar el comprobante');
134 | const transaction = transactionsByToken[req.body.token_ws];
135 | let html;
136 | if (transaction) {
137 | // La transacción fue aprobada
138 | html = 'Comprobante
';
139 | html += JSON.stringify(transaction);
140 | html += '
';
141 | html += '';
145 | } else {
146 | // La transacción fue cancelada
147 | html = 'Transacción ' + req.body.TBK_ORDEN_COMPRA + ' cancelada';
148 | }
149 | return res.send(html);
150 | });
151 |
152 | app.post('/anular', (req, res) => { // Notar que WebPay no permite anular RedCompra. Solo tarjetas de crédito
153 |
154 | const transaction = transactions[req.body.buyOrden];
155 |
156 | wp.nullify({
157 | authorizationCode: transaction.detailOutput.authorizationCode,
158 | authorizedAmount: transaction.detailOutput.amount,
159 | nullifyAmount: transaction.detailOutput.amount,
160 | buyOrder: transaction.buyOrder
161 | }).then((result) => {
162 | console.log('anulación:', result);
163 | return res.send('Bla bla comprobante:' + JSON.stringify(transaction));
164 | }).catch(onError(res));
165 | });
166 |
167 |
168 | app.listen(3000, () => {
169 | console.log('Server OK in http://localhost:3000');
170 | });
--------------------------------------------------------------------------------
/showcase/testOneclick.js:
--------------------------------------------------------------------------------
1 | //Unofficial WebPay SDK for Node.js
2 | //Copyright (C) 2017-2020 Rodrigo González Castillo , et al.
3 | //
4 | //This program is free software: you can redistribute it and/or modify
5 | //it under the terms of the GNU General Public License as published by
6 | //the Free Software Foundation, either version 3 of the License, or
7 | //(at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | //GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | //along with this program. If not, see .
16 | "use strict";
17 |
18 | const WebPay = require('../lib/WebPay');
19 | const express = require('express');
20 | const bodyParser = require('body-parser');
21 | const onError = require('./onError');
22 |
23 | let app = express();
24 | app.use(bodyParser.urlencoded({ extended: true }));
25 |
26 | const cert = require('./cert/oneClick');
27 |
28 | /**
29 | * 1. Instanciamos la clase WebPay.
30 | *
31 | * Notar que los certificados son simples strings, no buffer de archivos ni nada esotérico o místico.
32 | *
33 | * @type {WebPay}
34 | */
35 | let wp = new WebPay({
36 | commerceCode: cert.commerceCode,
37 | publicKey: cert.publicKey,
38 | privateKey: cert.privateKey,
39 | webpayKey: cert.webpayKey,
40 | verbose: true,
41 | env: WebPay.ENV.INTEGRACION
42 | });
43 |
44 | app.get('/', (req, res) => {
45 | res.send(`
46 |
47 |
48 |
49 | Test webpay-nodejs:OneClick
50 |
51 |
52 | Test webpay-nodejs OneClick
53 |
59 |
60 | `);
61 | });
62 |
63 | let username;
64 | app.post('/inscripcion', (req, res) => {
65 |
66 | let url = 'http://' + req.get('host');
67 |
68 | // Esto es un ejemplo. Obviamente en la vida real se usan bases de datos o alguna forma de persistencia
69 | username = req.body.username;
70 |
71 | /**
72 | *
73 | */
74 | wp.oneclick.initInscription({
75 | username: req.body.username,
76 | email: req.body.email,
77 | responseUrl: url + '/inscripcion-result'
78 | }).then((data) => {
79 | res.end(`
80 |
81 |
82 |
85 | Cargando...
86 |
87 | `);
88 | });
89 |
90 | });
91 |
92 | app.post('/inscripcion-result', (req, res) => {
93 |
94 | let url = 'http://' + req.get('host');
95 | let token = req.body.TBK_TOKEN;
96 |
97 | wp.oneclick.finishInscription(token).then((data) => {
98 |
99 | let dataStr = JSON.stringify(data);
100 |
101 | res.send(`
102 |
103 |
104 |
105 | Test webpay-nodejs
106 |
107 |
108 | Test webpay-nodejs: Tarjeta registrada
109 | ${dataStr}
110 |
115 |
116 |
121 |
122 | `);
123 | }).catch(onError(res));
124 |
125 | });
126 |
127 | app.post('/eliminarTarjeta', (req, res) => {
128 |
129 | wp.oneclick.removeUser({
130 | username: req.body.username,
131 | tbkUser: req.body.tbkUser
132 | }).then((data) => {
133 | res.end(JSON.stringify(data));
134 | }).catch(onError(res));
135 |
136 | });
137 |
138 | app.post('/pagar', (req, res) => {
139 |
140 | let amount = parseInt(req.body.amount);
141 | const buyOrder = Date.now(); // <-- no sigue el formato, no aseguro que funcione así en producción.
142 |
143 | wp.oneclick.authorize({
144 | tbkUser: req.body.tbkUser,
145 | username: username,
146 | buyOrder: buyOrder,
147 | amount: amount
148 | }).then((data) => {
149 | // Al ser un ejemplo, se está usando GET.
150 | // Transbank recomienda POST, el cual se debe hacer por el lado del cliente, obteniendo
151 | // esta info por AJAX... al final es lo mismo, así que no estresarse.
152 | const dataStr = JSON.stringify(data);
153 | res.send(`
154 |
155 |
156 |
157 | Test webpay-nodejs
158 |
159 |
160 | Test webpay-nodejs: Resultado de pago
161 | ${dataStr}
162 |
166 |
167 | `);
168 | }).catch(onError(res));
169 |
170 | });
171 |
172 | app.post('/anular', (req, res) => {
173 |
174 | wp.oneclick.codeReverseOneClick(parseInt(req.body.buyOrder)).then((result) => {
175 | return res.send('Pago reversado:' + JSON.stringify(result));
176 | }).catch(onError(res));
177 | });
178 |
179 |
180 | app.listen(3000, () => {
181 | console.log('Server OK in http://localhost:3000');
182 | });
--------------------------------------------------------------------------------
/showcase/testOneclickMall.js:
--------------------------------------------------------------------------------
1 | //Unofficial WebPay SDK for Node.js
2 | //Copyright (C) 2017-2020 Rodrigo González Castillo , et al.
3 | //
4 | //This program is free software: you can redistribute it and/or modify
5 | //it under the terms of the GNU General Public License as published by
6 | //the Free Software Foundation, either version 3 of the License, or
7 | //(at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | //GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | //along with this program. If not, see .
16 | "use strict";
17 |
18 | const WebPay = require('../lib/WebPay');
19 | const express = require('express');
20 | const bodyParser = require('body-parser');
21 | const onError = require('./onError');
22 |
23 | let app = express();
24 | app.use(bodyParser.urlencoded({ extended: true }));
25 |
26 | const cert = require('./cert/oneClickMall');
27 |
28 | /**
29 | * 1. Instanciamos la clase WebPay.
30 | *
31 | * Notar que los certificados son simples strings, no buffer de archivos ni nada esotérico o místico.
32 | *
33 | * @type {WebPay}
34 | */
35 | let wp = new WebPay({
36 | commerceCode: cert.commerceCode,
37 | publicKey: cert.publicKey,
38 | privateKey: cert.privateKey,
39 | webpayKey: cert.webpayKey,
40 | verbose: true,
41 | env: WebPay.ENV.INTEGRACION
42 | });
43 |
44 | app.get('/', (req, res) => {
45 | res.send(`
46 |
47 |
48 |
49 | Test webpay-nodejs:OneClickMall
50 |
51 |
52 | Test webpay-nodejs OneClickMall
53 |
59 |
60 | `);
61 | });
62 |
63 | let username;
64 | app.post('/inscripcion', (req, res) => {
65 |
66 | let url = 'http://' + req.get('host');
67 |
68 | // Esto es un ejemplo. Obviamente en la vida real se usan bases de datos o alguna forma de persistencia
69 | username = req.body.username;
70 |
71 | /**
72 | *
73 | */
74 | wp.oneclickmall.initInscription({
75 | username: req.body.username,
76 | email: req.body.email,
77 | returnUrl: url + '/inscripcion-result'
78 | }).then((data) => {
79 | res.end(`
80 |
81 |
82 |
85 | Cargando...
86 |
87 | `);
88 | }).catch(onError(res));
89 |
90 | });
91 |
92 | app.post('/inscripcion-result', (req, res) => {
93 |
94 | let url = 'http://' + req.get('host');
95 | let token = req.body.TBK_TOKEN;
96 |
97 | wp.oneclickmall.finishInscription(token).then((data) => {
98 |
99 | let dataStr = JSON.stringify(data);
100 |
101 | res.send(`
102 |
103 |
104 |
105 | Test webpay-nodejs
106 |
107 |
108 | Test webpay-nodejs: Tarjeta registrada
109 | ${dataStr}
110 |
111 |
116 |
117 |
123 |
124 | `);
125 | }).catch(onError(res));
126 |
127 | });
128 |
129 | app.post('/eliminarTarjeta', (req, res) => {
130 |
131 | wp.oneclickmall.removeInscription({
132 | username: req.body.username,
133 | tbkUser: req.body.tbkUser
134 | }).then((data) => {
135 | res.end(JSON.stringify(data));
136 | }).catch(onError(res));
137 |
138 | });
139 |
140 | app.post('/pagar', (req, res) => {
141 |
142 | let buyOrderBase = new Date().toISOString().slice(0,19).replace(/[^0-9]/g, "");
143 | let buyOrder = buyOrderBase + "000";
144 | let subBuyOrder1 = buyOrderBase + "001";
145 | let subBuyOrder2 = buyOrderBase + "002";
146 |
147 | wp.oneclickmall.authorize({
148 | tbkUser: req.body.tbkUser,
149 | username: username,
150 | buyOrder: buyOrder,
151 | storesInput: [{
152 | commerceId: 597020000585,
153 | buyOrder: subBuyOrder1,
154 | amount: parseInt(req.body.amount1),
155 | sharesNumber: 0
156 | }, {
157 | commerceId: 597020000586,
158 | buyOrder: subBuyOrder2,
159 | amount: parseInt(req.body.amount2),
160 | sharesNumber: 0
161 | }]
162 | }).then((data) => {
163 | // Por simplicidad del ejemplo se estan pasando los parametros a
164 | // traves del cliente de usando inputs, lo correcto es manejar estos
165 | // datos solo en backend
166 | const dataStr = JSON.stringify(data);
167 | res.send(`
168 |
169 |
170 |
171 | Test webpay-nodejs
172 |
173 |
174 | Test webpay-nodejs: Resultado de pago
175 | ${dataStr}
176 |
177 |
186 |
187 |
196 |
197 |
201 |
202 | `);
203 | }).catch(onError(res));
204 | });
205 |
206 | app.post('/reversar', (req, res) => {
207 | wp.oneclickmall.reverse(req.body.buyOrder).then((result) => {
208 | return res.send('Transacción reversada:' + JSON.stringify(result));
209 | }).catch(onError(res));
210 | });
211 |
212 | app.post('/anular', (req, res) => {
213 | wp.oneclickmall.nullify({
214 | commerceId: req.body.commerceId,
215 | buyOrder: req.body.buyOrder,
216 | authorizedAmount: parseInt(req.body.authorizedAmount),
217 | authorizationCode: req.body.authorizationCode,
218 | nullifyAmount: parseInt(req.body.amount)
219 | }).then((data) => {
220 | const dataStr = JSON.stringify(data);
221 | return res.send(`
222 |
223 |
224 |
225 | Test webpay-nodejs
226 |
227 |
228 | Test webpay-nodejs: Pago Anulado:
229 | ${dataStr}
230 |
231 |
237 |
238 | `);
239 | }).catch(onError(res));
240 | });
241 |
242 | app.post('/deshacerAnular', (req, res) => {
243 | wp.oneclickmall.reverseNullification({
244 | buyOrder: req.body.buyOrder,
245 | commerceId: req.body.commerceId,
246 | nullifyAmount: parseInt(req.body.nullifyAmount)
247 | }).then((result) => {
248 | return res.send('Pago anulado revalidado:' + JSON.stringify(result));
249 | }).catch(onError(res));
250 | });
251 |
252 |
253 | app.listen(3000, () => {
254 | console.log('Server OK in http://localhost:3000');
255 | });
256 |
--------------------------------------------------------------------------------