package II5117351e1a4f1d07d1c88690b7a75168::mod_paysitecash; use strict; sub checkPGateSettings { my $class = shift; my $settings = shift; my @errors; push @errors, 'check.empty_sid' unless $settings->{sid}; @errors; } sub checkProductSettings { my $class = shift; my ($product) = @_; my @errors; @errors; } sub go { my $class = shift; my $pgtxn = shift; my $settings = $pgtxn->getPGateSettings; my $order = $pgtxn->getOrder; my $url = "https://billing.paysite-cash.biz"; my $form = { site => $settings->{sid}, montant => $pgtxn->getAmount, devise => $pgtxn->getCurrencyCode, 'ref' => ref($pgtxn) . '-' . $pgtxn->id, email => $order->{user_email}, }; if ($pgtxn->getIsRecur) { my $recur = $pgtxn->getRecurSettings; $form->{subscription} = 1; $form->{periode} = $recur->{period_u} eq 'd' ? $recur->{period_l} . 'j' : $recur->{period_u} eq 'w' ? ($recur->{period_l} * 7) . 'j' : $recur->{period_u} eq 'm' ? $recur->{period_l} . 'm' : $recur->{period_u} eq 'y' ? ($recur->{period_l} * 12) . 'm' : die; $form->{nb_redebit} = $recur->{numinst} || 'x'; if ($recur->{trial_l}) { $form->{periode2} = $form->{periode}; $form->{montant2} = $form->{montant}; $form->{periode} = $recur->{trial_u} eq 'd' ? $recur->{trial_l} . 'j' : $recur->{trial_u} eq 'w' ? ($recur->{trial_l} * 7) . 'j' : $recur->{trial_u} eq 'm' ? $recur->{trial_l} . 'm' : $recur->{trial_u} eq 'y' ? ($recur->{trial_l} * 12) . 'm' : die; $form->{montant} = $recur->{trial_amount} || 0; } } $pgtxn->logg('REQ', $form); $pgtxn->getSaleOrFirstSaleInBulk->txnWaitingInit; Zen->getRequest->redirectPOST($url, $form); } sub feedbackReturnPgt { my $class = shift; my $in = Zen->getRequest->getInput; my ($pgtxn_class, $pgtxn_id) = split '-', $in->{ref}; die "invalid ref" unless $pgtxn_class && $pgtxn_id; my $pgtxn = $pgtxn_class->get($pgtxn_id); $pgtxn->checkValidForRequest; $pgtxn->logg('RET', $in); $pgtxn->redirectToReturnPage; } sub feedbackNotifyPgt { my $class = shift; my $in = Zen->getRequest->getInput; my ($pgtxn_class, $pgtxn_id) = split '-', $in->{ref}; die "invalid ref" unless $pgtxn_class && $pgtxn_id; my $pgtxn = $pgtxn_class->get($pgtxn_id); $pgtxn->checkValidForRequest; $pgtxn->logg('IPN', $in); my $settings = $pgtxn->getPGateSettings; if ($pgtxn->getIsRecur) { my $initSale = $pgtxn->getSaleOrFirstSaleInBulk; if ($in->{etat} eq 'ok') { if ($in->{type} == 1) { $pgtxn->txnPayment($in->{id_trans}, $in->{num_abo}); } else { my $recSale = $initSale->doSubscrRecur($in->{num_abo}, $in->{id_trans}); $recSale->{paid} = 1; $recSale->save; } } elsif ($in->{etat} eq 'end') { $initSale->doSubscrCancel; } } else { if ($in->{etat} eq 'ok') { $pgtxn->txnPayment($in->{id_trans}); } elsif ($in->{etat} eq 'refund') { $pgtxn->txnRefund; } } $pgtxn->getSaleOrFirstSaleInBulk->txnWaitingClose; print "Content-type: text/plain\n\n"; return; } 1; 