aboutsummaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/taler-merchant-httpd_post-orders-ID-pay.c')
-rw-r--r--src/backend/taler-merchant-httpd_post-orders-ID-pay.c44
1 files changed, 16 insertions, 28 deletions
diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
index ea8dd200..7ec76fc5 100644
--- a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
+++ b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
@@ -1300,11 +1300,15 @@ static void
1300trigger_payment_notification (struct PayContext *pc) 1300trigger_payment_notification (struct PayContext *pc)
1301{ 1301{
1302 { 1302 {
1303 struct TMH_OrderPayEvent pay_eh = { 1303 struct TMH_OrderPayEventP pay_eh = {
1304 .header.size = htons (sizeof (pay_eh)), 1304 .header.size = htons (sizeof (pay_eh)),
1305 .header.type = htons (TALER_DBEVENT_MERCHANT_ORDER_PAID) 1305 .header.type = htons (TALER_DBEVENT_MERCHANT_ORDER_PAID),
1306 .merchant_pub = pc->hc->instance->merchant_pub
1306 }; 1307 };
1307 1308
1309 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1310 "Notifying clients about payment of order %s\n",
1311 pc->order_id);
1308 GNUNET_CRYPTO_hash (pc->order_id, 1312 GNUNET_CRYPTO_hash (pc->order_id,
1309 strlen (pc->order_id), 1313 strlen (pc->order_id),
1310 &pay_eh.h_order_id); 1314 &pay_eh.h_order_id);
@@ -1316,14 +1320,16 @@ trigger_payment_notification (struct PayContext *pc)
1316 if ( (NULL != pc->session_id) && 1320 if ( (NULL != pc->session_id) &&
1317 (NULL != pc->fulfillment_url) ) 1321 (NULL != pc->fulfillment_url) )
1318 { 1322 {
1319#ifndef TALER_API_VERSION 1323 struct TMH_SessionEventP session_eh = {
1320#define TALER_DBEVENT_MERCHANT_SESSION_CAPTURED 1103
1321#endif
1322 struct TMH_SessionEvent session_eh = {
1323 .header.size = htons (sizeof (session_eh)), 1324 .header.size = htons (sizeof (session_eh)),
1324 .header.type = htons (TALER_DBEVENT_MERCHANT_SESSION_CAPTURED) 1325 .header.type = htons (TALER_DBEVENT_MERCHANT_SESSION_CAPTURED),
1326 .merchant_pub = pc->hc->instance->merchant_pub
1325 }; 1327 };
1326 1328
1329 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1330 "Notifying clients about session change to %s for %s\n",
1331 pc->session_id,
1332 pc->fulfillment_url);
1327 GNUNET_CRYPTO_hash (pc->session_id, 1333 GNUNET_CRYPTO_hash (pc->session_id,
1328 strlen (pc->session_id), 1334 strlen (pc->session_id),
1329 &session_eh.h_session_id); 1335 &session_eh.h_session_id);
@@ -1347,7 +1353,6 @@ execute_pay_transaction (struct PayContext *pc)
1347{ 1353{
1348 struct TMH_HandlerContext *hc = pc->hc; 1354 struct TMH_HandlerContext *hc = pc->hc;
1349 const char *instance_id = hc->instance->settings.id; 1355 const char *instance_id = hc->instance->settings.id;
1350 bool refunded;
1351 1356
1352 /* Avoid re-trying transactions on soft errors forever! */ 1357 /* Avoid re-trying transactions on soft errors forever! */
1353 if (pc->retry_counter++ > MAX_RETRIES) 1358 if (pc->retry_counter++ > MAX_RETRIES)
@@ -1421,6 +1426,7 @@ execute_pay_transaction (struct PayContext *pc)
1421 1426
1422 { 1427 {
1423 enum GNUNET_DB_QueryStatus qs; 1428 enum GNUNET_DB_QueryStatus qs;
1429
1424 /* Check if we refunded some of the coins */ 1430 /* Check if we refunded some of the coins */
1425 qs = TMH_db->lookup_refunds (TMH_db->cls, 1431 qs = TMH_db->lookup_refunds (TMH_db->cls,
1426 instance_id, 1432 instance_id,
@@ -1443,10 +1449,9 @@ execute_pay_transaction (struct PayContext *pc)
1443 "lookup refunds"); 1449 "lookup refunds");
1444 return; 1450 return;
1445 } 1451 }
1446 refunded = (qs > 0);
1447 } 1452 }
1448 /* Check if there are coins that still need to be processed */
1449 1453
1454 /* Check if there are coins that still need to be processed */
1450 if (0 != pc->pending) 1455 if (0 != pc->pending)
1451 { 1456 {
1452 /* we made no DB changes, so we can just rollback */ 1457 /* we made no DB changes, so we can just rollback */
@@ -1494,7 +1499,6 @@ execute_pay_transaction (struct PayContext *pc)
1494 "mark contract paid"); 1499 "mark contract paid");
1495 return; 1500 return;
1496 } 1501 }
1497 trigger_payment_notification (pc);
1498 } 1502 }
1499 1503
1500 { 1504 {
@@ -1518,25 +1522,9 @@ execute_pay_transaction (struct PayContext *pc)
1518 NULL); 1522 NULL);
1519 return; 1523 return;
1520 } 1524 }
1525 trigger_payment_notification (pc);
1521 } 1526 }
1522 1527
1523 /* Notify clients that have been waiting for the payment to succeed */
1524 if ( (NULL != pc->session_id) &&
1525 (NULL != pc->fulfillment_url) )
1526 TMH_long_poll_resume2 (pc->session_id,
1527 pc->fulfillment_url);
1528 TMH_long_poll_resume (pc->order_id,
1529 hc->instance,
1530 NULL,
1531 false);
1532 TMH_notify_order_change (hc->instance,
1533 pc->order_id,
1534 true, /* paid */
1535 refunded,
1536 false, /* wired */
1537 pc->timestamp,
1538 pc->order_serial);
1539
1540 /* Generate response (payment successful) */ 1528 /* Generate response (payment successful) */
1541 { 1529 {
1542 struct GNUNET_CRYPTO_EddsaSignature sig; 1530 struct GNUNET_CRYPTO_EddsaSignature sig;