Giter Site home page Giter Site logo

checkout-sdk-js's Introduction

@bigcommerce/checkout-sdk

Checkout JS SDK provides you with the tools you need to build your own checkout solution for a BigCommerce store.

The SDK has a convenient application interface for starting and completing a checkout flow. Behind the interface, it handles all the necessary interactions with our Storefront APIs and other payment SDKs. So you can focus on creating a checkout experience that is unique to your business.

Table of contents

Features

The Checkout JS SDK is a client-side JavaScript library for our Storefront Checkout API. It provides all the methods that are required to complete a checkout process, for example:

  • Sign in a customer and begin the checkout process
  • Set shipping, billing and other required information
  • Pay for the order and complete the checkout process

The library also provides integrations with all the payment methods supported by Optimized One Page Checkout, such as:

  • PayPal Express
  • Braintree
  • Square
  • Amazon
  • Klarna
  • AfterPay

Using this library in conjunction with your favorite UI framework, it is possible to build a bespoke checkout UI for a store, that can be augmented with additional features. With Bigcommerce's Open Checkout, we provide Checkout JS as our reference implementation of a checkout written in React to get you started.

Getting started

The Checkout JS SDK is the easiest way to build a bespoke checkout into your store’s theme. We have created the following tutorials to help you get started.

  • Open Checkout Quick Start - In this quick start tutorial, we’ll configure our development environment and make a code change to a fork of BigCommerce’s Open Checkout.
  • Installing Custom Checkouts - This article will outline how to package a custom checkout file, and install a custom checkout via the control panel.

Installation

Using NPM package

You can install this library using npm.

npm install --save @bigcommerce/checkout-sdk

Using CDN URL

You can also use this library by referencing a CDN URL.

https://checkout-sdk.bigcommerce.com/v1/loader.js

The main benefit of using the script URL above is that your application can automatically receive backward compatible updates and bug fixes from us, without having to manually perform an upgrade.

Once the above script is loaded, checkoutKitLoader instance will be available in the window and you can use it to load the module that you need for your application. i.e.:

const module = await checkoutKitLoader.load('checkout-sdk');
const service = module.createCheckoutService();

Currently, there are three modules available for public use:

  • checkout-sdk: This is the main module that contains all the public exports of the package.
  • checkout-button: This sub-module can be used to initialize checkout buttons in the storefront once a cart is created (i.e.: cart page).
  • embedded-checkout: This sub-module can be used to embed our Optimized One-Page Checkout in non-native storefronts (i.e.: Wordpress).

Please refer to the usage guide below for more information on each of them.

Requirements

Browser support

We release the library in ES5 so you don't have to do additional transpilation in order to use it. However, you do require the Promise polyfill if you need to support older browsers, such as IE11.

On the other hand, the CDN version already contains the necessary polyfill for it to work in IE11.

Framework

The library is framework agnostic. In other words, you can use it with any UI framework or library you want.

CORS

As our Storefront Web APIs currently don't support CORS, you will not be able to use the library outside of a BigCommerce store.

Usage

Below is a guide on how to use this library.

Initialize instance

First, you have to create a CheckoutService instance.

import { createCheckoutService } from '@bigcommerce/checkout-sdk';

const service = createCheckoutService();

Load checkout

Once you have the instance, you should load the current checkout and present the information to the customer.

const checkoutId = '0cfd6c06-57c3-4e29-8d7a-de55cc8a9052';
const state = await service.loadCheckout(checkoutId);

console.log(state.data.getCheckout());

The checkout object contains various information about the checkout process, such as the cart, the grand total etc... Once the data is loaded, you can retrieve it by calling the getters provided by the state object.

console.log(state.data.getCart());
console.log(state.data.getBillingAddress());
console.log(state.data.getShippingAddress());

In addition, you can also access the store's checkout configuration. The configuration object contains information about various settings related to checkout, such as the default currency of the store etc...

console.log(state.data.getConfig());

Sign in customer

Before you can collect other checkout information from the customer, you should first ask them to sign in. Once they are signed in, the checkout state will be populated with their personal details, such as their addresses.

const state = await service.signInCustomer({ email: '[email protected]', password: 'password123' });

console.log(state.data.getCustomer());

Alternatively, you can ask the customer to continue as a guest. Note that in this scenario, the email is stored as part of the billing address, but is also accessible via the cart object.

const state = await service.continueAsGuest({ email: '[email protected]' });

console.log(state.data.getCart().email);
console.log(state.data.getBillingAddress().email);

Passwordless Sign-in

Customers could sign in using a single-use link sent to their email address. Once they click on the link, they will be redirected back to the store as a signed-in user.

Learn more about it at CheckoutService#sendSignInEmail

Continue as guest

If your checkout settings allow it, your customers could continue the checkout as guests (without signing in).

