Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Cash App Pay payment method #53

Merged
merged 31 commits into from
Jan 31, 2024
Merged

Conversation

iamdharmesh
Copy link
Member

@iamdharmesh iamdharmesh commented Jan 22, 2024

All Submissions:

  • Does your code follow the WooCommerce Sniffs variant of WordPress coding standards?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?
  • Will this change require new documentation or changes to existing documentation?

Changes proposed in this Pull Request:

PR adds support for the "Cash App Pay" payment method to the extension. Additionally, the PR includes changes to support the block checkout.

Cash App Pay does not support stored payment methods; therefore, it cannot be used to place subscriptions or pre-order products.

Important Note:

PR is not tested with the Square production environment, it should be tested with the Square production environment before we merge/release this.

image

Payment method settings page:
image

Shortcode checkout Block checkout
image image

Notes for reviewer:

  1. E2E tests for this have not been added, it will be added as a follow-up PR to unblock this PR for the code review and QA.
  2. The Cash App Pay documentation states that it is available for buyers and sellers in the US only. Therefore, the current implementation limits Cash App Pay based on both the merchant’s country and the buyer’s country. For example, Cash App Pay will be available only if the store’s base address is in the US, and the customer’s billing address is also in the US. Could you please let me know if we should limit this by the store’s base address only or the customer’s billing address only instead of both?

Closes #50

Documentation updates:

The Cash App Pay section provided in the Google Docs below needs to be added to the Square Payments documentation page.
https://docs.google.com/document/d/1-OIyJ3uwaSTQ_-HLWgI4eZ_JsbCoP-cmpouxESfIbag/edit?usp=sharing

Steps to test the changes in this Pull Request:

Admin:

  1. Check out this PR branch and set up the extension (Connect to Square and select the business location).
  2. Navigate to WooCommerce settings and choose US as the base store location country if not already selected.
  3. Ensure that you receive a notice to enable "Cash App Pay (Square)" to commence accepting payments.
  4. Go to the payment method settings page, enable the payment method, and save other gateway settings.
  5. Choose a store base country other than the US and confirm that you receive a notice indicating that Cash App Pay is only supported in the US.

Frontend: (Block-based and shortcode checkout)

  1. Visit the frontend using a desktop/PC browser.
  2. Add any simple/variable product to the cart and proceed to the checkout page.
  3. Confirm that "Cash App Pay" is listed as an available gateway in the gateway options.
  4. Validate that the title, description, and pay button-related settings correctly reflect on the checkout page.
  5. Verify that the "Cash App Pay" gateway is removed from available options if the customer selects a country other than the US.
  6. Enter a US-based billing address and select "Cash App Pay" as the payment method.
  7. Click the "Cash App Pay" button, it will open a QR code popup.
  8. Scan the QR code using the phone's camera app, visit the payment link, approve the payment, and confirm that the order is successfully placed.
  9. Visit the frontend on the phone's browser.
  10. Follow the steps above until selecting "Cash App Pay" as the payment method.
  11. Click the "Cash App Pay" button, it will redirect you to the Cash App website.
  12. Complete the payment process there, ensuring redirection back to the checkout page and successful order placement.
  13. Repeat all the above steps using the Block-based checkout.

Order Pay page:

  1. Add any simple/variable product to the cart and generate an order with a pending payment status.
  2. Navigate to "My Account" > "Orders."
  3. Click the "Pay" button for the pending payment order.
  4. Pay the order using the "Cash App Pay" payment method and verify that the payment is collected without any issues.

Refunds:

  1. Place several orders using the "Cash App Pay" payment gateway.
  2. Go to "WooCommerce > Orders."
  3. Click on any order placed with the Cash App Pay payment method.
  4. Click on the refund button and attempt to refund the full amount, ensure that the order refund works as expected.
  5. Choose another order and attempt to refund a partial amount, confirm that the order refund works as expected.

Inventory sync:

  1. Set up Square product sync and activate inventory sync.
  2. Add any Square-synced product to the cart and place an order using "Cash App Pay."
  3. Verify that the inventory is correctly synced for the ordered product.
  4. Refund the order and confirm that the inventory is synced correctly for the same product.

Changelog entry

Add - Support for the Cash App Pay payment method.

@iamdharmesh iamdharmesh self-assigned this Jan 22, 2024
@jeffpaul jeffpaul added this to the Future Release milestone Jan 24, 2024
@iamdharmesh iamdharmesh changed the title [WIP] Add support for Cash App Pay payment method Add support for Cash App Pay payment method Jan 26, 2024
assets/js/frontend/wc-square-cash-app-pay.js Outdated Show resolved Hide resolved
includes/Gateway/Cash_App_Pay_Gateway.php Outdated Show resolved Hide resolved
includes/Gateway/Cash_App_Pay_Gateway.php Outdated Show resolved Hide resolved
@dkotter
Copy link
Contributor

dkotter commented Jan 26, 2024

@iamdharmesh Nice work here, this all looks great! I've left a few minor comments / suggestions but those things don't need to block QA, so moving this along for @qasumitbagthariya to start testing.

@dkotter
Copy link
Contributor

dkotter commented Jan 26, 2024

Note for other reviewers, there are some PHPCS failures getting flagged here but in looking at those, they all are around @since statements on filters, which those will be set appropriately during the release process, so those errors can be ignored for now

Copy link
Contributor

@jeffpaul jeffpaul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions to handle. Also curious if there are any e2e tests that are feasible here, admitting an actual test payment flow may not be feasible / something we can mock.

assets/blocks/cash-app-pay/index.js Show resolved Hide resolved
assets/blocks/cash-app-pay/utils.js Show resolved Hide resolved
assets/js/frontend/wc-square-cash-app-pay.js Show resolved Hide resolved
includes/Gateway/Cash_App_Pay_Gateway.php Show resolved Hide resolved
includes/Gateway/Cash_App_Pay_Gateway.php Show resolved Hide resolved
includes/Gateway/Cash_App_Pay_Gateway.php Show resolved Hide resolved
includes/Gateway/Cash_App_Pay_Gateway.php Show resolved Hide resolved
includes/Gateway/Cash_App_Pay_Gateway.php Show resolved Hide resolved
@iamdharmesh
Copy link
Member Author

@iamdharmesh
I noticed a Deprecated warning with PHP Version: 8.2.10 and 8.3.0, can you please check from your end?

Creation of dynamic property WooCommerce\Square\Gateway\Cash_App_Pay_Gateway::$button_theme is deprecated
wp-content/plugins/woocommerce-square/includes/Framework/PaymentGateway/Payment_Gateway.php:400

@qasumitbagthariya, I have fixed this in commit 35e7f42

@qasumitbagthariya
Copy link
Contributor

@iamdharmesh
I noticed a Deprecated warning with PHP Version: 8.2.10 and 8.3.0, can you please check from your end?
Creation of dynamic property WooCommerce\Square\Gateway\Cash_App_Pay_Gateway::$button_theme is deprecated
wp-content/plugins/woocommerce-square/includes/Framework/PaymentGateway/Payment_Gateway.php:400

@qasumitbagthariya, I have fixed this in commit 35e7f42

QA Update ✅

Thanks @iamdharmesh

I checked and confirmed now there is no error related Deprecated warning with PHP Version: 8.2.10 and 8.3.0 👍

@james-allan
Copy link
Contributor

james-allan commented Jan 30, 2024

Nice work here @iamdharmesh!

No action required on this point, but I wanted to call it out in case it catches up anyone else. I was been doing some testing and noticed that if you have a checkout failure (eg invalid US post code), the checkout fails as it should, however, I noticed this in the Cash App elements.

Screenshot 2024-01-30 at 1 47 47 pm
$CASHTAG_C_TOKEN

I couldn't find in the code a reference to that variable but it turns out this is how Cash App displays the customer's token in sandbox after they have authorized the payment. Docs reference.


Declining the payment

If I press the decline button on the phone (see left below) while processing the payment, the checkout just hangs forever it seems (see right below).

Screenshot 2024-01-30 at 1 47 47 pm
Decline.cash.app.mov

To continue you have to refresh the page. Note: this only impacts the shortcode/classic checkout. The Block checkout is unblocked on decline, however, you cannot then complete the payment again, you need to refresh.


