forked from br-paypaldev/code-sample-pagamentos-recorrentes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
updateRecurringPaymentsProfile-1.php
34 lines (26 loc) · 940 Bytes
/
updateRecurringPaymentsProfile-1.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_URL, 'https://api-3t.sandbox.paypal.com/nvp');
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query(array(
'USER' => 'usuario_da_api',
'PWD' => '123412432134',
'SIGNATURE' => 'assinatura.da.api',
'METHOD' => 'UpdateRecurringPaymentsProfile',
'VERSION' => '108',
'PROFILEID' => 'I-FYYMDB55ADSH',
'NOTE' => 'Uma nota opcional, explicando o motivo da mudança',
'AMT' => 120,
'CURRENCYCODE' => 'BRL'
)));
$response = curl_exec($curl);
curl_close($curl);
$nvp = array();
if (preg_match_all('/(?<name>[^\=]+)\=(?<value>[^&]+)&?/', $response, $matches)) {
foreach ($matches['name'] as $offset => $name) {
$nvp[$name] = urldecode($matches['value'][$offset]);
}
}
print_r($nvp);