c# - How to pass payment details to Google Wallet for digital goods API .net callback ashx -


the sample library referenced in tutorial uses ashx file process callback.

to validate payment sample code compares various items sent wallet results returned wallet.

using sandbox code executes expected , verifies provided not detailed comparisons. not know how pass details ashx file comparisons can performed. callback url specified in merchant profile, , in case named callback.ashx.

    <script type="text/javascript">     google.load('payments', '1.0', {         'packages': ['sandbox_config']      });      function purchase(callback) {         google.payments.inapp.buy({             "parameters": {},             "jwt": "<%=thejwt() %>",             "success": function (result) {                 if (isfunction(callback)) {                     callback(true, result);                 }             },             "failure": function (result) {                 if (isfunction(callback)) {                     callback(false, result);                 }             }         }     )     };      function isfunction(possiblefunction) {         return (typeof (possiblefunction) === typeof (function));     }      /*** s m p l e   o n l y ****     *******************************     !you should verify server side!     *******************************                     */     var sampleparseresult = function (isgood, data) {         var _console = (typeof window.console === "undefined");         if (isgood) {             var _str = "verify order no. " + data.response.orderid;             _str += "\ndetails:\n";             _str += data.request.name + " " + data.request.description + "\n";             _str += data.request.price + "\n";             alert(_str);             if (!_console) {                 console.log(data);             }         } else {             alert("failed");             if (!_console) {                 console.log(data);             }         }     }; </script> 

it works stands pass object containing request details ashx file. possible?

if you're referring this .net lib, wrote few years :) think recognize above :)

can clarify question? in case misunderstood -

the lib should already checking/verification (except order number validation), need store order number , details during postback - if i'm not mistaken, ashx sample has stub sending email...likely commented out , marked debug purposes only. can change part write sql table if want.

if buyer confirms purchase , google verifies buyer can indeed pay cake, google sends http post message

then in success callback above, happens on client side, should verify order number exists - re: match data returned google in success callback stored in db (previously/during postback). if exists, you've verified data...

if misunderstood, comment , i'll update answer...hth....

btw, lib hasn't been updated support subscriptions...just fyi...

update

here's "stub" referring in handler (ashx):

//sample private void parsepayload(inappitemobject claimobj, jwtheaderobject headerobj) {     //header jwtheaderobject     string foo = string.format("jwt headers{0}jwt algo: {1}{0}jwt kid: {2}{0}jwt typ: {3}{0}{0}", environment.newline, headerobj.alg, headerobj.kid, headerobj.typ);      //payload inappitemobject     string bar = string.format("jwt payload{0}jwt aud: {1}{0}jwt iss: {2}{0}jwt orderid: {3}{0}jwt sellerdata: {4}{0}jwt iat: {5}{0}" +             "jwt itemname: {6}{0}jwt itemprice: {7:c}{0}jwt item description: {8}{0}jwt exp: {9}{0}jwt typ: {10}{0}{0}", environment.newline, claimobj.aud, claimobj.iss, claimobj.response.orderid, claimobj.request.sellerdata, claimobj.iat,             claimobj.request.name, claimobj.request.price, claimobj.request.description, claimobj.exp, claimobj.typ);      debug(foo, bar); } 

you can change above standard db insert - in above claimobj have order details. along lines (sample):

using (sqlconnection conn = new sqlconnection(connstr)) {  .....  using (sqlcommand cmd = new sqlcommand(cmdtext, conn))  {   .....   cmd.parameters.addwithvalue("@ordernumber",claimobj.response.orderid);   cmd.parameters.addwithvalue("@productordered",claimobj.request.name);   .... 

the ashx file handles google postback (i realize maybe should have named file postback_handler_demo.ashx) before client side success callback. allows store (already server-side verified) data, prior client side callback.

you can query data existence of orderid (or other data matter) if/when success handler triggered in callback.


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

java.util.scanner - How to read and add only numbers to array from a text file -

iphone - Three second countdown in cocos2d -