PHP code example of chargebee / chargebee-php
1. Go to this page and download the library: Download chargebee/chargebee-php library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
chargebee / chargebee-php example snippets
use ChargeBee\ChargeBee\Environment;
use ChargeBee\ChargeBee\Subscription;
Environment::configure("your_site", "{your_site_api_key}");
$result = Subscription::create([
"id" => "__dev__KyVqH3NW3f42fD",
"planId" => "starter",
"customer" => [
"email" => "[email protected] ",
"firstName" => "John",
"lastName" => "Wayne"
]
]);
$subscription = $result->subscription();
$customer = $result->customer();
$card = $result->card();
use ChargeBee\ChargeBee\Environment;
use ChargeBee\ChargeBee\Models\Customer;
Environment::configure("your_site", "{your_site_api_key}");
$result = Customer::create(array(
"email" => "[email protected] ",
"first_name" => "john"
),
null,
array(
"chargebee-idempotency-key" => "<<UUID>>"
)
); // Replace <<UUID>> with a unique string
$customer = $result->customer();
print_r($customer);
$responseHeaders = $result->getResponseHeaders(); // Retrieves response headers
print_r($responseHeaders);
$idempotencyReplayedValue = $result->isIdempotencyReplayed(); // Retrieves Idempotency replayed header value
print_r($idempotencyReplayedValue);