NOTE: This library is still in development and is not ready to be used in production yet.
This library can be used to interact with the CloudSwipe API.
- PHP 5.4 or later
- JSON API PHP Client (auto-included via Composer)
You can install it via Composer. Run the following command:
composer require cloudswipe/cloudswipe-php
To use the bindings, use Composer's autoload:
require_once('vendor/autoload.php');
All API authentication is done using HTTP Authentication with the Secret Key available in your CloudSwipe account.
You can set the Secret Key for all requests like this:
CloudSwipe\CloudSwipe::setSecretKey("sk_store_12345");
// bare minimum invoice
$invoice = CloudSwipe\Invoice::create([
"description" => "T-Shirt",
"total" => 1995,
"currency" => "USD"
]);
// more detailed invoice
$invoice = CloudSwipe\Invoice::create([
"total" => 2705,
"currency" => "USD",
"customer" => [
"name" => "Bud Abbott",
"email" => "bud@abbott.com"
"billing_address" => [
"name" => "Bud Abbott",
"company" => "Laugh Lines",
"line1" => "123 Anystreet",
"line2" => "Suite A",
"city" => "Anytown",
"state" => "VA",
"zip" => "12345",
"country" => "US",
"phone" => "111-222-3333"
],
"shipping_address" => [
"name" => "Lou Costello",
"company" => "Laugh Lines",
"line1" => "456 Otherstreet",
"line2" => "Suite Z",
"city" => "Othertown",
"state" => "VA",
"zip" => "12345",
"country" => "US",
"phone" => "111-222-3333"
],
"line_items" => [
"header" => ["Item", "Description", "Quantity", "Total"],
"rows" => [
["T-Shirt", "Small, Blue", 1, 1095],
["Mug", "Branded Coffee Mug", 2, 535]
]
],
"line_totals" => [
"rows" => [
["Discount" => 500],
["Tax" => 245],
["Shipping" => 795]
]
],
"metadata" => [
"some-custom-field" => "some-custom-value"
]
]
]);
$invoice = CloudSwipe\Invoice::getOne("in_12345");
$invoices = CloudSwipe\Invoice::getAll();