Skip to content

Instantly share code, notes, and snippets.

@gHashTag
Created June 13, 2018 13:33
Show Gist options
  • Select an option

  • Save gHashTag/72d9322d4cb747cd844b1d60652cf3de to your computer and use it in GitHub Desktop.

Select an option

Save gHashTag/72d9322d4cb747cd844b1d60652cf3de to your computer and use it in GitHub Desktop.
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