-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmt760.php
More file actions
77 lines (59 loc) · 3.21 KB
/
mt760.php
File metadata and controls
77 lines (59 loc) · 3.21 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
class MT760Generator {
public static function generateMessage($senderBIC, $receiverBIC, $transactionReference, $guaranteeAmount, $expiryDate, $beneficiaryName, $applicantName, $issuingBankName, $issuingBankAddress, $issuingBankCountry, $issuingBankBIC, $advisingBankName, $advisingBankAddress, $advisingBankCountry, $advisingBankBIC, $applicableRules, $senderReference, $description, $currencyCode) {
// Define the message header
$header = "MT760 1\r\n";
// Define the sender and receiver information
$sender = "{1:" . $senderBIC . "}\r\n";
$receiver = "{2:" . $receiverBIC . "}\r\n";
// Define the transaction reference
$transaction = "{20:" . $transactionReference . "}\r\n";
// Define the guarantee amount and currency code
$amount = "{32B:" . $currencyCode . $guaranteeAmount . "}\r\n";
// Define the expiry date
$expiry = "{31C:" . $expiryDate . "}\r\n";
// Define the beneficiary and applicant names
$beneficiary = "{59:" . $beneficiaryName . "}\r\n";
$applicant = "{50:" . $applicantName . "}\r\n";
// Define the issuing bank information
$issuingBank = "{41A:" . $issuingBankName . "\r\n" . $issuingBankAddress . "\r\n" . $issuingBankCountry . "\r\n" . $issuingBankBIC . "}\r\n";
// Define the advising bank information
$advisingBank = "{42C:" . $advisingBankName . "\r\n" . $advisingBankAddress . "\r\n" . $advisingBankCountry . "\r\n" . $advisingBankBIC . "}\r\n";
// Define the applicable rules
$rules = "{77D:" . $applicableRules . "}\r\n";
// Define the sender's reference
$senderRef = "{20:REF" . $senderReference . "}\r\n";
// Define the description of the guarantee
$description = "{72:" . $description . "}\r\n";
// Construct the message
$message = $header . $sender . $receiver . $transaction . $amount . $expiry . $beneficiary . $applicant . $issuingBank . $advisingBank . $rules . $senderRef . $description . "-}";
return $message;
}
}
// Instantiate the MT760Generator class
$mt760Generator = new MT760Generator();
// Define the required parameters
$senderBIC = "ABCDUS33XXX";
$receiverBIC = "WXYZUS44XXX";
$transactionReference = "1234567890";
$guaranteeAmount = "1000000";
$expiryDate = "20230430";
$beneficiaryName = "John Doe";
$applicantName = "Jane Smith";
$issuingBankName = "ABC Bank";
$issuingBankAddress = "123 Main Street";
$issuingBankCountry = "USA";
$issuingBankBIC = "ABC123";
$advisingBankName = "XYZ Bank";
$advisingBankAddress = "456 Park Avenue";
$advisingBankCountry = "USA";
$advisingBankBIC = "XYZ456";
$applicableRules = "URDG758";
$senderReference = "9876543210";
$description = "Bank guarantee for invoice #12345";
$currencyCode = "USD";
// Generate the MT760 message
$message = $mt760Generator->generateMessage($senderBIC, $receiverBIC, $transactionReference, $guaranteeAmount, $expiryDate, $beneficiaryName, $applicantName, $issuingBankName, $issuingBankAddress, $issuingBankCountry, $issuingBankBIC, $advisingBankName, $advisingBankAddress, $advisingBankCountry, $advisingBankBIC, $applicableRules, $senderReference, $description, $currencyCode);
// Output the generated message
echo $message;
?>