New issue
Advanced search Search tips

Issue 751226 link

Starred by 1 user

Issue metadata

Status: Verified
Owner:
Closed: Aug 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Android , Windows , Chrome , Mac
Pri: 1
Type: Bug

Blocking:
issue 660926



Sign in to add a comment

Local mastercard is not triggering modifiers

Project Member Reported by rouslan@chromium.org, Aug 1 2017

Issue description

Chrome Version       : 62.0.3172.0 (canary)
OS Version: Android 7.1.2; Nexus 6P Build/N2G47G
URLs (if applicable) : https://rsolomakhin.github.io/pr/

What steps will reproduce the problem?
1. Enable chrome://flags/#enable-experimental-web-platform-features and chrome://flags/#web-payments-modifiers.
2. Add MasterCard to Autofill settings: 5555 5555 5555 4444
3. Open https://rsolomakhin.github.io/pr/.
4. Click "Buy" on page.
5. Select the "Mastercard****4444" card, if not already selected.

What is the expected result?
Payment should be discounted to USD $50.00 from original USD $55.00. The MasterCard discount should be one of the line items.

What happens instead of that?
Payment is still USD $55.00. The MasterCard discount is not being applied.

Please provide any additional information below. Attach a screenshot if
possible.

UserAgentString: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.13 Safari/537.36


Code used by the page:

/**
 * Initializes the payment request object.
 * @return {PaymentRequest} The payment request object.
 */
function buildPaymentRequest() {
  if (!window.PaymentRequest) {
    return null;
  }

  const supportedInstruments = [{
    supportedMethods: ['https://android.com/pay'],
    data: {
      merchantName: 'Rouslan Solomakhin',
      merchantId: '00184145120947117657',
      allowedCardNetworks: ['AMEX', 'MASTERCARD', 'VISA', 'DISCOVER'],
      paymentMethodTokenizationParameters: {
        tokenizationType: 'GATEWAY_TOKEN',
        parameters: {
          'gateway': 'stripe',
          'stripe:publishableKey': 'pk_live_lNk21zqKM2BENZENh3rzCUgo',
          'stripe:version': '2016-07-06',
        },
      },
    },
  }, {
    supportedMethods: ['basic-card'],
  }];

  const details = {
    total: {
      label: 'Donation',
      amount: {
        currency: 'USD',
        value: '55.00',
      },
    },
    displayItems: [{
      label: 'Original donation amount',
      amount: {
        currency: 'USD',
        value: '65.00',
      },
    }, {
      label: 'Friends and family discount',
      amount: {
        currency: 'USD',
        value: '-10.00',
      },
    }],
    modifiers: [{
      supportedMethods: ['basic-card'],
      data: {
        supportedTypes: ['debit'],
      },
      total: {
        label: 'Debit card discounted donation',
        amount: {
          currency: 'USD',
          value: '45.00',
        },
      },
      additionalDisplayItems: [{
        label: 'Debit card discount',
        amount: {
          currency: 'USD',
          value: '-10.00',
        },
      }],
    }, {
      supportedMethods: ['basic-card'],
      data: {
        supportedNetworks: ['mastercard'],
      },
      total: {
        label: 'MasterCard discounted donation',
        amount: {
          currency: 'USD',
          value: '50.00',
        },
      },
      additionalDisplayItems: [{
        label: 'MasterCard discount',
        amount: {
          currency: 'USD',
          value: '-5.00',
        },
      }],
    }],
  };

  let request = null;

  try {
    request = new PaymentRequest(supportedInstruments, details);
    if (request.canMakePayment) {
      request.canMakePayment().then(function(result) {
        info(result ? 'Can make payment' : 'Cannot make payment');
      }).catch(function(err) {
        error(err);
      });
    }
  } catch (e) {
    error('Developer mistake: \'' + e + '\'');
  }

  return request;
}

let request = buildPaymentRequest();

/**
 * Launches payment request that does not require shipping.
 */
function onBuyClicked() { // eslint-disable-line no-unused-vars
  if (!window.PaymentRequest || !request) {
    error('PaymentRequest API is not supported.');
    return;
  }

  try {
    request.show()
      .then(function(instrumentResponse) {
        window.setTimeout(function() {
          instrumentResponse.complete('success')
            .then(function() {
              done('This is a demo website. No payment will be processed.',
                instrumentResponse);
            })
            .catch(function(err) {
              error(err);
              request = buildPaymentRequest();
            });
        }, 2000);
      })
      .catch(function(err) {
        error(err);
        request = buildPaymentRequest();
      });
  } catch (e) {
    error('Developer mistake: \'' + e + '\'');
    request = buildPaymentRequest();
  }
}
 
Screenshot (Aug 1, 2017 4-16-08 PM).png
225 KB View Download
Status: Started (was: Untriaged)
Cc: anthonyvd@chromium.org
Labels: OS-Chrome OS-Linux OS-Mac OS-Windows
Anthony: Same issue happens on desktop with local cards. (Server cards are fine.)
Summary: Local mastercard is not triggering modifiers (was: Local mastercard is not triggering modifiers on Android)

Comment 4 Deleted

Blocking: 660926
Cc: -anthonyvd@chromium.org gogerald@chromium.org
Owner: anthonyvd@chromium.org
Fixed this on Android, pass it to anthonyvd@ for desktop,
Project Member

Comment 8 by bugdroid1@chromium.org, Aug 7 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/6fae0475a09388e17c07ba6fed383bb1e0eead2a

commit 6fae0475a09388e17c07ba6fed383bb1e0eead2a
Author: Anthony Vallee-Dubois <anthonyvd@chromium.org>
Date: Mon Aug 07 16:51:35 2017

[Web Payments] Match modifiers with local cards if no type specified

Bug:  751226 
Change-Id: If1598d21747ab14fdf7a54055c8f2c66be5426ef
Reviewed-on: https://chromium-review.googlesource.com/602610
Reviewed-by: mahmadi <mahmadi@chromium.org>
Reviewed-by: Mathieu Perreault <mathp@chromium.org>
Commit-Queue: Anthony Vallee-Dubois <anthonyvd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#492340}
[modify] https://crrev.com/6fae0475a09388e17c07ba6fed383bb1e0eead2a/chrome/browser/ui/views/payments/modifiers_browsertest.cc
[modify] https://crrev.com/6fae0475a09388e17c07ba6fed383bb1e0eead2a/components/payments/content/payment_request_spec.cc
[modify] https://crrev.com/6fae0475a09388e17c07ba6fed383bb1e0eead2a/components/payments/core/autofill_payment_instrument.cc
[modify] https://crrev.com/6fae0475a09388e17c07ba6fed383bb1e0eead2a/components/payments/core/autofill_payment_instrument.h
[modify] https://crrev.com/6fae0475a09388e17c07ba6fed383bb1e0eead2a/components/payments/core/payment_instrument.h
[modify] https://crrev.com/6fae0475a09388e17c07ba6fed383bb1e0eead2a/ios/chrome/browser/payments/ios_payment_instrument.h
[modify] https://crrev.com/6fae0475a09388e17c07ba6fed383bb1e0eead2a/ios/chrome/browser/payments/ios_payment_instrument.mm

Status: Fixed (was: Started)
Anthony, I cannot seem to get the mastercard modifier working on https://rsolomakhin.github.io/pr/ using two local cards: a 4242 4242 4242 4242 visa and a 5555 5555 5555 4445 mastercard. Can you verify that it's working?

Comment 11 by ma...@chromium.org, Aug 14 2017

Did you enable the flags? chrome://flags#web-payments-modifiers and chrome://flags#experimental-web-platform-features
Status: Verified (was: Fixed)
Doh! That was it, thank you.

Sign in to add a comment