Skip to content

Commit

Permalink
Merge branch 'develop' into try/poc-express-checkout-button-styles
Browse files Browse the repository at this point in the history
  • Loading branch information
alexflorisca authored Sep 4, 2024
2 parents 34b5607 + 9b93dae commit 58c81a9
Show file tree
Hide file tree
Showing 52 changed files with 808 additions and 220 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
matrix:
checkout: [ 'Default', 'Legacy' ]

name: ${{ matrix.checkout }} WP=latest, WC=latest, PHP=7.4"
name: ${{ matrix.checkout }} WP=latest, WC=latest, PHP=7.4
steps:
- name: Checkout repo
uses: actions/checkout@v4
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/generate-zip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Generate ZIP file

on:
workflow_dispatch:
workflow_call:

jobs:
generate-zip-file:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup node version
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'

- name: Generate ZIP file
run: npm run build && rm -rf ./woocommerce-gateway-stripe && unzip woocommerce-gateway-stripe.zip -d ./woocommerce-gateway-stripe

- name: Use the Upload Artifact GitHub Action
uses: actions/upload-artifact@v4
with:
name: woocommerce-gateway-stripe
path: woocommerce-gateway-stripe/
50 changes: 50 additions & 0 deletions .github/workflows/issue-gardening.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: 'Issue Gardening'

on:
schedule:
- cron: '0 0 * * *'

jobs:
issue-gardening:
name: ${{ matrix.name }}
runs-on: ubuntu-latest
if: ${{ github.repository == 'woocommerce/woocommerce-gateway-stripe' }}
strategy:
matrix:
include:

- name: 'Issues that require more info'
message: 'Help us move this issue forward. This issue is being marked stale since it has no activity after 15 days of requesting more information. Please add info requested so we can help move the issue forward.'
days-before-stale: 15
days-before-close: -1
only-labels: 'status: needs more info'
remove-stale-when-updated: true
stale-issue-label: 'status: stale'

- name: 'Issues without activity for 5 months'
message: "Hi,\nThis issue has gone 150 days (5 months) without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest version, you can help the project by responding to confirm the problem and by providing any updated reproduction steps.\nThanks for helping out."
days-before-stale: 150
days-before-close: -1
only-labels: ''
remove-stale-when-updated: true
stale-issue-label: 'status: needs confirmation'

- name: 'Issues without activity for 6 months'
message: 'This issue has gone 180 days (6 months) without any activity.'
days-before-stale: 30
days-before-close: -1
only-labels: 'status: needs confirmation'
remove-stale-when-updated: true
stale-issue-label: 'status: stale'

steps:
- name: Update issues
uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # v9.0.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: ${{ matrix.message }}
days-before-stale: ${{ matrix.days-before-stale }}
days-before-close: ${{ matrix.days-before-close }}
only-labels: ${{ matrix.only-labels }}
remove-stale-when-updated: ${{ matrix.remove-stale-when-updated }}
stale-issue-label: ${{ matrix.stale-issue-label }}
152 changes: 152 additions & 0 deletions .github/workflows/qit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
name: QIT Tests

on:
workflow_dispatch:
inputs:
test:
description: 'Test to run'
required: true
default: 'default'
type: choice
options:
- default
- activation
- api
- e2e
- phpstan
- phpcompat
- security
- malware
pull_request:
types: [opened, synchronize, reopened, labeled]
branches:
- trunk
- develop

permissions:
contents: read
pull-requests: write

jobs:
build:
if: "${{ ( inputs.test != '' && inputs.test != 'none' ) || contains(github.event.pull_request.labels.*.name, 'needs: qit default tests') || contains(github.event.pull_request.labels.*.name, 'needs: qit activation test') || contains(github.event.pull_request.labels.*.name, 'needs: qit api test') || contains(github.event.pull_request.labels.*.name, 'needs: qit e2e test') || contains(github.event.pull_request.labels.*.name, 'needs: qit phpstan test') || contains(github.event.pull_request.labels.*.name, 'needs: qit phpcompat test') || contains(github.event.pull_request.labels.*.name, 'needs: qit security test') || contains(github.event.pull_request.labels.*.name, 'needs: qit malware test') }}"
uses: woocommerce/woocommerce-gateway-stripe/.github/workflows/generate-zip.yml@fix-qit-security

