Skip to content

Commit

Permalink
feat(process-payment): generate correlationID from order information
Browse files Browse the repository at this point in the history
  • Loading branch information
samueldurantes committed Nov 9, 2023
1 parent 890a381 commit 8701f76
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
10 changes: 9 additions & 1 deletion includes/class-wc-openpix-pix-crediary.php
Original file line number Diff line number Diff line change
Expand Up @@ -594,11 +594,19 @@ public function getErrorFromResponse($response)
return '';
}

public function generate_correlation_id($order)
{
$order_key = str_replace('wc_order_', '', $order->get_order_key());
$order_id = $order->get_id();

return $order_key . '-' . $order_id;
}

public function process_payment($order_id)
{
$order = wc_get_order($order_id);

$correlationID = WC_OpenPix::uuid_v4();
$correlationID = $this->generate_correlation_id($order);

$url = OpenPixConfig::getApiUrl() . '/api/v1/charge';

Expand Down
10 changes: 9 additions & 1 deletion includes/class-wc-openpix-pix-parcelado.php
Original file line number Diff line number Diff line change
Expand Up @@ -601,11 +601,19 @@ public function getErrorFromResponse($response)
return '';
}

public function generate_correlation_id($order)
{
$order_key = str_replace('wc_order_', '', $order->get_order_key());
$order_id = $order->get_id();

return $order_key . '-' . $order_id;
}

public function process_payment($order_id)
{
$order = wc_get_order($order_id);

$correlationID = WC_OpenPix::uuid_v4();
$correlationID = $this->generate_correlation_id($order);

$url = OpenPixConfig::getApiUrl() . '/api/v1/charge';

Expand Down
9 changes: 8 additions & 1 deletion includes/class-wc-openpix-pix.php
Original file line number Diff line number Diff line change
Expand Up @@ -1067,12 +1067,19 @@ public function getErrorFromResponse($response)
return '';
}

public function generate_correlation_id($order)
{
$order_id = $order->get_id();

return $order->get_order_key() . '-' . $order_id;
}

public function process_payment($order_id)
{
global $woocommerce;
$order = wc_get_order($order_id);

$correlationID = WC_OpenPix::uuid_v4();
$correlationID = $this->generate_correlation_id($order);

$url = OpenPixConfig::getApiUrl() . '/api/v1/charge';

Expand Down

0 comments on commit 8701f76

Please sign in to comment.