import sdk from '../../../dist/index'
// import sdk from '@efox/pay'

const publicKey = {
  //   key: '250405304072',
  // key: 'AVLRNG',
  key:
    'https://secure.oceanpayment.com/gateway/service/test?account=140105&terminal=14010551&signValue=8b040de18d77b180bd60056ed982138b9c77b0e3a9d3ca52856eb0795d27190b&backUrl=https%3A%2F%2Ftest-portal-xpay.yy.com%2Frt%2FOceanpay%2FGate&noticeUrl=https%3A%2F%2Ftest-portal-xpay.yy.com%2Fntf%2FOceanpay%2FGate&methods=CreditCard&pages=0&order_number=20200826193554254990241530000&order_currency=USD&order_amount=0.10&billing_firstName=4295060390&billing_lastName=4295060390&billing_email=4295060390%40yy.com&billing_phone=N%2FA&billing_country=N%2FA&billing_city=N%2FA&billing_address=N%2FA&billing_zip=N%2FA&productSku=HagoDiamond&productName=Hago%E9%92%BB%E7%9F%B3&productNum=N%2FA&language=en_US&signStr=14010514010551https%3A%2F%2Ftest-portal-xpay.yy.com%2Frt%2FOceanpay%2FGate20200826193554254990241530000USD0.10429506039042950603904295060390%40yy.com',
  //   'https://secure.oceanpayment.com/gateway/service/pay?account=150260&terminal=15026001&signValue=9ed13875254b575300dbbc60c64a754fa8031d5c90d4aa6bf95a4d224abc46a6&backUrl=https%3A%2F%2Fwww.oceanpayment.com&noticeUrl=https%3A%2F%2Ftest-portal-xpay.yy.com%2Fntf%2FOceanpay%2FGate&methods=CreditCard&pages=0&order_number=test123456789&order_currency=USD&order_amount=0.1&billing_firstName=test&billing_lastName=test&billing_email=test@test.com&billing_phone=0755-123456789&billing_country=US&billing_city=Washington D.C.&billing_address=705A big Road&billing_zip=529012&productSku=#001&productName=dress&productNum=1&language=en_US&signStr=19132619132601https%3A%2F%2Ftest-portal-xpay.yy.com%2Frt%2FOceanpay%2FGate20200810214929555990291240000USD10.00429506039042950603904295060390%40yy.com',
}

const initialData = {
  env: 'dev',
  domId: 'app',
  // sdkName: '2checkout',
  sdkName: 'oceanPay',
  // nameInputTitle: '姓名',
  btnText: '提交',
  fieldData: {
    userName: 'José Silva',
  },
  callback: token => {
    console.log(token)
  },
  fieldOnChange: fieldValidtion => {
    console.log('改变', fieldValidtion)
  },
  fieldOnBlur: fieldValidtion => {
    console.log('失焦', fieldValidtion)
  },
  createToken: response => {
    console.log('token回调', response)
  },
  fieldComplete: fieldCompleteParams => {
    console.log('表单填写完成', fieldCompleteParams)
  },
  styleOption: {
    commonStyle: {},
    componentStyle: {
      formStyle: {
        padding: '20px',
      },
      nameInputStyle: {},
      cardInputStyle: {
        labelStyle: {
          // backgroundColor: 'red',
        },
      },
      expirationInputStyle: {},
      cvvInputStyle: {},
      btnStyle: {},
    },
  },
  label: {
    userNameLabel: 'User Name',
    cardNumberLabel: 'Card Number',
    expirationLabel: 'Card Due Date',
    cvvLabel: 'Card Cvv',
  },

  /**
   * 2checkout 语言码，需写进 SDK 文档（非规范国家码）
   * https://knowledgecenter.2checkout.com/Documentation/07Commerce/Checkout-links-and-options/2Checkout-supported-languages
   */
  language: 'zh',
}

const pay = new sdk(publicKey, initialData)

// setTimeout(async () => {
//   const res = await pay.getToken()
//   console.log('啊啊啊', res)
// }, 1000)

const holderName = '持卡人姓名'
// setTimeout(async () => {
//   const token = await pay.getToken(holderName)
//   console.log(token)
// }, 15000)
