├── 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 |
62 |
63 |