DeveloperBreeze

Tutorials Programming Tutorials, Guides & Best Practices

Explore 149+ expertly crafted tutorials tutorials, components, and code examples. Stay productive and build faster with proven implementation strategies and design patterns from DeveloperBreeze.

Integrating and Using NMI Payment Gateway in Laravel

Tutorial August 14, 2024
php

   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;
   }

This method uses the customer’s vault ID to process a payment for the specified amount. It handles test mode and logs the payment response using Laravel’s info logging.

Building an Advanced Weather App with Flutter and Dart

Tutorial August 12, 2024
dart

cd weather_app

Open the project in your preferred IDE.