fork download
  1.  
  2. <?php
  3. // Set your Stripe API key
  4. $stripeSecretKey = 'sk_test_51NrgcxSF9ONntPxRuGONq2JEBWMNmAfN9fT7vXgfd5wsCkKLzV24P3bwtoyR9PDOGLsz9v9i54wkHxL8ZFW1BKAM00seBvctNJ';
  5. // Define the endpoint URLs
  6. $createCustomerURL = 'https://a...content-available-to-author-only...e.com/v1/customers';
  7. // Create a customer
  8. $customerData = [
  9. 'name' => 'John Doe',
  10. 'email' => 'harshkumar140903@gmail.com',
  11. 'address' => [
  12. 'line1' => '123 Main Street',
  13. 'city' => 'City',
  14. 'postal_code' => '12345',
  15. 'state' => 'State',
  16. 'country' => 'US',
  17. ],
  18. 'phone' => '1234567890',
  19. 'metadata' => [
  20. 'custom_field_1' => 'value1',
  21. 'custom_field_2' => 'value2',
  22. ],
  23. ];
  24. $ch = curl_init($createCustomerURL);
  25. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  26. curl_setopt($ch, CURLOPT_POST, true);
  27. curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($customerData));
  28. curl_setopt($ch, CURLOPT_HTTPHEADER, [
  29. 'Authorization: Bearer ' . $stripeSecretKey,
  30. 'Content-Type: application/x-www-form-urlencoded',
  31. ]);
  32. $customerResponse = curl_exec($ch);
  33. $customer = json_decode($customerResponse);
  34. echo json_encode(['customer' => $customer]);
  35. ?>
  36.  
  37.  
Success #stdin #stdout 0.03s 26616KB
stdin
Standard input is empty
stdout
{"customer":null}