Code Monkey home page Code Monkey logo

coinbase-commerce-php's Introduction

CircleCI

Coinbase Commerce

Note: This repository is not actively maintained.

The official PHP library for the Coinbase Commerce API.

Table of contents

PHP versions

PHP version 5.4 and above are supported.

Documentation

For more details visit Coinbase API docs.

To start using this library register an account on Coinbase Commerce. You will find your API_KEY from User Settings.

Next initialize a Client for interacting with the API. The only required parameter to initialize a client is apiKey, however, you can also pass in baseUrl, apiVersion and timeout. Parameters can be also be set post-initialization:

use CoinbaseCommerce\ApiClient;

//Make sure you don't store your API Key in your source code!
$apiClientObj = ApiClient::init(<API_KEY>);
$apiClientObj->setTimeout(3);

Disable SSL Check

$apiClientObj->verifySsl(false);

The API resource class provides the following static methods: list, all, create, retrieve, updateById, deleteById. Additionally, the API resource class also provides the following instance methods: save, delete, insert, update.

Each API method returns an ApiResource which represents the JSON response from the API. When the response data is parsed into objects, the appropriate ApiResource subclass will automatically be used.

Client supports the handling of common API errors and warnings. All errors that occur during any interaction with the API will be raised as exceptions.

Error Status Code
APIException *
InvalidRequestException 400
ParamRequiredException 400
ValidationException 400
AuthenticationException 401
ResourceNotFoundException 404
RateLimitExceededException 429
InternalServerException 500
ServiceUnavailableException 503

Installation

Install with composer:

composer require coinbase/coinbase-commerce

Usage

use CoinbaseCommerce\ApiClient;

//Make sure you don't store your API Key in your source code!
ApiClient::init('API_KEY');

Checkouts

Checkouts API docs More examples on how to use checkouts can be found in the examples/Resources/CheckoutExample.php file

Load checkout resource class

use CoinbaseCommerce\Resources\Checkout;

Retrieve

$checkoutObj = Checkout::retrieve(<checkout_id>);

Create

$checkoutData = [
    'name' => 'The Sovereign Individual',
    'description' => 'Mastering the Transition to the Information Age',
    'pricing_type' => 'fixed_price',
    'local_price' => [
        'amount' => '100.00',
        'currency' => 'USD'
    ],
    'requested_info' => ['name', 'email']
];
$newCheckoutObj = Checkout::create($checkoutData);

// or

$newCheckoutObj = new Checkout();

$newCheckoutObj->name = 'The Sovereign Individual';
$newCheckoutObj->description = 'Mastering the Transition to the Information Age';
$newCheckoutObj->pricing_type = 'fixed_price';
$newCheckoutObj->local_price = [
    'amount' => '100.00',
    'currency' => 'USD'
];
checkoutObj->requested_info = ['name', 'email'];

checkoutObj->save();

Update

$checkoutObj = new Checkout();

$checkoutObj->id = <checkout_id>;
$checkoutObj->name = 'new name';

$checkoutObj->save();
// or
$newParams = [
    'name' => 'New name'
];

Checkout::updateById(<checkout_id>, $newParams});

Delete

$checkoutObj = new Checkout();

$checkoutObj->id = <checkout_id>;
$checkoutObj->delete();

// or

Checkout::deleteById(<checkout_id>);

List

List method returns ApiResourceList object.

$params = [
    'limit' => 2,
    'order' => 'desc'
];

$list = Checkout::getList($params);

foreach($list as $checkout) {
    var_dump($checkout);
}

// Get number of items in list
$count = $list->count();

// or
$count = count($list);

// Get number of all checkouts
$countAll = $list->countAll();

// Get pagination
$pagination = $list->getPagination();

// To load next page with previous setted params(in this case limit, order)
if ($list->hasNext()) {
    $list->loadNext();
    
    foreach($list as $checkout) {
        var_dump($checkout);
    }
}

Get all checkouts

$params = [
    'order' => 'desc'  
];

$allCheckouts = Checkout::getAll($params);

Charges

Charges API docs More examples on how to use charges can be found in the examples/Resources/ChargeExample.php file

Load charge resource class

use CoinbaseCommerce\Resources\Charge;

Retrieve

$chargeObj = Charge::retrieve(<charge_id>);

Create

