npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue3-coinbase-commerce

v0.0.2

Published

**English** | [简体中文](./README.zh-CN.md)

Downloads

17

Readme

Coinbase Commerce Vue3 Button

English | 简体中文

A button to embed a Coinbase Commerce checkout or charge directly into your Vue3 application.

Install

yarn add vue3-coinbase-commerce

# or npm

npm install --save vue3-coinbase-commerce

Usage

In Vue Single-File Components (SFC):

<script setup lang="ts">
  // import
  import { CoinbaseCommerceButton } from 'vue3-coinbase-commerce'
</script>

<template><div>
    <CoinbaseCommerceButton>Buy</CoinbaseCommerceButton>
</div></template>

<style scoped></style>

If you want to get the checkoutId dynamically from somewhere to use it, please check here

Getting Started

  1. To start accepting digital currency payments, first register for a Coinbase Commerce account here.
  2. Whitelist your domain in Settings.
  3. Follow the API Documentation here to create a charge or checkout.
    • Alternatively, create a checkout from the merchant dashboard and copy the ID found in the checkout's details.
  4. Pass the ID of the charge or checkout you create to the CoinbaseCommerceButton component
  5. That's it! You're ready to start accepting digital currency payments with Coinbase Commerce

Props

In addition to the regular button props, this component accepts some custom props:

| Prop Name | default | required | type | | ---------------- | --------- | --------------------- | --------- | | checkoutId | undefined | If no chargeId, yes | string | | chargeId | undefined | If no checkoutId, yes | string | | disableCaching | true | no | boolean |

Warning: If disableCaching is set to true, users that accidentally close their payment windows will be unable to see their transaction's status upon reopening.

Emits

| Emit Name | default | required | type | | ------------------- | --------- | -------- | ------------------------------ | | onLoad | undefined | no | () => void | | onModalLoaded1 | undefined | no | () => { checkoutId: string } | | onModalLoaded2 | undefined | no | () => { orderId: string } | | onChargeCreated | undefined | no | () => void | | onChargeSuccess | undefined | no | (MessageData) => void | | onChargeFailure | undefined | no | (MessageData) => void | | onPaymentDetected | undefined | no | (MessageData) => void | | onModalClosed | undefined | no | ()=>void |

MessageData like this:

export type MessageData = {
  event:
    | 'charge:created'
    | 'charge:failed'
    | 'charge_confirmed'
    | 'charge_failed'
    | 'payment_detected'
    | 'error_not_found'
    | 'checkout_modal_closed'
    | 'checkout_modal_loaded'
    | 'charge_created'
  charge: Charge
}

For more please click here

Info: Perhaps you noticed that there are two parts, onModalLoaded1 and onModalLoaded2, but what is the difference between these two parts? Simply put, if you pass in the checkoutId parameter, this part of the callback process of onModalLoaded1 -> onChargeCreated -> onModalLoaded2, if you pass in the chargeId parameter, it will directly call back onModalLoaded2. This can be used when the checkout to get the corresponding charge that is order.

Coinbase Wrap

This component allows you to use the checkoutid dynamically and consists of two parts, the CoinbaseWrap component and the useCoinbase function.

Introduce the component in App.vue or wherever you need it.

<script setup lang="ts">
  // import
  import { CoinbaseWrap } from 'vue3-coinbase-commerce'
</script>

<template><div>
    <CoinbaseWrap/>
</div></template>

<style scoped></style>

Then use the useCoinbase function to dynamically control the display of the page

<script setup lang="ts">
  // import
  import { CoinbaseWrap, useCoinbase } from 'vue3-coinbase-commerce'

  const { openWithCheckoutId } = useCoinbase()
  // get checkoutId from somewhere
  const checkoutId = someFunction()
  openWithCheckoutId(checkoutId)
</script>

The subsequent actions are the same as using the buttons, including the events that can be triggered.

License

MIT License.