Showing posts with label eway. Show all posts
Showing posts with label eway. Show all posts

Friday, January 16, 2015

eWay Shared Rapid Payment Using PHP

First, create an api from eway api setup page for online hosted rapid payment



Then download source code.


Browse http://localhost/ewayHosted/index.php and fill up Api Key & Password field and following by other fields and click 'Pay...' button. 
If all details are correct you would get data like below from eway:


stdClass Object
(
    [SharedPaymentUrl] => https://secure-au.sandbox.ewaypayments.com/sharedpage/sharedpayment?AccessCode=F9802jxD7ElfeXKsdljElP1OKxSJyKZHJuaRB8qf97fzPPiDGFS-JmlfVug7kAvkctMALC0cSrVtKdomIp0DPlJv0CdRAl4apAHgJNzFMo5TXfQ804a8-5BP80gWFSmOLsLgeXOGFrjiuBvfYPjjs8F1zBw==
    [AccessCode] => F9802jxD7ElfeXKsdljElP1OKxSJyKZHJuaRB8qf97fzPPiDGFS-JmlfVug7kAvkctMALC0cSrVtKdomIp0DPlJv0CdRAl4apAHgJNzFMo5TXfQ804a8-5BP80gWFSmOLsLgeXOGFrjiuBvfYPjjs8F1zBw==
    [Customer] => stdClass Object
        (
            [CardNumber] => 
            [CardStartMonth] => 
            [CardStartYear] => 
            [CardIssueNumber] => 
            [CardName] => 
            [CardExpiryMonth] => 
            [CardExpiryYear] => 
            [IsActive] => 
            [TokenCustomerID] => 
            [Reference] => KU060238
            [Title] => Mr.
            [FirstName] => Pritom
            [LastName] => Kumar
            [CompanyName] => WEB ACTIVE
            [JobDescription] => Developer
            [Street1] => 15 Smith St
            [Street2] => 
            [City] => Phillip
            [State] => ACT
            [PostalCode] => 2602
            [Country] => au
            [Email] => 
            [Phone] => 1800 10 10 65
            [Mobile] => 1800 10 10 65
            [Comments] => Some comments here
            [Fax] => 02 9852 2244
            [Url] => http://www.yoursite.com
        )

    [Payment] => stdClass Object
        (
            [TotalAmount] => 100
            [InvoiceNumber] => INVOICE1001
            [InvoiceDescription] => Individual Invoice Description
            [InvoiceReference] => 513456
            [CurrencyCode] => AUD
        )

    [FormActionURL] => https://secure-au.sandbox.ewaypayments.com/AccessCode/F9802jxD7ElfeXKsdljElP1OKxSJyKZHJuaRB8qf97fzPPiDGFS-JmlfVug7kAvkctMALC0cSrVtKdomIp0DPlJv0CdRAl4apAHgJNzFMo5TXfQ804a8-5BP80gWFSmOLsLgeXOGFrjiuBvfYPjjs8F1zBw==
    [CompleteCheckoutURL] => 
    [Errors] => 
)

Then collect 'AccessCode' from data returned and redirect to 'SharedPaymentUrl' where your original payment would process.




Need to fill up all fields and click on 'PAY NOW' button above.



Now click on 'FINALIZE TRANSACTION' button to redirect back to your original site from where you went.



And finally your transaction in eWay portal:



Sunday, January 26, 2014

eWay xml and direct payment url, account and credit card details


eWayServiceLinkURL:
 TEST: https://www.eway.com.au/gateway/ManagedPaymentService/test/managedCreditCardPayment.asmx
 LIVE: https://www.eway.com.au/gateway/ManagedPaymentService/managedCreditCardPayment.asmx
 
eWayProcessPaymentURL:
 TEST: https://www.eway.com.au/gateway/managedpayment/ProcessPayment
 LIVE: https://www.eway.com.au/gateway/managedpayment/ProcessPayment
 
eWaySOAPActionURL
 TEST: https://www.eway.com.au/gateway/managedpayment
 LIVE: https://www.eway.com.au/gateway/managedpayment
 
