我有一个支付网关的 API。我已经做了一切。
我已经定义了一个表格来获取签证/万事达卡/美国运通卡的详细信息。
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 ) ); }