Skipjack 支払いゲートウェイ用のプラグインの開発に取り組んでいます。このゲートウェイは、skipjack が提供する html フォームを使用して、注文情報を HTTP POST 経由でカスタム支払いフォームに渡します。このフォームをブラウザーにエコーし、javascript を介して自動送信する process_payment() 関数を作成しました。このフォームは、Chrome と Firefox では正常に送信されますが、Internet Explorer では送信されません。
これが process_payment() 関数です。
function process_payment( $order_id ) {
global $woocommerce;
$order = new WC_Order( $order_id );
// Reduce stock levels
$order->reduce_order_stock();
// Clear cart
$woocommerce->cart->empty_cart();
//Convert countries to codes provided by Skipjack
$BillingCountryCode = '';
$ShippingCountryCode = '';
if ($order->billing_country === 'US') {
$BillingCountryCode = '840';
} else if ($order->billing_country === 'Canada') {
$BillingCountryCode = '124';
}
if ($order->shipping_country === 'US') {
$ShippingCountryCode = '840';
} else if ($order->shipping_country === 'Canada') {
$ShippingCountryCode = '124';
}
$url = 'https://payments.skipjack.com/FormBuilder/VPOS.aspx';
//build form to pass data to Skipjack
echo'<BR><form name="Generator" method="post" action="' . $url . '">';
echo'<input type="hidden" name="url" value="' . $url . '">';
echo'<input type="hidden" name="VposContent" value="' . $this->settings['skipjack_vpos_code'] . '">';
echo'<input type="submit" name="DonateButton" class="button alt" style="font-size:25px;" align="center" value="Click Here to Process Payment and Complete Order" >';
echo'<input type="hidden" name="sjname" value="' . $order->billing_first_name . ' ' . $order->billing_last_name . '">';
echo'<input type="hidden" name="streetaddress" value="' . $order->billing_address_1 . '">';
echo'<input type="hidden" name="streetaddress2" value="' . $order->billing_address_2 . '">';
echo'<input type="hidden" name="city" value="' . $order->billing_city . '">';
echo'<input type="hidden" name="state" value="' . $order->billing_state . '">';
echo'<input type="hidden" name="zipcode" value="' . $order->billing_postcode . '">';
echo'<input type="hidden" name="country" value="' . $BillingCountryCode . '">';
echo'<input type="hidden" name="email" value="' . $order->billing_email . '">';
echo'<input type="hidden" name="shiptostreetaddress" value="' . $order->shipping_address_1 . '">';
echo'<input type="hidden" name="shiptostreetaddress2" value="' . $order->shipping_address_2 . '">';
echo'<input type="hidden" name="shiptocity" value="' . $order->shipping_city . '">';
echo'<input type="hidden" name="shiptostate" value="' . $order->shipping_state . '">';
echo'<input type="hidden" name="shiptozipcode" value="' . $order->shipping_postcode . '">';
echo'<input type="hidden" name="shiptocountry" value="' . $ShippingCountryCode . '">';
echo'<input type="hidden" name="shiptophone" value="' . $order->billing_phone . '">';
echo'<input type="hidden" name="ordernumber" value="' . $order->id . '">';
echo'<input type="hidden" name="transactionamount" value="' . $order->order_total . '">';
echo'</form>';
// //auto-submit above form
// echo'<script>';
// echo'document.Generator.submit();';
// echo'return true;';
// echo'</script>';
die;
// return;
}
現在、IE でこのプラグインを実行すると、フォームが (手動または JavaScript によって) 送信されると、チェックアウト ページが更新され、セッションの有効期限が切れたがフォームは送信されないというメッセージが表示されます。IE でソースを表示すると、明らかにページに表示されているにもかかわらず、フォームが表示されません。ただし、Chrome と FireFox では正しく動作します。
上記のコードでわかるように、echo を使用してフォームをブラウザに出力し、html として処理します。これを行うより良い方法はありますか?また、return を使用すると失敗メッセージが表示されたため、die を使用して php の実行を停止しました。ブラウザーはhttps://payments.skipjack.com/FormBuilder/VPOS.aspx (変数 $url に格納されている) にあるスキップジャック フォームにリダイレクトする必要があるため、何を返す必要がありますか?