behzadbabaei/omnipay-coinbase-commerce

Coinbase Commerce driver for the Omnipay payment processing library

v2.1.3 2021-10-11 09:51 UTC

This package is auto-updated.

Last update: 2024-10-25 20:10:23 UTC


README

Coinbase Commerce gateway for Omnipay payment processing library This package has implemented the Commerce API of Coinbase Payment systems For more information please visit the following link:Developer Document

Installation

Omnipay is installed via Composer. To install, simply add it to your composer.json file:

{
    "require": {
        "behzadbabaei/omnipay-coinbase-commerce": "dev-master"
    }
}

And run composer to update your dependencies:

composer update

Or you can simply run

composer require behzadbabaei/omnipay-coinbase-commerce

Basic Usage

  1. Use Omnipay gateway class:
    use Omnipay\Omnipay;
  1. Initialize CoinbaseCommerce gateway:
        $gateway = Omnipay::create('CoinbaseCommerce');

        $gateway->setAccessToken('your-api-key');
        $gateway->setApiVersion('your-api-version');
        $gateway->setLanguage(App::getLocale());

Creating an charge order

Call purchase, it will return the response which includes the public_id for further process. Please refer to the Developer Document for more information.

            $redirectUrl = 'success-url'
            $cancelUrl = 'cancel-url'

            $metaData = [
                'orderId' => $data['orderId']
            ];

            return $this->gateway->purchase([
                'name'        => $data['name'],
                'description' => $data['description'],
                'amount'      => $data['amount'],
                'currency'    => $data['currency'],
                'customData'  => $metaData,
                'redirectUrl' => $redirectUrl,
                'cancelUrl'   => $cancelUrl,
            ])->send()->getData();

Cancel an order

Please refer to the Developer Document for more information.

       return $this->gateway->cancel([
              'orderId' => $orderId
            ])->send()->getData();
        } catch (Throwable $exception) {
            return null;
        }

Retrieve an order

Please refer to the Developer Document for more information.

        return $this->gateway->fetchTransaction([
            'orderId' => $orderId
        ])->send()->getData();

For general usage instructions, please see the main Omnipay repository.

Support

If you are having general issues with Omnipay, we suggest posting on Stack Overflow. Be sure to add the omnipay tag so it can be easily found.

If you want to keep up to date with release announcement, discuss ideas for the project, or ask more detailed questions, there is also a mailing list which you can subscribe to.

If you believe you have found a bug, please report it using the GitHub issue tracker, or better yet, fork the library and submit a pull request.