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

spree-ember-paypal-express

v2.4.0-beta.1

Published

spree-ember addon for the gem better_spree_paypal_express

Downloads

9

Readme

Spree-ember-paypal-express

Build Status Code Climate

spree-ember addon for the gem better_spree_paypal_express

Currently this addon is meant to be used with Spree 2-4-stable.

Install

# not available yet, coming soon
ember install spree-ember-paypal-express

Dependencies

Backend

The following fork of better_spree_paypal_express is needed because it has two things:

  • The changes of PR #168
  • active_model_serializers version 0.8.2

Add to your Gemfile:

gem 'spree_paypal_express', github: 'givanse/better_spree_paypal_express', branch: 'ams_0.8.2'

Frontend

Usage

This addon adds an ember service, paypal-express, and it is injected into the spree service so you can access it from anywhere in your code. Ex:

  actions: {
    initPaypalExpress: function() {
      this.spree.paypalExpress.getRedirectURL().then(response => {
        // redirect to PayPal express
        window.open(response.redirect_url, '_self');
      });
    }
  }

When a payment is completed through PayPal, the page will redirect to the route confirmRouteName. In that route you'll be able to complete the order. Ex:

// ENV['paypal-express'].confirmRouteName
// defaults to spree.checkout

  beforeModel: function(transition) {                                            
    let qp = transition.queryParams;

    let paymentMethodId = qp.payment_method_id;
    let token = qp.token;
    let PayerID = qp.PayerID;

    if (!paymentMethodId || !token || !PayerID) {
      return true;
    }

    this.spree.paypalExpress.confirmOrder(paymentMethodId, token, PayerID)
    .then(() => {
      // the confirmation is done and the order has been advanced to complete

      // redirect is a method already provided by spree-ember
      this.redirect();
    });
  } 

To have more control during the confirmation phase you can use just the method this.spree.paypalExpress.confirm. You can use the confirmOrder implementation as a guide.

Configuration

In config/environment.js you can override the following default values:

ENV['paypal-express'] = {
  paymentMethodName: 'PayPal',
  cancelRouteName: 'spree.cart',
  confirmRouteName: 'spree.checkout'  
}

paymentMethodName is the name of the better_spree_paypal_express payment method that you want to use for every order. You configured that name through the Spree admin.

cancelRouteName is the route where the user is directed to after clicking the "cancel" link in the PayPal pay screen.

confirmRouteName is the route where the user is directed to after completing the payment process with PayPal.

Development

Installation

  • git clone this repository
  • npm install
  • bower install

Running

  • ember server
  • Visit your app at http://localhost:4200.

Running Tests

  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit http://www.ember-cli.com/.


Thanks to @hhff and @williscool for all the help given in the spree-ember gitter room.