@@ -37,94 +37,98 @@ public function __construct(
37
37
public function getTemplateValues ()
38
38
{
39
39
40
- if ($ this ->productMetadata ->getVersion () >= 2.3 && $ this ->productMetadata ->getVersion () < 2.4 ) {
41
- $ order = $ this ->payment ->getOrder ();
42
- } else {
43
- $ order_id = (int )$ this ->request ->getParam ('order_id ' );
44
- $ nonce = (string )$ this ->request ->getParam ('nonce ' );
45
- $ order = $ this ->orderRepository ->get ($ order_id );
46
- }
47
-
48
- $ total = $ order ->getGrandTotal ();
49
- $ currencySymbol = $ order ->getOrderCurrencyCode ();
50
- $ metaData = $ this ->helper ->getPaymentResponse ($ order ->getQuoteId ());
51
-
52
- if (empty ($ metaData )) {
53
- throw new \Magento \Framework \Exception \AlreadyExistsException (
54
- __ ('You can only add one address per cryptocurrency ' )
55
- );
56
- }
57
-
58
- $ qrCodeSize = $ this ->scopeConfig ->getValue ('payment/blockbee/qrcode_size ' , \Magento \Store \Model \ScopeInterface::SCOPE_STORE );
59
-
60
- $ branding = $ this ->scopeConfig ->getValue ('payment/blockbee/show_branding ' , \Magento \Store \Model \ScopeInterface::SCOPE_STORE );
61
-
62
- $ metaData = json_decode ($ metaData , true );
63
-
64
- if ($ nonce != $ metaData ['blockbee_nonce ' ]) {
65
- return false ;
66
- }
67
- $ cryptoValue = $ metaData ['blockbee_total ' ];
68
- $ cryptoCoin = $ metaData ['blockbee_currency ' ];
69
-
70
- if (isset ($ metaData ['blockbee_address ' ]) && !empty ($ metaData ['blockbee_address ' ])) {
71
- $ addressIn = $ metaData ['blockbee_address ' ];
72
- } else {
73
- /**
74
- * Makes request to API and generates all the payment data needed
75
- */
76
-
77
- $ selected = $ cryptoCoin ;
78
-
79
- $ params = [
40
+ try {
41
+ if ($ this ->productMetadata ->getVersion () >= 2.3 && $ this ->productMetadata ->getVersion () < 2.4 ) {
42
+ $ order = $ this ->payment ->getOrder ();
43
+ } else {
44
+ $ order_id = (int )$ this ->request ->getParam ('order_id ' );
45
+ $ nonce = (string )$ this ->request ->getParam ('nonce ' );
46
+ $ order = $ this ->orderRepository ->get ($ order_id );
47
+ }
48
+
49
+ $ total = $ order ->getGrandTotal ();
50
+ $ currencySymbol = $ order ->getOrderCurrencyCode ();
51
+ $ metaData = $ this ->helper ->getPaymentResponse ($ order ->getQuoteId ());
52
+
53
+ if (empty ($ metaData )) {
54
+ throw new \Magento \Framework \Exception \AlreadyExistsException (
55
+ __ ('You can only add one address per cryptocurrency ' )
56
+ );
57
+ }
58
+
59
+ $ qrCodeSize = $ this ->scopeConfig ->getValue ('payment/blockbee/qrcode_size ' , \Magento \Store \Model \ScopeInterface::SCOPE_STORE );
60
+
61
+ $ branding = $ this ->scopeConfig ->getValue ('payment/blockbee/show_branding ' , \Magento \Store \Model \ScopeInterface::SCOPE_STORE );
62
+
63
+ $ metaData = json_decode ($ metaData , true );
64
+
65
+ if ($ nonce != $ metaData ['blockbee_nonce ' ]) {
66
+ return false ;
67
+ }
68
+ $ cryptoValue = $ metaData ['blockbee_total ' ];
69
+ $ cryptoCoin = $ metaData ['blockbee_currency ' ];
70
+
71
+ if (isset ($ metaData ['blockbee_address ' ]) && !empty ($ metaData ['blockbee_address ' ])) {
72
+ $ addressIn = $ metaData ['blockbee_address ' ];
73
+ } else {
74
+ /**
75
+ * Makes request to API and generates all the payment data needed
76
+ */
77
+
78
+ $ selected = $ cryptoCoin ;
79
+
80
+ $ params = [
81
+ 'order_id ' => $ order ->getId (),
82
+ 'nonce ' => $ metaData ['blockbee_nonce ' ],
83
+ ];
84
+
85
+ $ callbackUrl = $ this ->payment ->getCallbackUrl ();
86
+
87
+ $ apiKey = $ this ->scopeConfig ->getValue ('payment/blockbee/api_key ' , \Magento \Store \Model \ScopeInterface::SCOPE_STORE );
88
+
89
+ $ api = new BlockbeeHelper ($ selected , $ apiKey , $ callbackUrl , $ params , true );
90
+ $ addressIn = $ api ->get_address ();
91
+ $ qrCode = $ api ->get_qrcode ('' , $ qrCodeSize );
92
+ $ qrCodeValue = $ api ->get_qrcode ($ cryptoValue , $ qrCodeSize );
93
+ $ this ->helper ->updatePaymentData ($ order ->getQuoteId (), 'blockbee_address ' , $ addressIn );
94
+ $ this ->helper ->updatePaymentData ($ order ->getQuoteId (), 'blockbee_qr_code_value ' , $ qrCodeValue ['qr_code ' ]);
95
+ $ this ->helper ->updatePaymentData ($ order ->getQuoteId (), 'blockbee_qr_code ' , $ qrCode ['qr_code ' ]);
96
+ $ this ->helper ->updatePaymentData ($ order ->getQuoteId (), 'blockbee_payment_url ' , $ this ->storeManager ->getStore ()->getUrl ('blockbee/index/payment/order_id/ ' . $ order ->getId () . '/nonce/ ' . $ metaData ['blockbee_nonce ' ]));
97
+
98
+ $ metaData = json_decode ($ this ->helper ->getPaymentResponse ($ order ->getQuoteId ()), true );
99
+ $ this ->mail ->sendMail ($ order , $ metaData );
100
+ }
101
+
102
+ $ ajaxParams = [
80
103
'order_id ' => $ order ->getId (),
81
- 'nonce ' => $ metaData ['blockbee_nonce ' ],
82
104
];
83
105
84
- $ callbackUrl = $ this ->payment ->getCallbackUrl ();
85
-
86
- $ apiKey = $ this ->scopeConfig ->getValue ('payment/blockbee/api_key ' , \Magento \Store \Model \ScopeInterface::SCOPE_STORE );
87
-
88
- $ api = new BlockbeeHelper ($ selected , $ apiKey , $ callbackUrl , $ params , true );
89
- $ addressIn = $ api ->get_address ();
90
- $ qrCode = $ api ->get_qrcode ('' , $ qrCodeSize );
91
- $ qrCodeValue = $ api ->get_qrcode ($ cryptoValue , $ qrCodeSize );
92
- $ this ->helper ->updatePaymentData ($ order ->getQuoteId (), 'blockbee_address ' , $ addressIn );
93
- $ this ->helper ->updatePaymentData ($ order ->getQuoteId (), 'blockbee_qr_code_value ' , $ qrCodeValue ['qr_code ' ]);
94
- $ this ->helper ->updatePaymentData ($ order ->getQuoteId (), 'blockbee_qr_code ' , $ qrCode ['qr_code ' ]);
95
- $ this ->helper ->updatePaymentData ($ order ->getQuoteId (), 'blockbee_payment_url ' , $ this ->storeManager ->getStore ()->getUrl ('blockbee/index/payment/order_id/ ' . $ order ->getId (). '/nonce/ ' . $ metaData ['blockbee_nonce ' ]));
96
-
97
- $ metaData = json_decode ($ this ->helper ->getPaymentResponse ($ order ->getQuoteId ()), true );
98
- $ this ->mail ->sendMail ($ order , $ metaData );
106
+ $ ajaxUrl = $ this ->payment ->getAjaxStatusUrl ($ ajaxParams );
107
+
108
+ $ metaData = $ this ->helper ->getPaymentResponse ($ order ->getQuoteId ());
109
+ $ metaData = json_decode ($ metaData , true );
110
+
111
+ return [
112
+ 'crypto_value ' => floatval ($ cryptoValue ),
113
+ 'currency_symbol ' => $ currencySymbol ,
114
+ 'total ' => $ total ,
115
+ 'address_in ' => $ addressIn ,
116
+ 'crypto_coin ' => $ cryptoCoin ,
117
+ 'ajax_url ' => $ ajaxUrl ,
118
+ 'qrcode_size ' => $ qrCodeSize ,
119
+ 'qrcode ' => $ metaData ['blockbee_qr_code ' ],
120
+ 'qrcode_value ' => $ metaData ['blockbee_qr_code_value ' ],
121
+ 'qrcode_default ' => $ this ->scopeConfig ->getValue ('payment/blockbee/qrcode_default ' , \Magento \Store \Model \ScopeInterface::SCOPE_STORE ),
122
+ 'show_branding ' => $ branding ,
123
+ 'qr_code_setting ' => $ this ->scopeConfig ->getValue ('payment/blockbee/qrcode_setting ' , \Magento \Store \Model \ScopeInterface::SCOPE_STORE ),
124
+ 'order_timestamp ' => strtotime ($ order ->getCreatedAt ()),
125
+ 'order_cancelation_timeout ' => $ this ->scopeConfig ->getValue ('payment/blockbee/order_cancelation_timeout ' , \Magento \Store \Model \ScopeInterface::SCOPE_STORE ),
126
+ 'refresh_value_interval ' => $ this ->scopeConfig ->getValue ('payment/blockbee/refresh_value_interval ' , \Magento \Store \Model \ScopeInterface::SCOPE_STORE ),
127
+ 'last_price_update ' => $ metaData ['blockbee_last_price_update ' ],
128
+ 'min_tx ' => $ metaData ['blockbee_min ' ],
129
+ ];
130
+ } catch (\Exception $ exception ) {
131
+ // Empty
99
132
}
100
-
101
- $ ajaxParams = [
102
- 'order_id ' => $ order ->getId (),
103
- ];
104
-
105
- $ ajaxUrl = $ this ->payment ->getAjaxStatusUrl ($ ajaxParams );
106
-
107
- $ metaData = $ this ->helper ->getPaymentResponse ($ order ->getQuoteId ());
108
- $ metaData = json_decode ($ metaData , true );
109
-
110
- return [
111
- 'crypto_value ' => floatval ($ cryptoValue ),
112
- 'currency_symbol ' => $ currencySymbol ,
113
- 'total ' => $ total ,
114
- 'address_in ' => $ addressIn ,
115
- 'crypto_coin ' => $ cryptoCoin ,
116
- 'ajax_url ' => $ ajaxUrl ,
117
- 'qrcode_size ' => $ qrCodeSize ,
118
- 'qrcode ' => $ metaData ['blockbee_qr_code ' ],
119
- 'qrcode_value ' => $ metaData ['blockbee_qr_code_value ' ],
120
- 'qrcode_default ' => $ this ->scopeConfig ->getValue ('payment/blockbee/qrcode_default ' , \Magento \Store \Model \ScopeInterface::SCOPE_STORE ),
121
- 'show_branding ' => $ branding ,
122
- 'qr_code_setting ' => $ this ->scopeConfig ->getValue ('payment/blockbee/qrcode_setting ' , \Magento \Store \Model \ScopeInterface::SCOPE_STORE ),
123
- 'order_timestamp ' => strtotime ($ order ->getCreatedAt ()),
124
- 'order_cancelation_timeout ' => $ this ->scopeConfig ->getValue ('payment/blockbee/order_cancelation_timeout ' , \Magento \Store \Model \ScopeInterface::SCOPE_STORE ),
125
- 'refresh_value_interval ' => $ this ->scopeConfig ->getValue ('payment/blockbee/refresh_value_interval ' , \Magento \Store \Model \ScopeInterface::SCOPE_STORE ),
126
- 'last_price_update ' => $ metaData ['blockbee_last_price_update ' ],
127
- 'min_tx ' => $ metaData ['blockbee_min ' ],
128
- ];
129
133
}
130
134
}
0 commit comments