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

@pinelab/vendure-plugin-accept-blue

v1.8.1

Published

Vendure plugin for creating subscriptions with the Accept Blue platform

Downloads

744

Readme

Vendure Accept Blue Subscriptions

Official documentation here

Create recurring subscriptions with the Accept Blue platform.

How it works

  1. A customer places an order with products that represent subscriptions
  2. Customer adds a payment to order with addPaymentToOrder and supplies credit card details:
    • A customer is created in Accept Blue
    • A payment method with the card details is added to the customer
    • A charge is created for the customer with the initial amount due
    • A recurring subscription(s) for that customer is created
  3. If all succeed, the order is transitioned to PaymentSettled

Getting started

  1. Add to your Vendure config:
  AcceptBluePlugin.init({
   vendureHost: 'https://my-vendure-backend.io'
  }),
  1. Start the server, create a payment method and select Accept Blue as handler
  2. Place an order and use one of the payment methods below:

:warning: Set Use test mode in your payment handler in the admin UI to use Accept Blue in test mode.

Payment methods

These are the different payment methods you can use to pay for an order. Keep in mind that these examples use sample input data.

Pay with Saved Payment Method

If a customer already has a payment method saved in Accept Blue, you can use that to pay for an order.

mutation {
  addPaymentToOrder(
    input: { method: "accept-blue", metadata: { paymentMethodId: 15087 } }
  ) {
    ... on Order {
      id
      code
    }
  }
}

Pay with Check

mutation {
  addPaymentToOrder(
    input: {
      method: "accept-blue"
      metadata: {
        name: "Hayden Zieme"
        routing_number: "011000138"
        account_number: "49000002087"
        account_type: "Checking"
        sec_code: "PPD"
      }
    }
  ) {
    ... on Order {
      id
      code
    }
  }
}

Pay with Nonce/Tokenized card

With the hosted tokenization form, you can obtain a token that represents a credit card, and use that to pay for an order. More info on hosted tokenization here: https://docs.accept.blue/tokenization/v0.2

mutation {
  addPaymentToOrder(
    input: {
      method: "accept-blue"
      metadata: {
        source: "nonce-z5frsiogt4kce2paljeb"
        last4: "1115"
        expiry_year: 2030
        expiry_month: 3
      }
    }
  ) {
    ... on Order {
      id
      code
    }
  }
}

Fetching Transactions and Subscriptions for placed orders

After an order is placed, the order.lines.acceptBlueSubscriptions is populated with the actual subscription values from the Accept Blue platform, so it will not call your strategy anymore. This is to better reflect the subscription that was actually created at the time of ordering.

This means you can now also get the transactions per subscriptions with the field order.lines.acceptBlueSubscriptions.transactions. To refund a transaction, you first need to get the transaction id.

# Sample query
{
  orderByCode(code: "NQWHJ7FNYV7M348Z") {
    id
    code
    lines {
      acceptBlueSubscriptions {
        name
        variantId
        amountDueNow
        priceIncludesTax
        recurring {
          amount
          interval
          intervalCount
          startDate
          endDate
        }
        transactions {
          id
          createdAt
          settledAt
          amount
          status
          errorCode
          errorMessage
          checkDetails {
            # This object is populated when the transaction was made with Check
            name
            routingNumber
            last4
          }
          cardDetails {
            # This object is populated when the transaction was made with a Credit Card
            name
            last4
            expiryMonth
            expiryYear
          }
        }
      }
    }
  }
}

Refunding

Only the initial payment is handled as a Vendure payment, any other refunds are done via a dedicated mutation:

  1. Fetch transactions for a customer or a subscription as explained above
  2. Use the transaction ID to create a refund:
mutation {
  refundAcceptBlueTransaction(transactionId: 123, amount: 4567, cvv2: "999") {
    referenceNumber
    version
    status
    errorMessage
    errorCode
    errorDetails
  }
}

The arguments amount and cvv2 are optional, see the Accept Blue Docs for more info.

CORS

If you run into CORS issues loading the Accept Blue hosted tokenization javascript library, you might need to remove the cross-origin key on your script tag.

Incoming events and webhooks

This plugin emits an AcceptBlueTransactionEvent whenever it receives a webhook with a transaction update from Accept Blue.

import { AcceptBlueTransactionEvent } from '@pinelab/vendure-plugin-accept-blue';

// In your project's application bootstrap
this.eventBus.ofType(AcceptBlueTransactionEvent).subscribe((event) => {
  // Do your magic here
  // Please see the JS docs of `AcceptBlueTransactionEvent` for more information on this object.
  // Event.orderLine may be undefined, for example when refund transactions come in. Refunds are currently not connected to an orderLine
});