Line # Revision Author
1 358 ahitrov package payments::Provider::Xsolla;
2
3 use strict;
4 use warnings 'all';
5
6 use base 'payments::Provider::Base';
7 use Contenido::Globals;
8 use payments::Keeper;
9 use Digest::MD5;
10 use Data::Dumper;
11 405 ahitrov use Net::Subnet;
12 358 ahitrov
13 sub get_iframe {
14 my $self = shift;
15 my (%opts) = @_;
16 my $id = delete $opts{id};
17 return unless $id;
18 my $sum = delete $opts{sum};
19 return unless $sum;
20
21 $sum = $sum =~ /\d+\.\d{2}/ ? $sum : sprintf( "%.2f", $sum );
22 359 ahitrov my @static_params = (
23 # 'action=directpayment',
24 'pid=26',
25 358 ahitrov 'marketplace=paydesk',
26 359 ahitrov 'special_skip_step=0',
27 'prime=26,16,27,6,64',
28 'other=1',
29 'limit=5',
30 );
31 my @sig_params = (
32 'out='.($opts{out} || '100.00'),
33 358 ahitrov 'project='.$state->{payments}{xsolla_app_id},
34 359 ahitrov 'theme='.($opts{theme} || 115),
35 358 ahitrov 'v1='.$id,
36 );
37 359 ahitrov push @sig_params, 'currency='.$opts{currency} if exists $opts{currency};
38 push @sig_params, 'email='.$opts{email} if exists $opts{email};
39 push @sig_params, 'userip='.$opts{userip} if exists $opts{userip};
40 push @sig_params, 'v2='.$opts{v2} if exists $opts{v2};
41 push @sig_params, 'v3='.$opts{v3} if exists $opts{v3};
42 @sig_params = sort { $a cmp $b } @sig_params;
43 my $str = join( '', @sig_params).$self->secret;
44 warn "Sign str: [$str]\n";
45 my $sign = Digest::MD5::md5_hex ( $str );
46 my $iframe = '<iframe id="paystation" src="https://secure.xsolla.com/paystation2/?'.join('&',@sig_params, 'sign='.$sign, @static_params).'" width="100%" height="100%">';
47 358 ahitrov return $iframe;
48 }
49
50
51 1;