Created
June 13, 2018 13:33
-
-
Save gHashTag/72d9322d4cb747cd844b1d60652cf3de to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component } from 'react'; | |
| import { View, Text } from 'react-native' | |
| import sha1 from 'js-sha1' | |
| const url = 'http://localhost:9000/fondy' | |
| class App extends Component { | |
| state = { | |
| amount: '100', | |
| merchant_id: '1404059', | |
| order_desc: 'Test payment', | |
| order_id: 'test8037875286', | |
| currency: 'RUB', | |
| response_url: 'https://api.fondy.eu/responsepage/', | |
| } | |
| async componentDidMount() { | |
| const { response_url, order_id, order_desc, currency, amount, merchant_id } = this.state | |
| try { | |
| const body = { | |
| "request": { | |
| "response_url": response_url, | |
| "order_id": order_id, | |
| "order_desc": order_desc, | |
| "currency": currency, | |
| "amount": amount, | |
| "merchant_id": merchant_id, | |
| "signature": sha1(`nYRTUcJ6EbEcYI6uJzbMm7Zs0bbQRrUI|${amount}|${currency}|${merchant_id}|${order_desc}|${order_id}`) | |
| } | |
| } | |
| console.log('signature', body) | |
| const res = await fetch(url, { | |
| method: 'POST', | |
| headers: new Headers({ | |
| 'Content-Type': 'application/json' | |
| }), | |
| body: JSON.stringify(body) | |
| }) | |
| const data = await res.json() | |
| console.log('data', data) | |
| //this.setState({ data }) | |
| } catch (e) { | |
| throw e | |
| } | |
| } | |
| render() { | |
| console.log('sha1', sha1('Hello world')) | |
| return ( | |
| <View> | |
| <Text>Fondy</Text> | |
| </View> | |
| ); | |
| } | |
| } | |
| export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment