Jump to content

Help Plz with this simple code


cgfunk126

Recommended Posts

I have the following function in place to allow people to change the status of their payment gateway from "inactive" to "active". Currently this function allows users to have as many gateways of any type to be active or inactive at any given point. I decided that I only want them to allow one gateway of the type "Direct" to be "active" at one time. Thus in order to make a different "direct" gateway to be "active they would have to inactivate the current gateway. The gateway type is being stored in a table called "gateway". If anyone could give me some pointers on how to make this happen i would highly appreciate it.

 

function store_gateway_status ($STORE, $GATEWAY){

GLOBAL $DB;

$ERROR = "";

$SQuery = "SELECT SG1.Status AS StoreGatewayStatus "

. " FROM ".$DB['Table']['StoreGateway']." AS SG1 "

. " WHERE SG1.StoreID='".$STORE['ID']."' "

. " AND SG1.GatewayID='".$GATEWAY['ID']."' ";

$SResult = mysql_query($SQuery, $DB['Link']);

$SRow = mysql_fetch_object($SResult);

$StoreGatewayStatus = $SRow->StoreGatewayStatus;

if ($StoreGatewayStatus == 'Inactive'){

$StoreGatewayStatus = 'Active';

}

else {

$StoreGatewayStatus = 'Inactive';

}

$UQuery = "UPDATE ".$DB['Table']['StoreGateway']." AS SG1 "

. " SET SG1.Status='".$StoreGatewayStatus."' "

. " WHERE SG1.StoreID='".$STORE['ID']."' "

. " AND SG1.GatewayID='".$GATEWAY['ID']."' ";

$UResult = mysql_query($UQuery, $DB['Link']);

if (strlen(mysql_error($DB['Link'])) > 0){

$ERROR = $ERROR."<BR>".mysql_error($DB['Link']);

}

return ($ERROR);

Link to comment
https://forums.phpfreaks.com/topic/117031-help-plz-with-this-simple-code/
Share on other sites

I am still a rookie but just looking at this from the outside could you just make another field in your table called activegateway.  If they want to change from one active gateway to another then replace activegateway field with the new active gateway.  Or have I missed what you are asking compleatly?

The problem is that their can be more than one possible gateway at "active" act one time depending on the type of gateway. If the gateway is type "3rd party" they are a allowed to have numerous gateways active. I want to restrict the number of active gateways with type "direct" to 1. I want to show the list of all their gateways but only allow them to have 1 "direct" gateway active. For instance I want all this to show up but I only want 1 gateway type direct to be active.

 

Gateway                    Setup    Status  Type

Authorize.Net                 EDIT   Active Direct

CyberSource                 EDIT   Active Direct

LinkPoint & YourPay         EDIT   Active Direct

PayPal                         EDIT   Inactive 3rd Party

PSIGate (Under Development) EDIT   Inactive Direct

OK so once again I am a rooke so bare with me tryingto think outside the box.  Some customer has this:

 

Gateway                      Setup        Status    Type

Authorize.Net                    EDIT      Active    Direct

CyberSource                    EDIT      Active    Direct

LinkPoint & YourPay            EDIT      Active    Direct

PayPal                            EDIT      Inactive    3rd Party

PSIGate (Under Development)    EDIT      Inactive    Direct

 

and you want this:

 

Gateway                      Setup        Status    Type

Authorize.Net                    EDIT      inactive    Direct

CyberSource                    EDIT      insctive    Direct

LinkPoint & YourPay            EDIT      Active    Direct

PayPal                            EDIT      Inactive    3rd Party

PSIGate (Under Development)    EDIT      Inactive    Direct

 

Have a form with a dropdown box that just list the customers direct type gateways.  That customer will pick his dorect type gateway and transmit.  Back sipe php code sets the other x number of Direct gateways to inactive and jus activates the one they chose.  You should be able to do this with an if statement if the name and number of gateways are known if not known then you would need to do it as a loop probably a for each and set them all to inactive then with that variable that is storing what one is active go back and make that one just active.  I hope this is making sence?

That definitely makes sense. The way i have it set up though is on the customers gateway page, theres is a list of all the gateway thats are available for the customer. Within this list i have the status button that enables them to change back in forth between active/inactive. keeping the same theory I just want to change the way the function is updating this information by allowing the function to only update a "direct" gateway to "active" if and only if the other "direct" gateways listed are set to "inactive"

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.