coinbase / coinbase-woocommerce

DEPRECATED — Accept Bitcoin on your WooCommerce-powered website.
39 stars 27 forks source link

Retry transactions if 503 error comes back #14

Closed alexbain closed 9 years ago

alexbain commented 10 years ago

Hi, a recent order placed on my woocommerce site failed to complete when the plugin received a 503 error from Coinbase. The order is now stuck in a pending state, and the customer has left the site so we don't have a way to complete the order.

It would be fantastic if the Coinbase plugin, upon receiving a 503, attempted to retry the request a few times (exponential backoff?) before admitting defeat.

Here's the stack trace:

Error while processing coinbase payment: Coinbase_ApiException::__set_state(array(
‘message’ => ‘Status code 503′,
‘string’ => ”,
‘code’ => 0,
‘file’ => ‘/PATH/wp-content/plugins/coinbase-woocommerce/coinbase-php/Coinbase/Requestor.php’,
‘line’ => 22,
‘trace’ =>
array (
0 =>
array (
‘file’ => ‘/PATH/wp-content/plugins/coinbase-woocommerce/coinbase-php/Coinbase/Rpc.php’,
‘line’ => 95,
‘function’ => ‘doCurlRequest’,
‘class’ => ‘Coinbase_Requestor’,
‘type’ => ‘->’,
‘args’ =>
array (
0 => NULL,
),
),
1 =>
array (
‘file’ => ‘/PATH/wp-content/plugins/coinbase-woocommerce/coinbase-php/Coinbase/Coinbase.php’,
‘line’ => 69,
‘function’ => ‘request’,
‘class’ => ‘Coinbase_Rpc’,
‘type’ => ‘->’,
‘args’ =>
array (
0 => ‘POST’,
1 => ‘buttons’,
2 =>
array (
‘button’ =>
array (
‘name’ => ‘Order #ID′,
‘price_string’ => AMOUNT,
‘price_currency_iso’ => ‘USD’,
‘callback_url’ => ‘https://URL/wc-api/WC_Gateway_Coinbase/?callback_secret=SECRET′,
‘custom’ => ID,
‘success_url’ => ‘https://URL/checkout/order-received/ID?key=wc_order_NUMBER&return_from_coinbase=1′,
‘cancel_url’ => ‘https://URL/cart/?cancel_order=true&order=wc_order_NUMBER&order_id=ID&redirect&_wpnonce=NONCE&return_from_coinbase=1&cancelled=1&order_key=wc_order_NUMBER′,
),
),
),
),
2 =>
array (
‘file’ => ‘/PATH/wp-content/plugins/coinbase-woocommerce/coinbase-php/Coinbase/Coinbase.php’,
‘line’ => 208,
‘function’ => ‘post’,
‘class’ => ‘Coinbase’,
‘type’ => ‘->’,
‘args’ =>
array (
0 => ‘buttons’,
1 =>
array (
‘button’ =>
array (
‘name’ => ‘Order #ID′,
‘price_string’ => AMOUNT,
‘price_currency_iso’ => ‘USD’,
‘callback_url’ => ‘https://URL/wc-api/WC_Gateway_Coinbase/?callback_secret=SECRET′,
‘custom’ => ID,
‘success_url’ => ‘https://URL/checkout/order-received/ID?key=wc_order_NUMBER&return_from_coinbase=1′,
‘cancel_url’ => ‘https://URL/cart/?cancel_order=true&order=wc_order_NUMBER&order_id=ID&redirect&_wpnonce=NONCE&return_from_coinbase=1&cancelled=1&order_key=wc_order_NUMBER′,
),
),
),
),
3 =>
array (
‘file’ => ‘/PATH/wp-content/plugins/coinbase-woocommerce/coinbase-woocommerce.php’,
‘line’ => 207,
‘function’ => ‘createButtonWithOptions’,
‘class’ => ‘Coinbase’,
‘type’ => ‘->’,
‘args’ =>
array (
0 =>
array (
‘name’ => ‘Order #ID′,
‘price_string’ => AMOUNT,
‘price_currency_iso’ => ‘USD’,
‘callback_url’ => ‘https://URL/wc-api/WC_Gateway_Coinbase/?callback_secret=SECRET′,
‘custom’ => ID,
‘success_url’ => ‘https://URL/checkout/order-received/ID?key=wc_order_NUMBER&return_from_coinbase=1′,
‘cancel_url’ => ‘https://URL/cart/?cancel_order=true&order=wc_order_NUMBER&order_id=ID&redirect&_wpnonce=NONCE&return_from_coinbase=1&cancelled=1&order_key=wc_order_NUMBER′,
),
),
),
4 =>
array (
‘file’ => ‘/PATH/wp-content/plugins/woocommerce/includes/class-wc-checkout.php’,
‘line’ => 676,
‘function’ => ‘process_payment’,
‘class’ => ‘WC_Gateway_Coinbase’,
‘type’ => ‘->’,
‘args’ =>
array (
0 => ID,
),
),
5 =>
array (
‘file’ => ‘/PATH/wp-content/plugins/woocommerce/includes/class-wc-ajax.php’,
‘line’ => 308,
‘function’ => ‘process_checkout’,
‘class’ => ‘WC_Checkout’,
‘type’ => ‘->’,
‘args’ =>
array (
),
),
6 =>
array (
‘function’ => ‘checkout’,
‘class’ => ‘WC_AJAX’,
‘type’ => ‘->’,
‘args’ =>
array (
0 => ”,
),
),
7 =>
array (
‘file’ => ‘/PATH/wp-includes/plugin.php’,
‘line’ => 470,
‘function’ => ‘call_user_func_array’,
‘args’ =>
array (
0 =>
array (
0 =>
WC_AJAX::__set_state(array(
)),
1 => ‘checkout’,
),
1 =>
array (
0 => ”,
),
),
),
8 =>
array (
‘file’ => ‘/PATH/wp-admin/admin-ajax.php’,
‘line’ => 92,
‘function’ => ‘do_action’,
‘args’ =>
array (
0 => ‘wp_ajax_nopriv_woocommerce_checkout’,
),
),
),
‘previous’ => NULL,
‘http_code’ => 503,
‘response’ => ‘
html, body, iframe { margin: 0; padding: 0; height: 100%; }
iframe { display: block; width: 100%; border: none; }
Application Error
‘,
))

Thanks!

aianus commented 9 years ago

Sorry about the missed sale. We're constantly trying to improve our availability and this should continue to get better as the platform matures.

I don't think retry with exponential backoff makes sense here (since trying again in a few seconds is unlikely to succeed and the user isn't going to sit around much longer waiting for the request to go through).