Skip to content

Commit

Permalink
Merge pull request #38 from pronamic/37-add-support-for-skiphppresult…
Browse files Browse the repository at this point in the history
…page-parameter

Add support for `skipHppResultPage` parameter.
  • Loading branch information
rvdsteege authored Dec 16, 2024
2 parents 9472065 + f542395 commit fc20141
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ final class Config extends GatewayConfig implements JsonSerializable {
*/
public $order_id = '';

/**
* Skip hosted result page.
*
* @var bool
*/
public $skip_hosted_result_page = false;

/**
* Construct config.
*/
Expand Down
3 changes: 3 additions & 0 deletions src/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,9 @@ public function start( Payment $payment ) {
}
}

// Skip hosted result page.
$order->set_skip_hosted_result_page( $this->config->skip_hosted_result_page );

// Maybe update access token.
$this->maybe_update_access_token();

Expand Down
29 changes: 29 additions & 0 deletions src/Integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,31 @@ public function get_settings_fields() {
'type' => 'text',
];

// Skip hosted result page.
$code_field = \sprintf( '<code>%s</code>', 'skipHppResultPage' );

$fields[] = [
'classes' => [ 'regular-text', 'code' ],
'description' => \sprintf(
/* translators: %s: <code>skipHppResultPage</code> */
\__(
'The Rabo Smart Pay %s field makes it possible to skip the hosted result page (also referred to as the "Success" or "Thank you" page).',
'pronamic_ideal'
),
$code_field
),
'label' => \__( 'Skip hosted result page', 'pronamic_ideal' ),
'meta_key' => '_pronamic_gateway_omnikassa_2_skip_hosted_result_page',
'section' => 'advanced',
'title' => \__( 'Skip hosted result page', 'pronamic_ideal' ),
'tooltip' => \sprintf(
/* translators: %s: <code>skipHppResultPage</code> */
\__( 'This setting defines the Rabo Smart Pay %s field.', 'pronamic_ideal' ),
$code_field
),
'type' => 'checkbox',
];

// Webhook.
$fields[] = [
'classes' => [ 'large-text', 'code' ],
Expand Down Expand Up @@ -203,6 +228,10 @@ public function get_config( $post_id ) {
$config->access_token_valid_until = $this->get_meta( $post_id, 'omnikassa_2_access_token_valid_until' );
$config->order_id = $this->get_meta( $post_id, 'omnikassa_2_order_id' );

$skip_hosted_result_page = $this->get_meta( $post_id, 'omnikassa_2_skip_hosted_result_page' );

$config->skip_hosted_result_page = 1 === \intval( $skip_hosted_result_page );

return $config;
}

Expand Down
21 changes: 21 additions & 0 deletions src/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ final class Order extends Message implements JsonSerializable {
*/
private $payment_brand_meta_data;

/**
* Skip hosted result page (also referred to as the success/thank you page) in the payment process.
*
* @var bool|null
*/
private $skip_hosted_result_page;

/**
* Construct order.
*
Expand Down Expand Up @@ -291,6 +298,16 @@ public function set_payment_brand_meta_data( $payment_brand_meta_data ) {
$this->payment_brand_meta_data = $payment_brand_meta_data;
}

/**
* Set skip hosted result page.
*
* @param bool $skip_hosted_result_page Skip hosted result page.
* @return void
*/
public function set_skip_hosted_result_page( $skip_hosted_result_page ) {
$this->skip_hosted_result_page = $skip_hosted_result_page;
}

/**
* Create and set new order items.
*
Expand Down Expand Up @@ -394,6 +411,10 @@ public function jsonSerialize() {
$data['paymentBrandMetaData'] = $this->payment_brand_meta_data;
}

if ( null !== $this->skip_hosted_result_page ) {
$data['skipHppResultPage'] = $this->skip_hosted_result_page;
}

return (object) $data;
}

Expand Down

0 comments on commit fc20141

Please sign in to comment.