coinbase_commerce
a dart library that connects to interact with the coinbase commerce api.
enables projects to connect seamlessly to coinbase and receive payments!
for more details visit coinbase api docs.
to start using library, you need to register on coinbase commerce and get your api_key from user settings.
next create a coinbase object for interacting with the api:
the object contains links to an dart class representations of the api resources checkout, charge and invoice.
each request returns a coinbaseresponseobject.
every coinbaseresponseobject matches the api response jsons and casts them as models.
features
- create charges
- cancel charges
- view charges
- list charges
- view the status of charges
- create invoices
- view invoices
- list invoices
- create checkouts
- delete checkouts
- view checkouts
- list checkouts
see also:
usage
to create a new instance of a coinbase_commerce object you have to supply your api as generated from the coinbase commerce settings page.
coinbase coinbase=coinbase('your api key here',debug:true);
charges
to create a new charge
chargeobject charge = await coinbase.createcharge(
name: 'coffee charge',
description: '3 cups of coffee',
currency: currencytype.usd,
pricingtype: pricingtype.fixedprice,
amount: 40);
to view the status of your previously created charge
statusobject status = statuscheck().checkchargestatus(image);
charges can either be (new, pending, completed, expired,
unresolved, resolved, canceled, refund pending, refunded,none)
in the case where it returns a status of none it implies that no record of the charge was seen.
to view the information concerning a particular charge
chargeobject charge = await coinbase.viewcharge('your charge id here');
to cancel a charge
chargeobject charge= await coinbase.cancelcharge('your charge id here');
to list all charges assoiciated with an account
list<chargeobject> charge = await coinbase.retrieveallcharges;
checkouts
to create a new checkout
checkoutobject checkout = await coinbase.createcheckout(
description: 'description',
name: 'name',
pricingtype: pricingtype.noprice,
currency: currencytype.usd);
to view the information concerning a particular checkout
checkoutobject charge = await coinbase.viewcheckout('your checkout id here');
to update a previously created checkout, supply the id and the new information,
checkoutobject checkout = await coinbase.updatecheckout(
checkoutid: 'c4357d83-42d4-4d7b-bc44-d0262b1efd25',
name: 'new name here');
to delete a checkout
checkoutobject checkout= await coinbase.deletecheckout('your checkout id here');
to list all charges assoiciated with an account
list<checkoutobject> checkoutlist = await coinbase.retrieveallcheckouts;
invoices
to create a new invoice
invoiceobject invoice = await coinbase.createinvoice(
businessname: 'businessname',
customeremail: '[email protected]',
customername: 'onuoha silver',
currency: currencytype.usd,
amount: 20,
);
to view an invoice
invoiceobject invoice = await coinbase
.viewinvoice('2a4aeb3e-a12b-4728-9c88-297dea5d2adb');
to retrieve all invoices
list<invoiceobject> invoice =await coinbase.retrieveallinvoices;
Comments are closed.