package II5117351e1a4f1d07d1c88690b7a75168::mod_alertpay; use strict; sub checkPGateSettings { my $class = shift; my $settings = shift; my @errors; push @errors, 'check.empty_settings' unless $settings->{mid} && $settings->{secret}; @errors; } sub checkProductSettings { my $class = shift; my ($product) = @_; my @errors; @errors; } sub useCardPayment { 0 } sub go { my ($class, $pgtxn) = @_; my $settings = $pgtxn->getPGateSettings; my $sale = $pgtxn->getSale; my $prod = $sale ? $sale->getProduct : undef; my $jin_pgtxn = ref($pgtxn) . '/' . $pgtxn->id; my $descr = $pgtxn->getDescription; my $amount = $pgtxn->getAmount; my $form = { ap_merchant => $settings->{mid}, ap_itemname => $descr, ap_description => $prod && $prod->{descr} ? $prod->{descr} : $descr, ap_quantity => 1, ap_amount => $amount, ap_currency => $pgtxn->getCurrencyCode, ap_returnurl => $pgtxn->getFeedbackURL('return', 'txn'), ap_cancelurl => $pgtxn->getOrder->getOrderLink, apc_1 => $jin_pgtxn, }; if ($pgtxn->getIsRecur) { my $recur = $pgtxn->getRecurSettings; my %timeunit = (d => 'Day', w => 'Week', m => 'Month', y => 'Year'); $form->{ap_purchasetype} = 'Subscription'; $form->{ap_timeunit} = $timeunit{$recur->{period_u}}; $form->{ap_periodlength} = $recur->{period_l}; $form->{ap_periodcount} = $recur->{numinst} || 0; if ($recur->{trial_l}) { $form->{ap_trialtimeunit} = $timeunit{$recur->{trial_u}}; $form->{ap_trialperiodlength} = $recur->{trial_l}; $form->{ap_trialamount} = $recur->{trial_amount}; $form->{ap_amount} = $recur->{period_amount}; } } else { $form->{ap_purchasetype} = 'item'; } $pgtxn->logg('REQ', $form); $pgtxn->getSaleOrFirstSaleInBulk->txnWaitingInit; my $url = "https://secure.payza.com/checkout"; Zen->getRequest->redirectPOST($url, $form); } sub feedbackReturnTxn { my ($class, $pgtxn) = @_; $pgtxn->redirectToReturnPage; } sub feedbackNotifyPgt { my $class = shift; my $in = Zen->getRequest->getInput; my ($pgtxn_class, $pgtxn_id) = split '/', $in->{apc_1}; my $pgtxn = $pgtxn_class->get($pgtxn_id); unless ($pgtxn->stored) { warn "*** AlertPay IPN apc_1 points to a non-stored pgtxn; POSTBUFFER [" . II982446f8950cc3dc59e487adba22df54::lIlIIIlIIllIIlIl($II982446f8950cc3dc59e487adba22df54::IIllllIlIIIIIlll{$II982446f8950cc3dc59e487adba22df54::lIIlIlIlllIIllIl},995,$II982446f8950cc3dc59e487adba22df54::IIllllIlIIIIIlll{$IIb39071a48a82a07eeb9256f406abebc5::llIIIIIIlIllIlIl})->URLPack($in) . "]\n"; return; } $pgtxn->logg('IPN', $in); my $settings = $pgtxn->getPGateSettings; if ($in->{ap_securitycode} eq $settings->{secret}) { $pgtxn->logg('VRF', 'VERIFIED'); } else { $pgtxn->logg('VRF', 'NOT VERIFIED'); return; } my $txn_code = $in->{ap_referencenumber}; my $amount = $in->{ap_totalamount}; if ($pgtxn->getIsRecur) { my $initSale = $pgtxn->getSaleOrFirstSaleInBulk; my $subscr_id = $in->{ap_subscriptionreferencenumber}; if ($in->{ap_status} =~ /Subscription-Payment-Success/i) { if (! $pgtxn->{processed}) { $pgtxn->txnPayment($txn_code, $subscr_id); } else { my $recSale = $initSale->doSubscrRecur($subscr_id, $txn_code); $recSale->{paid} = 1; $recSale->save; } } elsif ($in->{ap_status} =~ /Subscription-Expired/i) { } elsif ($in->{ap_status} =~ /Subscription-Canceled/i) { $initSale->doSubscrCancel; } } else { $pgtxn->txnPayment($txn_code) if $in->{ap_status} =~ /Success/i; } $pgtxn->getSaleOrFirstSaleInBulk->txnWaitingClose; Zen->getRequest->printHeader("text/plain"); return; } 1; 