@@ -35,30 +35,44 @@ import "github.com/jattento/go-iso8583/pkg/iso8583"
35
35
36
36
## Quick start
37
37
38
+ The API of this package is inspired in the go native json package
39
+ therefore it's pretty intuitive to use. Take a look at this!
40
+
38
41
``` go
39
42
import " github.com/jattento/go-iso8583/pkg/iso8583"
40
43
41
- type PurchaseRequest struct {
42
- MTI iso8583.MTI ` iso8583:"mti"`
43
- FirstBitmap iso8583.BITMAP ` iso8583:"bitmap,length:64"` // length is the maximum amount of represented elements.
44
- SecondBitmap iso8583.BITMAP ` iso8583:"1,length:64"` // length is the maximum amount of represented elements.
45
- PAN iso8583.LLVAR ` iso8583:"2"`
46
- ProcessingCode iso8583.VAR ` iso8583:"3"`
47
- Amount iso8583.VAR ` iso8583:"4,encoding:ebcdic"` // By default ASCII is assumed but dont limit yourself!
48
- DateTime iso8583.VAR ` iso8583:"7"`
49
- SystemTraceAuditNumber iso8583.VAR ` iso8583:"11,omitempty"` // omitempty is supported!
50
- LocalTransactionTime iso8583.VAR ` iso8583:"12"`
51
- LocalTransactionDate iso8583.VAR ` iso8583:"-"` // You can explicitly ignore a field.
52
- ExpirationDate iso8583.VAR ` iso8583:"14"`
53
- MerchantType iso8583.VAR ` iso8583:"18"`
54
- ICC iso8583.LLLVAR ` iso8583:"55"`
55
- SettlementCode iso8583.VAR ` iso8583:"66"`
56
- MessageNumber iso8583.VAR ` iso8583:"71"`
57
- TransactionDescriptor iso8583.VAR ` iso8583:"104"`
44
+ type exampleMessage struct {
45
+ MessageTypeIdentifier iso8583.MTI ` iso8583:"mti,length:4,encoding:ebcdic"`
46
+ Bitmap iso8583.BITMAP ` iso8583:"bitmap,length:64"`
47
+ SecondaryBitmap iso8583.BITMAP ` iso8583:"1,length:64,encoding:ebcdic,omitempty"`
48
+ PrimaryAccountNumber iso8583.LLVAR ` iso8583:"2,length:64,encoding:ebcdic,omitempty"`
49
+ ProcessingCode iso8583.VAR ` iso8583:"3,length:6,encoding:ebcdic,omitempty"`
50
+ AmountTransaction iso8583.VAR ` iso8583:"4,length:12,encoding:ebcdic,omitempty"`
51
+ AmountSettlement iso8583.VAR ` iso8583:"5,length:12,encoding:ebcdic,omitempty"`
52
+ AmountCardholderBilling iso8583.VAR ` iso8583:"6,length:12,encoding:ebcdic,omitempty"`
53
+ AcquiringInstitutionIDCode iso8583.LLVAR ` iso8583:"32,length:11,encoding:ebcdic,omitempty"`
54
+ ForwardingInstitutionIDCode iso8583.LLVAR ` iso8583:"33,length:11,encoding:ebcdic,omitempty"`
55
+ PrimaryAccountNumberExtended iso8583.LLVAR ` iso8583:"34,length:28,encoding:ebcdic,omitempty"`
56
+ Track2Data iso8583.LLVAR ` iso8583:"35,length:37,encoding:ebcdic,omitempty"`
57
+ Track3Data iso8583.LLLVAR ` iso8583:"36,length:104,encoding:ebcdic,omitempty"`
58
+ AdditionalResponseData iso8583.LLVAR ` iso8583:"44,length:25,encoding:ebcdic,omitempty"`
59
+ Track1Data iso8583.LLVAR ` iso8583:"45,length:76,encoding:ebcdic,omitempty"`
60
+ ExpandedAdditionalAmounts iso8583.LLLVAR ` iso8583:"46,length:999,encoding:ebcdic,omitempty"`
61
+ AdditionalDataNationalUse iso8583.LLLVAR ` iso8583:"47,length:999,encoding:ebcdic,omitempty"`
62
+ AdditionalDataPrivateUse iso8583.LLLVAR ` iso8583:"48,length:999,encoding:ebcdic,omitempty"`
63
+ CurrencyCodeTransaction iso8583.VAR ` iso8583:"49,length:3,encoding:ebcdic,omitempty"`
64
+ CurrencyCodeSettlement iso8583.VAR ` iso8583:"50,length:3,encoding:ebcdic,omitempty"`
65
+ CurrencyCodeCardholderBilling iso8583.VAR ` iso8583:"51,length:3,encoding:ebcdic,omitempty"`
66
+ PersonalIDNumberData iso8583.BINARY ` iso8583:"52,length:8,omitempty"`
67
+ SecurityRelatedControlInformation iso8583.VAR ` iso8583:"53,length:16,encoding:ebcdic,omitempty"`
68
+ AdditionalAmounts iso8583.LLLVAR ` iso8583:"54,length:120,encoding:ebcdic,omitempty"`
69
+ IntegratedCircuitCardSystemRelatedData iso8583.LLLBINARY ` iso8583:"55,length:999,encoding:ebcdic,omitempty"`
58
70
}
71
+ ```
59
72
73
+ ``` go
60
74
func GenerateStaticReqBytes () ([]byte , error ) {
61
- req := PurchaseRequest {
75
+ req := exampleMessage {
62
76
MTI: " 0100" ,
63
77
// FirstBitmap is generated by library
64
78
// SecondBitmap is generated by library
@@ -80,32 +94,12 @@ func GenerateStaticReqBytes() ([]byte, error) {
80
94
``` go
81
95
import " github.com/jattento/go-iso8583/pkg/iso8583"
82
96
83
- type PurchaseResponse struct {
84
- MTI iso8583.MTI ` iso8583:"mti,length:4"`
85
- FirstBitmap iso8583.BITMAP ` iso8583:"bitmap,length:64"` // length is the maximum amount of represented elements.
86
- SecondBitmap iso8583.BITMAP ` iso8583:"1,length:64"` // length is the maximum amount of represented elements.
87
- PAN iso8583.LLVAR ` iso8583:"2,length:2"` // length is the amount of bytes of the LL part.
88
- ProcessingCode iso8583.VAR ` iso8583:"3,length:6"`
89
- Amount iso8583.VAR ` iso8583:"4,length:12"`
90
- DateTime iso8583.VAR ` iso8583:"7,length:10"`
91
- SystemTraceAuditNumber iso8583.VAR ` iso8583:"11,length:6"`
92
- LocalTransactionTime iso8583.VAR ` iso8583:"12,length:6"`
93
- LocalTransactionDate iso8583.VAR ` iso8583:"13,length:4"`
94
- ExpirationDate iso8583.VAR ` iso8583:"14,length:4"`
95
- MerchantType iso8583.VAR ` iso8583:"18,length:4"`
96
- ResponseCode iso8583.VAR ` iso8583:"39,length:2"`
97
- ICC iso8583.LLLVAR ` iso8583:"55,length:3,encoding:ebcdic/ascii"` // LLL and VAR part use different encoding? Use a / to indicate both
98
- SettlementCode iso8583.VAR ` iso8583:"66,length:1"`
99
- MessageNumber iso8583.VAR ` iso8583:"71,length:4"`
100
- TransactionDescriptor iso8583.VAR ` iso8583:"104,length:100"`
101
- }
102
-
103
- func ReadResp (byt []byte ) (PurchaseResponse ,error ){
104
- var resp PurchaseResponse
97
+ func ReadResp (byt []byte ) (exampleMessage ,error ){
98
+ var resp exampleMessage
105
99
106
100
_ , err := iso8583.Unmarshal (byt,&resp)
107
101
if err != nil {
108
- return PurchaseResponse {}, err
102
+ return exampleMessage {}, err
109
103
}
110
104
111
105
return resp,nil
0 commit comments