test:
if: "${{ ( inputs.test != '' && inputs.test != 'none' ) || contains(github.event.pull_request.labels.*.name, 'needs: qit default tests') || contains(github.event.pull_request.labels.*.name, 'needs: qit activation test') || contains(github.event.pull_request.labels.*.name, 'needs: qit api test') || contains(github.event.pull_request.labels.*.name, 'needs: qit e2e test') || contains(github.event.pull_request.labels.*.name, 'needs: qit phpstan test') || contains(github.event.pull_request.labels.*.name, 'needs: qit phpcompat test') || contains(github.event.pull_request.labels.*.name, 'needs: qit security test') || contains(github.event.pull_request.labels.*.name, 'needs: qit malware test') }}"
needs: build
name: run
runs-on: ubuntu-latest

env:
NO_COLOR: 1
QIT_DISABLE_ONBOARDING: yes

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Download build
uses: actions/download-artifact@v4
with:
name: ${{ github.event.repository.name }}

- name: Build plugin zip
run: zip -r ${{ github.event.repository.name }}.zip ${{ github.event.repository.name }}

- name: Set PHP version
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
tools: composer:v2
coverage: none

- name: Install QIT via composer
run: composer require woocommerce/qit-cli

- name: Add partner
run: ./vendor/bin/qit partner:add --user='${{ secrets.PARTNER_USER }}' --application_password='${{ secrets.PARTNER_SECRET }}'

- name: Run activation test
if: "${{ ( inputs.tests == 'default' || inputs.tests == 'activation' ) || contains(github.event.pull_request.labels.*.name, 'needs: qit default tests') || contains(github.event.pull_request.labels.*.name, 'needs: qit activation test') }}"
id: run-activation-test
run: ./vendor/bin/qit run:activation ${{ github.event.repository.name }} --zip=${{ github.event.repository.name }}.zip --wait > activation-result.txt

- uses: marocchino/sticky-pull-request-comment@v2
if: ${{ failure() && steps.run-activation-test.conclusion == 'failure' }}
with:
header: QIT activation result
recreate: true
path: activation-result.txt

- name: Run API test
if: "${{ ( ( inputs.tests == 'default' || inputs.tests == 'api' ) || contains(github.event.pull_request.labels.*.name, 'needs: qit default tests') || contains(github.event.pull_request.labels.*.name, 'needs: qit api test') ) && ( success() || failure() ) }}"
id: run-api-test
run: ./vendor/bin/qit run:woo-api ${{ github.event.repository.name }} --zip=${{ github.event.repository.name }}.zip --wait > api-result.txt

- uses: marocchino/sticky-pull-request-comment@v2
if: ${{ failure() && steps.run-api-test.conclusion == 'failure' }}
with:
header: QIT API result
recreate: true
path: api-result.txt

- name: Run E2E test
if: "${{ ( ( inputs.tests == 'default' || inputs.tests == 'e2e' ) || contains(github.event.pull_request.labels.*.name, 'needs: qit default tests') || contains(github.event.pull_request.labels.*.name, 'needs: qit e2e test') ) && ( success() || failure() ) }}"
id: run-e2e-test
run: ./vendor/bin/qit run:woo-e2e ${{ github.event.repository.name }} --zip=${{ github.event.repository.name }}.zip --wait > e2e-result.txt

- uses: marocchino/sticky-pull-request-comment@v2
if: ${{ failure() && steps.run-e2e-test.conclusion == 'failure' }}
with:
header: QIT E2E result
recreate: true
path: e2e-result.txt

- name: Run PHPStan test
if: "${{ inputs.tests == 'phpstan' || contains(github.event.pull_request.labels.*.name, 'needs: qit phpstan test') && ( success() || failure() ) }}"
id: run-phpstan-test
run: ./vendor/bin/qit run:phpstan ${{ github.event.repository.name }} --zip=${{ github.event.repository.name }}.zip --wait > phpstan-result.txt

- uses: marocchino/sticky-pull-request-comment@v2
if: ${{ failure() && steps.run-phpstan-test.conclusion == 'failure' }}
with:
header: QIT PHPStan result
recreate: true
path: phpstan-result.txt