const state = await service.continueAsGuest({ email: '[email protected]' });

console.log(state.data.getBillingAddress());
console.log(state.data.getCustomer());

Learn more about it at CheckoutService#continueAsGuest

Set shipping details

Set shipping address

To set a shipping destination for the checkout, you should ask the customer to provide an address. To do that, you need to render a set of form fields for collecting their details. The set of fields also includes all the custom fields configured by the merchant.

const fields = state.data.getShippingAddressFields();

fields.forEach(field => {
    console.log(field);
});

To set the shipping address, you can collate all the address fields and construct a request payload.

const address = {
    firstName: 'Test',
    lastName: 'Tester',
    address1: '12345 Testing Way',
    city: 'Some City',
    stateOrProvinceCode: 'CA',
    postalCode: '95555',
    countryCode: 'US',
    phone: '555-555-5555',
    email: '[email protected]'
};

const state = await service.updateShippingAddress(address);

console.log(state.data.getShippingAddress());
console.log(state.data.getShippingOptions());

Set shipping option

Once the address is provided, you can get a list of shipping options available for the address and the cost for each option.

Then, you can ask the customer to select a shipping option from the list.

const address = state.data.getShippingAddress();
const options = state.data.getShippingOptions();
const state = await service.selectShippingOption(options[address.id].id);

console.log(state.data.getSelectedShippingOption());

Set billing details

In order to complete the checkout process, you also need to collect a billing address from the customer.

const state = await service.updateBillingAddress(address);

console.log(state.data.getBillingAddress());

Apply coupon or gift certificate

You may also want to accept any coupon code or gift certificate provided by the customer.

const state = await service.applyCoupon('COUPON');

console.log(state.data.getOrder().coupon);
const state = await service.applyGiftCertificate('GIFT');

console.log(state.data.getOrder().giftCertificate);

You can also allow the customer to remove any coupon code or gift certificate previously applied.

await service.removeCoupon('COUPON');
await service.removeGiftCertificate('GIFT');

Execute spam protection check

You can also enable bot protection to prevent bots and other types of automated abuse from creating orders. Note that enabling this feature increases checkout friction, which may affect conversions. As such, we recommend leaving this feature out if your store is not encountering bots.

await service.executeSpamCheck();

Learn more about it at CheckoutService#executeSpamCheck.

Submit payment and order

Load payment methods

Before you can place the order, you need to collect payment details from the customer. In order to do that, you must first load and present a list of available payment methods to the customer.

const state = await service.loadPaymentMethods();

console.log(state.data.getPaymentMethods());

Initialize payment method

After that, you should initialize the payment method so they are ready to accept payment details.

await service.initializePayment({ methodId: 'braintree' });

Some payment methods require you to provide additional initialization options. For example, Amazon requires a container ID in order to initialize their payment widget. Otherwise, they will not work properly.

await service.initializePayment({
    methodId: 'amazon',
    amazon: {
        container: 'walletWidget',
    },
});

Submit order

And then, you can ask the customer to provide payment details required by their chosen payment method. If the method is executed successfully, you will create an order and thereby complete the checkout process.

We may require human verification to be completed before payment can be processed, which will be handled during this step.

const payment = {
    methodId: 'braintree',
    paymentData: {
        ccExpiry: { month: 10, year: 20 },
        ccName: 'BigCommerce',
        ccNumber: '4111111111111111',
        ccType: 'visa',
        ccCvv: 123,
    },
};

const state = await service.submitOrder({ payment });

console.log(state.getOrder());

window.location.assign('/order-confirmation');

If the submission is successful, you should redirect the customer to the order confirmation page.

Finalize order

Also, for some payment methods, the customer may be asked to enter their payment details on an external website. For these methods, you must finalize the order when the customer is redirected back to the checkout page in order to complete the checkout flow. This should be done in the background before you present any checkout information to the customer.

await service.loadCheckout();

try {
    await service.finalizeOrderIfNeeded();

    window.location.assign('/order-confirmation');
} catch (error) {
    if (error.type !== 'order_finalization_not_required') {
        throw error;
    }
}

// Render the checkout view

Similarly, if the order finalization is successful, you should redirect the customer to the order confirmation page.

Load order

Once the order is created, you can make a call to retrieve it. This should be done on the order confirmation page so that you can present the final order to the customer.

const orderId = 123;
const state = await service.loadOrder(orderId);

console.log(state.data.getOrder());

Subscribe to changes

Your UI should react to changes to the checkout state. When there is a change, you should present the latest information to the customer. You can do that by subscribing to the checkout state.

The subscriber gets triggered every time there is a change in the state. If the change affects your view, you should re-render it in order to reflect the latest update. The subscriber provides a state object which you can use to get specific checkout information. It also provides meta information such as loading statuses, error details etc...

