@@ -302,13 +302,17 @@ int main()
302302 cJSON * payload = cJSON_GetObjectItem (transaction_data , "payload" );
303303 merchant_name = cJSON_GetStringValue (cJSON_GetObjectItem (cJSON_GetObjectItem (payload , "payee" ), "name" ));
304304
305- double amount = cJSON_GetNumberValue (cJSON_GetObjectItem (payload , "amount" ));
306- int length_for_amount = log10 (amount );
307- char * currency = cJSON_GetStringValue (cJSON_GetObjectItem (payload , "currency" ));
308- int total_length = length_for_amount + 4 + strlen (currency ) + 2 ;
309- transaction_amount = malloc (length_for_amount + 4 + strlen (currency ) + 2 );
310- sprintf (transaction_amount , "%s %f" , currency , amount );
311- transaction_amount [total_length - 1 ] = '\0' ;
305+ transaction_amount = cJSON_GetStringValue (cJSON_GetObjectItem (payload , "amount_display" ));
306+
307+ if (transaction_amount == NULL ) {
308+ double amount = cJSON_GetNumberValue (cJSON_GetObjectItem (payload , "amount" ));
309+ int length_for_amount = log10 (amount );
310+ char * currency = cJSON_GetStringValue (cJSON_GetObjectItem (payload , "currency" ));
311+ int total_length = length_for_amount + 4 + strlen (currency ) + 2 ;
312+ transaction_amount = malloc (length_for_amount + 4 + strlen (currency ) + 2 );
313+ sprintf (transaction_amount , "%s %f" , currency , amount );
314+ transaction_amount [total_length - 1 ] = '\0' ;
315+ }
312316 printf ("transaction amount %s\n" , transaction_amount );
313317
314318 additional_info = cJSON_GetStringValue (cJSON_GetObjectItem (transaction_data , "additional_info" ));
0 commit comments