Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tosspayments/payment-sdk-react-native

Package Overview
Dependencies
Maintainers
45
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tosspayments/payment-sdk-react-native

Payment SDK for React Native

  • 0.0.1-alpha002
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-64.29%
Maintainers
45
Weekly downloads
 
Created
Source

payment-sdk-react-native

Payment SDK for React Native

Installation

# npm
npm install @tosspayments/payment-sdk-react-native

# yarn
yarn add @tosspayments/payment-sdk-react-native

Usage

import { PaymentContextProvider, usePaymentWidget } from "payment-sdk-react-native";

// ...
export default function App() {
  const [amount, onChangeAmount] = useState<Amount>({
    value: 1000,
    currency: 'KRW',
    country: 'KR',
  });
  return <PaymentContextProvider 
    clientKey={`test_ck_0Poxy1XQL8R4P1zpv14V7nO5Wmlg`}
    customerKey={`TOSSPAYMENTS`}
    onSuccess={(success) => {
      Alert.alert('결제성공', `${JSON.stringify(success)}`);
    }}
    onFail={(fail) => {
      Alert.alert(`결제실패`, `${JSON.stringify(fail)}`);
    }}
  >
    <Widget amount={amount}>
  </PaymentContextProvider>
}

function Widget({ amount }: { amount: Amount }) {
  const widget = usePaymentWidget();
  return (
    <>
      <PaymentMethodWidget 
        amount={amount}
        variantKey={`DEFAULT`}
      />
      <AgreementWidget>
      <Button
        title="결제요청"
        onPress={() => {
          const agreeement = widget?.getAgreementStatus();
          if (agreeement?.agreedRequiredTerms != true) {
            Alert.alert('약관에 동의하지 않았습니다.');
            return;
          }
          widget?.requestPayments?.({
            orderId: "OrderId_123",
            orderName: "김토스",
            cultureExpense: true,
          });
        }}
      />
      <Button
        title="선택된 결제수단"
        onPress={() => {
            Alert.alert(`선택된 결제수단: ${JSON.stringify(widget?.getSelectedPaymentMethod())}`);
        }}
      />
    </>
  )
}

License

MIT

Keywords

FAQs

Package last updated on 18 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc