Disappearing Purchase Orders


 

hi there

 

we taking account payments named purchase orders, fine , works fine every , again observing of these go missing.. have no errors , cannot pinpoint issue.

 

the users receving email tracking number confirming order tackingnumber found in commerce server..

 

please tell why might happen , if there wrong way doing this.. major issue offline processing , missing payments means unhappy customers.

 

many thanks

 

ryan

 

 

private bool processpayment(decimal amount, string creditcardid)

{

bool transuccess = true;

using (transactionscope scope = new transactionscope(transactionscopeoption.required))

{

//get user profile

userobjectprofile user = currentuser.getuserprofile();

string trackingnumber = string.empty;

try

{

ordercontext ocx = commercecontext.current.ordersystem;

orderform orderform = new orderform("payment");

orderform.name = "payment";

//add address

addressprofile baddr = currentuser.getbillingaddress();

orderaddress orderaddress = new orderaddress("billing address", baddr.idasstring);

orderaddress.city = baddr.city;

orderaddress.countrycode = baddr.countrycode;

orderaddress.countryname = baddr.countryname;

orderaddress.line1 = baddr.addressline1;

orderaddress.line2 = baddr.addressline2;

orderaddress.postalcode = baddr.postalcode;

orderaddress.state = baddr.regioncode;

orderaddress.regioncode = baddr.regioncode;

orderaddress.regionname = baddr.regionname;

//add payment

dataset ds = ocx.getpaymentmethods();

datatable paymentmethodtable = ds.tables[0];

datarow row = paymentmethodtable.rows[0];

guid paymentid = (guid)row["paymentmethodid"];

creditcardprofile ccprofile = creditcardprofile.get(new guid(creditcardid));

creditcardpayment cc = new creditcardpayment(currentuser.getbillingaddress().idasstring, new guid(creditcardmanager.selectedid));

cc.creditcardnumber = ccprofile.accountnumber;

cc.expirationmonth = convert.toint32(ccprofile.expirationmonth);

cc.expirationyear = convert.toint32(ccprofile.expirationyear);

cc.customernameonpayment = ccprofile.displayname;

cc.creditcardidentifier = ccprofile.idasstring.replace("{", "").replace("}", "");

cc.cardtype = ccprofile.paymentgroupid.tostring();

cc.paymentmethodid = paymentmethodhelper.getpaymentmethod(ccprofile.paymentgroupid).methodid;

cc.paymentmethodname = paymentmethodhelper.getpaymentmethod(ccprofile.paymentgroupid).name;

cc.amount = amount;

orderform.payments.add(cc);

basket basket = ocx.getbasket(user.id, "payment");

basket.soldtoaddressid = user.id.tostring();

basket.billingcurrency = sitecontext.configuration.defaultcurrency;

basket.soldtoname = httpcontext.current.user.identity.name;

basket.orderforms.add(orderform);

basket.addresses.add(orderaddress);

pipelineinfo pipe = new pipelineinfo("basket", orderpipelinetype.basket);

pipe["catalogcontext"] = commercecontext.current.catalogsystem;

pipe.profiles.add("userobject", commercecontext.current.userprofile);

pipelineexecutionresult results = basket.runpipeline(pipe);

pipe.dispose();

pipe = new pipelineinfo("payaccount", orderpipelinetype.total);

results = basket.runpipeline(pipe);

pipe.dispose();

pipe = new pipelineinfo("accountpayment", orderpipelinetype.custom);

results = basket.runpipeline(pipe);

pipe.dispose();

pipe = new pipelineinfo("checkout", orderpipelinetype.checkout);

results = basket.runpipeline(pipe);

pipe.dispose();

//place payment in system

basket.name = "payment";

purchaseorder po = basket.saveasorder();

trackingnumber = po.trackingnumber;

po.save("site");

}

catch (system.exception e)

{

transuccess = false;;

}

if (transuccess)

{

scope.complete();

doubleday.email email = new doubleday.email();

email.sendemail(user.emailaddress, "payment confirmation", email.createpaymentemail(user.membernumber, trackingnumber, currencyconversion.active.convertandformat(amount)));

}

}

return transuccess;

}

mmmm, interresting problem.

from looking @ code, nothing pop to mind (other last po.save("site), seems useless nothing changed).

 

are those emails thing telling there missing orders. if, 100% sure these emails generated production envirronement? i'm asking, because i've seen in past, testing/staging envirronements configure production, , system sent email confused people.

 

hope helps...

 

j-p


Commerce Server  >  Commerce Server 2007



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

BizTalk Server 2013 Azure VM Log Shipping and HA for hosts

How to send non-standard Content-Type header ?