├── tests ├── .gitkeep ├── Assets │ ├── PM_700000000000001_acp.pfx │ └── verify_sign_acp.cer ├── bootstrap.php ├── LegacyQuickPayGatewayTest.php ├── LegacyMobileGatewayTest.php └── ExpressGatewayTest.php ├── .gitignore ├── .travis.yml ├── src ├── Message │ ├── ExpressResponse.php │ ├── ExpressCompletePurchaseResponse.php │ ├── LegacyCompletePurchaseResponse.php │ ├── LegacyMobilePurchaseResponse.php │ ├── AbstractLegacyMobileRequest.php │ ├── AbstractLegacyQuickPayRequest.php │ ├── LegacyQuickPayPurchaseResponse.php │ ├── ExpressQueryRequest.php │ ├── ExpressCompletePurchaseRequest.php │ ├── ExpressPurchaseResponse.php │ ├── LegacyCompletePurchaseRequest.php │ ├── ExpressRefundRequest.php │ ├── ExpressConsumeUndoRequest.php │ ├── ExpressFileTransferRequest.php │ ├── LegacyMobilePurchaseRequest.php │ ├── LegacyQuickPayPurchaseRequest.php │ ├── ExpressPurchaseRequest.php │ ├── AbstractLegacyRequest.php │ ├── BaseAbstractRequest.php │ └── AbstractExpressRequest.php ├── LegacyMobileGateway.php ├── LegacyQuickPayGateway.php ├── AbstractLegacyGateway.php ├── Helper.php └── ExpressGateway.php ├── CONTRIBUTING.md ├── composer.json ├── phpunit.xml.dist ├── LICENSE └── README.md /tests/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | /public 3 | /.idea 4 | composer.lock 5 | composer.phar 6 | phpunit.xml 7 | -------------------------------------------------------------------------------- /tests/Assets/PM_700000000000001_acp.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hubs/omnipay-unionpay/master/tests/Assets/PM_700000000000001_acp.pfx -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | php: 4 | - 5.3 5 | - 5.4 6 | - 5.5 7 | - 5.6 8 | 9 | before_script: 10 | - composer install -n --dev --prefer-source 11 | 12 | script: vendor/bin/phpcs --standard=PSR2 src && vendor/bin/phpunit --coverage-text 13 | -------------------------------------------------------------------------------- /tests/bootstrap.php: -------------------------------------------------------------------------------- 1 | add('Omnipay', __DIR__); 10 | -------------------------------------------------------------------------------- /src/Message/ExpressResponse.php: -------------------------------------------------------------------------------- 1 | data['respCode']) && $this->data['respCode'] == '00'; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | * Fork the project. 4 | * Make your feature addition or bug fix. 5 | * Add tests for it. This is important so I don't break it in a future version unintentionally. 6 | * Commit just the modifications, do not mess with the composer.json or CHANGELOG.md files. 7 | * Ensure your code is nicely formatted in the [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) 8 | style and that all tests pass. 9 | * Send the pull request. 10 | * Check that the Travis CI build passed. If not, rinse and repeat. 11 | -------------------------------------------------------------------------------- /src/Message/ExpressCompletePurchaseResponse.php: -------------------------------------------------------------------------------- 1 | data['is_paid']; 17 | } 18 | 19 | 20 | /** 21 | * Is the response successful? 22 | * 23 | * @return boolean 24 | */ 25 | public function isSuccessful() 26 | { 27 | return $this->data['verify_success']; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Message/LegacyCompletePurchaseResponse.php: -------------------------------------------------------------------------------- 1 | data['is_paid']; 17 | } 18 | 19 | 20 | /** 21 | * Is the response successful? 22 | * 23 | * @return boolean 24 | */ 25 | public function isSuccessful() 26 | { 27 | return $this->data['verify_success']; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lokielse/omnipay-unionpay", 3 | "type": "library", 4 | "description": "UnionPay gateway for Omnipay payment processing library", 5 | "keywords": [ 6 | "union", 7 | "unionpay", 8 | "gateway", 9 | "merchant", 10 | "omnipay", 11 | "pay", 12 | "payment", 13 | "purchase", 14 | "银联" 15 | ], 16 | "homepage": "https://github.com/lokielse/omnipay-unionpay", 17 | "license": "MIT", 18 | "authors": [ 19 | { 20 | "name": "Loki Else", 21 | "email": "lokielse@gmail.com" 22 | } 23 | ], 24 | "autoload": { 25 | "psr-4": { 26 | "Omnipay\\UnionPay\\": "src/" 27 | } 28 | }, 29 | "require": { 30 | "omnipay/common": "~2.0" 31 | }, 32 | "require-dev": { 33 | "omnipay/tests": "~2.0" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/LegacyMobileGateway.php: -------------------------------------------------------------------------------- 1 | createRequest('\Omnipay\UnionPay\Message\LegacyMobilePurchaseRequest', $parameters); 26 | } 27 | 28 | 29 | public function completePurchase(array $parameters = array ()) 30 | { 31 | return $this->createRequest('\Omnipay\UnionPay\Message\LegacyCompletePurchaseRequest', $parameters); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/LegacyQuickPayGateway.php: -------------------------------------------------------------------------------- 1 | createRequest('\Omnipay\UnionPay\Message\LegacyQuickPayPurchaseRequest', $parameters); 26 | } 27 | 28 | 29 | public function completePurchase(array $parameters = array ()) 30 | { 31 | return $this->createRequest('\Omnipay\UnionPay\Message\LegacyCompletePurchaseRequest', $parameters); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Message/LegacyMobilePurchaseResponse.php: -------------------------------------------------------------------------------- 1 | data; 30 | } 31 | 32 | 33 | public function getTradeNo() 34 | { 35 | if (isset($this->data['tn'])) { 36 | return $this->data['tn']; 37 | } else { 38 | return null; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | ./tests/ 15 | 16 | 17 | 18 | 20 | 21 | 22 | 23 | ./src 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/Message/AbstractLegacyMobileRequest.php: -------------------------------------------------------------------------------- 1 | array( 14 | 'trade' => 'http://222.66.233.198:8080/gateway/merchant/trade', 15 | 'query' => 'http://222.66.233.198:8080/gateway/merchant/query', 16 | ), 17 | 'production' => array( 18 | 'trade' => 'https://mgate.unionpay.com/gateway/merchant/trade', 19 | 'query' => 'https://mgate.unionpay.com/gateway/merchant/query', 20 | ), 21 | ); 22 | 23 | 24 | public function getOrderTimeout() 25 | { 26 | return $this->getParameter('orderTimeout'); 27 | } 28 | 29 | 30 | public function setOrderTimeout($value) 31 | { 32 | return $this->setParameter('orderTimeout', $value); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016-2017 Loki Else 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /src/Message/AbstractLegacyQuickPayRequest.php: -------------------------------------------------------------------------------- 1 | array( 14 | 'front' => 'http://202.101.25.184/UpopWeb/api/Pay.action', 15 | 'back' => 'http://202.101.25.184/UpopWeb/api/BSPay.action', 16 | 'query' => 'http://202.101.25.184/UpopWeb/api/Query.action', 17 | ), 18 | 'staging' => array( 19 | 'front' => 'https://www.epay.lxdns.com/UpopWeb/api/Pay.action', 20 | 'back' => 'https://www.epay.lxdns.com/UpopWeb/api/BSPay.action', 21 | 'query' => 'https://www.epay.lxdns.com/UpopWeb/api/Query.action', 22 | ), 23 | 'production' => array( 24 | 'front' => 'https://unionpaysecure.com/api/Pay.action', 25 | 'back' => 'https://besvr.unionpaysecure.com/api/BSPay.action', 26 | 'query' => 'https://query.unionpaysecure.com/api/Query.action', 27 | ), 28 | ); 29 | } 30 | -------------------------------------------------------------------------------- /tests/Assets/verify_sign_acp.cer: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIEOjCCA6OgAwIBAgIQAp05hXtzN+zGp6RHK8FdhjANBgkqhkiG9w0BAQUFADAk 3 | MQswCQYDVQQGEwJDTjEVMBMGA1UEChMMQ0ZDQSBURVNUIENBMB4XDTEyMDkwNzA4 4 | MzQ1NloXDTEzMDkwNzA4MzQ1NlowfDELMAkGA1UEBhMCQ04xFTATBgNVBAoTDENG 5 | Q0EgVEVTVCBDQTERMA8GA1UECxMITG9jYWwgUkExFDASBgNVBAsTC0VudGVycHJp 6 | c2VzMS0wKwYDVQQDFCQwNDFAWjIwMTItOS03QDAwMDQ5OTk5OlNJR05AMDAwMDAw 7 | NTcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC7VU6b07MNQxHwxM2E 8 | 1ymje/FxXLJhQTcwsKHHnq88KBcS8q1oz5fOMmuJ50zGlYfKEAbrZXlKKIdZtaqz 9 | Bs9ISXkLj3ZfYxUDLpJU2HdVb7DKNuVcCTSauRHMwYee2V8RTAmN/MrYVUe3b5J+ 10 | mpymmFXfvYdCprCC6a1F3yRvTOMVWFhREx4NlIRSuiOuQTtpEgBNFxa/h6xBYJnQ 11 | PLpgQH4cmiQJvXB0g6SBRMMCoHb3rTo97W7SWbiDoflmAkFYgfSdD8Qh+8hqo1QB 12 | C1EDAWE+GiGHhcXjsQbVq6bL4b7JHb4iSEyCQvcKcCrIcOGM+HVS08wFsg89lsK1 13 | RbJnAgMBAAGjggGPMIIBizAfBgNVHSMEGDAWgBRGctwlcp8CTlWDtYD5C9vpk7P0 14 | RTAdBgNVHQ4EFgQUhscavD0jmCmKd6n0W1NIfTIfFLowCwYDVR0PBAQDAgTwMAwG 15 | A1UdEwQFMAMBAQAwOwYDVR0lBDQwMgYIKwYBBQUHAwEGCCsGAQUFBwMCBggrBgEF 16 | BQcDAwYIKwYBBQUHAwQGCCsGAQUFBwMIMIHwBgNVHR8EgegwgeUwT6BNoEukSTBH 17 | MQswCQYDVQQGEwJDTjEVMBMGA1UEChMMQ0ZDQSBURVNUIENBMQwwCgYDVQQLEwND 18 | UkwxEzARBgNVBAMTCmNybDEyN18yMzgwgZGggY6ggYuGgYhsZGFwOi8vdGVzdGxk 19 | YXAuY2ZjYS5jb20uY246Mzg5L0NOPWNybDEyN18yMzgsT1U9Q1JMLE89Q0ZDQSBU 20 | RVNUIENBLEM9Q04/Y2VydGlmaWNhdGVSZXZvY2F0aW9uTGlzdD9iYXNlP29iamVj 21 | dGNsYXNzPWNSTERpc3RyaWJ1dGlvblBvaW50MA0GCSqGSIb3DQEBBQUAA4GBABaV 22 | 4RvJ+dQPr7sOANet1TYW5EbEKhKozrYvkX46ImJJUsnxYO/2ZStccJkR4F32q0gp 23 | WHusJbDoVwbMJPCYer3NJgYikkx22Foy5wlaoFBVBDHjownHZdb+qGjAEFc4KwyS 24 | 82rDuGyt6zvVVe1kaABnZhuOYKMHG9sycoVRskQO 25 | -----END CERTIFICATE----- 26 | -------------------------------------------------------------------------------- /src/Message/LegacyQuickPayPurchaseResponse.php: -------------------------------------------------------------------------------- 1 | getRequest()->getEndpoint('front'); 31 | } 32 | 33 | 34 | public function getRedirectMethod() 35 | { 36 | return 'POST'; 37 | } 38 | 39 | 40 | public function getRedirectData() 41 | { 42 | return $this->data; 43 | } 44 | 45 | 46 | public function getRedirectHtml() 47 | { 48 | $action = $this->getRequest()->getEndpoint('front'); 49 | $fields = $this->getFormFields(); 50 | $method = $this->getRedirectMethod(); 51 | 52 | $html = << 54 | 55 | 56 | 跳转中... 57 | 58 | 59 |
60 | {$fields} 61 |
62 | 63 | 64 | eot; 65 | 66 | return $html; 67 | } 68 | 69 | 70 | public function getFormFields() 71 | { 72 | $html = ''; 73 | foreach ($this->data as $key => $value) { 74 | $html .= "\n"; 75 | } 76 | 77 | return $html; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/Message/ExpressQueryRequest.php: -------------------------------------------------------------------------------- 1 | validate('certPath', 'certPassword', 'orderId', 'txnTime', 'txnAmt'); 24 | 25 | $data = array( 26 | 'version' => $this->getVersion(), 27 | 'encoding' => $this->getEncoding(), 28 | 'certId' => $this->getCertId(), 29 | 'signMethod' => $this->getSignMethod(), 30 | 'txnType' => '00', 31 | 'txnSubType' => '00', 32 | 'bizType' => $this->getBizType(), 33 | 'accessType' => $this->getAccessType(), 34 | 'channelType' => $this->getChannelType(), 35 | 'orderId' => $this->getOrderId(), 36 | 'merId' => $this->getMerId(), 37 | 'txnTime' => $this->getTxnTime(), 38 | ); 39 | 40 | $data = Helper::filterData($data); 41 | 42 | $data['signature'] = Helper::getParamsSignatureWithRSA($data, $this->getCertPath(), $this->getCertPassword()); 43 | 44 | return $data; 45 | } 46 | 47 | 48 | /** 49 | * Send the request with specified data 50 | * 51 | * @param mixed $data The data to send 52 | * 53 | * @return ResponseInterface 54 | */ 55 | public function sendData($data) 56 | { 57 | 58 | $data = $this->httpRequest('query', $data); 59 | 60 | return $this->response = new ExpressResponse($this, $data); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /tests/LegacyQuickPayGatewayTest.php: -------------------------------------------------------------------------------- 1 | gateway = Omnipay::create('UnionPay_LegacyQuickPay'); 24 | $this->gateway->setMerId('123456789'); 25 | $this->gateway->setSecretKey('xxxxxxx'); 26 | $this->gateway->setReturnUrl('http://example.com/return'); 27 | $this->gateway->setNotifyUrl('http://example.com/notify'); 28 | $this->gateway->setEnvironment('production'); 29 | 30 | } 31 | 32 | 33 | public function testPurchase() 34 | { 35 | $order = array ( 36 | 'orderNumber' => date('YmdHis'), //Your order ID 37 | 'orderTime' => date('YmdHis'), //Should be format 'YmdHis' 38 | 'title' => 'My order title', //Order Title 39 | 'orderAmount' => '100', //Order Total Fee 40 | ); 41 | 42 | /** 43 | * @var PurchaseResponse $response 44 | */ 45 | $response = $this->gateway->purchase($order)->send(); 46 | $this->assertTrue($response->isSuccessful()); 47 | $this->assertTrue($response->isRedirect()); 48 | } 49 | 50 | 51 | public function testCompletePurchase() 52 | { 53 | $options = array ( 54 | 'request_params' => array ( 55 | 'certId' => '3474813271258769001041842579301293446', 56 | 'signature' => 'xxxxxxx' 57 | ), 58 | ); 59 | 60 | /** 61 | * @var PurchaseResponse $response 62 | */ 63 | $response = $this->gateway->completePurchase($options)->send(); 64 | $this->assertFalse($response->isSuccessful()); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Message/ExpressCompletePurchaseRequest.php: -------------------------------------------------------------------------------- 1 | getRequestParams(); 24 | } 25 | 26 | 27 | public function setRequestParams($value) 28 | { 29 | $this->setParameter('request_params', $value); 30 | } 31 | 32 | 33 | public function getRequestParams() 34 | { 35 | return $this->getParameter('request_params'); 36 | } 37 | 38 | 39 | public function setCertDir($value) 40 | { 41 | $this->setParameter('certDir', $value); 42 | } 43 | 44 | 45 | public function getCertDir() 46 | { 47 | return $this->getParameter('certDir'); 48 | } 49 | 50 | 51 | public function getRequestParam($key) 52 | { 53 | $params = $this->getRequestParams(); 54 | if (isset($params[$key])) { 55 | return $params[$key]; 56 | } else { 57 | return null; 58 | } 59 | } 60 | 61 | 62 | /** 63 | * Send the request with specified data 64 | * 65 | * @param mixed $data The data to send 66 | * 67 | * @return ResponseInterface 68 | */ 69 | public function sendData($data) 70 | { 71 | $data['verify_success'] = Helper::verify($this->getRequestParams(), $this->getCertDir()); 72 | $data['is_paid'] = $data['verify_success'] && ($this->getRequestParam('respCode') == '00'); 73 | 74 | return $this->response = new ExpressCompletePurchaseResponse($this, $data); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /tests/LegacyMobileGatewayTest.php: -------------------------------------------------------------------------------- 1 | gateway = Omnipay::create('UnionPay_LegacyMobile'); 24 | $this->gateway->setMerId('123456789'); 25 | $this->gateway->setSecretKey('xxxxxxx'); 26 | $this->gateway->setReturnUrl('http://example.com/return'); 27 | $this->gateway->setNotifyUrl('http://example.com/notify'); 28 | $this->gateway->setEnvironment('production'); 29 | 30 | } 31 | 32 | 33 | public function testPurchase() 34 | { 35 | $order = array ( 36 | 'orderNumber' => date('YmdHis'), //Your order ID 37 | 'orderTime' => date('YmdHis'), //Should be format 'YmdHis' 38 | 'title' => 'My order title', //Order Title 39 | 'orderAmount' => '100', //Order Total Fee 40 | ); 41 | 42 | /** 43 | * @var PurchaseResponse $response 44 | */ 45 | $response = $this->gateway->purchase($order)->send(); 46 | $this->assertTrue($response->isSuccessful()); 47 | $this->assertFalse($response->isRedirect()); 48 | $this->assertNull($response->getTradeNo()); 49 | } 50 | 51 | 52 | public function testCompletePurchase() 53 | { 54 | $options = array ( 55 | 'request_params' => array ( 56 | 'certId' => '3474813271258769001041842579301293446', 57 | 'signature' => 'xxxxxxx' 58 | ), 59 | ); 60 | 61 | /** 62 | * @var PurchaseResponse $response 63 | */ 64 | $response = $this->gateway->completePurchase($options)->send(); 65 | $this->assertFalse($response->isSuccessful()); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/Message/ExpressPurchaseResponse.php: -------------------------------------------------------------------------------- 1 | getRequest()->getEndpoint('front'); 31 | } 32 | 33 | 34 | public function getRedirectMethod() 35 | { 36 | return 'POST'; 37 | } 38 | 39 | 40 | public function getRedirectData() 41 | { 42 | return $this->data; 43 | } 44 | 45 | 46 | public function getRedirectHtml() 47 | { 48 | $action = $this->getRequest()->getEndpoint('front'); 49 | $fields = $this->getFormFields(); 50 | $method = $this->getRedirectMethod(); 51 | 52 | $html = << 54 | 55 | 56 | 跳转中... 57 | 58 | 59 |
60 | {$fields} 61 |
62 | 63 | 64 | eot; 65 | 66 | return $html; 67 | } 68 | 69 | 70 | public function getFormFields() 71 | { 72 | $html = ''; 73 | foreach ($this->data as $key => $value) { 74 | $html .= "\n"; 75 | } 76 | 77 | return $html; 78 | } 79 | 80 | 81 | public function getTradeNo() 82 | { 83 | $endpoint = $this->getRequest()->getEndpoint('app'); 84 | 85 | $result = Helper::sendHttpRequest($endpoint, $this->data); 86 | 87 | parse_str($result, $data); 88 | 89 | if (is_array($data) && isset($data['tn'])) { 90 | return $data['tn']; 91 | } else { 92 | return null; 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/Message/LegacyCompletePurchaseRequest.php: -------------------------------------------------------------------------------- 1 | validateData(); 24 | 25 | return $this->getParameters(); 26 | } 27 | 28 | 29 | private function validateData() 30 | { 31 | $this->validate( 32 | 'request_params' 33 | ); 34 | } 35 | 36 | 37 | public function setRequestParams($value) 38 | { 39 | $this->setParameter('request_params', $value); 40 | } 41 | 42 | 43 | public function getRequestParams() 44 | { 45 | return $this->getParameter('request_params'); 46 | } 47 | 48 | 49 | public function getRequestParam($key) 50 | { 51 | $params = $this->getRequestParams(); 52 | if (isset($params[$key])) { 53 | return $params[$key]; 54 | } else { 55 | return null; 56 | } 57 | } 58 | 59 | 60 | /** 61 | * Send the request with specified data 62 | * 63 | * @param mixed $data The data to send 64 | * 65 | * @return ResponseInterface 66 | */ 67 | public function sendData($data) 68 | { 69 | 70 | $data['verify_success'] = $this->isSignMatch(); 71 | $data['is_paid'] = $data['verify_success'] && ($this->getRequestParam('respCode') == '00'); 72 | 73 | return $this->response = new LegacyCompletePurchaseResponse($this, $data); 74 | } 75 | 76 | 77 | protected function isSignMatch() 78 | { 79 | $requestSign = $this->getRequestParam('signature'); 80 | 81 | $query = Helper::getStringToSign($this->getParamsToSign()); 82 | 83 | return $requestSign === md5($query . '&' . md5($this->getSecretKey())); 84 | } 85 | 86 | 87 | private function getParamsToSign() 88 | { 89 | $data = $this->getRequestParams(); 90 | 91 | unset($data['signature']); 92 | unset($data['signMethod']); 93 | unset($data['bank']); 94 | 95 | return $data; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/Message/ExpressRefundRequest.php: -------------------------------------------------------------------------------- 1 | validate('certPath', 'certPassword', 'orderId', 'txnTime', 'txnAmt', 'queryId'); 24 | 25 | $data = array( 26 | 'version' => $this->getVersion(), //版本号 27 | 'encoding' => $this->getEncoding(), //编码方式 28 | 'certId' => $this->getCertId(), //证书ID 29 | 'signMethod' => $this->getSignMethod(), //签名方法 30 | 'txnType' => '04', //交易类型 31 | 'txnSubType' => '00', //交易子类 32 | 'bizType' => $this->getBizType(), //业务类型 33 | 'accessType' => $this->getAccessType(), //接入类型 34 | 'channelType' => $this->getChannelType(), //渠道类型 35 | 'orderId' => $this->getOrderId(), //商户订单号,重新产生,不同于原消费 36 | 'merId' => $this->getMerId(), //商户代码,请改成自己的测试商户号 37 | 'origQryId' => $this->getQueryId(), 38 | //原消费的queryId,可以从查询接口或者通知接口中获取 39 | 'txnTime' => $this->getTxnTime(), //订单发送时间,重新产生,不同于原消费 40 | 'txnAmt' => $this->getTxnAmt(), //交易金额,消费撤销时需和原消费一致 41 | 'backUrl' => $this->getNotifyUrl(), //后台通知地址 42 | 'reqReserved' => $this->getReqReserved(), 43 | //请求方保留域,透传字段,查询、通知、对账文件中均会原样出现 44 | ); 45 | 46 | $data = Helper::filterData($data); 47 | 48 | $data['signature'] = Helper::getParamsSignatureWithRSA($data, $this->getCertPath(), $this->getCertPassword()); 49 | 50 | return $data; 51 | } 52 | 53 | 54 | public function getQueryId() 55 | { 56 | return $this->getParameter('queryId'); 57 | } 58 | 59 | 60 | public function setQueryId($value) 61 | { 62 | $this->setParameter('queryId', $value); 63 | } 64 | 65 | 66 | /** 67 | * Send the request with specified data 68 | * 69 | * @param mixed $data The data to send 70 | * 71 | * @return ResponseInterface 72 | */ 73 | public function sendData($data) 74 | { 75 | 76 | $data = $this->httpRequest('back', $data); 77 | 78 | return $this->response = new ExpressResponse($this, $data); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/Message/ExpressConsumeUndoRequest.php: -------------------------------------------------------------------------------- 1 | validate('certPath', 'certPassword', 'orderId', 'txnTime', 'txnAmt', 'queryId'); 24 | 25 | $data = array( 26 | 'version' => $this->getVersion(), //版本号 27 | 'encoding' => $this->getEncoding(), //编码方式 28 | 'certId' => $this->getCertId(), //证书ID 29 | 'signMethod' => $this->getSignMethod(), //签名方法 30 | 'txnType' => '31', //交易类型 31 | 'txnSubType' => '00', //交易子类 32 | 'bizType' => $this->getBizType(), //业务类型 33 | 'accessType' => $this->getAccessType(), //接入类型 34 | 'channelType' => $this->getChannelType(), //渠道类型 35 | 'orderId' => $this->getOrderId(), //商户订单号,重新产生,不同于原消费 36 | 'merId' => $this->getMerId(), //商户代码,请改成自己的测试商户号 37 | 'origQryId' => $this->getQueryId(), 38 | //原消费的queryId,可以从查询接口或者通知接口中获取 39 | 'txnTime' => $this->getTxnTime(), //订单发送时间,重新产生,不同于原消费 40 | 'txnAmt' => $this->getTxnAmt(), //交易金额,消费撤销时需和原消费一致 41 | 'backUrl' => $this->getNotifyUrl(), //后台通知地址 42 | 'reqReserved' => $this->getReqReserved(), 43 | //请求方保留域,透传字段,查询、通知、对账文件中均会原样出现 44 | ); 45 | 46 | $data = Helper::filterData($data); 47 | 48 | $data['signature'] = Helper::getParamsSignatureWithRSA( 49 | $data, 50 | $this->getCertPath(), 51 | $this->getCertPassword() 52 | ); 53 | 54 | return $data; 55 | } 56 | 57 | 58 | public function getQueryId() 59 | { 60 | $this->getParameter('queryId'); 61 | } 62 | 63 | 64 | public function setQueryId($value) 65 | { 66 | $this->setParameter('queryId', $value); 67 | } 68 | 69 | 70 | /** 71 | * Send the request with specified data 72 | * 73 | * @param mixed $data The data to send 74 | * 75 | * @return ResponseInterface 76 | */ 77 | public function sendData($data) 78 | { 79 | 80 | $data = $this->httpRequest('back', $data); 81 | 82 | return $this->response = new ExpressResponse($this, $data); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/Message/ExpressFileTransferRequest.php: -------------------------------------------------------------------------------- 1 | validate('certPath', 'certPassword', 'txnTime', 'fileType', 'settleDate'); 24 | 25 | $data = array ( 26 | 'version' => $this->getVersion(), //版本号 27 | 'encoding' => $this->getEncoding(), //编码方式 28 | 'certId' => $this->getCertId(), //证书ID 29 | 'txnType' => '76', //交易类型 30 | 'signMethod' => $this->getSignMethod(), //签名方法 31 | 'txnSubType' => '01', //交易子类 32 | 'bizType' => '000000', //业务类型 33 | 'accessType' => '0', //接入类型 34 | 'merId' => $this->getMerId(), //商户代码 35 | 'settleDate' => '0119', //清算日期 36 | 'txnTime' => $this->getTxnTime(), //订单发送时间 37 | 'fileType' => $this->getFileType(), //文件类型 38 | ); 39 | 40 | $data = Helper::filterData($data); 41 | 42 | $data['signature'] = Helper::getParamsSignatureWithRSA($data, $this->getCertPath(), $this->getCertPassword()); 43 | 44 | return $data; 45 | } 46 | 47 | 48 | public function getFileType() 49 | { 50 | return $this->getParameter('fileType'); 51 | } 52 | 53 | 54 | public function setQueryId($value) 55 | { 56 | $this->setParameter('queryId', $value); 57 | } 58 | 59 | 60 | public function getQueryId() 61 | { 62 | return $this->getParameter('queryId'); 63 | } 64 | 65 | 66 | public function setSettleDate($value) 67 | { 68 | $this->setParameter('settleDate', $value); 69 | } 70 | 71 | 72 | public function getSettleDate() 73 | { 74 | return $this->getParameter('settleDate'); 75 | } 76 | 77 | 78 | public function setFileType($value) 79 | { 80 | $this->setParameter('fileType', $value); 81 | } 82 | 83 | 84 | /** 85 | * Send the request with specified data 86 | * 87 | * @param mixed $data The data to send 88 | * 89 | * @return ResponseInterface 90 | */ 91 | public function sendData($data) 92 | { 93 | 94 | $data = $this->httpRequest('back', $data); 95 | 96 | return $this->response = new ExpressResponse($this, $data); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/Message/LegacyMobilePurchaseRequest.php: -------------------------------------------------------------------------------- 1 | validateData(); 24 | 25 | $data = array ( 26 | 'version' => $this->getVersion(), 27 | 'charset' => $this->getEncoding(), 28 | 'transType' => $this->getTransType(), 29 | 'merId' => $this->getMerId(), 30 | 'backEndUrl' => $this->getNotifyUrl(), 31 | 'frontEndUrl' => $this->getReturnUrl(), 32 | 'orderDescription' => $this->getTitle(), 33 | 'orderTime' => $this->getOrderTime(), 34 | 'orderTimeout' => $this->getOrderTimeout(), 35 | 'orderNumber' => $this->getOrderNumber(), 36 | 'orderAmount' => $this->getOrderAmount(), 37 | 'orderCurrency' => $this->getOrderCurrency(), 38 | 'reqReserved' => '', 39 | ); 40 | 41 | $data = Helper::filterData($data); 42 | 43 | $data['signature'] = Helper::getParamsSignatureWithMD5($data, $this->getSecretKey()); 44 | $data['signMethod'] = 'md5'; 45 | 46 | return $data; 47 | } 48 | 49 | 50 | private function validateData() 51 | { 52 | $this->validate( 53 | 'version', 54 | 'encoding', 55 | 'transType', 56 | 'merId', 57 | //'returnUrl', 58 | 'notifyUrl', 59 | 'title', 60 | 'orderTime', 61 | //'orderTimeout', 62 | 'orderNumber', 63 | 'orderAmount', 64 | 'orderCurrency', 65 | 'secretKey', 66 | 'environment' 67 | ); 68 | } 69 | 70 | 71 | /** 72 | * Send the request with specified data 73 | * 74 | * @param mixed $data The data to send 75 | * 76 | * @return ResponseInterface 77 | */ 78 | public function sendData($data) 79 | { 80 | 81 | $endpoint = $this->getEndpoint('trade'); 82 | 83 | $result = Helper::sendHttpRequest($endpoint, $data); 84 | 85 | parse_str($result, $data); 86 | 87 | if (! is_array($data)) { 88 | $data = array(); 89 | } 90 | 91 | return $this->response = new LegacyMobilePurchaseResponse($this, $data); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/Message/LegacyQuickPayPurchaseRequest.php: -------------------------------------------------------------------------------- 1 | validateData(); 24 | 25 | $data = array ( 26 | 'version' => $this->getVersion(), 27 | 'charset' => $this->getEncoding(), //UTF-8, GBK等 28 | 'merId' => $this->getMerId(), //无卡商户填写 29 | 'merAbbr' => $this->getMerAbbr(), //商户名称 30 | 'transType' => $this->getTransType(), //交易类型,CONSUME or PRE_AUTH 31 | 'orderAmount' => $this->getOrderAmount(), //交易金额 32 | 'orderNumber' => $this->getOrderNumber(), //订单号,必须唯一 33 | 'orderTime' => $this->getOrderTime(), //交易时间, YYYYmmhhddHHMMSS 34 | 'orderCurrency' => $this->getOrderCurrency(), //交易币种,CURRENCY_CNY=>156 35 | 'customerIp' => $this->getCustomerIp(), //用户IP 36 | 'frontEndUrl' => $this->getReturnUrl(), //前台回调URL 37 | 'backEndUrl' => $this->getNotifyUrl(), //后台回调URL 38 | 'commodityUrl' => $this->getShowUrl(), 39 | 'commodityName' => $this->getTitle(), 40 | 'origQid' => '', 41 | 'acqCode' => '', 42 | 'merCode' => '', 43 | 'commodityUnitPrice' => '', 44 | 'commodityQuantity' => '', 45 | 'commodityDiscount' => '', 46 | 'transferFee' => '', 47 | 'customerName' => '', 48 | 'defaultPayType' => '', 49 | 'defaultBankNumber' => '', 50 | 'transTimeout' => '', 51 | 'merReserved' => '', 52 | ); 53 | 54 | $data = Helper::filterData($data); 55 | 56 | $data['signature'] = Helper::getParamsSignatureWithMD5($data, $this->getSecretKey()); 57 | $data['signMethod'] = 'md5'; 58 | 59 | return $data; 60 | } 61 | 62 | 63 | private function validateData() 64 | { 65 | $this->validate( 66 | 'transType', 67 | 'orderAmount', 68 | 'orderNumber', 69 | 'orderTime', 70 | 'orderCurrency', 71 | //'customerIp', 72 | 'returnUrl', 73 | 'notifyUrl', 74 | //'showUrl', 75 | 'title', 76 | 'secretKey' 77 | ); 78 | } 79 | 80 | 81 | /** 82 | * Send the request with specified data 83 | * 84 | * @param mixed $data The data to send 85 | * 86 | * @return ResponseInterface 87 | */ 88 | public function sendData($data) 89 | { 90 | return $this->response = new LegacyQuickPayPurchaseResponse($this, $data); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/Message/ExpressPurchaseRequest.php: -------------------------------------------------------------------------------- 1 | validateData(); 24 | 25 | $data = array ( 26 | //版本号 27 | 'version' => $this->getVersion(), 28 | //编码方式 29 | 'encoding' => $this->getEncoding(), 30 | //证书ID 31 | 'certId' => $this->getCertId(), 32 | //交易类型 33 | 'txnType' => $this->getTxnSubType() ?: '01', 34 | //交易子类 35 | 'txnSubType' => $this->getTxnSubType() ?: '01', 36 | //业务类型 37 | 'bizType' => $this->getBizType(), 38 | //前台通知地址 39 | 'frontUrl' => $this->getReturnUrl(), 40 | //后台通知地址 41 | 'backUrl' => $this->getNotifyUrl(), 42 | //签名方法 43 | 'signMethod' => $this->getSignMethod(), 44 | //渠道类型,07-PC,08-手机 45 | 'channelType' => $this->getChannelType(), 46 | //接入类型 47 | 'accessType' => $this->getAccessType(), 48 | //商户代码,请改自己的测试商户号 49 | 'merId' => $this->getMerId(), 50 | //商户订单号 51 | 'orderId' => $this->getOrderId(), 52 | //订单发送时间 53 | 'txnTime' => $this->getTxnTime(), 54 | //交易金额,单位分 55 | 'txnAmt' => $this->getTxnAmt(), 56 | //交易币种 57 | 'currencyCode' => $this->getCurrencyCode(), 58 | //默认支付方式 59 | 'defaultPayType' => $this->getDefaultPayType(), 60 | //订单描述,网关支付和wap支付暂时不起作用 61 | 'orderDesc' => $this->getOrderDesc(), 62 | //请求方保留域,透传字段,查询、通知、对账文件中均会原样出现 63 | 'reqReserved' => $this->getReqReserved(), 64 | ); 65 | 66 | $data = Helper::filterData($data); 67 | 68 | $data['signature'] = Helper::getParamsSignatureWithRSA($data, $this->getCertPath(), $this->getCertPassword()); 69 | 70 | return $data; 71 | } 72 | 73 | 74 | private function validateData() 75 | { 76 | $this->validate( 77 | 'certPath', 78 | 'certPassword', 79 | 'returnUrl', 80 | 'notifyUrl', 81 | 'merId', 82 | 'orderId', 83 | 'txnTime', 84 | 'orderDesc', 85 | 'txnAmt' 86 | ); 87 | } 88 | 89 | 90 | /** 91 | * Send the request with specified data 92 | * 93 | * @param mixed $data The data to send 94 | * 95 | * @return ResponseInterface 96 | */ 97 | public function sendData($data) 98 | { 99 | return $this->response = new ExpressPurchaseResponse($this, $data); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /tests/ExpressGatewayTest.php: -------------------------------------------------------------------------------- 1 | gateway = Omnipay::create('UnionPay_Express'); 24 | $this->gateway->setMerId('123456789'); 25 | $this->gateway->setCertDir(__DIR__ . '/Assets/'); // .pfx file 26 | $this->gateway->setCertPath(__DIR__ . '/Assets/PM_700000000000001_acp.pfx'); // .pfx file 27 | $this->gateway->setCertPassword('000000'); 28 | $this->gateway->setReturnUrl('http://example.com/return'); 29 | $this->gateway->setNotifyUrl('http://example.com/notify'); 30 | 31 | } 32 | 33 | 34 | public function testPurchase() 35 | { 36 | $order = array ( 37 | 'orderId' => date('YmdHis'), //Your order ID 38 | 'txnTime' => date('YmdHis'), //Should be format 'YmdHis' 39 | 'title' => 'My order title', //Order Title 40 | 'txnAmt' => '100', //Order Total Fee 41 | ); 42 | 43 | /** 44 | * @var PurchaseResponse $response 45 | */ 46 | $response = $this->gateway->purchase($order)->send(); 47 | $this->assertTrue($response->isSuccessful()); 48 | $this->assertTrue($response->isRedirect()); 49 | $this->assertNotEmpty($response->getRedirectHtml()); 50 | } 51 | 52 | 53 | public function testCompletePurchase() 54 | { 55 | $options = array ( 56 | 'request_params' => array ( 57 | 'certId' => '3474813271258769001041842579301293446', 58 | 'signature' => 'xxxxxxx' 59 | ), 60 | ); 61 | 62 | /** 63 | * @var PurchaseResponse $response 64 | */ 65 | $response = $this->gateway->completePurchase($options)->send(); 66 | $this->assertFalse($response->isSuccessful()); 67 | } 68 | 69 | 70 | public function testQuery() 71 | { 72 | $options = array ( 73 | 'certId' => '3474813271258769001041842579301293446', 74 | 'orderId' => 'xxxxxxx', 75 | 'txnTime' => date('YmdHis'), 76 | 'txnAmt' => '100', 77 | ); 78 | 79 | /** 80 | * @var PurchaseResponse $response 81 | */ 82 | $response = $this->gateway->query($options)->send(); 83 | $this->assertFalse($response->isSuccessful()); 84 | } 85 | 86 | 87 | public function testConsumeUndo() 88 | { 89 | $options = array ( 90 | 'certId' => '3474813271258769001041842579301293446', 91 | 'orderId' => 'xxxxxxx', 92 | 'txnAmt' => '100', 93 | 'queryId' => 'XXXXX', 94 | 'txnTime' => date('YmdHis'), 95 | ); 96 | 97 | /** 98 | * @var PurchaseResponse $response 99 | */ 100 | $response = $this->gateway->consumeUndo($options)->send(); 101 | $this->assertFalse($response->isSuccessful()); 102 | } 103 | 104 | 105 | public function testRefund() 106 | { 107 | $options = array ( 108 | 'certId' => '3474813271258769001041842579301293446', 109 | 'orderId' => '222222', 110 | 'queryId' => '333333', 111 | 'txnTime' => date('YmdHis'), 112 | 'txnAmt' => '100', 113 | ); 114 | 115 | /** 116 | * @var PurchaseResponse $response 117 | */ 118 | $response = $this->gateway->refund($options)->send(); 119 | $this->assertFalse($response->isSuccessful()); 120 | } 121 | 122 | 123 | public function testFileTransfer() 124 | { 125 | $options = array ( 126 | 'certId' => '3474813271258769001041842579301293446', 127 | 'txnTime' => date('YmdHis'), 128 | 'fileType' => '00', 129 | 'settleDate' => '0815', 130 | ); 131 | 132 | /** 133 | * @var PurchaseResponse $response 134 | */ 135 | $response = $this->gateway->fileTransfer($options)->send(); 136 | $this->assertFalse($response->isSuccessful()); 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /src/AbstractLegacyGateway.php: -------------------------------------------------------------------------------- 1 | '1.0.0', 18 | 'encoding' => 'utf-8', 19 | 'transType' => '01', 20 | 'orderCurrency' => '156', 21 | 'environment' => 'sandbox', //dev,sandbox,staging,production 22 | ); 23 | } 24 | 25 | 26 | public function setVersion($value) 27 | { 28 | return $this->setParameter('version', $value); 29 | } 30 | 31 | 32 | public function getVersion() 33 | { 34 | return $this->getParameter('version'); 35 | } 36 | 37 | 38 | public function setEncoding($value) 39 | { 40 | return $this->setParameter('encoding', $value); 41 | } 42 | 43 | 44 | public function getEncoding() 45 | { 46 | return $this->getParameter('encoding'); 47 | } 48 | 49 | 50 | public function setReturnUrl($value) 51 | { 52 | return $this->setParameter('returnUrl', $value); 53 | } 54 | 55 | 56 | public function getReturnUrl() 57 | { 58 | return $this->getParameter('returnUrl'); 59 | } 60 | 61 | 62 | public function setNotifyUrl($value) 63 | { 64 | return $this->setParameter('notifyUrl', $value); 65 | } 66 | 67 | 68 | public function getNotifyUrl() 69 | { 70 | return $this->getParameter('notifyUrl'); 71 | } 72 | 73 | 74 | public function setChannelType($value) 75 | { 76 | return $this->setParameter('channelType', $value); 77 | } 78 | 79 | 80 | public function getChannelType() 81 | { 82 | return $this->getParameter('channelType'); 83 | } 84 | 85 | 86 | public function setAccessType($value) 87 | { 88 | return $this->setParameter('accessType', $value); 89 | } 90 | 91 | 92 | public function getAccessType() 93 | { 94 | return $this->getParameter('accessType'); 95 | } 96 | 97 | 98 | public function setMerId($value) 99 | { 100 | return $this->setParameter('merId', $value); 101 | } 102 | 103 | 104 | public function getMerId() 105 | { 106 | return $this->getParameter('merId'); 107 | } 108 | 109 | 110 | public function getMerAbbr() 111 | { 112 | return $this->getParameter('merAbbr'); 113 | } 114 | 115 | 116 | public function setMerAbbr($value) 117 | { 118 | return $this->setParameter('merAbbr', $value); 119 | } 120 | 121 | 122 | public function setCurrencyCode($value) 123 | { 124 | return $this->setParameter('currencyCode', $value); 125 | } 126 | 127 | 128 | public function getCurrencyCode() 129 | { 130 | return $this->getParameter('currencyCode'); 131 | } 132 | 133 | 134 | public function setEnvironment($value) 135 | { 136 | return $this->setParameter('environment', $value); 137 | } 138 | 139 | 140 | public function getEnvironment() 141 | { 142 | return $this->getParameter('environment'); 143 | } 144 | 145 | 146 | public function setReqReserved($value) 147 | { 148 | return $this->setParameter('reqReserved', $value); 149 | } 150 | 151 | 152 | public function getReqReserved() 153 | { 154 | return $this->getParameter('reqReserved'); 155 | } 156 | 157 | 158 | public function setDefaultPayType($value) 159 | { 160 | return $this->setParameter('defaultPayType', $value); 161 | } 162 | 163 | 164 | public function getDefaultPayType() 165 | { 166 | return $this->getParameter('defaultPayType'); 167 | } 168 | 169 | 170 | public function getSecretKey() 171 | { 172 | return $this->getParameter('secretKey'); 173 | } 174 | 175 | 176 | public function setSecretKey($value) 177 | { 178 | return $this->setParameter('secretKey', $value); 179 | } 180 | 181 | 182 | public function getTransType() 183 | { 184 | return $this->getParameter('transType'); 185 | } 186 | 187 | 188 | public function setTransType($value) 189 | { 190 | return $this->setParameter('transType', $value); 191 | } 192 | 193 | 194 | public function getOrderCurrency() 195 | { 196 | return $this->getParameter('orderCurrency'); 197 | } 198 | 199 | 200 | public function setOrderCurrency($value) 201 | { 202 | return $this->setParameter('orderCurrency', $value); 203 | } 204 | } 205 | -------------------------------------------------------------------------------- /src/Message/AbstractLegacyRequest.php: -------------------------------------------------------------------------------- 1 | getParameter('version'); 17 | } 18 | 19 | 20 | public function setVersion($value) 21 | { 22 | return $this->setParameter('version', $value); 23 | } 24 | 25 | 26 | public function getEncoding() 27 | { 28 | return $this->getParameter('encoding'); 29 | } 30 | 31 | 32 | public function setEncoding($value) 33 | { 34 | return $this->setParameter('encoding', $value); 35 | } 36 | 37 | 38 | public function getMerId() 39 | { 40 | return $this->getParameter('merId'); 41 | } 42 | 43 | 44 | public function setMerId($value) 45 | { 46 | return $this->setParameter('merId', $value); 47 | } 48 | 49 | 50 | public function getMerAbbr() 51 | { 52 | return $this->getParameter('merAbbr'); 53 | } 54 | 55 | 56 | public function setMerAbbr($value) 57 | { 58 | return $this->setParameter('merAbbr', $value); 59 | } 60 | 61 | 62 | public function getTransType() 63 | { 64 | return $this->getParameter('transType'); 65 | } 66 | 67 | 68 | public function setTransType($value) 69 | { 70 | return $this->setParameter('transType', $value); 71 | } 72 | 73 | 74 | public function getOrderAmount() 75 | { 76 | return $this->getParameter('orderAmount'); 77 | } 78 | 79 | 80 | public function setOrderAmount($value) 81 | { 82 | return $this->setParameter('orderAmount', $value); 83 | } 84 | 85 | 86 | public function getOrderNumber() 87 | { 88 | return $this->getParameter('orderNumber'); 89 | } 90 | 91 | 92 | public function setOrderNumber($value) 93 | { 94 | return $this->setParameter('orderNumber', $value); 95 | } 96 | 97 | 98 | public function getOrderTime() 99 | { 100 | return $this->getParameter('orderTime'); 101 | } 102 | 103 | 104 | public function setOrderTime($value) 105 | { 106 | return $this->setParameter('orderTime', $value); 107 | } 108 | 109 | 110 | public function getOrderCurrency() 111 | { 112 | return $this->getParameter('orderCurrency'); 113 | } 114 | 115 | 116 | public function setOrderCurrency($value) 117 | { 118 | return $this->setParameter('orderCurrency', $value); 119 | } 120 | 121 | 122 | public function getCustomerIp() 123 | { 124 | return $this->getParameter('customerIp'); 125 | } 126 | 127 | 128 | public function setCustomerIp($value) 129 | { 130 | return $this->setParameter('customerIp', $value); 131 | } 132 | 133 | 134 | public function getReturnUrl() 135 | { 136 | return $this->getParameter('returnUrl'); 137 | } 138 | 139 | 140 | public function setReturnUrl($value) 141 | { 142 | return $this->setParameter('returnUrl', $value); 143 | } 144 | 145 | 146 | public function getNotifyUrl() 147 | { 148 | return $this->getParameter('notifyUrl'); 149 | } 150 | 151 | 152 | public function setNotifyUrl($value) 153 | { 154 | return $this->setParameter('notifyUrl', $value); 155 | } 156 | 157 | 158 | public function getShowUrl() 159 | { 160 | return $this->getParameter('showUrl'); 161 | } 162 | 163 | 164 | public function setShowUrl($value) 165 | { 166 | return $this->setParameter('showUrl', $value); 167 | } 168 | 169 | 170 | public function getTitle() 171 | { 172 | return $this->getParameter('title'); 173 | } 174 | 175 | 176 | public function setTitle($value) 177 | { 178 | return $this->setParameter('title', $value); 179 | } 180 | 181 | 182 | public function getEnvironment() 183 | { 184 | return $this->getParameter('environment'); 185 | } 186 | 187 | 188 | public function setEnvironment($value) 189 | { 190 | return $this->setParameter('environment', $value); 191 | } 192 | 193 | 194 | public function getSecretKey() 195 | { 196 | return $this->getParameter('secretKey'); 197 | } 198 | 199 | 200 | public function setSecretKey($value) 201 | { 202 | return $this->setParameter('secretKey', $value); 203 | } 204 | 205 | 206 | public function getEndpoint($type) 207 | { 208 | return $this->endpoints[$this->getEnvironment()][$type]; 209 | } 210 | } 211 | -------------------------------------------------------------------------------- /src/Helper.php: -------------------------------------------------------------------------------- 1 | setMerId($config['merId']); 48 | $gateway->setCertPath($config['certPath']); // .pfx file 49 | $gateway->setCertPassword($config['certPassword']); 50 | $gateway->setReturnUrl($config['returnUrl']); 51 | $gateway->setNotifyUrl($config['notifyUrl']); 52 | 53 | $order = [ 54 | 'orderId' => date('YmdHis'), //Your order ID 55 | 'txnTime' => date('YmdHis'), //Should be format 'YmdHis' 56 | 'orderDesc' => 'My order title', //Order Title 57 | 'txnAmt' => '100', //Order Total Fee 58 | ]; 59 | 60 | $response = $gateway->purchase($order)->send(); 61 | 62 | $response->getRedirectHtml(); //For PC/Wap 63 | $response->getTradeNo(); //For APP 64 | 65 | ``` 66 | 67 | ### Return/Notify 68 | ```php 69 | $gateway = Omnipay::create('UnionPay_Express'); 70 | $gateway->setMerId($config['merId']); 71 | $gateway->setCertDir($config['certDir']); //The directory contain *.cer files 72 | $response = $gateway->completePurchase(['request_params'=>$_REQUEST])->send(); 73 | if ($response->isPaid()) { 74 | //pay success 75 | }else{ 76 | //pay fail 77 | } 78 | ``` 79 | 80 | ### Query Order Status 81 | ```php 82 | $response = $gateway->Omnipay::queryStatus([ 83 | 'orderId' => '20150815121214', //Your site trade no, not union tn. 84 | 'txnTime' => '20150815121214', //Order trade time 85 | 'txnAmt' => '200', //Order total fee 86 | ])->send(); 87 | 88 | var_dump($response->isSuccessful()); 89 | var_dump($response->getData()); 90 | ``` 91 | 92 | ### Consume Undo 93 | ```php 94 | $response = $gateway->consumeUndo([ 95 | 'orderId' => '20150815121214', //Your site trade no, not union tn. 96 | 'txnTime' => date('YmdHis'), //Regenerate a new time 97 | 'txnAmt' => '200', //Order total fee 98 | 'queryId' => 'xxxxxxxxx', //Order total fee 99 | ])->send(); 100 | 101 | var_dump($response->isSuccessful()); 102 | var_dump($response->getData()); 103 | ``` 104 | 105 | ### Refund 106 | ```php 107 | $response = $gateway->refund([ 108 | 'orderId' => '20150815121214', //Your site trade no, not union tn. 109 | 'txnTime' => '20150815121214', //Order trade time 110 | 'txnAmt' => '200', //Order total fee 111 | ])->send(); 112 | 113 | var_dump($response->isSuccessful()); 114 | var_dump($response->getData()); 115 | ``` 116 | 117 | ### File Transfer 118 | ```php 119 | $response = $gateway->fileTransfer([ 120 | 'txnTime' => '20150815121214', //Order trade time 121 | 'settleDate' => '0119', //Settle Date 122 | 'fileType' => '00', //File Type 123 | ])->send(); 124 | 125 | var_dump($response->isSuccessful()); 126 | var_dump($response->getData()); 127 | ``` 128 | 129 | 130 | For general usage instructions, please see the main [Omnipay](https://github.com/omnipay/omnipay) 131 | repository. 132 | 133 | ## Related 134 | 135 | - [Laravel-Omnipay](https://github.com/ignited/laravel-omnipay) 136 | - [Omnipay-Alipay](https://github.com/lokielse/omnipay-alipay) 137 | - [Omnipay-WechatPay](https://github.com/lokielse/omnipay-wechatpay) 138 | 139 | ## Support 140 | 141 | If you are having general issues with Omnipay, we suggest posting on 142 | [Stack Overflow](http://stackoverflow.com/). Be sure to add the 143 | [omnipay tag](http://stackoverflow.com/questions/tagged/omnipay) so it can be easily found. 144 | 145 | If you want to keep up to date with release anouncements, discuss ideas for the project, 146 | or ask more detailed questions, there is also a [mailing list](https://groups.google.com/forum/#!forum/omnipay) which 147 | you can subscribe to. 148 | 149 | If you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/lokielse/omnipay-unionpay/issues), 150 | or better yet, fork the library and submit a pull request. 151 | -------------------------------------------------------------------------------- /src/ExpressGateway.php: -------------------------------------------------------------------------------- 1 | '5.0.0', 29 | 'encoding' => 'utf-8', 30 | 'txnType' => '01', 31 | 'txnSubType' => '01', 32 | 'bizType' => '000201', 33 | 'signMethod' => '01', 34 | 'channelType' => '08', //07-PC,08-手机 35 | 'accessType' => '0', 36 | 'currencyCode' => '156', 37 | 'orderDesc' => 'an order', 38 | 'reqReserved' => '', 39 | 'defaultPayType' => '0001', 40 | 'environment' => 'sandbox', 41 | ); 42 | } 43 | 44 | 45 | public function setVersion($value) 46 | { 47 | return $this->setParameter('version', $value); 48 | } 49 | 50 | 51 | public function getVersion() 52 | { 53 | return $this->getParameter('version'); 54 | } 55 | 56 | 57 | public function setEncoding($value) 58 | { 59 | return $this->setParameter('encoding', $value); 60 | } 61 | 62 | 63 | public function getEncoding() 64 | { 65 | return $this->getParameter('encoding'); 66 | } 67 | 68 | 69 | public function setTxnType($value) 70 | { 71 | return $this->setParameter('txnType', $value); 72 | } 73 | 74 | 75 | public function getTxnType() 76 | { 77 | return $this->getParameter('txnType'); 78 | } 79 | 80 | 81 | public function setTxnSubType($value) 82 | { 83 | return $this->setParameter('txnSubType', $value); 84 | } 85 | 86 | 87 | public function getTxnSubType() 88 | { 89 | return $this->getParameter('txnSubType'); 90 | } 91 | 92 | 93 | public function setBizType($value) 94 | { 95 | return $this->setParameter('bizType', $value); 96 | } 97 | 98 | 99 | public function getBizType() 100 | { 101 | return $this->getParameter('bizType'); 102 | } 103 | 104 | 105 | public function setReturnUrl($value) 106 | { 107 | return $this->setParameter('returnUrl', $value); 108 | } 109 | 110 | 111 | public function getReturnUrl() 112 | { 113 | return $this->getParameter('returnUrl'); 114 | } 115 | 116 | 117 | public function setNotifyUrl($value) 118 | { 119 | return $this->setParameter('notifyUrl', $value); 120 | } 121 | 122 | 123 | public function getNotifyUrl() 124 | { 125 | return $this->getParameter('notifyUrl'); 126 | } 127 | 128 | 129 | public function setSignMethod($value) 130 | { 131 | return $this->setParameter('signMethod', $value); 132 | } 133 | 134 | 135 | public function getSignMethod() 136 | { 137 | return $this->getParameter('signMethod'); 138 | } 139 | 140 | 141 | public function setChannelType($value) 142 | { 143 | return $this->setParameter('channelType', $value); 144 | } 145 | 146 | 147 | public function getChannelType() 148 | { 149 | return $this->getParameter('channelType'); 150 | } 151 | 152 | 153 | public function setAccessType($value) 154 | { 155 | return $this->setParameter('accessType', $value); 156 | } 157 | 158 | 159 | public function getAccessType() 160 | { 161 | return $this->getParameter('accessType'); 162 | } 163 | 164 | 165 | public function setMerId($value) 166 | { 167 | return $this->setParameter('merId', $value); 168 | } 169 | 170 | 171 | public function getMerId() 172 | { 173 | return $this->getParameter('merId'); 174 | } 175 | 176 | 177 | public function setCurrencyCode($value) 178 | { 179 | return $this->setParameter('currencyCode', $value); 180 | } 181 | 182 | 183 | public function getCurrencyCode() 184 | { 185 | return $this->getParameter('currencyCode'); 186 | } 187 | 188 | 189 | public function setEnvironment($value) 190 | { 191 | return $this->setParameter('environment', $value); 192 | } 193 | 194 | 195 | public function getEnvironment() 196 | { 197 | return $this->getParameter('environment'); 198 | } 199 | 200 | 201 | public function setCertDir($value) 202 | { 203 | return $this->setParameter('certDir', $value); 204 | } 205 | 206 | 207 | public function getCertDir() 208 | { 209 | return $this->getParameter('certDir'); 210 | } 211 | 212 | 213 | public function setCertPath($value) 214 | { 215 | return $this->setParameter('certPath', $value); 216 | } 217 | 218 | 219 | public function getCertPath() 220 | { 221 | return $this->getParameter('certPath'); 222 | } 223 | 224 | 225 | public function setCertPassword($value) 226 | { 227 | return $this->setParameter('certPassword', $value); 228 | } 229 | 230 | 231 | public function getCertPassword() 232 | { 233 | return $this->getParameter('certPassword'); 234 | } 235 | 236 | 237 | public function setOrderDesc($value) 238 | { 239 | return $this->setParameter('orderDesc', $value); 240 | } 241 | 242 | 243 | public function getOrderDesc() 244 | { 245 | return $this->getParameter('orderDesc'); 246 | } 247 | 248 | 249 | public function setReqReserved($value) 250 | { 251 | return $this->setParameter('reqReserved', $value); 252 | } 253 | 254 | 255 | public function getReqReserved() 256 | { 257 | return $this->getParameter('reqReserved'); 258 | } 259 | 260 | 261 | public function setDefaultPayType($value) 262 | { 263 | return $this->setParameter('defaultPayType', $value); 264 | } 265 | 266 | 267 | public function getDefaultPayType() 268 | { 269 | return $this->getParameter('defaultPayType'); 270 | } 271 | 272 | 273 | public function purchase(array $parameters = array()) 274 | { 275 | return $this->createRequest('\Omnipay\UnionPay\Message\ExpressPurchaseRequest', $parameters); 276 | } 277 | 278 | 279 | public function completePurchase(array $parameters = array()) 280 | { 281 | return $this->createRequest('\Omnipay\UnionPay\Message\ExpressCompletePurchaseRequest', $parameters); 282 | } 283 | 284 | 285 | public function query(array $parameters = array()) 286 | { 287 | return $this->createRequest('\Omnipay\UnionPay\Message\ExpressQueryRequest', $parameters); 288 | } 289 | 290 | 291 | public function consumeUndo(array $parameters = array()) 292 | { 293 | return $this->createRequest('\Omnipay\UnionPay\Message\ExpressConsumeUndoRequest', $parameters); 294 | } 295 | 296 | 297 | public function refund(array $parameters = array()) 298 | { 299 | return $this->createRequest('\Omnipay\UnionPay\Message\ExpressRefundRequest', $parameters); 300 | } 301 | 302 | 303 | public function fileTransfer(array $parameters = array()) 304 | { 305 | return $this->createRequest('\Omnipay\UnionPay\Message\ExpressFileTransferRequest', $parameters); 306 | } 307 | } 308 | -------------------------------------------------------------------------------- /src/Message/BaseAbstractRequest.php: -------------------------------------------------------------------------------- 1 | 'frontTransReq.do', 17 | 'back' => 'backTransReq.do', 18 | 'app' => 'appTransReq.do', 19 | 'query' => 'queryTrans.do', 20 | ); 21 | 22 | 23 | public function getEndpoint($type) 24 | { 25 | if ($this->getEnvironment() == 'production') { 26 | return $this->productionEndpoint . $this->methods[$type]; 27 | } else { 28 | return $this->sandboxEndpoint . $this->methods[$type]; 29 | } 30 | } 31 | 32 | 33 | public function getEnvironment() 34 | { 35 | return $this->getParameter('environment'); 36 | } 37 | 38 | 39 | public function setVersion($value) 40 | { 41 | return $this->setParameter('version', $value); 42 | } 43 | 44 | 45 | public function getVersion() 46 | { 47 | return $this->getParameter('version'); 48 | } 49 | 50 | 51 | public function setEncoding($value) 52 | { 53 | return $this->setParameter('encoding', $value); 54 | } 55 | 56 | 57 | public function getEncoding() 58 | { 59 | return $this->getParameter('encoding'); 60 | } 61 | 62 | 63 | public function setTxnType($value) 64 | { 65 | return $this->setParameter('txnType', $value); 66 | } 67 | 68 | 69 | public function getTxnType() 70 | { 71 | return $this->getParameter('txnType'); 72 | } 73 | 74 | 75 | public function getTxnSubType() 76 | { 77 | return $this->getParameter('txnSubType'); 78 | } 79 | 80 | 81 | public function setTxnSubType($value) 82 | { 83 | return $this->setParameter('txnSubType', $value); 84 | } 85 | 86 | 87 | public function setBizType($value) 88 | { 89 | return $this->setParameter('bizType', $value); 90 | } 91 | 92 | 93 | public function getBizType() 94 | { 95 | return $this->getParameter('bizType'); 96 | } 97 | 98 | 99 | public function setReturnUrl($value) 100 | { 101 | return $this->setParameter('returnUrl', $value); 102 | } 103 | 104 | 105 | public function getReturnUrl() 106 | { 107 | return $this->getParameter('returnUrl'); 108 | } 109 | 110 | 111 | public function setNotifyUrl($value) 112 | { 113 | return $this->setParameter('notifyUrl', $value); 114 | } 115 | 116 | 117 | public function getNotifyUrl() 118 | { 119 | return $this->getParameter('notifyUrl'); 120 | } 121 | 122 | 123 | public function setSignMethod($value) 124 | { 125 | return $this->setParameter('signMethod', $value); 126 | } 127 | 128 | 129 | public function getSignMethod() 130 | { 131 | return $this->getParameter('signMethod'); 132 | } 133 | 134 | 135 | public function setChannelType($value) 136 | { 137 | return $this->setParameter('channelType', $value); 138 | } 139 | 140 | 141 | public function getChannelType() 142 | { 143 | return $this->getParameter('channelType'); 144 | } 145 | 146 | 147 | public function setAccessType($value) 148 | { 149 | return $this->setParameter('accessType', $value); 150 | } 151 | 152 | 153 | public function getAccessType() 154 | { 155 | return $this->getParameter('accessType'); 156 | } 157 | 158 | 159 | public function setMerId($value) 160 | { 161 | return $this->setParameter('merId', $value); 162 | } 163 | 164 | 165 | public function getMerId() 166 | { 167 | return $this->getParameter('merId'); 168 | } 169 | 170 | 171 | public function setCurrencyCode($value) 172 | { 173 | return $this->setParameter('currencyCode', $value); 174 | } 175 | 176 | 177 | public function getCurrencyCode() 178 | { 179 | return $this->getParameter('currencyCode'); 180 | } 181 | 182 | 183 | public function setEnvironment($value) 184 | { 185 | return $this->setParameter('environment', $value); 186 | } 187 | 188 | 189 | public function setCertPath($value) 190 | { 191 | return $this->setParameter('certPath', $value); 192 | } 193 | 194 | 195 | public function getCertPath() 196 | { 197 | return $this->getParameter('certPath'); 198 | } 199 | 200 | 201 | public function setCertPassword($value) 202 | { 203 | return $this->setParameter('certPassword', $value); 204 | } 205 | 206 | 207 | public function getCertPassword() 208 | { 209 | return $this->getParameter('certPassword'); 210 | } 211 | 212 | 213 | public function setOrderDesc($value) 214 | { 215 | return $this->setParameter('orderDesc', $value); 216 | } 217 | 218 | 219 | public function getOrderDesc() 220 | { 221 | return $this->getParameter('orderDesc'); 222 | } 223 | 224 | 225 | public function setReqReserved($value) 226 | { 227 | return $this->setParameter('reqReserved', $value); 228 | } 229 | 230 | 231 | public function getReqReserved() 232 | { 233 | return $this->getParameter('reqReserved'); 234 | } 235 | 236 | 237 | public function setOrderId($value) 238 | { 239 | return $this->setParameter('orderId', $value); 240 | } 241 | 242 | 243 | public function getOrderId() 244 | { 245 | return $this->getParameter('orderId'); 246 | } 247 | 248 | 249 | public function setTxnTime($value) 250 | { 251 | return $this->setParameter('txnTime', $value); 252 | } 253 | 254 | 255 | public function getTxnTime() 256 | { 257 | return $this->getParameter('txnTime'); 258 | } 259 | 260 | 261 | public function setTxnAmt($value) 262 | { 263 | return $this->setParameter('txnAmt', $value); 264 | } 265 | 266 | 267 | public function getTxnAmt() 268 | { 269 | return $this->getParameter('txnAmt'); 270 | } 271 | 272 | 273 | public function setRequestType($value) 274 | { 275 | return $this->setParameter('requestType', $value); 276 | } 277 | 278 | 279 | public function getRequestType() 280 | { 281 | return $this->getParameter('requestType'); 282 | } 283 | 284 | 285 | public function setDefaultPayType($value) 286 | { 287 | return $this->setParameter('defaultPayType', $value); 288 | } 289 | 290 | 291 | public function getDefaultPayType() 292 | { 293 | return $this->getParameter('defaultPayType'); 294 | } 295 | 296 | 297 | public function setCertDir($value) 298 | { 299 | return $this->setParameter('certDir', $value); 300 | } 301 | 302 | 303 | public function getCertDir() 304 | { 305 | return $this->getParameter('certDir'); 306 | } 307 | 308 | 309 | protected function httpRequest($method, $data) 310 | { 311 | $result = Helper::sendHttpRequest($this->getEndpoint($method), $data); 312 | 313 | parse_str($result, $data); 314 | 315 | if (! is_array($data)) { 316 | $data = array(); 317 | } 318 | 319 | return $data; 320 | } 321 | 322 | 323 | protected function getCertId() 324 | { 325 | return Helper::getCertId($this->getCertPath(), $this->getCertPassword()); 326 | } 327 | } 328 | -------------------------------------------------------------------------------- /src/Message/AbstractExpressRequest.php: -------------------------------------------------------------------------------- 1 | 'frontTransReq.do', 21 | 'back' => 'backTransReq.do', 22 | 'app' => 'appTransReq.do', 23 | 'query' => 'queryTrans.do', 24 | ); 25 | 26 | 27 | public function getEndpoint($type) 28 | { 29 | if ($this->getEnvironment() == 'production') { 30 | return $this->productionEndpoint . $this->methods[$type]; 31 | } else { 32 | return $this->sandboxEndpoint . $this->methods[$type]; 33 | } 34 | } 35 | 36 | 37 | public function getEnvironment() 38 | { 39 | return $this->getParameter('environment'); 40 | } 41 | 42 | 43 | public function setVersion($value) 44 | { 45 | return $this->setParameter('version', $value); 46 | } 47 | 48 | 49 | public function getVersion() 50 | { 51 | return $this->getParameter('version'); 52 | } 53 | 54 | 55 | public function setEncoding($value) 56 | { 57 | return $this->setParameter('encoding', $value); 58 | } 59 | 60 | 61 | public function getEncoding() 62 | { 63 | return $this->getParameter('encoding'); 64 | } 65 | 66 | 67 | public function setTxnType($value) 68 | { 69 | return $this->setParameter('txnType', $value); 70 | } 71 | 72 | 73 | public function getTxnType() 74 | { 75 | return $this->getParameter('txnType'); 76 | } 77 | 78 | 79 | public function getTxnSubType() 80 | { 81 | return $this->getParameter('txnSubType'); 82 | } 83 | 84 | 85 | public function setTxnSubType($value) 86 | { 87 | return $this->setParameter('txnSubType', $value); 88 | } 89 | 90 | 91 | public function setBizType($value) 92 | { 93 | return $this->setParameter('bizType', $value); 94 | } 95 | 96 | 97 | public function getBizType() 98 | { 99 | return $this->getParameter('bizType'); 100 | } 101 | 102 | 103 | public function setReturnUrl($value) 104 | { 105 | return $this->setParameter('returnUrl', $value); 106 | } 107 | 108 | 109 | public function getReturnUrl() 110 | { 111 | return $this->getParameter('returnUrl'); 112 | } 113 | 114 | 115 | public function setNotifyUrl($value) 116 | { 117 | return $this->setParameter('notifyUrl', $value); 118 | } 119 | 120 | 121 | public function getNotifyUrl() 122 | { 123 | return $this->getParameter('notifyUrl'); 124 | } 125 | 126 | 127 | public function setSignMethod($value) 128 | { 129 | return $this->setParameter('signMethod', $value); 130 | } 131 | 132 | 133 | public function getSignMethod() 134 | { 135 | return $this->getParameter('signMethod'); 136 | } 137 | 138 | 139 | public function setChannelType($value) 140 | { 141 | return $this->setParameter('channelType', $value); 142 | } 143 | 144 | 145 | public function getChannelType() 146 | { 147 | return $this->getParameter('channelType'); 148 | } 149 | 150 | 151 | public function setAccessType($value) 152 | { 153 | return $this->setParameter('accessType', $value); 154 | } 155 | 156 | 157 | public function getAccessType() 158 | { 159 | return $this->getParameter('accessType'); 160 | } 161 | 162 | 163 | public function setMerId($value) 164 | { 165 | return $this->setParameter('merId', $value); 166 | } 167 | 168 | 169 | public function getMerId() 170 | { 171 | return $this->getParameter('merId'); 172 | } 173 | 174 | 175 | public function setCurrencyCode($value) 176 | { 177 | return $this->setParameter('currencyCode', $value); 178 | } 179 | 180 | 181 | public function getCurrencyCode() 182 | { 183 | return $this->getParameter('currencyCode'); 184 | } 185 | 186 | 187 | public function setEnvironment($value) 188 | { 189 | return $this->setParameter('environment', $value); 190 | } 191 | 192 | 193 | public function setCertPath($value) 194 | { 195 | return $this->setParameter('certPath', $value); 196 | } 197 | 198 | 199 | public function getCertPath() 200 | { 201 | return $this->getParameter('certPath'); 202 | } 203 | 204 | 205 | public function setCertPassword($value) 206 | { 207 | return $this->setParameter('certPassword', $value); 208 | } 209 | 210 | 211 | public function getCertPassword() 212 | { 213 | return $this->getParameter('certPassword'); 214 | } 215 | 216 | 217 | public function setOrderDesc($value) 218 | { 219 | return $this->setParameter('orderDesc', $value); 220 | } 221 | 222 | 223 | public function getOrderDesc() 224 | { 225 | return $this->getParameter('orderDesc'); 226 | } 227 | 228 | 229 | public function setReqReserved($value) 230 | { 231 | return $this->setParameter('reqReserved', $value); 232 | } 233 | 234 | 235 | public function getReqReserved() 236 | { 237 | return $this->getParameter('reqReserved'); 238 | } 239 | 240 | 241 | public function setOrderId($value) 242 | { 243 | return $this->setParameter('orderId', $value); 244 | } 245 | 246 | 247 | public function getOrderId() 248 | { 249 | return $this->getParameter('orderId'); 250 | } 251 | 252 | 253 | public function setTxnTime($value) 254 | { 255 | return $this->setParameter('txnTime', $value); 256 | } 257 | 258 | 259 | public function getTxnTime() 260 | { 261 | return $this->getParameter('txnTime'); 262 | } 263 | 264 | 265 | public function setTxnAmt($value) 266 | { 267 | return $this->setParameter('txnAmt', $value); 268 | } 269 | 270 | 271 | public function getTxnAmt() 272 | { 273 | return $this->getParameter('txnAmt'); 274 | } 275 | 276 | 277 | public function setRequestType($value) 278 | { 279 | return $this->setParameter('requestType', $value); 280 | } 281 | 282 | 283 | public function getRequestType() 284 | { 285 | return $this->getParameter('requestType'); 286 | } 287 | 288 | 289 | public function setDefaultPayType($value) 290 | { 291 | return $this->setParameter('defaultPayType', $value); 292 | } 293 | 294 | 295 | public function getDefaultPayType() 296 | { 297 | return $this->getParameter('defaultPayType'); 298 | } 299 | 300 | 301 | public function setCertDir($value) 302 | { 303 | return $this->setParameter('certDir', $value); 304 | } 305 | 306 | 307 | public function getCertDir() 308 | { 309 | return $this->getParameter('certDir'); 310 | } 311 | 312 | 313 | protected function httpRequest($method, $data) 314 | { 315 | $result = Helper::sendHttpRequest($this->getEndpoint($method), $data); 316 | 317 | parse_str($result, $data); 318 | 319 | if (! is_array($data)) { 320 | $data = array (); 321 | } 322 | 323 | return $data; 324 | } 325 | 326 | 327 | protected function getCertId() 328 | { 329 | return Helper::getCertId($this->getCertPath(), $this->getCertPassword()); 330 | } 331 | } 332 | --------------------------------------------------------------------------------