Skip to content

Commit

Permalink
Update PaymentRequestUtils.php
Browse files Browse the repository at this point in the history
  • Loading branch information
spencerfinnell committed Feb 23, 2023
1 parent ade4568 commit 3cae993
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/RestApi/Internal/Payment/Utils/PaymentRequestUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ public static function get_payment_metadata( $request ) {
$unit_amount = self::get_unit_amount( $request );
$quantity = self::get_quantity( $request );
$subtotal = $unit_amount * $quantity;
$amount = self::get_amount( $request );

$metadata = array(
'simpay_form_id' => $form->id,
Expand All @@ -356,24 +355,27 @@ public static function get_payment_metadata( $request ) {
),
);

/** @var array<string, string> $custom_fields Custom fields. */
$custom_fields = isset( $form_values['simpay_field'] )
? $form_values['simpay_field']
: array();

foreach ( $custom_fields as $key => $value ) {
// Skip empty.
if ( '' === trim( $value ) ) {
continue;
}

$metadata[ $key ] = $value;
}

$license = simpay_get_license();

// Add additional metadata for non-lite licenses.
if ( false === $license->is_lite() ) {
// Custom fields.
/** @var array<string, string> $custom_fields Custom fields. */
$custom_fields = isset( $form_values['simpay_field'] )
? $form_values['simpay_field']
: array();

foreach ( $custom_fields as $key => $value ) {
// Skip empty.
if ( '' === trim( $value ) ) {
continue;
}

$metadata[ $key ] = $value;
}

$amount = self::get_amount( $request );

// Fee recovery.
$fee_recovery = FeeRecoveryUtils::get_fee_recovery_unit_amount(
$request,
Expand Down

0 comments on commit 3cae993

Please sign in to comment.