eWay支付网关

时间:2011-05-17 09:17:59

标签: php soap

我正在尝试从eway(澳大利亚)实施定期网络服务。但是,我怎么都无法让它工作。

我一直在搞电子邮件

“名称空间”http://www.eway.com.au/gateway/rebill/manageRebill“中的元素'rebillCustomerCreate'内容不完整。预期可能的元素列表:'CustomerRef'。”

这是WSDL:https://www.eway.com.au/gateway/rebill/test/manageRebill_test.asmx?wsdl

我是SOAP新手。试图在PHP中实现它。任何人都可以指出我做错了吗?

这是我的PHP代码:

<?php
$URL = "https://www.eway.com.au/gateway/rebill/test/manageRebill_test.asmx?wsdl";
$option = array("trace"=>true);
$client = new SOAPClient($URL, $option);
$functions = $client->__getFunctions();
$headeroptions =array('eWAYCustomerID'=>"87654321",'Username'=>"test@eway.com.au","Password"=>"test");
$header = new SOAPHeader('http://www.eway.com.au/gateway/rebill/manageRebill', 'eWAYHeader',$headeroptions);

$bodyoptions = array(
    "customerTitle" => "Mr",
    "customerFirstName" => "firstname",
    "customerLastName" => "lastname",
    "customerAddress" => "address",
    "customerSuburb" => "someniceplace",
    "customerState" => "somenicestate",
    "customerCompany" => "somecompany",
    "customerPostCode" => "411026",
    "customerCountry" => "australia",
    "customerEmail" => "test@eway.com",
    "customerFax" => "123456",
    "customerPhone1" => "123456",
    "customerPhone2" => "123456",
    "customerRef" => "abc123",
    "customerJobDesc" => "Developer",
    "customerComments" => "Make it work",
    "customerURL" => "www.nicesite.com"
);

try{
    $response = $client->__soapCall("CreateRebillCustomer", $bodyoptions,NULL,$header,$outputHeader);
    echo $client->__getLastRequest();
    //$response = $client->CreateRebillCustomer($bodyoptions);
    var_dump($response);
} catch(SOAPFault $e){
    print $e;
}
?>

3 个答案:

答案 0 :(得分:4)

我试图创建eWay定期结算和客户, 希望它能帮助其他新人:)

   <?php
    $URL = "https://www.eway.com.au/gateway/rebill/test/manageRebill_test.asmx?wsdl";
    $option = array("trace"=>true);
    $client = new SOAPClient($URL, $option);
    $functions = $client->__getFunctions();
    $headeroptions =array('eWAYCustomerID'=>"87654321",'Username'=>"test@eway.com.au","Password"=>"test123");
    $header = new SOAPHeader('http://www.eway.com.au/gateway/rebill/manageRebill', 'eWAYHeader',$headeroptions);

    $bodyoptions = array(
                    "CreateRebillCustomer" => array(
                        "customerTitle" => "Mr",                   
                          "customerFirstName"=>"Muhammad",
                          "customerLastName"=>"Shahzad",
                          "customerAddress"=>"cust ome rAddress",
                          "customerSuburb"=>"customer Suburb",
                          "customerState"=>"ACT",
                          "customerCompany"=>"customer Company",
                          "customerPostCode"=>"2345",
                          "customerCountry"=>">Australia",
                          "customerEmail"=>"test@gamil.com",
                          "customerFax"=>"0298989898",
                          "customerPhone1"=>"0297979797",
                          "customerPhone2"=>"0297979797",
                          "customerRef"=>"Ref123",
                          "customerJobDesc"=>"customerJobDesc",
                          "customerComments"=>"customerComments",                    
                          "customerURL" => "http://www.acme.com.au"
                       )
                    );

        try{
            $response = $client->__soapCall("CreateRebillCustomer", $bodyoptions,NULL,$header,$outputHeader);
            //echo $client->__getLastRequest();
            //$response = $client->CreateRebillCustomer($bodyoptions);
            //echo "<pre>";echo "<br/>";
           // print_r($response);        
                echo    $result         = $response->CreateRebillCustomerResult->Result;echo "<br/>";
                echo    $customerId     = $response->CreateRebillCustomerResult->RebillCustomerID;echo "<br/>";
                echo "<br/>";
            if($result=='Success' AND $customerId){
                echo 'Member Created at eWay Successfully!...<br/>';
                echo 'Creating Recurring Billing Cycle on eWay,Please wait......<br/>';
                //$UpdateRebillCustomer = CreateRebillEvent($customerId);
                //print_r($UpdateRebillCustomer);

            }
            else{
                echo    $ErrorSeverity  = $response->CreateRebillCustomerResult->ErrorSeverity;echo "<br/>";
                echo    $ErrorDetails   = $response->CreateRebillCustomerResult->ErrorDetails;echo "<br/>";
            }
        }
        catch(SOAPFault $e){
            print $e;
        }

        if($customerId){


                    $bodyoptions2 = array(
                    "CreateRebillEvent " => array(
                          "RebillCustomerID" => $customerId,                   
                          "RebillInvRef" => "Ref123",
                          "RebillInvDes"=>"description",
                          "RebillCCName"=>"Mr Andy Person",
                          "RebillCCNumber"=>"4444333322221111",
                          "RebillCCExpMonth"=>"12",
                          "RebillCCExpYear"=>"15",
                          "RebillInitAmt"=>"100",
                          "RebillInitDate"=>date('d/m/Y'),
                          "RebillRecurAmt"=>"200",
                          "RebillStartDate"=>date('d/m/Y'),
                          "RebillInterval"=>"31",
                          "RebillIntervalType"=>"1",
                          "RebillEndDate"=>"31/12/2013",                     
                       )
                    );
            try{    
                $response = $client->__soapCall("CreateRebillEvent", $bodyoptions2,NULL,$header,$outputHeader);
                //echo   $client->__getLastRequest();           
                //print_r($response);
                echo "<br/>";
                  echo  $result2        = $response->CreateRebillEventResult->Result;echo "<br/>";
                  echo  $RebillCustomerID   = $response->CreateRebillEventResult->RebillCustomerID;echo "<br/>";
                if($result2=='Success'){
                    echo 'Recurring Cycle Created Successfully at eWay!...<br/>';
                    echo 'Member Id is ===>'.$RebillCustomerID;
                    //$UpdateRebillCustomer = CreateRebillEvent($customerId);
                    //print_r($UpdateRebillCustomer);                           
                }
                else{
                    echo    $ErrorSeverity  = $response->CreateRebillEventResult->ErrorSeverity;echo "<br/>";
                    echo    $ErrorDetails   = $response->CreateRebillEventResult->ErrorDetails;echo "<br/>";
                }

            }
         catch(SOAPFault $e){
            print $e;
         }

         }

      ?>

答案 1 :(得分:0)

我建议你使用eWay提供的库和样本。

转到this页面。转到“源代码”选项卡。 ,下载PHP源代码。还有指示。

答案 2 :(得分:0)

2年后,我遇到了同样的问题!

可能对某人有用:

$bodyoptions = array(
  "CreateRebillCustomer" => array(
    "customerTitle" => "Mr",
    ...
  )
);