-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
115 additions
and
82 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,49 @@ | ||
package generator | ||
|
||
import "github.com/mrwan200/promptparse-go/lib" | ||
import ( | ||
"fmt" | ||
|
||
func BOTBarcode(billerId string, ref1 string, ref2 string, amount float64) string { | ||
barcode := lib.BOTBarcode{ | ||
BillerID: billerId, | ||
Ref1: ref1, | ||
Ref2: ref2, | ||
Amount: amount, | ||
"github.com/mrwan200/promptparse-go/lib" | ||
) | ||
|
||
// Generate PromptPay Bill Payment (Tag 30) QR Code | ||
func BillPayment(billerID string, amount float64, ref1 string, ref2 string, ref3 string) string { | ||
tag30 := []lib.TLVTag{ | ||
lib.Tag("00", "A000000677010112"), | ||
lib.Tag("01", billerID), | ||
lib.Tag("02", ref1), | ||
} | ||
|
||
if ref2 != "" { | ||
result := append(tag30, lib.Tag("03", ref2)) | ||
tag30 = result | ||
} | ||
|
||
payload := []lib.TLVTag{ | ||
lib.Tag("00", "01"), | ||
lib.Tag("01", "11"), | ||
lib.Tag("30", lib.Encode(tag30)), | ||
lib.Tag("53", "764"), | ||
lib.Tag("58", "TH"), | ||
} | ||
|
||
if amount != 0 { | ||
payload[1] = lib.Tag("01", "12") | ||
// Append data | ||
result := append(payload, lib.Tag("54", fmt.Sprintf("%.2f", float64(amount*100)/100))) | ||
payload = result | ||
} | ||
|
||
if ref3 != "" { | ||
// Append data | ||
result := append(payload, lib.Tag("62", ref3)) | ||
payload = result | ||
} | ||
|
||
tag, err := lib.WithCRCTag(lib.Encode(payload), "63") | ||
if err != nil { | ||
return "" | ||
} | ||
|
||
return barcode.ToString() | ||
return tag | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package generator | ||
|
||
import "github.com/mrwan200/promptparse-go/lib" | ||
|
||
func BOTBarcode(billerId string, ref1 string, ref2 string, amount float64) string { | ||
barcode := lib.BOTBarcode{ | ||
BillerID: billerId, | ||
Ref1: ref1, | ||
Ref2: ref2, | ||
Amount: amount, | ||
} | ||
|
||
return barcode.ToString() | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package generator | ||
|
||
import "github.com/mrwan200/promptparse-go/lib" | ||
|
||
// Generate Slip Verify QR Code | ||
// | ||
// This also called "Mini-QR" that embedded in slip used for verify transactions | ||
func SlipVerify(sendingBank string, transRef string) string { | ||
payload := []lib.TLVTag{ | ||
lib.Tag("00", lib.Encode([]lib.TLVTag{ | ||
{ | ||
ID: "00", | ||
Value: "000001", | ||
}, | ||
{ | ||
ID: "01", | ||
Value: sendingBank, | ||
}, | ||
{ | ||
ID: "02", | ||
Value: transRef, | ||
}, | ||
})), | ||
lib.Tag("51", "TH"), | ||
} | ||
|
||
tag, err := lib.WithCRCTag(lib.Encode(payload), "91") | ||
if err != nil { | ||
return "" | ||
} | ||
|
||
return tag | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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