Developer forum

Forum » Development » GateProvider - how do i handle return data - Continued

GateProvider - how do i handle return data - Continued


Reply

----

Sorry about making a new thread,

got tons of errors when posting a reply in the original thread.

----

 

 

Hi Lasse,

 

It's been a while, summer holidays and all :-)

 

But i still have some questions about gateway providers.
 

 

I've made an override for the method GetReturnValuesFromUrl() and in it i look at my response from me payment provider and update my orders.

 

Basicly i have 2 scenarios, Success or fail, if i, as i read you previous reply, use the value from  Ecom:Order.Gateway.Page.OK as my response adress from paymentmodule, I hit my step 6 as i should when the payment went well.

But i also hit step 6 when somthing goes bad, and DW creates an order.

 

Can i somewhere in the GetReturnValuesFromUrl() method, tell DW not to create the Order when something went wrong with a payment.

 

ATM my code looks like this:

 

public override void GetReturnValuesFromUrl( Dynamicweb.eCommerce.Orders.Order Order ) {      

  string Status = getQueryString( "status" ).ToUpper();
  string Status_code = getQueryString( "Status_code" );

  string OK_url = string.Format( "/Default.aspx?ID={0}&_OID_={1}&step=5&TransactionState=Ok", getQueryString( "ID" ), Order.ID );
  string ERROR_url = string.Format( "/Default.aspx?ID={0}&_OID_={1}&step=5&TransactionState=Error", getQueryString( "ID" ), Order.ID );
 
  // If transaction was successfull do this
  if ( Status.Equals("A") && Status_code.Equals("0") ) {
 //Order.GatewayResult = "";
 Order.TransactionNumber = getQueryString( "Transaction_id" );
 Order.TransactionPayGatewayCode = getQueryString( "Payment_method" );
 Order.TransactionType = getQueryString( "Card_type" );
 Order.TransactionStatus = Status + "" + Status_code;
 Order.TransactionAmount = Order.Price.PricePIP;
 Order.UpdateGatewayResult( true );
  } else {
 // There was an error
  }

  base.GetReturnValuesFromUrl( Order );
}


Replies

 
Reply
mn@co3.dk wrote:

----

Sorry about making a new thread,

got tons of errors when posting a reply in the original thread.

----

 

 

Hi Lasse,

 

It's been a while, summer holidays and all :-)

 

But i still have some questions about gateway providers.
 

 

I've made an override for the method GetReturnValuesFromUrl() and in it i look at my response from me payment provider and update my orders.

 

Basicly i have 2 scenarios, Success or fail, if i, as i read you previous reply, use the value from  Ecom:Order.Gateway.Page.OK as my response adress from paymentmodule, I hit my step 6 as i should when the payment went well.

But i also hit step 6 when somthing goes bad, and DW creates an order.

 

Can i somewhere in the GetReturnValuesFromUrl() method, tell DW not to create the Order when something went wrong with a payment.

 

ATM my code looks like this:

 

public override void GetReturnValuesFromUrl( Dynamicweb.eCommerce.Orders.Order Order ) {      

  string Status = getQueryString( "status" ).ToUpper();
  string Status_code = getQueryString( "Status_code" );

  string OK_url = string.Format( "/Default.aspx?ID={0}&_OID_={1}&step=5&TransactionState=Ok", getQueryString( "ID" ), Order.ID );
  string ERROR_url = string.Format( "/Default.aspx?ID={0}&_OID_={1}&step=5&TransactionState=Error", getQueryString( "ID" ), Order.ID );
 
  // If transaction was successfull do this
  if ( Status.Equals("A") && Status_code.Equals("0") ) {
 //Order.GatewayResult = "";
 Order.TransactionNumber = getQueryString( "Transaction_id" );
 Order.TransactionPayGatewayCode = getQueryString( "Payment_method" );
 Order.TransactionType = getQueryString( "Card_type" );
 Order.TransactionStatus = Status + "" + Status_code;
 Order.TransactionAmount = Order.Price.PricePIP;
 Order.UpdateGatewayResult( true );
  } else {
 // There was an error
  }

  base.GetReturnValuesFromUrl( Order );
}

I think you should handle this in your template. In the template you probably set the pages your gateway should redirect to on success and failure.
 

Here you could set the page to be Step 5 on failure.

 
Reply

The payment provider only acceps 2 urls, a Callback url and a Cancel url.

So the Callback url is used for both success and error.

 

And therefore GetReturnValuesFromUrl needs to handle both events.

 

 

 

 

 

 
Reply
mn@co3.dk wrote:

The payment provider only acceps 2 urls, a Callback url and a Cancel url.

So the Callback url is used for both success and error.

 

And therefore GetReturnValuesFromUrl needs to handle both events.

 

 

 

 

 

The callback url you use, Page.OK, contains 'TransactionState=Ok' in the querystring, which tells DW that the transaction went well. A way to bend this is to redirect to 'TransactionState=Error' from your custom code.
 

Use the current url and just replace the transactionstate (remember to keep the rest of the querystring, like the _OID_ which is used to fetch the correct order).

 

Please let me know if this works.

 

 - Lasse

 
Reply

Hi Lasse,
 

 

It works as you would espect i think.

When i add a redirection to the same URL with 'TransactionState=Error' instead of 'OK' the method GetReturnValuesFromUrl() is run again, creating a loop.

 

but by redirecting to /Default.aspx?ID=1&_OID_=ORDER1&step=5&TransactionState=Error i get the desired effect.

 

Haven't testet thoroughly but i seems to work.

 

Using this method revealed a new problem.

When i hit the errorpage my cart isn't cleared which is good, if it wasn't for the payment providers denial of duplicate order IDs.

 

Assuming a user added some items to the cart and got around to paying online.

The user got an error during payment and got redirect to the error page in Dynamicweb.

If he now corrected the error, and went on to paying again. the paymentprovider would return error, because the ORDERID was already use in another transaction.

 

Either i need to clear the cart on error, or i need to change the orderid of his current cart to a new one.

 

The best aproach would be to change the ID of his current order, but is that possible?

 

The alternative is clearing his cart, and have him start over again.

 

Any better ideas?

 

Regards

  Martin

 

You must be logged in to post in the forum