eWayDirectPaymentURL:
 TEST: https://www.eway.com.au/gateway_cvn/xmltest/testpage.asp
 LIVE: https://www.eway.com.au/gateway/xmlpayment.asp
 
eWAYCustomerID:
 TEST: 87654321
 
Username:
 TEST: test@eway.com.au
 
Password:
 TEST: test123
 
Credit Card:
 TEST: 4444333322221111
 
Credit Card CVV:
 TEST: 123 (or any other 3 or 4 digit number)
 
Credit Card Expiry:
 TEST: 01/15 (any valid date)
 
Credit Card Name:
 TEST: test (or any other valid name)

Wednesday, August 14, 2013

Php create/edit eWay token for further payment

<?php
function 
create_token_eway()
{
    
$testUrl "https://www.eway.com.au/gateway/ManagedPaymentService/test/managedCreditCardPayment.asmx";
    
$liveUrl "https://www.eway.com.au/gateway/ManagedPaymentService/managedCreditCardPayment.asmx";
  
    
$eWaySOAPActionURL    "https://www.eway.com.au/gateway/managedpayment";
    
$eWayCustomerId       "87654321";
    
/* test account */
    
$eWayCustomerEmail    "test@eway.com.au";
    
/* test email */
    
$eWayCustomerPassword "test123";
    
/* test password */
  
    
$updateCustomer false;
    
$customTag      "CreateCustomer";
    
/* For update customer: "UpdateCustomer". */
    /**
     * If you want to update existing customer do the following -
     */
    
if ($updateCustomer) {
        
$updateCustomerEWayId "9876543211000";
        
/* Already saved customer id. */
        
$customTag            "UpdateCustomer";
        
$updateCustomerEWayId "<managedCustomerID>"  

              $updateCustomerEWayId 
              "</managedCustomerID>";
    }
  
    
$directXML "<?xml version=\"1.0\" encoding=\"utf-8\"?>
        <soap12:Envelope 

            xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
            xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
            xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">
            <soap12:Header>
            <eWAYHeader xmlns=\"" 
$eWaySOAPActionURL "\">
                <eWAYCustomerID>" 
$eWayCustomerId "</eWAYCustomerID>
                <Username>" 
$eWayCustomerEmail "</Username>
                <Password>" 
$eWayCustomerPassword "</Password>
            </eWAYHeader>
        </soap12:Header>
          <soap12:Body>
            <" 
$customTag " xmlns=\"" $eWaySOAPActionURL "\">
                " 
$updateCustomerEWayId "
                <Title>Mr.</Title>
                <FirstName>Pritom</FirstName>
                <LastName>Kumar Mondal</LastName>
                <Address></Address>
                <Suburb></Suburb>
                <State></State>
                <Company>Khulna University</Company>
                <PostCode></PostCode>
                <Country>au</Country>
                <Email>pritomkucse@gmail.com</Email>
                <Fax></Fax>
                <Phone></Phone>
                <Mobile></Mobile>
                <CustomerRef>CSE-060238</CustomerRef>
                <JobDesc></JobDesc>
                <Comments></Comments>
                <URL></URL>
                <CCNumber>4444333322221111</CCNumber>
                <CCNameOnCard>Pritom K Mondal</CCNameOnCard>
                <CCExpiryMonth>12</CCExpiryMonth>
                <CCExpiryYear>15</CCExpiryYear>
            </" 
$customTag ">
        </soap12:Body>
        </soap12:Envelope>"
;
  
    
$result makeCurlCall(

    $testUrl/* CURL URL */ 
    "POST"/* CURL CALL METHOD */  
    array(
        
/* CURL HEADERS */
        
"Content-Type: text/xml; charset=utf-8",
        
"Accept: text/xml",
        
"Pragma: no-cache",
        
"SOAPAction: " $eWaySOAPActionURL "/" $customTag,
        
"Content_length: " strlen(trim($directXML))
    ), 

    null/* CURL GET PARAMETERS */  
    $directXML /* CURL POST PARAMETERS AS XML */ );
  
    if (
$result != null && isset($result["response"])) {
        echo 
$result["response"]; /* Result printed below */
    }
    die(
"");
}
 


