Skip to content

Commit

Permalink
Initial release 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
marcialpaulg committed Sep 7, 2021
1 parent bac798d commit 380bc54
Show file tree
Hide file tree
Showing 46 changed files with 1,280 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
composer.phar
/vendor/
composer.lock

# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
Expand Down
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,24 @@
# Coinbase commerce PHP8
Coinbase commerce library for PHP8. works in Laravel8

Coinbase commerce library for PHP8. works in Laravel8

Library is based in https://commerce.coinbase.com/docs/api/

\*\*NOTE: help me improve this repo

# Installation

marcialpaulg/coinbase-commerce-php8 is available in [Packagist](https://packagist.org/), and installation via [Composer](https://getcomposer.org/)

run
`composer require marcialpaulg/coinbase-commerce-php8`

Note that the vendor folder and the `vendor/autoload.php` script are generated by `Composer`; they are not part of this library.

# Usage

check our [examples](https://github.com/marcialpaulg/coinbase-commerce-php8/tree/main/examples)

# License

marcialpaulg/coinbase-commerce-php8 is open-sourced software licensed under the [MIT license](LICENSE).
24 changes: 24 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "marcialpaulg/coinbase-commerce-php8",
"description": "Coinbase commerce PHP8 library",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Marcial Paul Gargoles",
"email": "[email protected]"
}
],
"require": {
"php": "^8.0",
"guzzlehttp/guzzle": "^7.0.1",
"illuminate/collections": "^8.0"
},
"autoload": {
"psr-4": {
"MarcialPaulG\\Coinbase\\": "src/"
}
},
"prefer-stable": true,
"minimum-stability": "dev"
}
27 changes: 27 additions & 0 deletions examples/CancelingCharge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

require '../vendor/autoload.php';

use MarcialPaulG\Coinbase\Coinbase;
use MarcialPaulG\Coinbase\Exceptions\InvalidRequestException;
use MarcialPaulG\Coinbase\Exceptions\RateLimitExceededException;

// Your API KEY
$api_key = 'YOUR_API_KEY';

// throw exception
$throw_exceptions = true;

$coinbase = new Coinbase($api_key, $throw_exceptions);

////////////////////////////////////////////////////////////////////////////////

$charge_code_id = 'CHARGE_CODE_OR_CHARGE_ID';

try {

$data = $coinbase->cancelCharge($charge_code_id);
} catch (InvalidRequestException | RateLimitExceededException $e) {

echo $e->getMessage();
}
55 changes: 55 additions & 0 deletions examples/CreatingCharge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

require '../vendor/autoload.php';

use MarcialPaulG\Coinbase\Charge;
use MarcialPaulG\Coinbase\Coinbase;
use MarcialPaulG\Coinbase\Exceptions\InvalidRequestException;
use MarcialPaulG\Coinbase\Exceptions\RateLimitExceededException;

$api_key = 'YOUR_API_KEY';

$throw_exceptions = true;

$coinbase = new Coinbase($api_key, $throw_exceptions);

////////////////////////////////////////////////////////////////////////////////

try {


$charge = new Charge(
name: "The Sovereign Individual",
description: "Mastering the Transition to the Information Age",
pricing_type: "fixed_price",
amount: "100.00",
currency: "USD",
metadata: [
"customer_id" => "id_1005",
"customer_name" => "Satoshi Nakamoto"
],
redirect_url: "https://charge/completed/page",
cancel_url: "https://charge/canceled/page"
);

$data = $coinbase->request($charge);

// OR

$data = $coinbase->createCharge(
name: "The Sovereign Individual",
description: "Mastering the Transition to the Information Age",
pricing_type: "fixed_price",
amount: "100.00",
currency: "USD",
metadata: [
"customer_id" => "id_1005",
"customer_name" => "Satoshi Nakamoto"
],
redirect_url: "https://charge/completed/page",
cancel_url: "https://charge/canceled/page"
);
} catch (InvalidRequestException | RateLimitExceededException $e) {

echo $e->getMessage();
}
44 changes: 44 additions & 0 deletions examples/CreatingCheckout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

require '../vendor/autoload.php';

use MarcialPaulG\Coinbase\Checkout;
use MarcialPaulG\Coinbase\Coinbase;
use MarcialPaulG\Coinbase\Exceptions\InvalidRequestException;
use MarcialPaulG\Coinbase\Exceptions\RateLimitExceededException;

$api_key = 'YOUR_API_KEY';

$throw_exceptions = true;

$coinbase = new Coinbase($api_key, $throw_exceptions);

////////////////////////////////////////////////////////////////////////////////

try {

$checkout = new Checkout(
name: "The Sovereign Individual",
description: "Mastering the Transition to the Information Age",
pricing_type: "fixed_price",
amount: "100.00",
currency: "USD",
requested_info: ['email', 'name'],
);

$data = $coinbase->request($checkout);

// OR

$data = $coinbase->createCheckout(
name: "The Sovereign Individual",
description: "Mastering the Transition to the Information Age",
pricing_type: "fixed_price",
amount: "100.00",
currency: "USD",
requested_info: ['email', 'name'],
);
} catch (InvalidRequestException | RateLimitExceededException $e) {

echo $e->getMessage();
}
45 changes: 45 additions & 0 deletions examples/CreatingInvoice.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

require '../vendor/autoload.php';

