Skip to content

Commit

Permalink
feat: ✨ Add a flag in payment metadata to tell if it's blocks or not
Browse files Browse the repository at this point in the history
  • Loading branch information
DouglasCorreiaMeli committed Jan 10, 2024
1 parent 0d80ea7 commit 692cccb
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Entities/Metadata/PaymentMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,9 @@ class PaymentMetadata
* @var PaymentMetadataCpp
*/
public $cpp_extra;

/**
* @var string
*/
public $blocks_payment;
}
31 changes: 31 additions & 0 deletions src/Order/OrderMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ class OrderMetadata
*/
private const PIX_ON = 'pix_on';

/**
* @const
*/
private const BLOCKS_PAYMENT = 'blocks_payment';

/**
* @var OrderMeta
*/
Expand Down Expand Up @@ -439,4 +444,30 @@ public function updatePaymentsOrderMetadata(\WC_Order $order, array $paymentsId)
}
}
}

/**
* Update an order's payments metadata
*
* @param \WC_Order $order
* @param array $paymentsId
*
* @return void
*/
public function markPaymentAsBlocks(\WC_Order $order, string $value)
{
$this->orderMeta->update($order, self::BLOCKS_PAYMENT, $value);
}

/**
* Update an order's payments metadata
*
* @param \WC_Order $order
* @param array $paymentsId
*
* @return void
*/
public function getPaymentBlocks(\WC_Order $order)
{
return $this->orderMeta->get($order, self::BLOCKS_PAYMENT);
}
}
1 change: 1 addition & 0 deletions src/Transactions/AbstractTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ public function getInternalMetadata(): PaymentMetadata
$metadata->cpp_extra = new PaymentMetadataCpp();
$metadata->cpp_extra->platform_version = $this->mercadopago->woocommerce->version;
$metadata->cpp_extra->module_version = MP_VERSION;
$metadata->blocks_payment = $this->mercadopago->orderMetadata->getPaymentBlocks($this->order);

return $metadata;
}
Expand Down

0 comments on commit 692cccb

Please sign in to comment.