У меня есть API платежного шлюза. Я все сделал.
Я определил форму для получения визы / мастер-карты / карты для американского происхождения - express.
public function payment_fields() {
// I will echo() the form, but you can close PHP tags and print it directly in HTML
echo '<fieldset id="wc-' . esc_attr( $this->id ) . '-cc-form" class="wc-credit-card-form wc-payment-form" style="background:transparent;">';
// Add this action hook if you want your custom payment gateway to support it
do_action( 'woocommerce_credit_card_form_start', $this->id );
// I recommend to use inique IDs, because other gateways could already use #ccNo, #expdate, #cvc
echo '
<div class="form-row form-row-wide">
<label>Brand<span class="required">*</span></label>
<select id="datafast_brand" name="datafast_brand">
<option>American Express</option>
<option selected>Visa</option>
<option>Mastercard</option>
</select>
</div>
<div class="form-row form-row-first">
<label>Card Number <span class="required">*</span></label>
<input id="datafast_cardnumber" name="datafast_cardnumber" value="4263982640269299" type="text" autocomplete="off" placeholder="Car Number">
</div>
<div class="form-row form-row-last">
<label>Card Holder <span class="required">*</span></label>
<input id="datafast_cardholder" value="tazeem" type="text" autocomplete="off" placeholder="Card Holder">
</div>
<div class="form-row form-row-first">
<label>Expiry Date <span class="required">*</span></label>
<input id="datafast_expdate" value="02/23" name="datafast_expdate" type="text" autocomplete="off" placeholder="MM / YY">
</div>
<div class="form-row form-row-last">
<label>Card Code (CVC) <span class="required">*</span></label>
<input id="datafast_cvv" name="datafast_cvv" value="837" type="text" autocomplete="off" placeholder="CVC">
</div>
<div class="clear"></div>';
do_action( 'woocommerce_credit_card_form_end', $this->id );
echo '<div class="clear"></div></fieldset>';
}
Теперь я хочу, чтобы при нажатии на кнопку «разместить заказ» информация о вышеупомянутой карте была получена и отображена в этой функции для обработки карты. Ранее информацию о заказе необходимо сохранить в базе данных и отправить по электронной почте клиенту.
public function payment_fields() {
public function process_payment( $order_id ) {
global $woocommerce;
// we need it to get any order detailes
$order = wc_get_order( $order_id );
**// here i want to show/get details of above card details. to process card before order submission.**
// we received the payment
$order->payment_complete();
$order->reduce_order_stock();
// some notes to customer (replace true with false to make it private)
$order->add_order_note( 'Hey, your order is processed by DATAFAST payment gateway. Kindly confirm payment then release Order! Thank you!', true );
// Empty cart
$woocommerce->cart->empty_cart();
// Redirect to the thank you page
return array(
'result' => 'success',
'redirect' => $this->get_return_url( $order )
);
}