Skip to content

Apple pay (PayPal)#3050

Merged
Crabcyborg merged 4 commits intopaypalfrom
apple_pay
Mar 30, 2026
Merged

Apple pay (PayPal)#3050
Crabcyborg merged 4 commits intopaypalfrom
apple_pay

Conversation

@Crabcyborg
Copy link
Copy Markdown
Contributor

No description provided.

@Crabcyborg Crabcyborg changed the base branch from master to paypal March 30, 2026 15:27
@deepsource-io
Copy link
Copy Markdown

deepsource-io bot commented Mar 30, 2026

DeepSource Code Review

We reviewed changes in c1b60ed...36b9640 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

Important

Some issues found as part of this review are outside of the diff in this pull request and aren't shown in the inline review comments due to GitHub's API limitations. You can see those issues on the DeepSource dashboard.

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
PHP Mar 30, 2026 3:37p.m. Review ↗
JavaScript Mar 30, 2026 3:37p.m. Review ↗

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 30, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 34f85698-1265-4e0d-9c6f-b8991e2e8e75

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch apple_pay

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

render: renderApplePayButton
} );
} else {
console.log( 'Apple Pay not available:', applePayEligibilityResult );
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Avoid using console in code that runs on the browser


It is considered a best practice to avoid the use of any console methods in JavaScript code that will run on the browser.

NOTE: If your repository contains a server side project, you can add "nodejs" to the environment property of analyzer meta in .deepsource.toml.
This will prevent this issue from getting raised.
Documentation for the analyzer meta can be found here.
Alternatively, you can silence this issue for your repository as shown here.

If a specific console call is meant to stay for other reasons, you can add a skipcq comment to that line.
This will inform other developers about the reason behind the log's presence, and prevent DeepSource from flagging it.

// Use paypal.Applepay().config() as the definitive eligibility check (per PayPal multiparty docs).
try {
applePayConfig = await paypal.Applepay().config();
console.log( '[FrmApplePay] config() response:', JSON.stringify( applePayConfig, null, 2 ) );
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Avoid using console in code that runs on the browser


It is considered a best practice to avoid the use of any console methods in JavaScript code that will run on the browser.

NOTE: If your repository contains a server side project, you can add "nodejs" to the environment property of analyzer meta in .deepsource.toml.
This will prevent this issue from getting raised.
Documentation for the analyzer meta can be found here.
Alternatively, you can silence this issue for your repository as shown here.

If a specific console call is meant to stay for other reasons, you can add a skipcq comment to that line.
This will inform other developers about the reason behind the log's presence, and prevent DeepSource from flagging it.

}
} catch ( err ) {
console.error( '[FrmApplePay] config() threw error:', err );
return 'Apple Pay config check failed: ' + err.message;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unexpected string concatenation


In ES2015 (ES6), we can use template literals instead of string concatenation.

Comment on lines +931 to +949
async function renderApplePayButton() {
const method = paymentMethods.get( 'apple_pay' );
if ( ! method ) {
return;
}

const container = method.containerEl;
container.innerHTML = '';

const btn = document.createElement( 'apple-pay-button' );
btn.setAttribute( 'buttonstyle', 'black' );
btn.setAttribute( 'type', 'buy' );
btn.setAttribute( 'locale', 'en' );
btn.style.width = '100%';
btn.style.height = '40px';

btn.addEventListener( 'click', onApplePayButtonClick );
container.appendChild( btn );
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Found `async` function without any `await` expressions


A function that does not contain any await expressions should not be async (except for some edge cases in TypeScript which are discussed below). Asynchronous functions in JavaScript behave differently than other functions in two important ways:

createOrderForApplePay()
.then( ( orderId ) => {
return applepay.confirmOrder( {
orderId: orderId,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Expected property shorthand


ECMAScript 6 provides a concise form for defining object literal methods and properties. This syntax can make defining complex object literals much cleaner.

*/
function getFormTotal() {
const totalField = thisForm.querySelector( '[data-frmtotal]' );
if ( totalField && totalField.value ) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Prefer using an optional chain expression instead, as it's more concise and easier to read


The optional chaining operator can be used to perform null checks before accessing a property, or calling a function.

@Crabcyborg Crabcyborg changed the title Apple pay Apple pay (PayPal) Mar 30, 2026
@Crabcyborg Crabcyborg merged commit bf25dc1 into paypal Mar 30, 2026
14 of 15 checks passed
@Crabcyborg Crabcyborg deleted the apple_pay branch March 30, 2026 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant