1

The Error is

Fatal error: Uncaught Stripe_ApiConnectionError: Could not connect to Stripe (https://api.stripe.com). Please check your internet connection and try again. If this problem persists, you let us know at support@stripe.com. (Network error [errno 6]: Could not resolve host: api.stripe.com) in C:\xampp\htdocs\smilingfeetafrica\creditcard\lib\Stripe\ApiRequestor.php:220 Stack trace: #0 C:\xampp\htdocs\smilingfeetafrica\creditcard\lib\Stripe\ApiRequestor.php(194): Stripe_ApiRequestor->handleCurlError(6, 'Could not resol...') #1 C:\xampp\htdocs\smilingfeetafrica\creditcard\lib\Stripe\ApiRequestor.php(123): Stripe_ApiRequestor->_curlRequest('post', 'https://api.str...', Array, Array) #2 C:\xampp\htdocs\smilingfeetafrica\creditcard\lib\Stripe\ApiRequestor.php(73): Stripe_ApiRequestor->_requestRaw('post', '/v1/customers', Array) #3 C:\xampp\htdocs\smilingfeetafrica\creditcard\lib\Stripe\ApiResource.php(76): Stripe_ApiRequestor->request('post', '/v1/custo in C:\xampp\htdocs\smilingfeetafrica\creditcard\lib\Stripe\ApiRequestor.php on line 220

index.php

<?php require_once('./config.php'); ?>
<html>
<form action="charge.php" method="post">
  <script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
          data-key="<?php echo $stripe['publishable_key']; ?>"
          data-name="Smiling Feet Africa";
          data-amount="6000"
          data-label="Donate Now";
          data-description="Donation To Smiling Feet Africa";
          data-image="https://scontent.fdel1-1.fna.fbcdn.net/v/t1.0-9/15267710_1800934823517876_8537040350463715708_n.jpg?oh=c28d57192ddfff07dfcdf2e09bed10da&oe=58B7699D";
          data-locale="auto"></script>
</form>
</html>

config.php

<?php
require_once('lib/stripe.php');

$stripe = array(
  "secret_key"      => "sk_test_iiL4w4FTUReerKcuW6O4hDMu",
  "publishable_key" => "pk_test_MyunyEF75C8aFGTA2S483IIQ"
);

Stripe::setApiKey($stripe['secret_key']);
?>

charge.php

<?php
  require_once(dirname(__FILE__).'/config.php');

  $token  = $_POST['stripeToken'];

  $customer = Stripe_Customer::create(array(
      'email' => 'customer@example.com',
      'source'  => $token
  ));

  $charge = Stripe_Charge::create(array(
      'customer' => $customer->id,
      'amount'   => 5000,
      'currency' => 'usd'
  ));

  echo '<h1>Successfully charged $50.00!</h1>';
?>

I am running on the localhost.Please help me.

0 Answers0