paypal_ipn.php

来自「this the oscommerce 3.0 aplha 4」· PHP 代码 · 共 481 行 · 第 1/3 页

PHP
481
字号
        if (empty($result) === false) {          $osC_XML = new osC_XML($result);// there is a PHP 5.1.2 XML root namespace bug; http://bugs.php.net/bug.php?id=37035          $result = $osC_XML->toArray();          if (isset($result['SOAP-ENV:Envelope']['SOAP-ENV:Body']['DoVoidResponse'])) {            $result = $result['SOAP-ENV:Envelope']['SOAP-ENV:Body']['DoVoidResponse'];            $data = array('root' => array('Ack' => $result['Ack']));            if ($result['Ack'] != 'Success') {              $data['root']['Errors'] = array('ShortMessage' => $result['Errors']['ShortMessage'],                                              'LongMessage' => $result['Errors']['LongMessage'],                                              'ErrorCode' => $result['Errors']['ErrorCode']);            }            $osC_XML = new osC_XML($data);            $Qtransaction = $osC_Database->query('insert into :table_orders_transactions_history (orders_id, transaction_code, transaction_return_value, transaction_return_status, date_added) values (:orders_id, :transaction_code, :transaction_return_value, :transaction_return_status, now())');            $Qtransaction->bindTable(':table_orders_transactions_history', TABLE_ORDERS_TRANSACTIONS_HISTORY);            $Qtransaction->bindInt(':orders_id', $id);            $Qtransaction->bindInt(':transaction_code', 2);            $Qtransaction->bindValue(':transaction_return_value', $osC_XML->toXML());            $Qtransaction->bindInt(':transaction_return_status', ($result['Ack'] == 'Success' ? 1 : 0));            $Qtransaction->execute();          }        }      }    }/** * Send a status enquiry of the transaction to the gateway server * * @access public * @param $id The ID of the order */    function inquiryTransaction($id) {      global $osC_Database;      $Qorder = $osC_Database->query('select transaction_return_value from :table_orders_transactions_history where orders_id = :orders_id and transaction_code = 1 order by date_added limit 1');      $Qorder->bindTable(':table_orders_transactions_history', TABLE_ORDERS_TRANSACTIONS_HISTORY);      $Qorder->bindInt(':orders_id', $id);      $Qorder->execute();      if ($Qorder->numberOfRows() === 1) {        $osC_XML = new osC_XML($Qorder->value('transaction_return_value'));        $result = $osC_XML->toArray();        $string = '<?xml version="1.0" encoding="UTF-8"?>                  <SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">                    <SOAP-ENV:Header>                      <RequesterCredentials xmlns="urn:ebay:api:PayPalAPI" SOAP-ENV:mustUnderstand="1">                        <Credentials xmlns="urn:ebay:apis:eBLBaseComponents">                          <Username>' . MODULE_PAYMENT_PAYPAL_IPN_API_USERNAME . '</Username>                          <Password>' . MODULE_PAYMENT_PAYPAL_IPN_API_PASSWORD . '</Password>                          <Subject/>                        </Credentials>                      </RequesterCredentials>                    </SOAP-ENV:Header>                    <SOAP-ENV:Body>                      <GetTransactionDetailsReq xmlns="urn:ebay:api:PayPalAPI">                        <GetTransactionDetailsRequest xsi:type="ns:GetTransactionDetailsRequestType">                          <Version xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="xsd:string">1.0</Version>                          <TransactionID xsi:type="ebl:TransactionId">' . $result['root']['txn_id'] . '</TransactionID>                        </GetTransactionDetailsRequest>                      </GetTransactionDetailsReq>                    </SOAP-ENV:Body>                  </SOAP-ENV:Envelope>';        $result = $this->sendTransactionToGateway($this->_gateway_server, $string, '', 'post', MODULE_PAYMENT_PAYPAL_IPN_API_CERTIFICATE);        if (empty($result) === false) {          $osC_XML = new osC_XML($result);// there is a PHP 5.1.2 XML root namespace bug; http://bugs.php.net/bug.php?id=37035          $result = $osC_XML->toArray();          if (isset($result['SOAP-ENV:Envelope']['SOAP-ENV:Body']['GetTransactionDetailsResponse'])) {            $info = $result['SOAP-ENV:Envelope']['SOAP-ENV:Body']['GetTransactionDetailsResponse'];            $result =& $info['PaymentTransactionDetails'];            if ($info['Ack'] == 'Success') {              $data = array('root' => array('ReceiverInfo' => array('Business' => $result['ReceiverInfo']['Business'],                                                                    'Receiver' => $result['ReceiverInfo']['Receiver'],                                                                    'ReceiverID' => $result['ReceiverInfo']['ReceiverID']),                                            'PayerInfo' => array('Payer' => $result['PayerInfo']['Payer'],                                                                 'PayerID' => $result['PayerInfo']['PayerID'],                                                                 'PayerStatus' => $result['PayerInfo']['PayerStatus'],                                                                 'PayerName' => array('Salutation' => $result['PayerInfo']['PayerName']['Salutation'],                                                                                      'FirstName' => $result['PayerInfo']['PayerName']['FirstName'],                                                                                      'MiddleName' => $result['PayerInfo']['PayerName']['MiddleName'],                                                                                      'LastName' => $result['PayerInfo']['PayerName']['LastName'],                                                                                      'Suffix' => $result['PayerInfo']['PayerName']['Suffix']),                                                                 'PayerCountry' => $result['PayerInfo']['PayerCountry'],                                                                 'PayerBusiness' => $result['PayerInfo']['PayerBusiness'],                                                                 'Address' => array('Name' => $result['PayerInfo']['Address']['Name'],                                                                                    'Street1' => $result['PayerInfo']['Address']['Street1'],                                                                                    'Street2' => $result['PayerInfo']['Address']['Street2'],                                                                                    'CityName' => $result['PayerInfo']['Address']['CityName'],                                                                                    'StateOrProvince' => $result['PayerInfo']['Address']['StateOrProvince'],                                                                                    'Country' => $result['PayerInfo']['Address']['Country'],                                                                                    'CountryName' => $result['PayerInfo']['Address']['CountryName'],                                                                                    'PostalCode' => $result['PayerInfo']['Address']['PostalCode'],                                                                                    'AddressOwner' => $result['PayerInfo']['Address']['AddressOwner'],                                                                                    'AddressStatus' => $result['PayerInfo']['Address']['AddressStatus'])),                                            'PaymentInfo' => array('TransactionID' => $result['PaymentInfo']['TransactionID'],                                                                   'ParentTransactionID' => $result['PaymentInfo']['ParentTransactionID'],                                                                   'ReceiptID' => $result['PaymentInfo']['ReceiptID'],                                                                   'TransactionType' => $result['PaymentInfo']['TransactionType'],                                                                   'PaymentType' => $result['PaymentInfo']['PaymentType'],                                                                   'PaymentDate' => $result['PaymentInfo']['PaymentDate'],                                                                   'GrossAmount' => $result['PaymentInfo']['GrossAmount'],                                                                   'GrossAmountCurrencyID' => $result['PaymentInfo']['GrossAmount attr']['currencyID'],                                                                   'TaxAmount' => $result['PaymentInfo']['TaxAmount'],                                                                   'TaxAmountCurrencyID' => $result['PaymentInfo']['TaxAmount attr']['currencyID'],                                                                   'ExchangeRate' => $result['PaymentInfo']['ExchangeRate'],                                                                   'PaymentStatus' => $result['PaymentInfo']['PaymentStatus'],                                                                   'PendingReason' => $result['PaymentInfo']['PendingReason'],                                                                   'ReasonCode' => $result['PaymentInfo']['ReasonCode']),                                            'PaymentItemInfo' => array('InvoiceID' => $result['PaymentItemInfo']['InvoiceID'],                                                                       'Custom' => $result['PaymentItemInfo']['Custom'],                                                                       'Memo' => $result['PaymentItemInfo']['Memo'],                                                                       'SalesTax' => $result['PaymentItemInfo']['SalesTax'],                                                                       'PaymentItem' => array('Name' => $result['PaymentItemInfo']['PaymentItem']['Name'],                                                                                              'Number' => $result['PaymentItemInfo']['PaymentItem']['Number'],                                                                                              'Quantity' => $result['PaymentItemInfo']['PaymentItem']['Quantity'],                                                                                              'SalesTax' => $result['PaymentItemInfo']['PaymentItem']['SalesTax']),                                                                       'Subscription' => array('SubscriptionID' => $result['PaymentItemInfo']['Subscription']['SubscriptionID'],                                                                                               'Username' => $result['PaymentItemInfo']['Subscription']['Username'],                                                                                               'Password' => $result['PaymentItemInfo']['Subscription']['Password'],                                                                                               'Recurrences' => $result['PaymentItemInfo']['Subscription']['Recurrences']),                                                                       'SubscriptionRecurring' => $result['PaymentItemInfo']['Subscription attr']['recurring'],                                                                       'SubscriptionReattempt' => $result['PaymentItemInfo']['Subscription attr']['reattempt'],                                                                       'Auction' => array('BuyerID' => $result['PaymentItemInfo']['Auction']['BuyerID']))));            } else {              $data = array('root' => array('Ack' => $info['Ack'],                                            'Errors' => array('ShortMessage' => $info['Errors']['ShortMessage'],                                                              'LongMessage' => $info['Errors']['LongMessage'],                                                              'ErrorCode' => $info['Errors']['ErrorCode'])));            }            $osC_XML = new osC_XML($data);            $Qtransaction = $osC_Database->query('insert into :table_orders_transactions_history (orders_id, transaction_code, transaction_return_value, transaction_return_status, date_added) values (:orders_id, :transaction_code, :transaction_return_value, :transaction_return_status, now())');            $Qtransaction->bindTable(':table_orders_transactions_history', TABLE_ORDERS_TRANSACTIONS_HISTORY);            $Qtransaction->bindInt(':orders_id', $id);            $Qtransaction->bindInt(':transaction_code', 4);            $Qtransaction->bindValue(':transaction_return_value', $osC_XML->toXML());            $Qtransaction->bindInt(':transaction_return_status', ($info['Ack'] == 'Success' ? 1 : 0));            $Qtransaction->execute();          }        }      }    }  }?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?