[interchange-cvs] interchange - heins modified 2 files
interchange-core@icdevgroup.org
interchange-core@icdevgroup.org
Wed Aug 14 10:21:11 2002
User: heins
Date: 2002-08-14 14:20:45 GMT
Modified: dist/foundation/etc log_transaction profiles.order
Log:
* New etc/profiles.order and etc/log_transaction to match the
new checkout page. Improvments:
-- The &charge process is now done and checked for in this
step, so a failure in the order process can be easily
rolled back when an error in log_transaction does occur.
-- The errors that occur in this process are transmitted back
to the checkout page.
-- Each payment type has a different log_transaction step,
making it easier to fail/succeed based on database query
steps.
-- The order profile is relegated to being just a form checker,
with no active transaction steps inside of it. Having &charge
in the profile was a mistake.
Revision Changes Path
2.3 +142 -9 interchange/dist/foundation/etc/log_transaction
rev 2.3, prev_rev 2.2
Index: log_transaction
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /var/cvs/interchange/dist/foundation/etc/log_transaction,v
retrieving revision 2.2
retrieving revision 2.3
diff -u -r2.2 -r2.3
--- log_transaction 20 Jul 2002 16:25:36 -0000 2.2
+++ log_transaction 14 Aug 2002 14:20:45 -0000 2.3
@@ -1,12 +1,104 @@
#### begin [value mv_order_number] #####
-[tmp transaction_record]
[loop list=3D"transactions orderline inventory userdb"]
[flag type=3Dwrite table=3D"[loop-code]"]
[/loop]
+[tmp transaction_record]
+Total order: [total-cost]
+Payment processing...payment_method=3D[value mv_order_profile]
+[set do_payment][/set]
+[set do_invoice][/set]
+
+[try]
+
+[if value mv_order_profile eq postal]
+
+ [comment]Sales order only[/comment]
+ Payment: [value name=3Dmv_payment set=3D"Check or Money Order (will call)=
"]
+
+[elsif value mv_order_profile eq purchase_order]
+ limit=3D[scratch tmp_climit]
+ total=3D[data session latest_total]
+ [perl userdb]
+ return unless length($Scratch->{tmp_climit});
+ my $limit =3D $Tag->data( 'userdb', 'credit_limit', $Session->{username}=
);
+ my $minus =3D $Session->{latest_total};
+ $minus =3D -$minus;
+ my $expect =3D $limit + $minus;
+ Log("Access to userdb worked... limit=3D$limit minus=3D$minus expect=3D$=
expect");
+ $Tag->data(
+ 'userdb',
+ 'credit_limit',
+ $Session->{username},
+ {
+ value =3D> $minus,
+ increment =3D> 1,
+ }
+ );
+ my $remain =3D $Tag->data( 'userdb', 'credit_limit', $Session->{username=
});
+ Log("Write to userdb worked...expect=3D'$expect' remain=3D'$remain'");
+ if ($expect ne $remain) {
+ die errmsg(
+ "error setting credit limit! Limit was %s, subtract %s, got %s, expect=
%s.\n",
+ $limit,
+ $Session->{latest_total},
+ $remain,
+ $expect,
+ );
+ }
+ $Scratch->{credit_limit} =3D $remain;
+ return "Credit limit was=3D$limit\nCredit limit now=3D$remain\n";
+ [/perl]
+[/elsif]
+[elsif value mv_order_profile eq online_check]
+ [set do_invoice]1[/set]
+[/elsif]
+[elsif value mv_order_profile eq cod]
+ [comment] do nothing [/comment]
+[/elsif]
+[elsif variable MV_PAYMENT_MODE]
+ [tmp name=3D"charge_succeed"][charge route=3D"[var MV_PAYMENT_MODE]"][/tm=
p]
+ [if scratch charge_succeed]
+ [then]
+ [set do_invoice]1[/set]
+ [set do_payment]1[/set]
+ Real-time charge succeeded. ID=3D[data session payment_id]
+ [/then]
+ [else]
+ Real-time charge FAILED. Reason: [data session cybercash_error]
+ [calc]
+ die errmsg(
+ "Real-time charge failed. Reason: %s",
+ errmsg($Session->{cybercash_error}),
+ );
+ [/calc]
+ [/else]
+ [/if]
+[/elsif]
+
+[else]
+ Offline credit card [value mv_credit_card_type] [value mv_credit_card_ref=
erence].
+ Payment: [value name=3Dmv_payment set=3D"COD"]
+[/else]
+[/if]
+
+[calc]
+ $Values->{mv_payment} =3D~ s/\%c/$Values->{mv_credit_card_type}/g;
+ return;
+[/calc]
+
+[/try]
+
+[catch error-set=3D"Payment process" error-scratch=3D"mv_route_failed"]
+ There was an error accepting payment: $ERROR$
+[/catch]
+
+[goto if=3D"[scratch mv_route_failed]"]
+
[if type=3Dexplicit compare=3D`
return 1 if ! $Session->{logged_in} or $Session->{login_table} ne 'userd=
b';
return 0;
`]
+[try]
[if session logged_in]
[userdb function=3Dlogout clear=3D0 clear_cart=3D0]
[/if]
@@ -29,6 +121,11 @@
[perl] die errmsg("Auto-create of user failed."); [/perl]
[/else]
[/if]
+[/try]
+[catch error-set=3D"Customer record creation" error-scratch=3D"mv_route_fa=
iled"]
+There was an error adding you to the customer table.
+[/catch]
+
[/if]
=20
[comment][perl] Log("Starting report."); [/perl][/comment]
@@ -41,7 +138,7 @@
code: [value mv_order_number]
store_id: __STORE_ID__
order_number: [value mv_order_number]
-session__MVC_FIELDMUNGE__: [data session id]
+session: [data session id]
username: [data session username]
shipmode: [value mv_shipmode] ([shipping-desc])
shipping: [shipping noformat=3D1]
@@ -88,7 +185,13 @@
parent: __PARENT__
po_number: [value filter=3Dstrip name=3Dpo_number]=20
[/import]
+[/try]
+
+[catch error-set=3D"log_orderline_table" error-scratch=3D"mv_route_failed"]
+There was an error adding the order to the transaction table. It was: $ERR=
OR$
+[/catch]
=20
+[try]
[if value mv_payment_mode eq purchase_order]
set credit_limit: [seti credit_limit][data
table=3Duserdb
@@ -108,11 +211,11 @@
code: [value mv_order_number]-[item-increment]
store_id: __STORE_ID__
order_number: [value mv_order_number]
-session__MVC_FIELDMUNGE__: [data session id]
+session: [data session id]
username: [data session username]
shipmode: [item-modifier mv_shipmode]
sku: [item-code]
-options: [item-filter mac strip][item-options report=3D1][/item-filter]
+options: [item-filter mac strip][item-options report=3D1 type=3Dvalue][/it=
em-filter]
quantity: [item-quantity]
price: [item-price noformat]
subtotal: [item-subtotal noformat]
@@ -152,16 +255,46 @@
=20
[/try]
=20
-[catch]
-[set mv_route_failed]1[/set]
-There was an error adding to the transaction log.
+[catch
+ error-set=3D"log_orderline_table"
+ error-scratch=3D"mv_route_failed"
+ ]
+There was an error adding the items to the orderline table: $ERROR$
+[/catch]
+
+[goto if=3D"[scratch mv_route_failed]"]
+
+[try]
+Realtime: [scratch realtime]
+Add to SQL-Ledger: [accounting function=3Dcreate_order_entry do_invoice=3D=
"[scratch do_invoice]" do_payment=3D"[scratch do_payment]"]
+[/try]
+
+[catch
+ error-set=3D"log_accounting_xfer"
+ error-scratch=3D"mv_route_failed"
+ ]
+There was an error transferring accounting information: $ERROR$
[/catch]
=20
-[userdb save]
+[goto if=3D"[scratch mv_route_failed]"]
=20
+[try]
+[tmpn tmp_user_save]FAILED[/tmpn]
+[if type=3Dexplicit compare=3D"[userdb save]"]
+[tmpn tmp_user_save]SUCCESS[/tmpn]
+[/if]
+Saved user information to user database: [scratch tmp_user_save]
[if scratch auto_create]
Logout auto-created user: [userdb function=3Dlogout clear=3D0 clear_cart=
=3D0]
[/if]
+[/try]
+
+[catch
+ error-set=3D"log_userdb_table"
+ error-scratch=3D"mv_route_failed"
+ ]
+There was an error updating the user information: $ERROR$
+[/catch]
=20
[comment]Past add data entry.[/comment]
=20
@@ -171,7 +304,7 @@
$out =3D~ s/^\s+//mg;
$out =3D~ s/\s+$//mg;
$out =3D~ s/[\r\n]+/\n/;
- $out =3D~ s/:\n(1|yes|succe\w+|fail\w+)\n/: $1\n/g;
+ $out =3D~ s/:\n(\d+|yes|succe\w+|fail\w+)\n/: $1\n/ig;
return $out;
[/perl]
#### end [value mv_order_number] #####
2.1 +53 -81 interchange/dist/foundation/etc/profiles.order
rev 2.1, prev_rev 2.0
Index: profiles.order
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /var/cvs/interchange/dist/foundation/etc/profiles.order,v
retrieving revision 2.0
retrieving revision 2.1
diff -u -r2.0 -r2.1
--- profiles.order 18 Jul 2001 02:20:59 -0000 2.0
+++ profiles.order 14 Aug 2002 14:20:45 -0000 2.1
@@ -4,77 +4,6 @@
&set =3D mv_junk 0
__END__
=20
-__NAME__ checkout_profile
-fname=3Drequired
-lname=3Drequired
-address1=3Drequired
-city=3Drequired
-country=3Drequired
-[if value country =3D~ /^(US|CA)$/i]
- state=3Dstate_province
- zip=3Dpostcode
-[/if]
-&or phone_night=3Dphone, phone_day=3Dphone Must have day or evening phone =
number
-
-&fatal =3D yes
-email=3Drequired
-email=3Demail
-
-&set =3D mv_payment Incomplete
-
-[if value fax_order =3D=3D 1]
-&set =3D mv_payment Check or Money Order (will call)
-
-[elsif value fax_order =3D=3D 2]
-project_id=3Drequired Please include your PO number
-&set =3D mv_payment Purchase order [value project_id]
-[value name=3Dtmp_total set=3D"[total-cost noformat=3D1]" hide=3D1]
-[perl tables=3D"pricing products userdb"]
- $CGI->{credit_limit_ok} =3D 1;
- my $total =3D delete $Values->{tmp_total};
- return unless $limit =3D tag_data('userdb', 'credit_limit', $Session->{us=
ername});
- Log("credit_limit=3D$limit total=3D$total");
- delete $CGI->{credit_limit_ok};
- if($limit >=3D $total) {
- $CGI->{credit_limit_ok} =3D 1;
- }
- return;
-[/perl]
-credit_limit_ok=3Dmandatory Credit limit exceeded.
-[/elsif]
-
-[elsif value fax_order =3D=3D 3]
-&set =3D mv_payment COD
-[value name=3Dmv_handling set=3Dcod hide=3D1]
-[/elsif]
-[elsif variable MV_PAYMENT_MODE]
-&credit_card=3Dstandard keep __CREDIT_CARDS_ACCEPTED__
-&charge=3D[var MV_PAYMENT_MODE][cgi mv_payment_test]
-&set=3Dmv_payment Real-time ([var MV_PAYMENT_MODE]) Credit Card=20
-[/elsif]
-
-[elsif config CyberCash]
-&fail=3D../special_pages/failed
-&charge=3D[var CYBER_MODE]
-[/elsif]
-
-[elsif config CreditCardAuto]
-mv_credit_card_valid=3Drequired Credit card fails tests.
-&set=3Dmv_payment Credit Card (%c)
-[/elsif]
-
-[else]
-&credit_card=3Dstandard __CREDIT_CARDS_ACCEPTED__
-&set=3Dmv_payment Credit Card (%c)
-[/else]
-[/if]
-
-&calc =3D $Values->{mv_payment} =3D~ s/\%c/$Values->{mv_credit_card_type}/=
g; 1;
-&final =3D yes
-&setcheck=3Dmv_email [value email]
-
-__END__
-
__NAME__ shipping_address
fname=3Drequired
lname=3Drequired
@@ -131,9 +60,10 @@
&set =3D mv_payment Incomplete
=20
[if variable MV_PAYMENT_MODE]
+[value name=3Dmv_payment_realtime set=3D""]
&credit_card=3Dstandard keep __CREDIT_CARDS_ACCEPTED__
-&charge=3D[var MV_PAYMENT_MODE][cgi mv_payment_test]
&set=3Dmv_payment Real-time Credit Card (%c -- [var MV_PAYMENT_MODE])
+&set=3Dmv_payment_realtime 1
[else]
&credit_card=3Dstandard __CREDIT_CARDS_ACCEPTED__
&set=3Dmv_payment Credit Card (%c)
@@ -167,26 +97,36 @@
prof_po_accepted=3Drequired This site doesn't accept purchase orders. You =
should not have been offered that option; please contact us.
=20
project_id=3Drequired Please include your PO number
-&set =3D mv_payment Purchase order [value project_id]
-[value name=3Dtmp_total set=3D"[total-cost noformat=3D1]" hide=3D1]
-[perl tables=3D"pricing products userdb"]
+
+[if session logged_in] [cgi name=3Dlogged_in_po set=3D1 hide=3D1]
+[else] [cgi name=3Dlogged_in_po set=3D""] [/else]
+[/if]
+logged_in_po=3Dmandatory Must have pre-existing account for PO.
+
+[value name=3Dmv_payment set=3D"Incomplete" hide=3D1]
+[tmp tmp_total][total-cost noformat=3D1][/tmp]
+[tmp tmp_climit][data table=3Duserdb col=3Dcredit_limit key=3D"[data sessi=
on username]"][/tmp]
+[calc]
$CGI->{credit_limit_ok} =3D 1;
- my $total =3D delete $Values->{tmp_total};
- return unless $limit =3D tag_data('userdb', 'credit_limit', $Session->{us=
ername});
+ my $total =3D $Scratch->{tmp_total};
+ my $limit =3D $Scratch->{tmp_climit};
+ return unless length($limit);
Log("credit_limit=3D$limit total=3D$total");
delete $CGI->{credit_limit_ok};
if($limit >=3D $total) {
$CGI->{credit_limit_ok} =3D 1;
}
return;
-[/perl]
+[/calc]
credit_limit_ok=3Dmandatory Credit limit exceeded.
+&set=3Dmv_payment PO number [value project_id]
+
&final =3D yes
&setcheck=3Dmv_email [value email]
=20
__END__
=20
-__NAME__ mail_order
+__NAME__ postal
fname=3Drequired
lname=3Drequired
address1=3Drequired
@@ -215,10 +155,10 @@
__NAME__ cod
fname=3Drequired
lname=3Drequired
-[if value address1 =3D~ /p\.o\.\s*box\b/i]
+[if value address1 =3D~ /p\.?o\.?\s*box\b/i]
not_po_box=3Dmandatory No PO boxes allowed for COD.
[/if]
-[if value address2 =3D~ /p\.o\.\s*box\b/i]
+[if value address2 =3D~ /p\.?o\.?\s*box\b/i]
not_po_box=3Dmandatory No PO boxes allowed for COD.
[/if]
address1=3Drequired
@@ -241,6 +181,38 @@
&set =3D mv_payment COD
&calc =3D $Values->{mv_handling} .=3D "\0cod" unless $Values->{mv_handling=
} =3D~ /\bcod\b/; return 1;
=20
+&final =3D yes
+&setcheck=3Dmv_email [value email]
+
+__END__
+
+__NAME__ online_check
+fname=3Drequired
+lname=3Drequired
+address1=3Drequired
+city=3Drequired
+country=3Drequired
+[if value country =3D~ /^(US|CA)$/i]
+ state=3Dstate_province
+ zip=3Dpostcode
+[/if]
+&or phone_night=3Dphone, phone_day=3Dphone Must have day or evening phone =
number
+
+&set =3D prof_mode_accepted [var CHECK_ACCEPTED]
+
+prof_mode_accepted=3Drequired This site doesn't accept online checks. You =
should not have been offered that option; please contact us.
+[value name=3Dcheck_route filter=3Ddigits hide=3D1]
+check_num=3Drequired You must supply a check number for us to use.
+check_acct=3Drequired You must supply your checking account number.
+check_route=3Drequired You must supply your bank's ABA routing number. The=
y are always 9 digits.
+&and
+check_route=3Dlength 9-9 ABA bank route numbers are always 9 digits.
+check_bank_phone=3Drequired We need your bank's phone number.
+&fatal =3D yes
+email=3Drequired
+email=3Demail
+
+&set =3D mv_payment Online check
&final =3D yes
&setcheck=3Dmv_email [value email]
=20