/* makeCurlCall */ 
function makeCurlCall($url$method "GET"$headers null$gets null$posts null)
{
    
$ch curl_init();
    if (
$gets != null) {
        
$url .= "?" . (http_build_query($gets));
    }
    
curl_setopt($chCURLOPT_URL$url);
    
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
    
curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
  
    if (
$posts != null) {
        
curl_setopt($chCURLOPT_POSTFIELDS$posts);
    }
    if (
$method == "POST") {
        
curl_setopt($chCURLOPT_POSTtrue);
    } else if (
$method == "PUT") {
        
curl_setopt($chCURLOPT_CUSTOMREQUEST"PUT");
    } else if (
$method == "HEAD") {
        
curl_setopt($chCURLOPT_NOBODYtrue);
    }
    if (
$headers != null && is_array($headers)) {
        
curl_setopt($chCURLOPT_HTTPHEADER$headers);
    }
    
$response curl_exec($ch);
    
$code     curl_getinfo($chCURLINFO_HTTP_CODE);
  
    
curl_close($ch);
    return array(
        
"code" => $code,
        
"response" => $response
    
);
}
 

create_token_eway();?>

Output

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"  
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <CreateCustomerResponse  
         xmlns="https://www.eway.com.au/gateway/managedpayment">
         <CreateCustomerResult>9876543211000</CreateCustomerResult>
      </CreateCustomerResponse>
   </soap:Body>
</soap:Envelope>

Wednesday, August 7, 2013

Refund transaction using php api using eWay account

/* Refund using eWay */
function refund_using_eway()
{
    $testUrl = "https://www.eway.com.au/gateway/xmltest/refund_test.asp";
    $liveUrl = "https://www.eway.com.au/gateway/xmlpaymentrefund.asp";

    $eWaySOAPActionURL = "https://www.eway.com.au/gateway/managedpayment";
    $eWayCustomerId = "87654321";
    $eWayTotalAmount = 100;
    $directXML = "<ewaygateway>" .
        "<ewayCustomerID>" . $eWayCustomerId . "</ewayCustomerID>" .
        "<ewayOriginalTrxnNumber>20488</ewayOriginalTrxnNumber>" .
        "<ewayTotalAmount>" . $eWayTotalAmount . "</ewayTotalAmount>" .
        "<ewayCardExpiryMonth>01</ewayCardExpiryMonth>" .
        "<ewayCardExpiryYear>2015</ewayCardExpiryYear>" .
        "<ewayOption1></ewayOption1>" .
        "<ewayOption2></ewayOption2>" .
        "<ewayOption3></ewayOption3>" .
        "<ewayRefundPassword>test123</ewayRefundPassword>" .
        "</ewaygateway>";

    $result = makeCurlCall(
        $testUrl, /* CURL URL */
        "POST", /* CURL CALL METHOD */
        array( /* CURL HEADERS */
            "Content-Type: text/xml; charset=utf-8",
            "Accept: text/xml",
            "Pragma: no-cache",
            "SOAPAction: " . $eWaySOAPActionURL,
            "Content_length: " . strlen(trim($directXML))
        ),
        null, /* CURL GET PARAMETERS */
        $directXML /* CURL POST PARAMETERS AS XML */
    );

    if ($result != null && isset($result["response"])) {
        $response = new SimpleXMLElement($result["response"]);
        $response = simpleXMLToArray($response);
        print_r2($response);
    }
    die("");
}

/* makeCurlCall */
function makeCurlCall($url, $method = "GET", $headers = null, $gets = null, $posts = null) {
    $ch = curl_init();
    if($gets != null)
    {
        $url.="?".(http_build_query($gets));
    }
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

    if($posts != null)
    {
        curl_setopt($ch, CURLOPT_POSTFIELDS, $posts);
    }
    if($method == "POST") {
        curl_setopt($ch, CURLOPT_POST, true);
    } else if($method == "PUT") {
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
    } else if($method == "HEAD") {
        curl_setopt($ch, CURLOPT_NOBODY, true);
    }
    if($headers != null && is_array($headers))
    {
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    }
    $response = curl_exec($ch);
    $code = curl_getinfo($ch,CURLINFO_HTTP_CODE);

    curl_close($ch);
    return array(
        "code" => $code,
        "response" => $response
    );
}

/* Response */
Array
(
    [ewayTrxnStatus] => Array
        (
            [__cdata] => False
        )

    [ewayTrxnNumber] => Array
        (
            [__cdata] =>
        )

    [ewayTrxnOption1] => Array
        (
            [__cdata] =>
        )

    [ewayTrxnOption2] => Array
        (
            [__cdata] =>
        )

    [ewayTrxnOption3] => Array
        (
            [__cdata] =>
        )

    [ewayAuthCode] => Array
        (
            [__cdata] =>
        )

    [ewayReturnAmount] => Array
        (
            [__cdata] => 100
        )

    [ewayTrxnError] => Array
        (
            [__cdata] => Error: Invalid Original Transaction Number. Your credit card has not been billed for this transaction.
        )

)

/* Dont worry about ewayTrxnError, when you refund live it will work */

Saturday, June 29, 2013

eWay transaction using php api direct payment

/* Pay using eWay */
function pay_using_eway()
{
    $testUrl = "https://www.eway.com.au/gateway_cvn/xmltest/testpage.asp";
    $liveUrl = "https://www.eway.com.au/gateway_cvn/xmlpayment.asp";
    $eWaySOAPActionURL = "https://www.eway.com.au/gateway/managedpayment";
    $eWayCustomerId = "87654321"; /* test account */
    $eWayTotalAmount = 100; /* 1$ = 100 cent */
    $directXML = "<ewaygateway>".
        "<ewayCustomerID>".$eWayCustomerId."</ewayCustomerID>".
        "<ewayTotalAmount>".$eWayTotalAmount."</ewayTotalAmount>".
        "<ewayCustomerFirstName></ewayCustomerFirstName>".
        "<ewayCustomerLastName></ewayCustomerLastName>".
        "<ewayCustomerEmail></ewayCustomerEmail>".
        "<ewayCustomerAddress></ewayCustomerAddress>".
        "<ewayCustomerPostcode></ewayCustomerPostcode>".
        "<ewayCustomerInvoiceDescription></ewayCustomerInvoiceDescription>".
        "<ewayCustomerInvoiceRef> Invoice Reference </ewayCustomerInvoiceRef>".
        "<ewayCardHoldersName>Card Holder Name</ewayCardHoldersName>".
        "<ewayCardNumber>4444333322221111</ewayCardNumber>".
        "<ewayCardExpiryMonth>01</ewayCardExpiryMonth>".
        "<ewayCardExpiryYear>2015</ewayCardExpiryYear>".
        "<ewayCVN>123</ewayCVN>".
        "<ewayTrxnNumber></ewayTrxnNumber>".
        "<ewayOption1></ewayOption1>".
        "<ewayOption2></ewayOption2>".
        "<ewayOption3></ewayOption3>".
    "</ewaygateway>";

    $result = makeCurlCall(
        $testUrl, /* CURL URL */
        "POST", /* CURL CALL METHOD */
        array( /* CURL HEADERS */
            "Content-Type: text/xml; charset=utf-8",
            "Accept: text/xml",
            "Pragma: no-cache",
            "SOAPAction: ".$eWaySOAPActionURL,
            "Content_length: ".strlen(trim($directXML))
        ),
        null, /* CURL GET PARAMETERS */
        $directXML /* CURL POST PARAMETERS AS XML */
    );

    if($result != null && isset($result["response"])) {
        $response = new SimpleXMLElement($result["response"]);
        $response = simpleXMLToArray($response);
        print_r2($response);
    }
    die("");
}

