水星支付系统

时间:2012-07-06 12:06:33

标签: php payment-gateway payment

我正在尝试使用发送API请求的水银支付系统,作为回报,我收到了付款ID。 根据他们的文档,在获得付款ID后,我们必须将其作为帖子发送给付款流程主持人https://hc.mercurydev.net/CheckoutPOS.aspx 我被重定向到页面,金额没有正确显示。 有什么建议吗?

以下是请求API

function get_ms_payment_id($ms_merchant_id,$ms_password,$order_header_id,$amount,$tax,$success_url,$failure_url)
{
    $soap_request = '<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">';
    $soap_request .= '<SOAP-ENV:Body>';
    $soap_request .= '<InitializePayment xmlns="http://www.mercurypay.com/">';
    $soap_request .= '<request> ';
    $soap_request .= '<MerchantID>'.$ms_merchant_id.'</MerchantID> ';
    $soap_request .= '<Password>'.$ms_password.'</Password> ';
    $soap_request .= '<Invoice>'.$order_header_id.'</Invoice> ';
    $soap_request .= '<TotalAmount>50.23</TotalAmount>';
    $soap_request .= '<TaxAmount>'.$tax.'</TaxAmount>';
    $soap_request .= '<TranType>Sale</TranType> ';
    $soap_request .= '<Frequency>OneTime</Frequency>';
    $soap_request .= '<Memo>Your Memo</Memo> ';
    $soap_request .= '<PartialAuth>Off</PartialAuth> ';
    $soap_request .= '<ProcessCompleteUrl>'.$success_url.'</ProcessCompleteUrl> ';
    $soap_request .= '<ReturnUrl>'.$failure_url.'</ReturnUrl> ';
    $soap_request .= '<DisplayStyle>Custom</DisplayStyle>';
    $soap_request .= '<BackgroundColor>Gray</BackgroundColor>';
    $soap_request .= '<FontColor>Black</FontColor>';
    $soap_request .= '<FontFamily>FontFamily1</FontFamily>';
    $soap_request .= '<FontSize>Medium</FontSize>';
    $soap_request .= '<PageTitle>Demo Ecommerce Merchant</PageTitle>';
    $soap_request .= '<SecurityLogo>on</SecurityLogo>';
    $soap_request .= '<OrderTotal>on</OrderTotal>';
    $soap_request .= '<SubmitButtonText>Submit</SubmitButtonText>';
    $soap_request .= '<CancelButtonText>Cancel</CancelButtonText>';
    $soap_request .= '</request> ';
    $soap_request .= '</InitializePayment>';
    $soap_request .= '</SOAP-ENV:Body>';
    $soap_request .= '</SOAP-ENV:Envelope>';

    $header = array("POST /ws/ws.asmx HTTP/1.1", 
        "Host: w1.mercurypay.com", 
        "Content-Type: text/xml; charset=utf-8",
        "SOAPAction: \"http://www.mercurypay.com/InitializePayment\"");

    $url = "https://hc.mercurydev.net/hcws/hcservice.asmx";

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    //curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 4);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $soap_request);

    $result = curl_exec($ch);

    include_once('xml.php');
    $x_data = XML_unserialize($result);

    $x_data = $x_data["soap:Envelope"];
    $x_data = $x_data["soap:Body"];
    $x_data = $x_data["InitializePaymentResponse"];
    $result = $x_data["InitializePaymentResult"];

    return($result);
}

作为回应我收到了有效的paymentId,使用paymentId后我将其发布到支付网关 但是支付网关上没有适当的金额。

以下是支付网关的屏幕截图

http://screencast.com/t/FbULkAy01X0L

谢谢

1 个答案:

答案 0 :(得分:2)

要获得MercuryPay的最新集成,请查看Aktive-Merchant实施of MercuryPay

以下是一个简短的例子:

<?php
use AktiveMerchant\Billing\Base; //Use Base class
use AktiveMerchant\Billing\Mercury; //Use Mercury gateway
use AktiveMerchant\Billing\CreditCard;

Base::mode('test') // Remove this on production mode

$gateway = new Mercury(array('login'=>'<login>', 'password'=>'<password>'));

$credit_card = new CreditCard( 
    array(
        "first_name" => "John",
        "last_name" => "Doe",
        "number" => "41111111111111",
        "month" => "12",
        "year" => "2012",
        "verification_value" => "123"
    )
);

$credit_card->isValid(); // Returns true or false

# Extra options for transaction
$options = array(
    'order_id' => 'REF' . $gateway->generateUniqueId(),
    'description' => 'Test Transaction',
    'address' => array(
        'address1' => '1234 Street',
        'zip' => '98004',
        'state' => 'WA'
    )
);

$amount = 100; #100 cents 1.00 dollars

# Authorize transaction
$response = $gateway->authorize($amount, $credit_card, $options);
if ( $response->success() ) {
    echo 'Success Authorize';
} else {
    echo $response->message();
}

您可以从交易中获取PaymentId

$response->authorization();