File Coverage

blib/lib/Net/Payment/CCAvenue.pm
Criterion Covered Total %
statement 24 24 100.0
branch n/a
condition n/a
subroutine 10 10 100.0
pod 2 2 100.0
total 36 36 100.0


line stmt bran cond sub pod time code
1             package Net::Payment::CCAvenue;
2              
3 2     2   1371 use Moose;
  2         5  
  2         17  
4 2     2   12793 use Digest::MD5 qw/md5_hex/;
  2         3  
  2         171  
5 2     2   976 use Crypt::Mode::CBC;
  2         14275  
  2         51  
6 2     2   13 use URI;
  2         4  
  2         676  
7              
8             =head1 NAME
9              
10             Net::Payment::CCAvenue::NonSeamless - Processing orders using CCAvenue billing page!
11              
12             =head1 VERSION
13              
14             Version 0.01
15              
16             =cut
17              
18             our $VERSION = '0.02';
19              
20             =head1 See More
21              
22             =over 2
23              
24             =item L<Net::Payment::CCAvenue::NonSeamless>
25             =item L<Net::Payment::CCAvenue::NonSeamless::Response>
26              
27             =head1 Attributes
28              
29             =head2 service_url
30              
31             CCAVENUE service url.
32              
33             =head2 encryption_key
34              
35             Encryption key provided by CCAVENUE.
36              
37             =head2 access_code
38              
39             Access code provided by CCAVENUE.
40              
41             =head2 merchant_id
42              
43             Merchant identifier provided by CCAVENUE.
44              
45             =cut
46              
47             has service_url => (
48             is => 'ro',
49             isa => 'URI',
50             lazy_build => 1
51             );
52              
53             sub _build_service_url {
54 1     1   2 my ($self) = @_;
55 1         4 return URI->new('https://secure.ccavenue.ae/transaction/transaction.do');
56             }
57              
58             has [ qw(encryption_key access_code merchant_id) ] => (
59             is => 'ro',
60             isa => 'Str',
61             required => 1
62             );
63              
64             =head2 encryption_key_md5
65              
66             128-bit hash value of the encryption key.
67              
68             =cut
69              
70             has encryption_key_md5 => (
71             is => 'ro',
72             isa => 'Str',
73             lazy_build => 1,
74             );
75              
76             sub _build_encryption_key_md5 {
77 1     1   3 my ($self) = @_;
78 1         28 return md5_hex $self->encryption_key;
79             }
80              
81             =head2 encryption_key_bin
82              
83             Binary format of 128 bit hash value of encryption key.
84              
85             =cut
86              
87             has encryption_key_bin => (
88             is => 'ro',
89             isa => 'Str',
90             lazy_build => 1,
91             );
92              
93             sub _build_encryption_key_bin {
94 1     1   3 my ($self) = @_;
95 1         29 return pack("H*",$self->encryption_key_md5);
96             }
97              
98             =head2 aes_cipher
99              
100             AES encryption cipher.
101              
102             =cut
103              
104             has aes_cipher => (
105             is => 'ro',
106             isa => 'Crypt::Mode::CBC',
107             lazy_build => 1
108             );
109              
110             sub _build_aes_cipher {
111 1     1   3 my ($self) = @_;
112 1         58 return Crypt::Mode::CBC->new( 'AES', 1 );
113             }
114              
115             =head2 init_vector
116              
117             Init vector for AES encryption.
118              
119             =cut
120              
121             has init_vector => (
122             is => 'ro',
123             isa => 'Str',
124             default => sub {
125             return pack( "C*",
126             0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
127             0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f );
128             }
129             );
130              
131             =head1 SUBROUTINES/METHODS
132              
133             =head2 encrypt_data
134              
135             Data to be encrypted as 128 bit AES encryption.
136              
137             =cut
138              
139             sub encrypt_data {
140 2     2 1 978 my ( $self, $data ) = @_;
141 2         57 return unpack(
142             'H*',
143             $self->aes_cipher->encrypt(
144             $data, $self->encryption_key_bin, $self->init_vector
145             )
146             );
147             }
148              
149             =head2 decrypt_data
150              
151             Decrypte the given encrypted data.
152              
153             =cut
154              
155             sub decrypt_data {
156 1     1 1 871 my ( $self, $encrypted_data ) = @_;
157 1         31 return $self->aes_cipher->decrypt(
158             pack( 'H*', $encrypted_data ),
159             $self->encryption_key_bin,
160             $self->init_vector
161             );
162             }
163              
164             =head1 AUTHOR
165              
166             Rakesh Kumar Shardiwal, C<< <rakesh.shardiwal at gmail.com> >>
167              
168             =head1 BUGS
169              
170             Please report any bugs or feature requests to C<bug-net-payment-ccavenue-nonseamless at rt.cpan.org>, or through
171             the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-Payment-CCAvenue-NonSeamless>. I will be notified, and then you'll
172             automatically be notified of progress on your bug as I make changes.
173              
174              
175             =head1 SUPPORT
176              
177             You can find documentation for this module with the perldoc command.
178              
179             perldoc Net::Payment::CCAvenue::NonSeamless
180              
181              
182             You can also look for information at:
183              
184             =over 4
185              
186             =item * RT: CPAN's request tracker (report bugs here)
187              
188             L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-Payment-CCAvenue-NonSeamless>
189              
190             =item * AnnoCPAN: Annotated CPAN documentation
191              
192             L<http://annocpan.org/dist/Net-Payment-CCAvenue-NonSeamless>
193              
194             =item * CPAN Ratings
195              
196             L<http://cpanratings.perl.org/d/Net-Payment-CCAvenue-NonSeamless>
197              
198             =item * Search CPAN
199              
200             L<http://search.cpan.org/dist/Net-Payment-CCAvenue-NonSeamless/>
201              
202             =back
203              
204              
205             =head1 ACKNOWLEDGEMENTS
206              
207              
208             =head1 LICENSE AND COPYRIGHT
209              
210             Copyright 2021 Rakesh Kumar Shardiwal.
211              
212             This program is free software; you can redistribute it and/or modify it
213             under the terms of the the Artistic License (2.0). You may obtain a
214             copy of the full license at:
215              
216             L<http://www.perlfoundation.org/artistic_license_2_0>
217              
218             Any use, modification, and distribution of the Standard or Modified
219             Versions is governed by this Artistic License. By using, modifying or
220             distributing the Package, you accept this license. Do not use, modify,
221             or distribute the Package, if you do not accept this license.
222              
223             If your Modified Version has been derived from a Modified Version made
224             by someone other than you, you are nevertheless required to ensure that
225             your Modified Version complies with the requirements of this license.
226              
227             This license does not grant you the right to use any trademark, service
228             mark, tradename, or logo of the Copyright Holder.
229              
230             This license includes the non-exclusive, worldwide, free-of-charge
231             patent license to make, have made, use, offer to sell, sell, import and
232             otherwise transfer the Package with respect to any patent claims
233             licensable by the Copyright Holder that are necessarily infringed by the
234             Package. If you institute patent litigation (including a cross-claim or
235             counterclaim) against any party alleging that the Package constitutes
236             direct or contributory patent infringement, then this Artistic License
237             to you shall terminate on the date that such litigation is filed.
238              
239             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
240             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
241             THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
242             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
243             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
244             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
245             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
246             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
247              
248              
249             =cut
250              
251             1; # End of Net::Payment::CCAvenue::NonSeamless