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

Make types PayPalButtonOnApprove PayPalButtonOnCancel OnApproveData OnApproveActions available in the package #602

Open
zallesov opened this issue Jan 10, 2025 · 1 comment

Comments

@zallesov
Copy link

🚀 Feature Proposal

export more types from the package for users.

Motivation

I'd like to type my handlers parameters with types like OnApproveActions so that inside an implementation I have access to .restart() method for example.

Example

This would be how I'd use types in my code

import { OnApproveData, OnApproveActions } from "@paypal/react-paypal-js";
const onApprove = async (data: OnApproveData, actions:OnApproveActions) => {
@mcdado
Copy link

mcdado commented Feb 10, 2025

You can import them from @paypal/paypal-js like this:

import {
  CreateOrderData,
  FUNDING_SOURCE,
  PayPalButtonsComponentOptions,
  PayPalCardFieldsComponentOptions,
  OnApproveData
} from "@paypal/paypal-js";

Alas, not all types are exported! I'm missing OnCancelData which currently is a generic Record type:

export type PayPalButtonOnCancel = (
    data: Record<string, unknown>,
    actions: OnCancelledActions,
) => void;

It would be so easy to export it as well:

type OnCancelledData = {
  orderID: string;
};

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

No branches or pull requests

2 participants