1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* PayPal driver for Omnipay PHP payment library |
5
|
|
|
* |
6
|
|
|
* @link https://github.com/hiqdev/omnipay-paypal |
7
|
|
|
* @package omnipay-paypal |
8
|
|
|
* @license MIT |
9
|
|
|
* @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Omnipay\PayPal\Message; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* PayPal Complete Purchase Request. |
16
|
|
|
*/ |
17
|
|
|
class CompletePurchaseRequest extends AbstractRequest |
18
|
|
|
{ |
19
|
|
|
protected $mainEndpoint = 'https://ipnpb.paypal.com/cgi-bin/webscr'; |
20
|
|
|
protected $testEndpoint = 'https://ipnpb.sandbox.paypal.com/cgi-bin/webscr'; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Get the data for this request. |
24
|
|
|
* @return array request data |
25
|
2 |
|
*/ |
26
|
|
|
public function getData() |
27
|
2 |
|
{ |
28
|
|
|
$this->validate('purse'); |
29
|
2 |
|
|
30
|
2 |
|
return array_merge([ |
31
|
2 |
|
'cmd' => '_notify-validate', |
32
|
|
|
], $this->httpRequest->request->all()); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Send the request with specified data. |
37
|
|
|
* @param mixed $data The data to send |
38
|
|
|
* @return CompletePurchaseResponse |
39
|
1 |
|
*/ |
40
|
|
|
public function sendData($data) |
41
|
1 |
|
{ |
42
|
|
|
$this->httpClient->setConfig([ |
43
|
1 |
|
'curl.options' => [ |
44
|
1 |
|
CURLOPT_SSLVERSION => 1, |
45
|
1 |
|
CURLOPT_SSL_VERIFYHOST => 2, |
46
|
|
|
CURLOPT_SSL_VERIFYPEER => 1, |
47
|
|
|
], |
48
|
|
|
]); |
49
|
1 |
|
|
50
|
1 |
|
$httpResponse = $this->httpClient->post($this->getEndpoint(), null, $data)->send(); |
51
|
|
|
$data['_result'] = $httpResponse->getBody(1); |
52
|
1 |
|
|
53
|
|
|
return $this->response = new CompletePurchaseResponse($this, $data); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|