use MarcialPaulG\Coinbase\Coinbase;
use MarcialPaulG\Coinbase\Exceptions\InvalidRequestException;
use MarcialPaulG\Coinbase\Exceptions\RateLimitExceededException;
use MarcialPaulG\Coinbase\Invoice;

$api_key = 'YOUR_API_KEY';

$throw_exceptions = true;

$coinbase = new Coinbase($api_key, $throw_exceptions);

////////////////////////////////////////////////////////////////////////////////

try {


$invoice = new Invoice(
business_name: "The Sovereign Individual",
customer_email: "[email protected]",
amount: "100.00",
currency: "USD",
customer_name: "Mars",
memo: "for test"
);

$data = $coinbase->request($invoice);

// OR

$data = $coinbase->createInvoice(
business_name: "The Sovereign Individual",
customer_email: "[email protected]",
amount: "100.00",
currency: "USD",
customer_name: "Mars",
memo: "for test"
);
} catch (InvalidRequestException | RateLimitExceededException $e) {

echo $e->getMessage();
}
26 changes: 26 additions & 0 deletions examples/DeletingCheckout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

require '../vendor/autoload.php';

use MarcialPaulG\Coinbase\Coinbase;
use MarcialPaulG\Coinbase\Exceptions\InvalidRequestException;
use MarcialPaulG\Coinbase\Exceptions\RateLimitExceededException;

$api_key = 'YOUR_API_KEY';

$throw_exceptions = true;

$coinbase = new Coinbase($api_key, $throw_exceptions);

////////////////////////////////////////////////////////////////////////////////

try {


$checkout_id = 'CHECKOUT_ID';

$data = $coinbase->deleteCheckout($checkout_id);
} catch (InvalidRequestException | RateLimitExceededException $e) {

echo $e->getMessage();
}
25 changes: 25 additions & 0 deletions examples/GettingChargeInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

require '../vendor/autoload.php';

use MarcialPaulG\Coinbase\Coinbase;
use MarcialPaulG\Coinbase\Exceptions\InvalidRequestException;
use MarcialPaulG\Coinbase\Exceptions\RateLimitExceededException;

$api_key = 'YOUR_API_KEY';

$throw_exceptions = true;

$coinbase = new Coinbase($api_key, $throw_exceptions);

////////////////////////////////////////////////////////////////////////////////

try {

$charge_code_id = 'CHARGE_CODE_OR_CHARGE_ID';

$data = $coinbase->getCharge($charge_code_id);
} catch (InvalidRequestException | RateLimitExceededException $e) {

echo $e->getMessage();
}
26 changes: 26 additions & 0 deletions examples/GettingCheckoutInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

require '../vendor/autoload.php';

use MarcialPaulG\Coinbase\Coinbase;
use MarcialPaulG\Coinbase\Exceptions\InvalidRequestException;
use MarcialPaulG\Coinbase\Exceptions\RateLimitExceededException;

$api_key = 'YOUR_API_KEY';

$throw_exceptions = true;

$coinbase = new Coinbase($api_key, $throw_exceptions);

////////////////////////////////////////////////////////////////////////////////

try {


$checkout_id = 'CHECKOUT_ID';

$data = $coinbase->getCheckout($checkout_id);
} catch (InvalidRequestException | RateLimitExceededException $e) {

echo $e->getMessage();
}
25 changes: 25 additions & 0 deletions examples/GettingEventInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

require '../vendor/autoload.php';

use MarcialPaulG\Coinbase\Coinbase;
use MarcialPaulG\Coinbase\Exceptions\InvalidRequestException;
use MarcialPaulG\Coinbase\Exceptions\RateLimitExceededException;

$api_key = 'YOUR_API_KEY';

$throw_exceptions = true;

$coinbase = new Coinbase($api_key, $throw_exceptions);

////////////////////////////////////////////////////////////////////////////////

try {

$event_id = 'EVENT_ID';

$data = $coinbase->getEvent($event_id);
} catch (InvalidRequestException | RateLimitExceededException $e) {

echo $e->getMessage();
}
25 changes: 25 additions & 0 deletions examples/GettingInvoiceInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

require '../vendor/autoload.php';

use MarcialPaulG\Coinbase\Coinbase;
use MarcialPaulG\Coinbase\Exceptions\InvalidRequestException;
use MarcialPaulG\Coinbase\Exceptions\RateLimitExceededException;

$api_key = 'YOUR_API_KEY';

$throw_exceptions = true;

$coinbase = new Coinbase($api_key, $throw_exceptions);

////////////////////////////////////////////////////////////////////////////////

try {

$invoice_code_id = 'INVOICE_CODE_OR_INVOICE_ID';

$data = $coinbase->getInvoice($invoice_code_id);
} catch (InvalidRequestException | RateLimitExceededException $e) {

echo $e->getMessage();
}
23 changes: 23 additions & 0 deletions examples/ListingCharges.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

require '../vendor/autoload.php';

use MarcialPaulG\Coinbase\Coinbase;
use MarcialPaulG\Coinbase\Exceptions\InvalidRequestException;
use MarcialPaulG\Coinbase\Exceptions\RateLimitExceededException;

$api_key = 'YOUR_API_KEY';

$throw_exceptions = true;

$coinbase = new Coinbase($api_key, $throw_exceptions);

////////////////////////////////////////////////////////////////////////////////

try {

$data = $coinbase->listCharges();
} catch (InvalidRequestException | RateLimitExceededException $e) {

echo $e->getMessage();
}
Loading

0 comments on commit 380bc54

Please sign in to comment.