- name: Run PHPCompat test
if: "${{ inputs.tests == 'phpcompat' || contains(github.event.pull_request.labels.*.name, 'needs: qit phpcompat test') && ( success() || failure() ) }}"
id: run-phpcompat-test
run: ./vendor/bin/qit run:phpcompatibility ${{ github.event.repository.name }} --zip=${{ github.event.repository.name }}.zip --wait > phpcompat-result.txt

- uses: marocchino/sticky-pull-request-comment@v2
if: ${{ failure() && steps.run-phpcompat-test.conclusion == 'failure' }}
with:
header: QIT PHPCompat result
recreate: true
path: phpcompat-result.txt

- name: Run security test
if: "${{ inputs.tests == 'security' || contains(github.event.pull_request.labels.*.name, 'needs: qit security test') && ( success() || failure() ) }}"
id: run-security-test
run: ./vendor/bin/qit run:security ${{ github.event.repository.name }} --zip=${{ github.event.repository.name }}.zip --wait > security-result.txt

- uses: marocchino/sticky-pull-request-comment@v2
if: ${{ failure() && steps.run-security-test.conclusion == 'failure' }}
with:
header: QIT security result
recreate: true
path: security-result.txt

- name: Run malware test
if: "${{ inputs.tests == 'malware' || contains(github.event.pull_request.labels.*.name, 'needs: qit malware test') && ( success() || failure() ) }}"
id: run-malware-test
run: ./vendor/bin/qit run:malware ${{ github.event.repository.name }} --zip=${{ github.event.repository.name }}.zip --wait > malware-result.txt

- uses: marocchino/sticky-pull-request-comment@v2
if: ${{ failure() && steps.run-malware-test.conclusion == 'failure' }}
with:
header: QIT malware result
recreate: true
path: malware-result.txt
17 changes: 17 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
*** Changelog ***

= 8.7.0 - xxxx-xx-xx =
* Fix - Support custom name and description for Afterpay.
* Fix - Link APM charge IDs in Order Details page to their Stripe dashboard payments page.
* Fix - Fix Indian subscription processing by forcing the recreation of mandates during switches (upgrading/downgrading).
* Fix - Add back support for Stripe Link autofill for shortcode checkout.
* Fix - Fix undefined method error caused by settings refactor when connecting Stripe account.
* Fix - Fix multiple compatibility issues and deprecation warnings when running the extension on PHP 8.1.
* Fix - Re-connect promotional surface blinking after disappearing for merchants that have already connected their Stripe account.
* Fix - Fix possible fatal errors when Stripe settings format is invalid during account connection.
* Fix - Clear webhook state after reconfiguring webhooks to remove outdated error and success statuses.
* Fix - Prevent payment methods from being detached from Stripe customers on non-production sites when a WP user is deleted with the new checkout experience enabled.
* Add - Log incoming webhook events and their request body.
* Add - Show UPE payment methods in saved order on block checkout page.
* Add - Display UI elements for connection type and expired keys status for Stripe accounts linked via the WooCommerce Stripe App.
* Tweak - Delete the notice about the missing customization options on the updated checkout experience.
* Fix - Prevent fatal error when canceling uncaptured orders by ensuring refunds array is expanded in Stripe API response.
* Fix - Fix error in saving settings when express payment methods are disabled.
* Fix - Catch error when getting intent from order.
* Fix - Handle undefined array key when no matching customer account is found when guest customers checkout.
* Tweak - Update capabilities to payment methods mapping.
* Fix - Address QIT Security test errors.
* Fix - Address QIT PHPStan test errors.
* Update - Specify the JS Stripe API version as 2024-06-20.
* Tweak - Use order ID from 'get_order_number' in stripe intent metadata.
* Fix - Ensure payment tokens are detached from Stripe when a user is deleted, regardless of if the admin user has a Stripe account.
* Fix - Address Klarna availability based on correct presentment currency rules.

= 8.6.1 - 2024-08-09 =
* Tweak - Improves the wording of the invalid Stripe keys errors, instructing merchants to click the "Configure connection" button instead of manually setting the keys.
Expand Down
5 changes: 4 additions & 1 deletion client/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ export default class WCStripeAPI {
}

createStripe( key, locale, betas = [] ) {
const options = { locale };
const options = {
locale,
apiVersion: this.options.apiVersion,
};

if ( betas.length ) {
options.betas = betas;
Expand Down
7 changes: 7 additions & 0 deletions client/blocks/payment-request/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getSetting } from '@woocommerce/settings';
import { __ } from '@wordpress/i18n';
import { PAYMENT_METHOD_NAME } from './constants';
import { PaymentRequestExpress } from './payment-request-express';
import { applePayImage } from './apple-pay-preview';
Expand All @@ -14,6 +15,12 @@ const componentStripePromise = loadStripe();

const paymentRequestPaymentMethod = {
name: PAYMENT_METHOD_NAME,
title: 'Stripe',
description: __(
'This will show users the ApplePay, GooglePay, or Stripe Link button depending on their browser and logged in status.',
'woocommerce-gateway-stripe'
),
gatewayId: 'stripe',
content: <PaymentRequestExpress stripe={ componentStripePromise } />,
edit: <ApplePayPreview />,
canMakePayment: ( cartData ) => {
Expand Down
67 changes: 63 additions & 4 deletions client/classic/upe/deferred-intent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import jQuery from 'jquery';
import WCStripeAPI from '../../api';
import {
generateCheckoutEventNames,
getPaymentMethodTypes,
getSelectedUPEGatewayPaymentMethod,
getStripeServerData,
isPaymentMethodRestrictedToLocation,
Expand All @@ -10,12 +11,13 @@ import {
} from '../../stripe-utils';
import './style.scss';
import {
processPayment,
mountStripePaymentElement,
createAndConfirmSetupIntent,
confirmVoucherPayment,
confirmWalletPayment,
createAndConfirmSetupIntent,
mountStripePaymentElement,
processPayment,
} from './payment-processing';
import enableStripeLinkPaymentMethod from 'wcstripe/stripe-link';

jQuery( function ( $ ) {
// Create an API object, which will be used throughout the checkout.
Expand Down Expand Up @@ -87,12 +89,69 @@ jQuery( function ( $ ) {
for ( const upeElement of $(
'.wc-stripe-upe-element'
).toArray() ) {
await mountStripePaymentElement( api, upeElement );
const component = await mountStripePaymentElement(
api,
upeElement
);
restrictPaymentMethodToLocation( upeElement );
maybeEnableStripeLinkPaymentMethod(
component.elements,
upeElement.dataset.paymentMethodType
);
}
}
}

function maybeEnableStripeLinkPaymentMethod( elements, paymentMethodType ) {
const isCheckout = getStripeServerData()?.isCheckout;
if ( ! isCheckout ) {
return;
}

if ( paymentMethodType !== 'card' ) {
return;
}

const isStripeLinkEnabled = getPaymentMethodTypes(
paymentMethodType
).includes( 'link' );
if ( ! isStripeLinkEnabled ) {
return;
}

enableStripeLinkPaymentMethod( {
api,
elements,
emailId: 'billing_email_field',
complete_billing: () => {
return document.getElementById( 'billing_address_1' ) !== null;
},
complete_shipping: () => {
return document.getElementById( 'shipping_address_1' ) !== null;
},
shipping_fields: {
line1: 'shipping_address_1',
line2: 'shipping_address_2',
city: 'shipping_city',
state: 'shipping_state',
postal_code: 'shipping_postcode',
country: 'shipping_country',
first_name: 'shipping_first_name',
last_name: 'shipping_last_name',
},
billing_fields: {
line1: 'billing_address_1',
line2: 'billing_address_2',
city: 'billing_city',
state: 'billing_state',
postal_code: 'billing_postcode',
country: 'billing_country',
first_name: 'billing_first_name',
last_name: 'billing_last_name',
},
} );
}

function restrictPaymentMethodToLocation( upeElement ) {
if ( isPaymentMethodRestrictedToLocation( upeElement ) ) {
togglePaymentMethodForCountry( upeElement );
Expand Down
Loading

0 comments on commit 58c81a9

Please sign in to comment.