Download the PHP package pondersource/billing-api without Composer
On this page you can find all versions of the php package pondersource/billing-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pondersource/billing-api
More information about pondersource/billing-api
Files in pondersource/billing-api
Package billing-api
Short Description A Billing API for Heroku, Github, AWS
License MIT
Homepage https://github.com/pondersource/billing-api
Informations about the package billing-api
Billing API PHP Client
Requirements
- PHP 7.3+ or 8.x
A PHP client for the Billing Platform API working for Invoices, Account, Apps .etc
Usage
- Checkout this repo
- Create a .env file you can do it go to the CLI and run
- Comment/uncomment the service for which you want to retrieve invoices or usage info (Google, AWS, Github, Heroku).
- Run
composer install
- Go to https://github.com/settings/tokens/new and create a personal access token. Tick 'admin:org' and 'user' as scopes.
-
Save this in your
.env
file as: -
You need to show your own Github Username:
- Run
echo -n; heroku auth:token
to get a personal token for Heroku or you can do it simple just runheroku auth:token
inside CLI. -
Save this in your
.env
file as: - Working with google you need to run first from CLI
-
It generate you json file that you can copy and paste inside Google
- Run
php index.php
- When you run
php index.php
every service will generate xml or json array collection of item UBL and JSON
Heroku API Client
``
We are using Heroku Invoices for simple user and we can use in the same way for the teams and I will show you response of one of the function. We will work directly with platform API of the Heroku and fetching inforamtion.
-
Response json from first method for simple Heroku Invoice
- Reponse UBL from first method for simple Heroku Invoice
Google API Client
``
Inside your json file you will generate it in the up you can see instruction. We are using Google Cloud library for take information for services and other stuff.
-
Response from JSON one of example
- Response UBL show one of example
GitHub API PHP Client
Namespace PonderSource\GitHubApi
Authorization
We need to provide the user's TOKEN(We recommend to use TOKENS with expiration date)
Headers
Recuired Headers to call the GitHub API endpoints:
Methods
We can ask for billing information either for a user or organization
Organization
- getOrgSharedStorageBilling($org)
- getOrgActionsBilling($org)
- getOrgPackagesBillingInfo($org)
User
- getUserSharedStorageBilling($user)
- getUserActionsBilling($user)
- getUserPackagesBillingInfo($user)
Example
Get shared storage billing for an organization
At the billing-api/index.php
first we need to create the GitHub Client
1) First we have to initialize the GitHub Client
2) Now we can choose between the 6 available functions and retrieve billing info(JSON) either for Organization or User.
3) Response
AWS API PHP Client
Namespace PonderSource\AWSApi
-
PHP library for communication with AWS services: AWS SDK.
- Cost Explorer API endpoint:
https://ce.us-east-1.amazonaws.com
.
Credentials
From ~/.aws/credentials.ini
we can retireve the credentials
-
AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
Using temporary security credentials with the AWS CLI
aws sts get-session-token --serial-number arn-of-the-mfa-device --token-code code-from-token
Root Access Keys VS IAM Access Keys
-
Root access
- Allow full access to all resources in the account
- IAM Access Keys
- Access to AWS services and resources for users in your AWS account
Example
1) At the billing-api/index.php
first we need to create AWS Client
2) Now we can get Cost and Usage report. Please consider, that the User have to enable the Cost Explorer first(It may take some time to ingest the data)
All versions of billing-api with dependencies
guzzlehttp/psr7 Version ^1.0
php-http/message Version ^1.5
php-http/curl-client Version ^2.1
psr/http-message Version ^1.0
http-interop/http-factory-guzzle Version ^1.0
phpunit/phpunit Version ^9.5
google/cloud-billing Version ^1.3
google/cloud-storage Version ^1.26
sabre/xml Version ^2.2