Laravel Programming Tutorials, Guides & Best Practices
Explore 51+ expertly crafted laravel tutorials, components, and code examples. Stay productive and build faster with proven implementation strategies and design patterns from DeveloperBreeze.
Adblocker Detected
It looks like you're using an adblocker. Our website relies on ads to keep running. Please consider disabling your adblocker to support us and access the content.
Tutorial
php
Integrating and Using NMI Payment Gateway in Laravel
Add the following method to the NMI class:
public function processPaymentUsingVault($customerVaultId, $totalAmount)
{
$data = [
'security_key' => $this->securityKey,
'customer_vault_id' => $customerVaultId,
'amount' => $totalAmount,
];
if ($this->production === false) {
$data['test_mode'] = 'enabled';
}
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $this->url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query($data),
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false,
]);
$response = curl_exec($curl);
curl_close($curl);
if ($response === false) {
return [
'responsetext' => 'error',
'error' => 'Payment processing failed',
];
}
\Log::info('NMI Payment Response: ' . $response);
parse_str($response, $parsedResponse);
return $parsedResponse;
}Aug 14, 2024
Read More