@@ -99,10 +99,11 @@ public function process_payment( $order_id ) {
99
99
100
100
if (!$ invoice ) {
101
101
$ invoice = $ this ->strike ->invoice ([
102
- 'currency ' => $ order ->get_currency (),
103
- 'amount ' => $ order ->get_total (),
104
- 'metadata ' => [ 'order_id ' => $ order ->get_id () ],
105
- 'webhook ' => self ::get_webhook_url ($ order ->get_id ())
102
+ 'currency ' => $ order ->get_currency (),
103
+ 'amount ' => $ order ->get_total (),
104
+ 'description ' => self ::make_desc ($ order ),
105
+ 'metadata ' => [ 'order_id ' => $ order ->get_id () ],
106
+ 'webhook ' => self ::get_webhook_url ($ order ->get_id ())
106
107
]);
107
108
$ this ->update_invoice ($ order , $ invoice );
108
109
@@ -209,6 +210,19 @@ protected static function get_qr_uri($invoice) {
209
210
$ image = $ writer ->writeString (strtoupper ('lightning: ' . $ invoice ->payreq ));
210
211
return 'data:image/png;base64, ' . base64_encode ($ image );
211
212
}
213
+
214
+ protected static function make_desc ($ order ) {
215
+ $ total = $ order ->get_total () . ' ' .$ order ->get_currency ();
216
+ $ desc = get_bloginfo ('name ' ) . ': ' . $ total . ' for ' ;
217
+ $ products = $ order ->get_items ();
218
+ while (strlen ($ desc ) < 100 && count ($ products )) {
219
+ $ product = array_shift ($ products );
220
+ if (count ($ products )) $ desc .= $ product ['name ' ] . ' x ' . $ product ['qty ' ] . ', ' ;
221
+ else $ desc = substr ($ desc , 0 , -2 ) . ' and ' . $ product ['name ' ].' x ' .$ product ['qty ' ];
222
+ }
223
+ if (count ($ products )) $ desc = substr ($ desc , 0 , -2 ) . ' and ' . count ($ products ) . ' more ' ;
224
+ return $ desc ;
225
+ }
212
226
}
213
227
214
228
new WC_Gateway_Lightning ();
0 commit comments