Skip to content

Commit d5472a3

Browse files
committed
Add a select at checkout for the desired payment result
1 parent fc9c432 commit d5472a3

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

includes/Bogus_Gateway.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@
3232
class Bogus_Gateway extends \WC_Payment_Gateway {
3333

3434

35+
/** @var string the "accepted" payment result code */
36+
const PAYMENT_RESULT_APPROVED = 'approved';
37+
38+
/** @var string the "declined" payment result code */
39+
const PAYMENT_RESULT_DECLINED = 'declined';
40+
41+
/** @var string the "held" payment result code */
42+
const PAYMENT_RESULT_HELD = 'held';
43+
44+
3545
/** @var string subscriptions setting */
3646
private $subscriptions;
3747

@@ -130,6 +140,27 @@ public function init_form_fields() {
130140
}
131141

132142

143+
/**
144+
* Renders the gateway payment fields.
145+
*
146+
* @since x.y.z
147+
*/
148+
public function payment_fields() {
149+
150+
parent::payment_fields();
151+
152+
woocommerce_form_field( "{$this->id}_payment_result", [
153+
'type' => 'select',
154+
'label' => __( 'Result', 'woocommerce-dev-helper' ),
155+
'options' => [
156+
self::PAYMENT_RESULT_APPROVED => __( 'Approved', 'woocommerce-dev-helper' ),
157+
self::PAYMENT_RESULT_DECLINED => __( 'Declined', 'woocommerce-dev-helper' ),
158+
self::PAYMENT_RESULT_HELD => __( 'Held', 'woocommerce-dev-helper' ),
159+
],
160+
] );
161+
}
162+
163+
133164
/**
134165
* Returns true if Subscriptions support is enabled.
135166
*

0 commit comments

Comments
 (0)