Problem With Class

Discussion in 'PHP' started by adamjblakey, Jul 13, 2009.

  1. #1
    Hi,

    For some reason this script is just not running. I have tried error reporting but does not come back with anything. Can anyone see where the problem lies?

    index.php
    
    //example
    
    include_once("class.xpay.php");
    
    $operation = array(    "amount"=>(1000);
    $customerinfo = array(    "nameprefix"=>"Mr.",
                "firstname"=>"James",
                "lastname"=>"Dean",
                "company"=>"",
                "street"=>("123 Astreet St"),
                "city"=>"Acity",
                "stateprov"=>"Acounty",
                "postcode"=>"AB11CD",
                "countrycode"=>"UK",
                "phone"=>"",
                "email"=>"");
    
    $paymentmethod = array(    "type"=>"VISA",
                "number"=>"4111111111111111",
                "issue"=>"",
                "startdate"=>"",
                "securitycode"=>"123",
                "expirydate"=>"01/01";
    $order = array(        "orderreference"=>"Order001",
                "orderinformation"=>"Order");
    
    $xpay = new Xpay($sitereference,$certlocation,$port = 5000,$host = "127.0.0.1")
    $result = $xpay->auth($operation,$customerinfo,$paymentmethod,$order);
    
    if($result["Result"] == 1){
        print "The transaction was successful";
    }
    
    PHP:
    Cheers,
    Adam
     
    adamjblakey, Jul 13, 2009 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    $xpay = new Xpay($sitereference,$certlocation,$port = 5000,$host = "127.0.0.1")

    needs to be:


    $xpay = new Xpay($sitereference,$certlocation,5000,"127.0.0.1");
     
    jestep, Jul 13, 2009 IP
  3. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #3
    as on phpclasses site

    the example code is

    include_once("class.xpay.php"); 
    
    $operation = array(    "amount"=>(1000); 
    $customerinfo = array(    "nameprefix"=>"Mr.", 
                "firstname"=>"James", 
                "lastname"=>"Dean", 
                "company"=>"", 
                "street"=>("123 Astreet St"), 
                "city"=>"Acity", 
                "stateprov"=>"Acounty", 
                "postcode"=>"AB11CD", 
                "countrycode"=>"UK", 
                "phone"=>"", 
                "email"=>""); 
    
    $paymentmethod = array(    "type"=>"VISA", 
                "number"=>"4111111111111111", 
                "issue"=>"", 
                "startdate"=>"", 
                "securitycode"=>"123", 
                "expirydate"=>"01/01"; 
    $order = array(        "orderreference"=>"Order001", 
                "orderinformation"=>"Order"); 
    
    $xpay = new Xpay($sitereference,$certlocation,$port = 5000,$host = "127.0.0.1") 
    $result = $xpay->auth($operation,$customerinfo,$paymentmethod,$order); 
    
    if($result["Result"] == 1){ 
        print "The transaction was successful"; 
    } 
    PHP:
    Regards

    Alex
     
    kmap, Jul 13, 2009 IP
  4. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #4
    it's wrong, you set default value if an argument is omited in your function / constructor definition, not when you call the function... in your case, you can just drop both port and host, unless they differ from the default ones in the class.
     
    dimitar christoff, Jul 13, 2009 IP