-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfraud_validator.sol
More file actions
44 lines (36 loc) · 1.79 KB
/
fraud_validator.sol
File metadata and controls
44 lines (36 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;
contract FraudValidator {
struct Organization {
address id;
string name;
string http;
}
mapping (string => Organization) public getOrganization;
event RegisterOrganization(Organization organization);
struct PaymentMethod {
Organization organization;
bytes32 paymetMethodHash;
string http;
}
mapping (bytes32 => PaymentMethod) public getPaymentMethod;
event RegisterPaymentMethod(PaymentMethod paymentMethod);
function registerOrganization(string memory _name, string memory _http) public payable returns(Organization memory) {
Organization memory organization = Organization(msg.sender, _name, _http);
getOrganization[_name] = organization;
emit RegisterOrganization(organization);
return organization;
}
function registerPaymentMethod(string memory _name, string memory _description, string memory _reference, string memory _http) public payable returns(PaymentMethod memory) {
bytes32 paymentMethodHash = keccak256(abi.encodePacked(_description, _reference));
PaymentMethod memory paymentMethod = PaymentMethod(getOrganization[_name], paymentMethodHash, _http);
getPaymentMethod[paymentMethodHash] = paymentMethod;
emit RegisterPaymentMethod(paymentMethod);
return paymentMethod;
}
function validatePaymentMethod(string memory _description, string memory _reference) public view returns(string memory, string memory, Organization memory) {
bytes32 paymentMethodHash = keccak256(abi.encodePacked(_description, _reference));
PaymentMethod memory paymentMethod = getPaymentMethod[paymentMethodHash];
return (_description, _reference, paymentMethod.organization);
}
}