Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Envelope to TRP payload conversion #150

Merged
merged 5 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/openvasp/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import (
)

var (
ErrNilEnvelope = errors.New("envelope is nil")
ErrUnknownState = errors.New("envelope is in an unknown state")
ErrInvalidState = errors.New("envelope is invalid")
ErrEnvelopeError = errors.New("envelope has an error")
ErrEmptyConfirmation = errors.New("must specify either txid or canceled in confirmation")
ErrAmbiguousConfirmation = errors.New("cannot specify both txid and canceled in confirmation")
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/openvasp/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const (

func TestTransferInquiry(t *testing.T) {
// Load the payload fixture
payload, err := loadPayload("testdata/payload.json")
payload, err := loadInquiryPayload("testdata/inquiry.json")
require.NoError(t, err, "could not open fixture at testdata/payload.json")
require.NotEmpty(t, payload, "payload does not contain any data")

Expand Down Expand Up @@ -587,7 +587,7 @@ func (m *MockHandler) incr(call string) {
m.calls[call]++
}

func loadPayload(path string) (inquiry *Inquiry, err error) {
func loadInquiryPayload(path string) (inquiry *Inquiry, err error) {
var f *os.File
if f, err = os.Open(path); err != nil {
return nil, err
Expand Down
226 changes: 226 additions & 0 deletions pkg/openvasp/testdata/identity.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
{
"originator": {
"originator_persons": [
{
"natural_person": {
"name": {
"name_identifiers": [
{
"primary_identifier": "Howard",
"secondary_identifier": "Jane",
"name_identifier_type": "NATURAL_PERSON_NAME_TYPE_CODE_LEGL"
},
{
"primary_identifier": "Price",
"secondary_identifier": "Jane",
"name_identifier_type": "NATURAL_PERSON_NAME_TYPE_CODE_MAID"
}
],
"local_name_identifiers": [],
"phonetic_name_identifiers": []
},
"geographic_addresses": [
{
"address_type": "ADDRESS_TYPE_CODE_HOME",
"department": "",
"sub_department": "",
"street_name": "Greystone Street",
"building_number": "28",
"building_name": "",
"floor": "",
"post_box": "",
"room": "",
"post_code": "38017",
"town_name": "Collierville",
"town_location_name": "",
"district_name": "",
"country_sub_division": "TN",
"address_line": [],
"country": "US"
}
],
"national_identification": {
"national_identifier": "112502920",
"national_identifier_type": "NATIONAL_IDENTIFIER_TYPE_CODE_SOCS",
"country_of_issue": "US",
"registration_authority": "RA000748"
},
"customer_identification": "2642",
"date_and_place_of_birth": {
"date_of_birth": "1992-10-04",
"place_of_birth": "West Islip, NY"
},
"country_of_residence": "US"
}
}
],
"account_numbers": [
"14HmBSwec8XrcWge9Zi1ZngNia64u3Wd2v"
]
},
"beneficiary": {
"beneficiary_persons": [
{
"natural_person": {
"name": {
"name_identifiers": [
{
"primary_identifier": "Clark",
"secondary_identifier": "Lawrence",
"name_identifier_type": "NATURAL_PERSON_NAME_TYPE_CODE_LEGL"
},
{
"primary_identifier": "Clark",
"secondary_identifier": "Larry",
"name_identifier_type": "NATURAL_PERSON_NAME_TYPE_CODE_ALIA"
}
],
"local_name_identifiers": [],
"phonetic_name_identifiers": []
},
"geographic_addresses": [
{
"address_type": "ADDRESS_TYPE_CODE_HOME",
"department": "",
"sub_department": "",
"street_name": "Watling St",
"building_number": "249",
"building_name": "",
"floor": "",
"post_box": "",
"room": "",
"post_code": "WD7 7AL",
"town_name": "Radlett",
"town_location_name": "",
"district_name": "",
"country_sub_division": "",
"address_line": [],
"country": "United Kingdom"
}
],
"national_identification": {
"national_identifier": "319560446",
"national_identifier_type": "NATIONAL_IDENTIFIER_TYPE_CODE_DRLC",
"country_of_issue": "GB",
"registration_authority": "RA000591"
},
"customer_identification": "5610",
"date_and_place_of_birth": {
"date_of_birth": "1986-12-13",
"place_of_birth": "Leeds, United Kingdom"
},
"country_of_residence": "GB"
}
}
],
"account_numbers": [
"14WU745djqecaJ1gmtWQGeMCFim1W5MNp3"
]
},
"originating_vasp": {
"originating_vasp": {
"legal_person": {
"name": {
"name_identifiers": [
{
"legal_person_name": "AliceCoin, Inc.",
"legal_person_name_identifier_type": "LEGAL_PERSON_NAME_TYPE_CODE_LEGL"
},
{
"legal_person_name": "Alice VASP",
"legal_person_name_identifier_type": "LEGAL_PERSON_NAME_TYPE_CODE_SHRT"
},
{
"legal_person_name": "AliceCoin",
"legal_person_name_identifier_type": "LEGAL_PERSON_NAME_TYPE_CODE_TRAD"
}
],
"local_name_identifiers": [],
"phonetic_name_identifiers": []
},
"geographic_addresses": [
{
"address_type": "ADDRESS_TYPE_CODE_BIZZ",
"department": "",
"sub_department": "",
"street_name": "Roosevelt Place",
"building_number": "23",
"building_name": "",
"floor": "",
"post_box": "",
"room": "",
"post_code": "02151",
"town_name": "Boston",
"town_location_name": "",
"district_name": "",
"country_sub_division": "MA",
"address_line": [],
"country": "US"
}
],
"customer_number": "",
"national_identification": {
"national_identifier": "5493004YBI24IF4TIP92",
"national_identifier_type": "NATIONAL_IDENTIFIER_TYPE_CODE_LEIX",
"country_of_issue": "US",
"registration_authority": "RA000744"
},
"country_of_registration": "US"
}
}
},
"beneficiary_vasp": {
"beneficiary_vasp": {
"legal_person": {
"name": {
"name_identifiers": [
{
"legal_person_name": "Bob's Discount VASP, PLC",
"legal_person_name_identifier_type": "LEGAL_PERSON_NAME_TYPE_CODE_LEGL"
},
{
"legal_person_name": "Bob VASP",
"legal_person_name_identifier_type": "LEGAL_PERSON_NAME_TYPE_CODE_SHRT"
}
],
"local_name_identifiers": [],
"phonetic_name_identifiers": []
},
"geographic_addresses": [
{
"address_type": "ADDRESS_TYPE_CODE_BIZZ",
"department": "",
"sub_department": "",
"street_name": "Grimsby Road",
"building_number": "762",
"building_name": "",
"floor": "",
"post_box": "",
"room": "",
"post_code": "OX8 U89",
"town_name": "Oxford",
"town_location_name": "",
"district_name": "",
"country_sub_division": "",
"address_line": [],
"country": "GB"
}
],
"customer_number": "",
"national_identification": {
"national_identifier": "213800AQUAUP6I215N33",
"national_identifier_type": "NATIONAL_IDENTIFIER_TYPE_CODE_LEIX",
"country_of_issue": "GB",
"registration_authority": "RA000589"
},
"country_of_registration": "GB"
}
}
},
"transfer_path": {
"transfer_path": []
},
"payload_metadata": {
"transliteration_method": []
}
}
77 changes: 77 additions & 0 deletions pkg/openvasp/testdata/inquiry.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"asset": {
"slip0044": "BTC"
},
"amount": 1,
"callback": "https://beneficiary.com/transferConfirmation?q=3454366424",
"IVMS101": {
"originator": {
"originatorPersons": [
{
"naturalPerson": {
"name": {
"nameIdentifier": [
{
"primaryIdentifier": "Post",
"secondaryIdentifier": "Johnny",
"nameIdentifierType": "LEGL"
}
]
},
"geographicAddress": [
{
"addressType": "GEOG",
"streetName": "Potential Street",
"buildingNumber": "123",
"buildingName": "Cheese Hut",
"postCode": "91361",
"townName": "Thousand Oaks",
"countrySubDivision": "California",
"country": "US"
}
],
"customerIdentification": "1002390"
}
}
]
},
"beneficiary": {
"beneficiaryPersons": [
{
"naturalPerson": {
"name": {
"nameIdentifier": [
{
"primaryIdentifier": "Tilcott",
"secondaryIdentifier": "Mildred",
"nameIdentifierType": "LEGL"
}
]
}
}
}
],
"accountNumber": [
"mhtL3YVFdpTVffmLgUp4h4bcP3Su2zr5qx"
]
},
"originatingVASP": {
"originatingVASP": {
"legalPerson": {
"name": {
"nameIdentifier": [
{
"legalPersonName": "Alice VASP",
"legalPersonNameIdentifierType": "LEGL"
}
]
},
"nationalIdentification": {
"nationalIdentifier": "GTFZ00N6IHYMHHNT8S51",
"nationalIdentifierType": "LEIX"
}
}
}
}
}
}
Loading