$chargeData = [
    'name' => 'The Sovereign Individual',
    'description' => 'Mastering the Transition to the Information Age',
    'local_price' => [
        'amount' => '100.00',
        'currency' => 'USD'
    ],
    'pricing_type' => 'fixed_price'
];
Charge::create($chargeData);

// or
$chargeObj = new Charge();

$chargeObj->name = 'The Sovereign Individual';
$chargeObj->description = 'Mastering the Transition to the Information Age';
$chargeObj->local_price = [
    'amount' => '100.00',
    'currency' => 'USD'
];
$chargeObj->pricing_type = 'fixed_price';
$chargeObj->save();

List

$list = Charge::getList();

foreach($list as $charge) {
    var_dump($list);
}

$pagination = $list->getPagination();

Get all charges

$allCharges = Charge::getAll();

Resolve a charge

Resolve a charge that has been previously marked as unresolved.

$chargeObj = Charge::retrieve(<charge_id>);

if ($chargeObj) {
    $chargeObj->resolve();
}

Cancel a charge

Cancels a charge that has been previously created. Note: Only new charges can be successfully canceled. Once payment is detected, charge can no longer be canceled.

$chargeObj = Charge::retrieve(<charge_id>);

if ($chargeObj) {
    $chargeObj->cancel();
}

Events

Events API Docs More examples on how to use events can be found in the examples/Resources/EventExample.php file

Load event resource class

use CoinbaseCommerce\Resources\Event;

Retrieve

$eventObj = Event::retrieve(<event_id>);

List

$listEvent = Event::getList();

foreach($listEvent as $event) {
    var_dump($event);
}

$pagination = $listEvent->getPagination();

Get all events

$allEvents = Event::getAll();

Warnings

It's prudent to be conscious of warnings. The library will log all warnings to a standard PSR-3 logger if one is configured.

use CoinbaseCommerce\ApiClient;

//Make sure you don't store your API Key in your source code!
$apiClientObj = ApiClient::init(<API_KEY>);
$apiClientObj->setLogger($logger);

Webhooks

Coinbase Commerce signs the webhook events it sends to your endpoint, allowing you to validate and verify that they weren't sent by someone else. You can find a simple example of how to use this with Express in the examples/Webhook folder

Verify Signature header

use CoinbaseCommerce\Webhook;

try {
    Webhook::verifySignature($signature, $body, $sharedSecret);
    echo 'Successfully verified';
} catch (\Exception $exception) {
    echo $exception->getMessage();
    echo 'Failed';
}

Testing and Contributing

Any and all contributions are welcome! The process is simple: fork this repo, make your changes, run the test suite, and submit a pull request. To run the tests, clone the repository and run the following commands:

composer install
composer test

License

Apache-2.0

coinbase-commerce-php's People

Contributors

btidude avatar douglasokolaa avatar guacamoli avatar imeleshko avatar joshuachinemezu avatar maksim-s avatar mpoletiek avatar oa-coinbase avatar sahil-cb avatar samiragadri-34 avatar scott-huson avatar sds avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coinbase-commerce-php's Issues

Using on Windows

I am on windows and i started using the package directly(put on my project directory). I wrote this:

require_once './coinbase-commerce-php-master/src/ApiClient.php';
require_once './coinbase-commerce-php-master/src/Resources/ApiResource.php';
require_once './coinbase-commerce-php-master/src/Resources/ResourcePathInterface.php';
require_once './coinbase-commerce-php-master/src/Resources/Charge.php';

use CoinbaseCommerce\ApiClient;
use CoinbaseCommerce\Resources\Charge;

But i get an error that i couldn't resolve:
Fatal error: Trait 'CoinbaseCommerce\Resources\Operations\CreateMethodTrait' not found in ...

I left it and i install Composer and the package but it but i don't know what to put in require_once now.
require_once __DIR__ . "/vendor/autoload.php"; doesn't work because i'm on Windows

Not synced with blockchain

I've requested a withdrawal that was confirmed on blockchain. However, Coinbase Commerce shows it as if it were not confirmed, and due to this the platform doesn't allow me to make withdrawals!!

Donation showing on pricing type as no_price

I am developing a website with wallet feature. User can add any amount to their wallet, which can be used to play games or buy stuffs on the website. The site accepts cryptocurrency as their main payment.

ISSUE:
I am creating charges using "no_price" as pricing type. And when user pays using cryptocurrency, the completed screen shows "Thank you for your donation". I cannot find how to update this text while creating charges.
Please help!!

How to get BTC only payments?

Hello. I want to make only BTC payments available, without local currency, without other crypto currencies. How can I get that?

Thanks!

Sandbox

how do I create the Sandbox API key for this commerce code testing?

Main Page Documentation on Canceling Charges is inaccurate

Hello!

Just noticed this in the readme concerning canceling charges.

$chargeObj = Charge::retrieve(<charge_id>);

if ($chargeObj) {
    $chargeObj->confirm();
}

I believe it should be the following instead.

$chargeObj = Charge::retrieve(<charge_id>);

if ($chargeObj) {
    $chargeObj->cancel();
}

Use charge code in redirect URL

Hello,

Is it possible to use a charge code (random unique 8 characters ID) in its redirect URL?

The documentation doesn't state any way to do it, and AFAIK there's no way to update a charge, so I doubt this is possible but I thought I'd still ask.

For now I'm myself generating a random code which I use in my redirect URL, and I know I could also store the charge code in a database once my API receives a charge:confirmed event, but I thought using the charge code in the redirect URL right away would be fancier and would open up more possibilities (at least in my case).

So maybe this could be a nice feature to add anyway?

Can't install because old dependency guzzlehttp 5.x

Can you please update the Guzzlehttp version to 6^ ?
On my system:

google/apiclient v2.2.2 requires guzzlehttp/guzzle (~5.3.1|~6.0)
google/auth v1.3.3 requires guzzlehttp/guzzle (~5.3.1|~6.0)
rapidwebltd/php-google-oauth-2-handler v1.2.2 requires guzzlehttp/guzzle (^6.3)

Error installing:

Problem 1
- Installation request for coinbase/coinbase-commerce ^1.0 -> satisfiable by coinbase/coinbase-commerce[v1.0.0].
- Conclusion: remove guzzlehttp/guzzle 6.3.3
- Conclusion: don't install guzzlehttp/guzzle 6.3.3
- coinbase/coinbase-commerce v1.0.0 requires guzzlehttp/guzzle ^5.0 -> satisfiable by guzzlehttp/guzzle[5.0.0, 5.0.1, 5.0.2, 5.0.3, 5.1.0, 5.2.0, 5.3.0, 5.3.1, 5.3.2, 5.3.3].
- Can only install one of: guzzlehttp/guzzle[5.3.1, 6.3.3].
- Can only install one of: guzzlehttp/guzzle[5.3.2, 6.3.3].
- Can only install one of: guzzlehttp/guzzle[5.3.3, 6.3.3].
- Can only install one of: guzzlehttp/guzzle[5.0.0, 6.3.3].
- Can only install one of: guzzlehttp/guzzle[5.0.1, 6.3.3].
- Can only install one of: guzzlehttp/guzzle[5.0.2, 6.3.3].
- Can only install one of: guzzlehttp/guzzle[5.0.3, 6.3.3].
- Can only install one of: guzzlehttp/guzzle[5.1.0, 6.3.3].
- Can only install one of: guzzlehttp/guzzle[5.2.0, 6.3.3].
- Can only install one of: guzzlehttp/guzzle[5.3.0, 6.3.3].
- Installation request for guzzlehttp/guzzle (locked at 6.3.3) -> satisfiable by guzzlehttp/guzzle[6.3.3].

Required parameter missing: pricing_type

I tried to create charge

ApiClient::init(CryptoAPI::first()->apikey);
        $chargeObj = new Charge();

        $chargeObj->name = 'The Sovereign Individual';
        $chargeObj->description = 'Mastering the Transition to the Information Age';
        $chargeObj->local_price = [
            'amount' => '100.00',
            'currency' => 'USD'
        ];
        $chargeObj->pricing_type = 'fixed_price';
        $chargeObj->save();
        return redirect($chargeObj->hosted_url);

And got error Required parameter missing: pricing_type

PHP 7.2
Shared Hosting

How to check for overpaid?

The API docs leave me puzzled how I should check for overpaid (or underpaid) payments.

Currently my webhook is checking for:

if ($event->type == 'charge:confirmed' || $event->type == 'charge:resolved') {

Completely Broken Extension and No Support

What is the point of posting this extension when it does not even work with the latest Magento?? Currently all these issues exist with 2.3.4:

  1. Cant view any orders made with extension:
    1 exception(s):
    Exception #0 (Magento\Framework\Exception\NoSuchEntityException): Unable to find coinbase order with store id "ORD-200325-4-008"

  2. Extension creates order immediately when submitting even if you change your mind and cancel or try to go back and return to checkout or cart.

  3. Orders never complete sucessfully going to the success "thank you page" instead you always get:
    "Sorry something went wrong, you will be redirected to checkout in 5 seconds." then back to checkout page...yet the order is made!

  4. Numerous issues trying to cancel, view receipt, etc. Virtually anything you can click on with this extension is broke.

What is wrong with the developers that are in charge of this mess? No one replies to messages, I tried contact through Linkedin. I've sent 5 emails to Coinbbase Commerce Support and they never reply. I don't understand why have this extension and git page if no one responsible ever replies, tries to fix the extension or even shows up here. It's extremely frustrating and maddening because the extension actually looks visually nice and if it worked would be wonderful. Compared to the Coinpayments terrible extension this one actually is very customer friendly......to bad it is completely broken though. Does anyone have any idea how we can get help to fix this?

implode() variable order deprecated error when creating checkout object

PHP 7.4.4

Attempting to create a checkout object and I'm having a deprecation error thrown.

    use CoinbaseCommerce\ApiClient;
    use CoinbaseCommerce\Resources\Checkout;

    $checkout_data = [
        'name' => '1 of a thing',
        'description' => 'Tokens for use on Qoin Live.',
        'pricing_type' => 'fixed_price',
        'local_price' => [
            'amount' => 10,
            'currency' => 'USD'
        ],
        'requested_info' => []
    ];
    $checkout_obj = Checkout::create($checkout_data);

This produces the following error in vendor/coinbase/coinbase-commerce/src/Util.php:63 (joinPath()):

implode(): Passing glue string after array is deprecated. Swap the parameters

How to authenticate coinbase commerce api in Laravel

Hello Sir, I want to authenticate API key in Laravel. It means how can I check entered API key is valid or not. Pleas e give me a suggestion.

Thank you,

I am using,
"php": "^7.1.3",
"laravel/framework": "5.8.*",
"coinbase/coinbase-commerce": "^1.0",

Error: Internal Server Error, Code: 500

Request
POST https://api.commerce.coinbase.com/charges

Headers:

Content-Type:application/json
X-CC-Api-Key:*****************************
X-CC-Version:2018-03-22

Body:

name:test
description:test
pricing_type:fixed_price
local_price[amount]:100
local_price[currency]:USD

Response

{
    "status": 500,
    "error": "Internal Server Error"
}

Sandbox or sending test webhooks?

Hi,

I have been working with PayPal's API for almost 10 years. One thing they do that I can't find on your system is sandboxing. I also can't figure out any way to send test webhook events. Can you guys please advise?

Verify SSL removed?

Did you remove the verify SSL option? I wanna test stuff on local server and I can't because the verify ssl option is removed...

Required parameter missing: pricing_type

Request

POST https://api.commerce.coinbase.com/charges HTTP/1.1
Host: api.commerce.coinbase.com
User-Agent: coinbase-http-client
Content-Length: 128
Content-Type: applicaton/json
X-Cc-Api-Key: 2226376d-53a4-484a-a838-99f960a6a432
X-Cc-Version: 2018-03-22
Accept-Encoding: gzip

{"name":"Test Charge","description":"Test Charge","pricing_type":"fixed_price","local_price":{"amount":"5.00","currency":"USD"}}

Response

HTTP/1.1 400 Bad Request
Date: Fri, 23 Apr 2021 12:38:10 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 89
Connection: keep-alive
Set-Cookie: __cfduid=d5f077d3f3511407e9e76f02c6bb67b8d1619181490; expires=Sun, 23-May-21 12:38:10 GMT; path=/; domain=.commerce.coinbase.com; HttpOnly; SameSite=Lax
Cache-Control: no-cache
Vary: Cookie, Origin
X-Content-Type-Options: nosniff
X-Frame-Options: deny
X-Request-Id: 0e9650a7-28a1-414c-8bcb-cca572bd228b
CF-Cache-Status: DYNAMIC
cf-request-id: 09a055e9a20000615f568dd000000001
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 644725bc3b3c615f-ORD

{"error":{"type":"invalid_request","message":"Required parameter missing: pricing_type"}}

which method do i use to create a payment method

I have tested the checkout and charge classes and none of them redirects a user to the payment gateway with the fixed price I have specified.

My question is how do I pass parameters to the user so that those parameters will be used as the payment amount without needing the user to enter another amount.

And again I'm not being redirected to the payment gateway. Please tell me the method that will take me to the payment gateway.

Your requirements could not be resolved to an installable set of packages.

Hi! I'm trying to install lib, I use composer require coinbase/coinbase-commerce but I get error:

Your requirements could not be resolved to an installable set of packages.

Problem 1
- coinbase/coinbase-commerce v1.0.0 requires guzzlehttp/guzzle ^5.0 -> found guzzlehttp/guzzle[5.0.0, ..., 5.3.4] but it conflicts with your root composer.json require (^7.5).
- coinbase/coinbase-commerce[v1.0.1, ..., 1.0.11] require guzzlehttp/guzzle ~5.0|~6.0 -> found guzzlehttp/guzzle[5.0.0, ..., 5.3.4, 6.0.0, ..., 6.5.8] but it conflicts with your root composer.json require (^7.5).
- Root composer.json requires coinbase/coinbase-commerce * -> satisfiable by coinbase/coinbase-commerce[v1.0.0, v1.0.1, 1.0.11].

I trying composer require coinbase/coinbase-commerce:* -W but I get some issue

`logo_url` fails to load

(X-CC-Version: 2018-03-22)

When using a custom logo_url the image fails to load throwing the following error:

Refused to load the image 'https://[edited].com/image.jpg' because it violates the following Content Security Policy directive: "img-src 'self' data: https://exceptions.coinbase.com/js https://res.cloudinary.com https://www.google-analytics.com/ https://images.coinbase.com".

The domain is whitelisted in the account settings, so not sure what's the problem. I guess the Content-Security-Policy has to be relaxed?

Coinbase Commerce payment protocol

Now that Coinbase is switching to this weird new payment protocol where native BTC gets dropped (lol)... is this package this valid for the new API?

I mean... it's abandoned by Coinbase (because why would you want to support the devs actually using your product...) but at least it still kinda works for the current/old API.

Rly?!

Check out those fees tho:

Note the Securely signed in to Coinbase. However, the ginormous network fee persists, despite having enabled instant transfers on my account.

Am I expected to sell a $5 product that incurs a nearly 100% markup in network fees? I am not sure why this interface -- although well done -- is providing the ability to sign in with Coinbase if there is no viable financial incentive to do so.

The irony is that I wanted to add Coinbase Commerce to my solution in addition to PayPal to contrast the two options, all the while denoting that "PayPal has fees" whereas Coinbase does not. While technically true, the network fees are a killer and make PayPal look like a steal at this point.

Finally, I'm digging how Coinbase Commerce's last tweet was from last year. Is anyone still working over there? This is the same company that recently went to market valuated at over $100B, right?

Send money to someone

Please how can we send money to a customer with this APi ? I have no ideas yet but i want to add this function to my website

Payment threshold is invalid

CoinbaseCommerce\Exceptions\InvalidRequestException
Payment threshold is invalid

I get this error when creating a charge.

Cancel a Charge is not yet implemented ?

It's not yet possible to cancel a charge using this api ? The documentation mentions $charge->confirm() but this is also not working. Will add a PR if needed.

No webhook signature

Hi,
The Coinbase Commerce webhook request DOES NOT include the "X-CC-Webhook-Signature" header.
I'm receiving the request on a php page; here all the headers I get:

{
    "User-Agent": "weipay-webhooks",
    "Content-Length": "1453",
    "X-Forwarded-For": "54.175.255.217",
    "X-Predictor": "1",
    "Host": "my.domain.name.com"
}

I've obviously whitelisted my domain.
I think Coinbase is doing a fowarding and forgot to foward the headers in the request...
Someone knows how to fix this? I contacted Coinbase Support recently, waiting for their reply.

Charge "Comfirm" Method Does Not Exist - Fatal Error

It appears the "confirm()" method doesn't exist when doing something like...
$x = Charge::retrieve("some_id"); $x->confirm()

I do see a "cancel" method in the Charge extended class, but which also throws fatal error for undefined method. Is there a missing Trait?

What gives?

Is there any way to refund in coinbase commerce?

Hello Sir, I want to know is there any API available for refund? Please give me a suggestion.

Thank you.

I am using,
"php": "^7.1.3",
"laravel/framework": "5.8.*",
"coinbase/coinbase-commerce": "^1.0",

Can only resolve an UNRESOLVED charge

I am trying to sniff out OVERPAID charges and auto-resolve them.

I do a Charge::retrieve() and then find the last item of the timeline $timeline = (array) $charge->timeline;

This works and I get this last item:

=> [
     "status" => "UNRESOLVED",
     "context" => "OVERPAID",
     "time" => "2020-05-31T20:43:00Z",
     "payment" => [
       "network" => "ethereum",
       "transaction_id" => "REMOVED",
       "value" => [
         "amount" => "0.047840500",
         "currency" => "ETH",
       ],
     ],
   ]

So the status is UNRESOLVED and the context is OVERPAID. Great. So I run:

                    if ($last['status'] == 'UNRESOLVED' && $last['context'] == 'OVERPAID') {
                        $charge->resolve();
                    }

Which throws this error:
CoinbaseCommerce/Exceptions/InvalidRequestException with message 'can only resolve an UNRESOLVED charge'

This IMHO doesn't make any sense as the charge is UNRESOLVED. And in the CB dashboard I can actually resolve the charge by clicking a button.

how to verify signature in laravel

Hi, I wanted to know, I have a laravel project, and tried to implement this package in order to support payments with crypto.

The only problem I have is that I don't know how can I verify coinbase's signature on the webhook events.

What I'm trying to do is something like this example from the readme file:

use CoinbaseCommerce\Webhook;

try {
    Webhook::verifySignature($signature, $body, $sharedSecret);
    echo 'Successfully verified';
} catch (\Exception $exception) {
    echo $exception->getMessage();
    echo 'Failed';
}

I don't have any problem getting the signature or the shared secret, but I don't know how can I get the raw body of the request.

If anyone can help, I'd really appreciate it.

I'm using the following:

  • PHP 8.0.10
  • Laravel 8.61.0
  • coinbase/coinbase-commerce: "^1.0",

Required parameter missing: pricing_type

I'm trying to create a new charge using cURL from the following PHP code:

public function btc_create_charge() {
	$post = [
		'name' => 'user1',
		'description' => 'passuser1',
		'local_price' => [
			'amount' => '100.00',
			'currency' => 'USD'
		],
		'pricing_type' => 'fixed_price'
	];
	// echo "<pre>"; print_r(json_encode($post)); die;
	$ch = curl_init();

	curl_setopt_array(
		$ch, array(
		CURLOPT_URL => "https://api.commerce.coinbase.com/charges",
		CURLOPT_RETURNTRANSFER => true,
		CURLOPT_ENCODING => "",
		CURLOPT_MAXREDIRS => 10,
		CURLOPT_TIMEOUT => 0,
		CURLOPT_FOLLOWLOCATION => true,
		CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
		CURLOPT_CUSTOMREQUEST => "POST",
		CURLOPT_POSTFIELDS => json_encode($post),
		CURLOPT_HTTPHEADER => array(
			"X-CC-Api-Key: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
			"X-CC-Version: 2018-03-22"
		),
	));
	$server_output = curl_exec($ch);
	curl_close ($ch);
	$res=json_decode($server_output, true);
	echo '<pre>'; print_r($res); die;
}

Expected output:

JSON Response

I'm getting the following output:

Array
(
    [error] => Array
        (
            [type] => invalid_request
            [message] => Required parameter missing: pricing_type
        )

)

NOTE: I'm able to perform other operations using my API key, so I presume there's no problem with that.

Use without composer

Currently, I require these files for the webhooks:

require_once 'typo3conf/ext/products/Classes/Coinbase/src/ApiClient.php';
require_once 'typo3conf/ext/products/Classes/Coinbase/src/Util.php';
require_once 'typo3conf/ext/products/Classes/Coinbase/src/Webhook.php';

use CoinbaseCommerce\ApiClient;
use CoinbaseCommerce\Resources\Event;
use CoinbaseCommerce\Webhook;

But right now I end up with the following error:

Class 'CoinbaseCommerce\Resources\Event' not found | Error thrown in file /html/typo3/typo3conf/ext/products/Classes/Coinbase/src/Webhook.php in line 26

Line 26 is this: return new Event($data['event']);

Before this error occurred, I had the error Class 'CoinbaseCommerce\Util' not found, which I "fixed" by including the Util.php file. But I cannot include the file Resources/Event.php, throws an error 500. So I am not sure how to fix this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.