1
0
Fork 0
Transaction checkout modal dialog component for React, embeddable into React projects as a frontend component. Made with React and Vite for Freelance client in 2023. https://vityaschel.github.io/checkout-dialog
This repository has been archived on 2025-09-18. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
Find a file
2023-12-02 14:02:00 +03:00
dist Add build 2023-12-02 14:01:00 +03:00
src fixed 2023-12-02 13:12:43 +03:00
.eslintrc.cjs Add eccrypto alternative library encrypting 2023-08-10 02:20:25 +04:00
.gitignore Add build 2023-12-02 14:01:00 +03:00
package-lock.json Add build 2023-12-02 14:01:00 +03:00
package.json Add build 2023-12-02 14:01:00 +03:00
pnpm-lock.yaml Add loading, success alert 2023-08-18 16:40:26 +04:00
README.md Add README image 2023-12-02 14:02:00 +03:00
tsconfig.json PaySelection 2023-08-10 20:27:32 +04:00
tsconfig.node.json Initial commit 2023-08-09 22:18:40 +04:00
vite.config.ts Fix external emotion dep 2023-08-16 16:59:18 +04:00

Checkout modal

Screenshot

Visit interactive demo

Компонент для оплаты на сайте в модальном окне с поддержкой cloudpayments и payselection.

Types definitions запакованы, стили скомпилированы в style.css.

Использование

import { CheckoutModal } from 'checkout-modal'
import type { CheckoutModalRef } from 'checkout-modal'
import 'checkout-modal/index.css'

function Main() {
  const checkoutRef = React.useRef<CheckoutModalRef>()

  const email = 'hi@hloth.dev'

  React.useEffect(() => {
    checkoutRef.current?.open({
      initialValues: {
        email
      },
      paymentInfo: {
        title: 'Оплата подписки "название магазина"',
        priceString: '999 ₽',
        priceInRub: 999
      },
      /* paymentProcessor: { 
        name: 'auto', 
        resolver: (cardNumber: string) => {
          return { name: 'cloudpayments', publicId: 'test_api_000000000000000002' }
        }
      }*/,
      // paymentProcessor: { name: 'cloudpayments', publicId: 'test_api_000000000000000002' },
      paymentProcessor: { name: 'payselection', publickey: '0405397f7577bd835210a57708aafe876786dc8e2d12e6880917d61a4ad1d03a75068ea6bc26554c7a1bf5b50ed40105837eee001178579279eca57f89bdff5fc2' },
      checkboxes: [
        { defaultActive: true, htmlLabel: 'Foo bar' },
        { defaultActive: true, htmlLabel: 'Hello world' },
      ],
      emailRequired: true
    }, (cryptogram: string, email: string) => {
      alert(cryptogram)
      console.log('set-email', email)
      return true
    })
  }, [])

  return (
    <CheckoutModal
      ref={checkoutRef}
    />
  )
}

В колбэке onSuccess в котором передается cryptogram нужно возвращать boolean, означающий удался ли запрос или нет (показать ошибку или успех).

Обязательна настройка сервер-сайд рендеринга https://mui.com/material-ui/guides/server-rendering/