Other tests

  • Classic checkout
    • Is shown when the store is eligible.
    • Is not displayed when the store is in-eligible.
    • Purchases complete successfully.
    • ✅ Fixed Declining the payment blocks the checkout. See details in section above.
    • When subscriptions accept manual payments Cash App is available
    • With subscriptions only accepting automatic payments, Cash App is not available.
  • Block checkout
    • Is shown when the store is eligible.
    • Is not displayed when the store is in-eligible.
    • Not shown while subscription products are in the cart - unless manual payments are allowed.
    • Purchases complete successfully.
    • ✅ Fixed Declining the payment unblocks the checkout but then the place order button is clickable and the Cash App button displays a new modal that hangs. See video below.!
block.checkout.decline.mov
  • Pay for order page
    • Is shown when the store is eligible.
    • ✅ Fixed Is not displayed when the store is in-eligible.
      • The payment element is shown, it just constantly hangs and there's a console error.
Screenshot 2024-01-30 at 5 28 46 pm Screenshot 2024-01-30 at 5 27 24 pm
  • processes payments successfully.
  • ✅ Fixed declining the payment behaves exactly like the classic checkout. The form is blocked permanently until the page is refreshed.
  • My Account > Add payment method page
    • As expected, Cash App isn't shown at all.
  • Refunds
    • Partial Refund - partial refund processed in Square successfully. (screenshot)
    • Full Refund - refund processed in Square successfully. (screenshot)
    • Order notes added for refund 👍

@iamdharmesh
Copy link
Member Author

Thanks for the detailed review @james-allan.

I have addressed the reported issue/feedback in the commit 9d3bc1f, could you please help to check it once.

Thanks.

Copy link
Contributor

@jeffpaul jeffpaul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In running through testing with @iamdharmesh and @dkotter earlier today, this PR feels solid for initial release to our Square merchants. I had wanted to do a full test of the CashApp integration using our Production test site, but I did not realize that would require a "live" bank account creation (which we do not currently have) so I'm investigating how to solve for that for future testing in Production.

For now, the flows in a "classic" front-end approach and via the block-based checkout works as expected. Subscriptions and Pre-Orders set for future payment properly do not show the CashApp button. Gift cards appear to function as expected with CashApp as do refunds on orders.

Two areas that are not covered in this initial PR/release that we'll likely want to follow up on quickly are:

  • Adding support for partial payments (wherein a shopper might use a credit card or gift card in tandem with CashApp to fully pay for an order)
  • Confirm with Square, but in reading their docs it appears that the autocomplete variable set to AUTHORIZED may allow us to support both Charge and Authorization methods for merchants

Copy link
Contributor

@james-allan james-allan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good. Thanks @iamdharmesh

@qasumitbagthariya
Copy link
Contributor

Regression / Smoke Test Report ✅

Tested with Archive File created via "php woorelease.phar build repo_URL" (Composer version 2.5.5, npm version 8.19.4, node version 16.20.0)

Testing Environment

  • WordPress: 6.4.2
  • Theme: Storefront 4.5.4
  • WooCommerce - 8.5.2
  • PHP: 8.0.30
  • Web Server: Nginx 1.20.2
  • Browser: Chrome
  • OS: macOS Ventura 13.3
  • Git Branch: smoke-testing

Status- Working expected with Plugin Archive/Zip file same as fix specific branch.

Next Step- Ready to Merge 🚀

Status update
@ankitguptaindia @vikrampm1

[Cash App Pay] Added end-to-end (E2E) tests for the Cash App Pay payment method.
@vikrampm1 vikrampm1 modified the milestones: Future Release, 4.5.0 Jan 31, 2024
@vikrampm1 vikrampm1 marked this pull request as ready for review January 31, 2024 15:30
@vikrampm1 vikrampm1 merged commit 7c8d0f5 into trunk Jan 31, 2024
4 of 5 checks passed
@vikrampm1 vikrampm1 deleted the feature/cash-app-pay branch January 31, 2024 15:31
@vikrampm1 vikrampm1 mentioned this pull request Jan 31, 2024
16 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for Cash App payment method
6 participants