![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/public_html/quickqr/includes/payments/paypal/subscription/ |
<?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' => '123123123123',
'SIGNATURE' => 'assinatura.da.api',
'METHOD' => 'SetExpressCheckout',
'VERSION' => '108',
'LOCALECODE' => 'pt_BR',
'PAYMENTREQUEST_0_AMT' => 100,
'PAYMENTREQUEST_0_CURRENCYCODE' => 'BRL',
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
'PAYMENTREQUEST_0_ITEMAMT' => 100,
'L_PAYMENTREQUEST_0_NAME0' => 'Exemplo',
'L_PAYMENTREQUEST_0_DESC0' => 'Assinatura de exemplo',
'L_PAYMENTREQUEST_0_QTY0' => 1,
'L_PAYMENTREQUEST_0_AMT0' => 100,
'L_BILLINGTYPE0' => 'RecurringPayments',
'L_BILLINGAGREEMENTDESCRIPTION0' => 'Exemplo',
'CANCELURL' => 'http://localhost/cancel.html',
'RETURNURL' => 'http://localhost/sucesso.html'
)));
$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]);
}
}
if (isset($nvp['ACK']) && $nvp['ACK'] == 'Success') {
$query = array(
'cmd' => '_express-checkout',
'token' => $nvp['TOKEN']
);
$redirectURL = sprintf('https://www.sandbox.paypal.com/cgi-bin/webscr?%s', http_build_query($query));
header('Location: ' . $redirectURL);
} else {
// Opz, something went wrong.
// Check the error logs for debugging.
}