service.subscribe(state => {
    // Return the current checkout
    console.log(state.data.getCheckout());

    // Return an error object if unable to load checkout
    console.log(state.errors.getLoadCheckoutError());

    // Return `true` if in the process of loading checkout
    console.log(state.statuses.isLoadingCheckout());
});

If you are only interested in certain parts of the state, you can filter out irrelevant changes by providing a filter function to the subscriber.

const filter = state => state.data.getCart();

service.subscribe(state => {
    console.log(state.data.getCart())
}, filter);

You can retrieve the same state object outside of a subscriber if there is a need for it.

const state = service.getState();

console.log(state);

Cancel requests

If you need to cancel a request before it is complete, you can provide a Timeout object when making the request. An example use case might be to implement a UI that updates the shipping address whenever there is a change - so you want to abort any pending requests and only take the latest one.

import { createTimeout } from '@bigcommerce/checkout-js-sdk';

const address = { countryCode: 'US' };
const timeout = createTimeout();

service.updateShippingAddress(address, { timeout });
timeout.complete(); // Aborts the update

API reference

We provide an extensive API reference.

The functions provided by the SDK are:

See also

  • Checkout JS - This is our reference implementation of a checkout built using the Checkout JS SDK.
  • Storefront APIs - The documentation for Storefront Checkout & Cart Web APIs.

Notes

  • If you are using this library on the checkout page of a Stencil theme, you must have Optimized One Page Checkout enabled. Otherwise, you will not be able to preview your changes.
  • You should only use this library on a HTTPS page unless you are developing locally.
  • In order to keep up to date on the latest changes, please subscribe to this repository by clicking on the watch button.

Contribution

We actively maintain and add new features to the library in order to support our official checkout (Optimized Checkout). But we also accept contributions from the community.

If you want to contribute, please refer to the contribution guide.

License

MIT

checkout-sdk-js's People

Contributors

alanmunozn avatar andriivitvitskyi1990 avatar animesh1987 avatar bc-acherednichenko avatar bc-ania avatar bc-dronov avatar bc-nick avatar bc-pablorivera avatar bc-peng avatar bc-sebastianszafraniec avatar bcsnyk avatar danieldelcore avatar davidchin avatar dependabot-preview[bot] avatar dependabot[bot] avatar helga1507 avatar icatalina avatar jfranciscont avatar leebigcommerce avatar lpschz avatar mauricio-sg avatar pascalzajac avatar pavlenkom avatar roberbnd avatar robinong avatar serhii-tkachenko avatar sure-round avatar tharaae avatar toma-r avatar vitalii-koshovyi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

checkout-sdk-js's Issues

the getCustomer() not working properly after login

When i use signInCustomer and after success signin i try ti retrieve the customer from the state with getCustomer(), i have an empty customer as response, it becomes available after some seconds, tipically i need to refresh the page.
Same issue when i signout, the customer is retrievable from the state also after succefull signout for some seconds.
This occurs always in local environment, and often in staging environement.

Missing group name and id in customer object

Previously, the older "quote" API included the customer group id and customer group name as part of the customer object. However, the newer checkout endpoint does not include this data.

Is it possible to add these properties back to the customer object returned by the checkout endpoint?

Unexpected state values returned from service.signInCustomer

Running this piece of code:

import {createCheckoutService} from '@bigcommerce/checkout-sdk'
const service = createCheckoutService()
service.loadCheckout().then(() => {
  service.signInCustomer({
    email: '[email protected]',
    password: 'test',
  }).then((state) => console.log(state.data.getCustomer()))
})

Logs:

{
  "id": 0,
  "isGuest": true,
  "email": "",
  "firstName": "",
  "lastName": "",
  "fullName": "",
  "addresses": [],
  "storeCredit": 0
}

Am I missing something here?

"custom product" is not included in cart

Steps reproduce:

  1. Login to BigCommerce admin.
  2. From Orders > Add, Create a new order
  3. In "Add product" page select "Add a custom product" and specify SKU and price
  4. Save order as draft. You'll get draft order URL
  5. Open URL

Expected: Checkout SDK returns cart information for this draft orders
Actual: cart information returned from checkout SDK does not contain any item information about a custom product.

Feature request - need way to detect inventory missing

Currently, if we use the sdk in cart page, there is no way to tell missing inventory. All APIs works without error until user try to place order.

Can you add API/properties so developer of SDK can check the inventory at the beginning of checkout flow?

Shipping option undefined error on order submit

Dear Support,

We are using BC checkout-sdk-js for one of our client. We setup stencil theme locally and up running with checkout-sdk-js.
While submitting order, getting error "Shipping option undefined".
Find the attached screenshot:

checkout-sdk-issue

deinitializePayment issue with google pay.

Hello, I'm having a problem with Google Pay.

I can initialize google pay and proceed through checkout just fine, but when I try to use deinitializePayment to select a different payment method, I get an error:

vendors~main.js:1 Uncaught (in promise) Error: Unable to proceed because payment method data is unavailable or not properly configured.
    at n._subscribe (vendors~main.js:1)
    at n._trySubscribe (vendors~main.js:1)
    at n.subscribe (vendors~main.js:1)
    at n._subscribe (vendors~main.js:1)
    at n._trySubscribe (vendors~main.js:1)
    at n.subscribe (vendors~main.js:1)
    at t.call (vendors~main.js:1)
    at n.subscribe (vendors~main.js:1)
    at t.call (vendors~main.js:1)
    at n.subscribe (vendors~main.js:1)

Once google pay is initialized, how can I remove it so we can choose another payment method again?

Thanks.

Address with custom field creation not working

I have 2 custom fields in customer addresses. If i palce an order with a "new" address with theese 2 custom fields set, bigcommerce creates the order with the custom fields in the order addresses, and it also creates the new customer address, but in the customer address the custom fields are empty.

AMAZON PAY CONTAINER ID

I am trying to implement amazon pay on bigcommerce checkout custom SDK, but in the documentation it states I need an amazon pay container ID. I Have contacted amazon and they said they dont have an amazon pay container ID. can someone help

How can we let users subscribe newsletters?

Is it possible to let user subscribe newsletters via checkout SDK?

Looks like SDK expose config (below) but there is no method to update user's preference. Can such method be added?

export interface ShopperConfig {
    defaultNewsletterSignup: boolean;
    passwordRequirements: PasswordRequirements;
    showNewsletterSignup: boolean;
}

How to acces the Tax total?

I see there is a tax interface: and I have found a reference to tax in another issue, but I can't seem to find the tax property in any of the returned states that I look at.

Which part of the state is tax supposed to belong to? I was thinking maybe shipping consignments.

Could someone share an example of retrieving the tax value? Thanks!

Draft Order not working

For some reason unknown to us draft orders don't wont work in custom checkout:

  • the custom product is correctly added to the cart
  • when going to the checkout, the checkout appears empty

Seen on Chrome (latest), OSX (latest), Macbook Pro 15" Retina
Video: Youtube
Test Link: Draft Order

Uncaught (in promise) TypeError: Cannot read property 'imageUrl' of undefined at n (theme-bundle.chunk.22.js:1) at theme-bundle.chunk.22.js:1 at x (theme-bundle.main.js:70) at Generator._invoke (theme-bundle.main.js:70) at Generator.t.(anonymous function) [as next] (https://cdn11.bigcommerce.com/s-pqeliom1as/stencil/af777a10-2226-0137-c6c4-0242ac11001f/e/5ac69dc0-1ca0-0137-61a6-0242ac110025/dist/theme-bundle.main.js:70:17264) at i (theme-bundle.chunk.22.js:1) at theme-bundle.chunk.22.js:1 n @ theme-bundle.chunk.22.js:1 (anonymous) @ theme-bundle.chunk.22.js:1 x @ theme-bundle.main.js:70 (anonymous) @ theme-bundle.main.js:70 t.(anonymous function) @ theme-bundle.main.js:70 i @ theme-bundle.chunk.22.js:1 (anonymous) @ theme-bundle.chunk.22.js:1 Promise.then (async) i @ theme-bundle.chunk.22.js:1 (anonymous) @ theme-bundle.chunk.22.js:1 Promise.then (async) i @ theme-bundle.chunk.22.js:1 (anonymous) @ theme-bundle.chunk.22.js:1 (anonymous) @ theme-bundle.chunk.22.js:1 (anonymous) @ theme-bundle.chunk.22.js:1 (anonymous) @ theme-bundle.chunk.22.js:1 x @ theme-bundle.main.js:70 (anonymous) @ theme-bundle.main.js:70 t.(anonymous function) @ theme-bundle.main.js:70 i @ theme-bundle.chunk.22.js:1 (anonymous) @ theme-bundle.chunk.22.js:1 Promise.then (async) i @ theme-bundle.chunk.22.js:1 (anonymous) @ theme-bundle.chunk.22.js:1 Promise.then (async) i @ theme-bundle.chunk.22.js:1 (anonymous) @ theme-bundle.chunk.22.js:1 Promise.then (async) i @ theme-bundle.chunk.22.js:1 (anonymous) @ theme-bundle.chunk.22.js:1 (anonymous) @ theme-bundle.chunk.22.js:1 (anonymous) @ theme-bundle.chunk.22.js:1 (anonymous) @ theme-bundle.main.js:41 l @ theme-bundle.main.js:39 u @ theme-bundle.main.js:39 setTimeout (async) (anonymous) @ theme-bundle.main.js:39 c @ theme-bundle.main.js:39 add @ theme-bundle.main.js:39 (anonymous) @ theme-bundle.main.js:39 t.Deferred @ theme-bundle.main.js:70 then @ theme-bundle.main.js:39 C.fn.ready @ theme-bundle.main.js:39 t.load @ theme-bundle.main.js:41 (anonymous) @ theme-bundle.main.js:60 x @ theme-bundle.main.js:70 (anonymous) @ theme-bundle.main.js:70 t.(anonymous function) @ theme-bundle.main.js:70 i @ theme-bundle.main.js:60 (anonymous) @ theme-bundle.main.js:60 (anonymous) @ theme-bundle.main.js:39 t.exports @ theme-bundle.main.js:41 g.(anonymous function) @ theme-bundle.main.js:41 y @ theme-bundle.main.js:41 b @ theme-bundle.main.js:41

Visa Checkout: "Sign In To Visa Checkout" Does not trigger Visa Modal.

This has probably been answered so hopefully I can be pointed to a resource. I have the same issue with PayPal so I am hoping this helps that issue as well.

Screen Shot 2019-07-11 at 1 01 52 PM

I render the payment options, and when I select "Visa Checkout", I can see the initialization happen successfully:

Screen Shot 2019-07-11 at 1 04 20 PM

When I inspect the DOM, the HTML appears to be the same as the live non checkout SDK functional version:

<div class="collapse show" style="">
    <div class="form-checklist-body">
        <div class="paymentMethod paymentMethod--walletButton">
            <a id="walletButton" href="">Sign In To Visa Checkout</a>
        </div>
    </div>
</div>;

However, when I click the sign in link, it just redirects me back to /. I would expect the initialization to override this link and maybe it's not?

I am obviously missing one key component here as this is basically the same behavior with all the hosted payment methods I am trying.

Thanks for the feedback in advance!

Cancel PayPal payment method not working after selected

So, I am using the CheckoutButtonInitializer with the BraintreePayPal payment method.

Once the user signs into their PayPal account, the page refreshes and the only payment method available is the BraintreePayPal one, which works as expected - however I can't seem to deinitalize or cancel this method in any way, to give the user choice of all payment options again - could you advise?

With Google Pay (via CheckoutButtonInitializer also), I am running the following commands if the user wants to change their mind on payment method after they've selected a card in the Google Pay modal window (and the page has refreshed after selection).

await checkoutService.deinitializeCustomer({
     methodId: methodId
})

await checkoutService.signOutCustomer({
     methodId: methodId
})

The variable methodId equals googlepaystripe or googlepaybraintree in the above examples.

The above works for Google Pay only. If we do the same for PayPal, it does nothing. The method is still the only one available after the actions are run.

I am assuming from here that PayPal is included in the 'some' payment methods require their own sign-in/out flow - which is why I'm trying the signOutCustomer method, which seems to work for Google Pay.

how to apply store credit

Hi, first thanks for helping me out.
When reading docs, my understanding is that I can switch to use store credit when submitOrder
this.service.submitOrder({ payment, useStoreCredit: true, })

My questions is, once customer logged in, how can I apply storecredit to cart/order? is this need to be done manually? Thank you

Feature request - better types for coupon errors

Problem

Currently, when user try to apply coupon applyCoupon method may give generic error like Error: Coupon code '1DAA7FDCB4F9925' is not eligible for this checkout.

This can indicate lots of things:

  • User may need to add more items to cart because coupon has minimum cart amount limit
  • User may need to add different items to cart because coupon is specific to certain product
  • etc..

If coupon is disabled, we get errors like Error: Coupon code '7AD4E90C18D1DCC' is invalid. There is no way for SDK client to distinguish this vs error above without parsing error message.

Request

Define type for coupon error. Error type should have a type enum so SDK client can distinguish various errors and can provide proper message to users.

LineItemOption does not expose ID needed for POST order API call

Issue

CheckoutSDK provides LineItemOption that has name_id and value_id fields. Looks like it expose values from api/storefront/checkout/<id> endpoint.

When I try using these value_ids with v2 POST order API (use case - when submitOrder failed for some reason and cart is abandoned, we'd like to create an order from backend), API failed with "The options of one or more products are invalid." error.

api storefront checkout id
screen shot 2018-11-18 at 10 11 50 am

It turns out, this value_id is different (?) than product_options.value we can use for v2 POST order API. If you inspect DOM in the product page, you see attribute index is 118 in screenshot below while value_id is 8. When I change value to 118, POST order API worked.

product_page
postman 2018-11-18 10-25-47

Feature request

Can you update value_id to be same value that POST order API expect, or add another field?

Multiple Braintree PayPal checkout buttons not appearing correctly on cart page

There seems to be an issue with the Braintree PayPal integration. I have noticed recently that only one of the three PayPal buttons on our checkout are appearing. Please see below:

The cart page has 3 locations where the button is supposed to appear.

Location 1: Mobile-only top location
Location 2: Desktop-only top location
Location 3: Mobile and Desktop bottom location

The buttons used to appear in all three locations as expected, but recently I've noticed that only Location 1 is appearing, and the other two locations do not show a button.

This is troublesome for us since we need the button to appear in multiple places. For example, here is the mobile layout, which works correctly since the mobile-only top location is the first one in the markup. The PayPal button appears correctly underneath the AmazonPay button:

paypal_location1

However, there should also be a PayPal button in Location 3 underneath the Amazon button, but as you can see, it does not appear:

paypal_location3

Additionally, on desktop, no PayPal buttons appear since desktop uses Location 2 and Location 3:

paypal_location2and3

Location 2 and 3 both contain the code to show the button, but they never appear:

paypal_code

To reproduce, go to https://www.storeyourboard.com/skateboard-deck-display-floating-mount/ and click "Add to Cart". The issue appears on the cart page as long as an item is in the cart.

In other words, the checkout buttons only appear when an item is in your cart. So make sure there is an item in your cart. Then anytime you visit the cart page, you will see the issue.

I can also see that 3 calls to get the checkout button are being made, but only one is being rendered. I started by reporting the issue to PayPal, but I'm now pretty sure the issue is on the BigCommerce side since the issue does not occur in their testing environment.

Again, this used to work correctly, so I'm assuming it has something to do with the new checkout SDK. Can someone help figure this out?

Instructions on how to add the option to save a payment method

I am using the checkout sdk in conjunction with the reactjs checkout-app.

I intend to provide user with option to persist the cc for future purchases when they check out. Already on the BC plus plan.

I would like some pointers on how that can be accomplished.

I see there is a loadPaymentMethods, but I don't see a way to "update" or "persist' a payment method.

Presumably it would be somewhere in the submitOrder method. I do see that the submitOrder method has a "RequestOptions" field, which can be a "PaymentRequestOptions". Presumably I can pass some flag there saying I want to persist this payment method. But doc doesn't mention how that can be done.

Please provide pointer on how to do this. Thanks.

Google analytics enhanced transaction tracking not working with hosted payment

Expected Behavior
When using hosted payment solutions such as Adyen the customer should be redirected to checkout so that the finalize payment method can be invoked to add additional jscript (eg Google Analytics Conversion Tracking) can be fired.

Current behavior
As payments.bigcommerce.com handles redirect to the order confirmation page for hosted payment gateways skips the return to checkout, finalize order can’t be invoked therefor the transaction can’t be send to google analytics.

Any tips making the bundle smaller?

When I include this library, my bundle size increased by about 500K. I'm using webpack 4 production build. Why is this library so big when it's just a wrapper around some APIs? Any tips on minimizing the bundle?

Braintree Credit Card and Braintree PayPal Credit Card payment errors

@capsula4 thanks for your quick reply - I viewed the api requests from the HAR file - it is a little confusing to me since it seems like the posting of the order is fine, as well as the get request for the completed order data:

2018-10-12_1028

I have double checked and the order is not posting to the store, when i refresh the page the order is still in the cart. One thing I did notice was the post data from showing a blank customer message:

00000270

I am not exactly sure why this is showing as I have not added any place for a customer message, and I couldnt find it being required in the docs anywhere

Originally posted by @PeteyRev in #430 (comment)

I'm experiencing this same issue, I've done as @PeteyRev has suggested and changed service from a Vuex store property to data on the main app component, the results are no different. Maybe @PeteyRev can provide more insight as to the solution for this or @davidchin given that this has the 'investigate' tag on it now. I'm able to successfully use the test payment gateway with the same code, but braintree credit cards and braintree paypal result in this exact error. The orders are created as 'Pending'.

Screen Shot 2019-06-30 at 11 44 46 PM

Screen Shot 2019-06-30 at 11 45 04 PM

Screen Shot 2019-06-30 at 11 45 52 PM

Determine whether a credit card or debit card is being used?

With surcharging/convenience fee gaining traction we are looking to see if we can both:
a) Determine whether a credit card or debit card is being used.
b) If a debit card is being used to checkout then remove the predetermined surcharge amount.

