paypal_ipn.php
来自「this the oscommerce 3.0 aplha 4」· PHP 代码 · 共 481 行 · 第 1/3 页
PHP
481 行
return $this->_keys; }/** * Returns the available post transaction actions in an array * * @access public * @param $history An array of transaction actions already processed * @return array */ function getPostTransactionActions($history) { if ( (osc_empty(MODULE_PAYMENT_PAYPAL_IPN_API_USERNAME) === false) && (osc_empty(MODULE_PAYMENT_PAYPAL_IPN_API_PASSWORD) === false) && (osc_empty(MODULE_PAYMENT_PAYPAL_IPN_API_CERTIFICATE) === false) ) { $actions = array(4 => 'inquiryTransaction'); if ( (in_array('2', $history) === false) && (in_array('3', $history) === false) ) { $actions[2] = 'cancelTransaction'; $actions[3] = 'approveTransaction'; } return $actions; } return false; }/** * Approves the transaction at the gateway server * * @access public * @param $id The ID of the order */ function approveTransaction($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> <DoCaptureReq xmlns="urn:ebay:api:PayPalAPI"> <DoCaptureRequest xmlns="urn:ebay:api:PayPalAPI"> <Version xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="xsd:string">1.0</Version> <AuthorizationID>' . $result['root']['auth_id'] . '</AuthorizationID> <Amount currencyID="' . $result['root']['mc_currency'] . '" xsi:type="cc:BasicAmountType">' . $result['root']['mc_gross'] . '</Amount> <CompleteType>Complete</CompleteType> </DoCaptureRequest> </DoCaptureReq> </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']['DoCaptureResponse'])) { $info = $result['SOAP-ENV:Envelope']['SOAP-ENV:Body']['DoCaptureResponse']; $result =& $info['DoCaptureResponseDetails']; if ($info['Ack'] == 'Success') { $data = array('root' => array('AuthorizationID' => $result['AuthorizationID'], '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'], 'FeeAmount' => $result['PaymentInfo']['FeeAmount'], 'FeeAmountCurrencyID' => $result['PaymentInfo']['FeeAmount 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']))); } 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', 3); $Qtransaction->bindValue(':transaction_return_value', $osC_XML->toXML()); $Qtransaction->bindInt(':transaction_return_status', ($info['Ack'] == 'Success' ? 1 : 0)); $Qtransaction->execute(); } } } }/** * Cancels the transaction at the gateway server * * @access public * @param $id The ID of the order */ function cancelTransaction($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> <DoVoidReq xmlns="urn:ebay:api:PayPalAPI"> <DoVoidRequest xmlns="urn:ebay:api:PayPalAPI"> <Version xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="xsd:string">1.0</Version> <AuthorizationID>' . $result['root']['auth_id'] . '</AuthorizationID> </DoVoidRequest> </DoVoidReq> </SOAP-ENV:Body> </SOAP-ENV:Envelope>'; $result = $this->sendTransactionToGateway($this->_gateway_server, $string, '', 'post', MODULE_PAYMENT_PAYPAL_IPN_API_CERTIFICATE);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?