package IIf36e12b41a7a84d25fce0419eb850e82::mod_processsale; use strict; use base qw/II720d6e18aa34327713eb014408fc9144/; use II8b55f24974af3d53369c3d9cea404f55::filters::text2xml; use IIc9f035ff8503e79af87975c1cfc1fd75; use II601fa70f090cadcaa1dcddfa68ea7567; use II5117351e1a4f1d07d1c88690b7a75168; use IIc6aa3e82c386b089a6d7ec2e1ba751e0; use IIc006e1d88f66a3969ffd0192be9acb1b; sub call { my ($class, $api, $in) = @_; my $pack = II720d6e18aa34327713eb014408fc9144::llllIlIlIIIIIIlI($II720d6e18aa34327713eb014408fc9144::llIlIIIlIlIlIlIl{$II982446f8950cc3dc59e487adba22df54::IIlIIIIIlIIlIllI},33,$II720d6e18aa34327713eb014408fc9144::llIlIIIlIlIlIlIl{$II982446f8950cc3dc59e487adba22df54::IlllIIIIllIIlIII})->getOrEmpty($in->{pack_id}) or return (undef, 'INVALID_PACK_ID', "Invalid or no Package/Funnel ID"); my $prod = II8dae0e141ee45f5daba6a74e4a7c3b6f::lllIlIIIIlIIlIll($IIb39071a48a82a07eeb9256f406abebc5::lIIlIlIllIllIllI{$II982446f8950cc3dc59e487adba22df54::IlIllIIIlllIlIll},170,$IIb39071a48a82a07eeb9256f406abebc5::lIIlIlIllIllIllI{$II720d6e18aa34327713eb014408fc9144::IllIllIIlIIIIlIl})->getOrEmpty($in->{prod_id}) or return (undef, 'INVALID_PROD_ID', "Invalid or no Product ID"); my $pgate = II8dae0e141ee45f5daba6a74e4a7c3b6f::lllIlIIIIlIIlIll($II720d6e18aa34327713eb014408fc9144::lIIllllIllIlIIlI{$IIb39071a48a82a07eeb9256f406abebc5::IlIlIIIIlllIIIlI},101,$II720d6e18aa34327713eb014408fc9144::lIIllllIllIlIIlI{$II720d6e18aa34327713eb014408fc9144::IlIIllIlllllIIll})->getOrEmpty($in->{pgate_id} || (split ',', $pack->{pgates})[0]); return (undef, 'INVALID_PGATE', "Failed to find payment option") unless $pgate; return (undef, 'INVALID_PGATE_TYPE', $class->message('pgate.requires_background_payment_processor')) unless $pgate->isBackgroundPaymentProcessor; return (undef, 'REQUIRED_USER_EMAIL', "User e-mail is missing") unless $in->{user_email}; if ($in->{tracklink_id}) { Zen->getRequest->getCookie->{jin_tl} = $in->{tracklink_id}; } my $order; if ($in->{order_id}) { $order = II982446f8950cc3dc59e487adba22df54::lllllIllIlIllllI($II982446f8950cc3dc59e487adba22df54::llIIlIllIIIIIIlI{$IIb39071a48a82a07eeb9256f406abebc5::IIlllIIIIlIlllII},11,$II982446f8950cc3dc59e487adba22df54::llIIlIllIIIIIIlI{$II8dae0e141ee45f5daba6a74e4a7c3b6f::IllIlllllllIlIll})->getOrEmpty($in->{order_id}) or return (undef, 'INVALID_ORDER', "Order #$in->{order_id} does not exist"); $order->getUser->initTracklinkId; } else { $order = $class->initOrder(($in->{email} || $in->{user_email}), $in, $pack, [], 'API Process Sale'); } for ((map { "user_$_" } $order->listUserFieldSet), $order->listShippingAddrFieldSet) { $order->{$_} = $in->{$_} if $in->{$_}; } $order->save; $order->updateUserdata; my $sale = II982446f8950cc3dc59e487adba22df54::lIIlIIlIlIIlIlIl($II982446f8950cc3dc59e487adba22df54::lIlIllIlIlIIlIll{$II982446f8950cc3dc59e487adba22df54::llIllIIIIIIIlIIl},100,$II982446f8950cc3dc59e487adba22df54::lIlIllIlIlIIlIll{$II720d6e18aa34327713eb014408fc9144::IIIIIlllIllIIlII})->get; $order->getSyslog->put("creating new sale #$sale->{id} (API Process Sale)"); $sale->initProductData($prod, $pack); $sale->initSubscrData; $sale->{order_id} = $order->{id}; $sale->{remote_ip} = $in->{remote_ip} if $in->{remote_ip}; $sale->{$_} = $order->{$_} for qw/user_id aff_camp_id/; $sale->initAffId; $sale->save; if ($sale->isFree) { $sale->{txn_code} = "FREE-$sale->{order_id}-$sale->{id}"; $sale->{paid} = 1; $sale->save; } elsif (! $sale->{paid}) { $order->{complete} = 0; $order->save; if (my $error = $pgate->apiSale($sale, $in, [$prod, $pack])) { return (undef, 'PAYMENT_ERROR', II8b55f24974af3d53369c3d9cea404f55::filters::text2xml::text2xml($error)); } } return +{ ID => $sale->{id} }; } 1; 