I searched through the SDK and I couldn't find any endpoints that determine debit vs credit.

Allow creating customers in Checkout flow

N.B. This issue has been crossposted to Cornerstone Theme Git as it's not clear to me which one would be the appropriate.

Introduction

Our store has implemented user registration via a proprietary middleware handling user registration right inside the checkout. In this way we have increased conversion rate by 400%. I would like to bring this issue up as it seems one of the most underrated missing features of BigCommerce and concerns the checkout in particular.

Current Feature Set

Right now to register a user during checkout following steps have to be taken:

  1. Add a product to cart
  2. Proceed to Checkout
  3. Click Sign-In
  4. Click Register User
  5. Leave Checkout to user registration page
  6. Fill out 11 form fields containing the full address
  7. save the new account and return to the home page
  8. return to checkout by finding the basket
  9. complete billing address
  10. Pay

Problems with this process

  1. Confusing for customers
  2. Less qualified data for the merchant due to more guest-accounts than neccessary(guest account vs customer account)
  3. pushing customers to guest checkout instead of user registration providing especially in GDPR countries many legal issues (a registered user gives a legal justification to store data, while guest user data can only be stored as long as necessary for processing the order, as long as they don't opt in into privacy and general terms such as a regular user)
  4. guest users support less features in BC (nobody ever explained why)
  5. users with intention to register eventually have a higher abandoning rate due to more complex process with confusing changes to UI and UX

To give a clear comparison you can find below our proprietary true one page checkout (screenshot) compared to the steps necessary and BigCommerce right now to execute a registration when purchasing a good.

Solution

The BigCommerce API v2 and v3 support customer registration. They should be embedded in the Checkout SDK enabling a truly conversion optimised checkout improving revenue for merchants. See the picture below for an example of a one-page solution as we have implemented it with a custom middleware vs a video registration of todays default one page optimized checkout when registering a customer.

Screenshot 2019-07-16 at 14 15 27

Phone number on checkout

@bookernath referenced in #514 the usage of the customer Current Customer API. Trying to query additional fields of the customer it seems nevertheless impossible to get the phone number.

Error Installing with Yarn

I am using node version 8.11.1

When I attempt to install the package: yarn add @bigcommerce/checkout-sdk'

$ yarn add @bigcommerce/checkout-sdk
yarn add v1.6.0
warning ../../../package.json: No license field
[1/4] 🔍  Resolving packages...
warning @bigcommerce/checkout-sdk > messageformat > glob > [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
[2/4] 🚚  Fetching packages...
error @bigcommerce/[email protected]: The engine "node" is incompatible with this module. Expected version "^6.10.0".
error Found incompatible module
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

Error when install the module

I got this error when install the module

npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/Volumes/Data/cavanaughs/cornerstone/node_modules/npm/node_modules/dezalgo/node_modules/asap' -> '/Volumes/Data/cavanaughs/cornerstone/node_modules/npm/node_modules/dezalgo/node_modules/.asap.DELETE'
npm ERR! enoent This is related to npm not being able to find a file

CDN for umd build

Hi, is checkout-sdk.umd.js on a CDN some where? I would like to use it in a script tag, but I don't want to host it myself.

Clearing out coupon errors

Is there a way to clear out a coupon error without having to enter a valid coupon?

Right now the state seems to be stuck with the coupon error until a valid coupon is entered. However, It would be useful to have a method to clear out the error for coupons.

Problem using service.finalizeOrderIfNeeded(); with hosted page payment

Good morning, i need to use some code in custom checkout sdk "after" successful payment in external payment gateway hosted page. Following the documentation https://github.com/bigcommerce/checkout-sdk-js#finalize-order i call the await service.finalizeOrderIfNeeded(); and after this i need to call some js before redirecting to the order confirmation page.
In most cases the redirection to the order confirmation page is done directly by the sdk, not the code in my custom checkout page, in fact in the integration panel of bigcommerce the gateway redirection page is payments.bigcommerce.com/... and cannot be changed.

Sometimes it works but i think it is only a failover behaivoir

Connect Amazon Pay Button with Amazon Pay Widget

We are using React based checkout provided by big commerce to customize few things in checout page , here is the link of our website : https://www.babiesgetaway.com/

Now, for amazon pay button we have used one npm package as bigcommerce button initializer doesn't support amazon pay button initialization.

for amazon pay widget , we are using the default initializePayment service of big commerce :

this.service.initializePayment({ methodId: 'amazon', amazon: { container: 'walletWidgetDiv', onReady:this.amazonOnReady, onPaymentSelect:this.amazonOnPaymentSelect, onError:this.amazonOnError } })

Now, we are able to login & get the access_token via amazon pay button but when customer selects the "amazon pay" as an payment option , amazon pay widget is throwing error "buyer's session is expired"

image

so how do we connect amazon pay button with its widget ?

Braintree payment methods incorrect

I'm using sandbox Braintree account (I had to call support to get them to enable it).

Here are the important settings:

screen shot 2018-10-11 at 08 21 34

Here is the response from the API:

screen shot 2018-10-11 at 08 23 34

No logo is returned for Paypal but is returned for the credit card form. This is the opposite from the stock optimized checkout and seems wrong.

Feature request - expose shipping tax

Problem

Currently checkout object only expose one tax field. If user select shipping option using shipping estimator in cart page, there is no way to tell breakdown between subtotal tax and shipping tax

shippingtax

Proposal 1

taxes field already returns array. It should return two entry, one for subtotal tax and another for shipping tax

Proposal 2 (less ideal)

sdk should provide removeShippingOption method so user of sdk can remove shipping option to calculate subtotal fix

IE11 transpiling issue with messageformat

The messageformat library uses template literals which will cause an error with IE11 (might be a problem with the build process). Changing the version to 2.2.1 fixes the problem.

loadCheckout throws exception instead of returning error as getLoadCheckoutError

Following code seems ok but in reality it throws exception at runtime.

  const result = await sdk.loadCheckout();
  if (result.errors.getLoadCheckoutError()) {
     console.log('error');
  }

When I call this logic in cart page, if user completes the checkout and then come back to cart page, exception with message Checkout Id <id> does not exist (<id> is alphanumeric sequence)

I think loadCheckout should always resolve regardless of success or not, and if it ends up in error, return error details with result.errors.getLoadCheckoutError()

Payment Unexpected Error

I am building a custom checkout using the Checkout SDK React example as a basis. I am now noticing an issue with submitting payments via the Cybersource credit card payment method. Upon submission I am receiving "An unexpected error occurred." Using Google dev tools, I can see the error returned by
https://payments.bigcommerce.com/api/public/v1/orders/payments is:

image

I cannot figure out why this is happening, the card being used is valid. The payment data upon submission appears as such:

image

The payment configuration for Cybersource comes through as:

image

Anyone have any thoughts?

Documentation request - difference between cart.discountAmount and cart.discounts.discountedAmount

More detailed documentation will help SDK users a lot :)

For instance, one may think cart.discountAmount is a sum of cart.discounts.discountedAmount, but in reality these two seems to be completely independent value (!)
My current understanding is cart.discountAmount is a cart-level discount while cart.discounts is a user-entered coupons.

Can these information explicitly added to https://github.com/bigcommerce/checkout-sdk-js/blob/master/docs/interfaces/cart.md ?
screen shot 2018-08-25 at 7 39 01 pm

Customer state after sign in is stale.

I have gone about trying this in many different ways, but here is the gist of it.

I sign in the customer, then log the state of the customer:

const state = yield service.signInCustomer({ email, password });
console.log('CUST AFTER SIGN IN', state.data.getCustomer());

However, the data is always coming back as a guest: {id: 0, isGuest: true, email: "", firstName: "", lastName: "", …}

It doesn't seem to be a timing issue, as I wait a minute then call state.data.getCustomer() and still the same results.

I know the sign in is a success because I see the updated customer profile after I do a hard page reload.

This is driving me bonkers, please halp!

Adding item to cart with storefront api doesn't trigger `subscribe(` handler

I'm using this API to add an item to the cart. But my checkoutService.subscribe( isn't getting triggered.

When I reload the page I can see the item has been added to the cart.

Is this a known issue - is there a work around?

Here is my code:

const checkoutService = createCheckoutService()
export const subscribeToBigCommerceData = async handler => {
  await Promise.all([
    checkoutService.loadCheckout(),
    checkoutService.loadShippingCountries(),
    checkoutService.loadShippingOptions(),
    checkoutService.loadBillingCountries(),
    checkoutService.loadPaymentMethods(),
  ])
  checkoutService.subscribe(handler)
}

LineItemOption.value is empty for checkbox modifier option

  1. Create modifier option via API as documented in https://developer.bigcommerce.com/api-docs/catalog/products/modifier-options#modifier_add-modifer
    Just in case link changes, API payload is:
{
  "type": "checkbox",
  "required": false,
  "config": {
    "default_value": "Yes",
    "checked_by_default": false,
    "checkbox_label": "Check for Donation"
  },
  "display_name": "Add a $5 Donation"
}
  1. Now go to storefront and add item. Below is console.log of item.options. As you can see , value of option (Yes/No) is shown in cart page, but it's not available from SDK.

bc_sdk_valud_is_empty

Create a user on the confirmation screen

I have noted the responses on #419 but this is a slightly different request, so I thought I'd ask anyway.

We are looking to create a custom confirmation page that matches the look of the custom checkout we have in place. One of the things we would need is the ability for the user to add a password to create an account - if they went through the cart as a guest.

We aren't looking to have a general sign up process during the checkout, like #419.

I'm guessing this isn't currently possible from the docs, but I thought I'd check if I'd missed something, or whether this could be an option in future?

How to make Paypal Express checkout go direct to Using Credit or Debit Card?

Right now when the customer selects Paypal and clicks place order, a pop up will show up display Paypal Login form. If they want to pay using a credit card without Paypal account, they need to take one more step so the Credit Card form can show up. I would prefer the customers can go directly to the Credit Card form.

I believe it can achieve by sending addition parameters like SOLUTIONTYPE = "Sole" in SetExpressCheckout API (here).

Could you guide me on how to do it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.