/* makeCurlCall */
function makeCurlCall($url, $method = "GET", $headers = null, $gets = null, $posts = null) {
    $ch = curl_init();
    if($gets != null)
    {
        $url.="?".(http_build_query($gets));
    }
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

    if($posts != null)
    {
        curl_setopt($ch, CURLOPT_POSTFIELDS, $posts);
    }
    if($method == "POST") {
        curl_setopt($ch, CURLOPT_POST, true);
    } else if($method == "PUT") {
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
    } else if($method == "HEAD") {
        curl_setopt($ch, CURLOPT_NOBODY, true);
    }
    if($headers != null && is_array($headers))
    {
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    }
    $response = curl_exec($ch);
    $code = curl_getinfo($ch,CURLINFO_HTTP_CODE);

    curl_close($ch);
    return array(
        "code" => $code,
        "response" => $response
    );
}

/* Response */ 
Array
(
    [ewayTrxnStatus] => Array
        (
            [__cdata] => True
        )

    [ewayTrxnNumber] => Array
        (
            [__cdata] => 20466
        )

    [ewayTrxnReference] => Array
        (
            [__cdata] => 
        )

    [ewayTrxnOption1] => Array
        (
            [__cdata] => 
        )

    [ewayTrxnOption2] => Array
        (
            [__cdata] => 
        )

    [ewayTrxnOption3] => Array
        (
            [__cdata] => 
        )

    [ewayAuthCode] => Array
        (
            [__cdata] => 123456
        )

    [ewayReturnAmount] => Array
        (
            [__cdata] => 100
        )

    [ewayTrxnError] => Array
        (
            [__cdata] => 00,Transaction Approved(Test CVN Gateway)
        )

)
 
http://www.eway.com.au/developers/api/direct-payments 

Wednesday, May 16, 2012

Direct post integration eway

Create a eWay account. go: http://www.eway.com.au/developers/partners/become-a-partner.html

Post data as:

<form action="https://www.eway.com.au/gateway/payment.asp" method="post" name="formEWay">
<input type="hidden" name="ewayCustomerID" value=""/>
<input type="hidden" name="ewayTotalAmount" value=""/>
<input type="hidden" name="ewayCustomerFirstName" value=""/>
<input type="hidden" name="ewayCustomerLastName" value=""/>
<input type="hidden" name="ewayCustomerEmail" value=""/>
<input type="hidden" name="ewayCustomerAddress" value=""/>
<input type="hidden" name="ewayCustomerPostcode" value=""/>
<input type="hidden" name="ewayCustomerInvoiceDescription" value="Purchase Order - 10"/>
<input type="hidden" name="ewayCustomerInvoiceRef" value=""/>
<input type="hidden" name="eWAYURL" value="http://dom.com/ewayreturn.php"/>
<input type="hidden" name="eWAYSiteTitle" value="<?php echo $_SERVER["SERVER_NAME"] ?>"/>
<input type="hidden" name="eWAYAutoRedirect" value="1"/>
<input type="hidden" name="eWAYTrxnNumber" value=""/>
<input type="submit" value="Process Secure Credit Card Transaction using eWay"/>
</form>

After return from eway, try the following.
if(isset($_POST['ewayTrxnReference']) && isset($_POST['ewayTrxnStatus']) && isset($_POST['ewayTrxnNumber'])) {
    $orderStatus = "Open";
    $pGateResult = "false";
    $txn_id = $_POST['ewayTrxnReference'];
    $result = $_POST['ewayTrxnStatus'];
    $order_number = $_POST['ewayTrxnNumber'];
    $returnAmount = 0;
    if(isset($_POST["eWAYReturnAmount"])) {
        $returnAmount = $this->getValueReturnedFromeWay($_POST["eWAYReturnAmount"]);
    }
    if (!empty($result) && strcmp('True', trim($result)) == 0) {
         $pGateResult = "true";
         $orderStatus = "Paid";
    }
}