[WordPress] Paysimple API を統合する (何を確認してください ' s 間違っている)

スポンサーリンク

質問

こんにちはシンプルでお支払 Paysimple API と私は常にこのエラーが出る 1 時間を統合です:

string(196)”{「メタ」: {「エラー」: {「ErrorCode」:”UnexpectedError”、”エラー メッセージ”:”TraceCode”[]:”API8D22C4FA49D9E36″}、”HttpStatus”:”InternalServerError”、”HttpStatusCode”: 500″PagingDetails”: null}、”応答”: null}”

応答: 500

ここでは、当社ウェブサイト。内部に戻ります詳細を入力するときサーバー エラー http://jdma.biz/temp/contact-us-2/

更新: ここでは、カスタムの form.php のコード

PaySimple マニュアル: http://developer.paysimple.com/documentation/ の支払いに行く

 <?php
  /*
 Plugin Name: Custom Contact Form
 Plugin URI: http://example.com
  Description: Simple non-bloated WordPress Contact Form
 Version: 1.0
*/

add_action('wp_enqueue_scripts','custom_form_init');

function custom_form_init() {
    wp_enqueue_script('custom-form-js', plugins_url( '/js/custom-form.js', __FILE__ ));
}

function html_form_code() {
    echo '<span class="show-error" style="border: 1px solid red;padding: 5px;border-radius: 3px;color: rgb(251, 7, 7);"></span>';
    echo '<form action="' . esc_url( $_SERVER['REQUEST_URI'] ) . '" method="post" class="custom-contact-form">
    <p>Your Name (required)<br>
        <span class="wpcf7-form-control-wrap your-name">
            <input type="text" 
            name="name" 
            value=""
            id="contact-name"
            size="40" 
            class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required" 
            aria-required="true" 
            aria-invalid="false">
        </span>
    </p>

    <p>Your Email (required)<br>
        <span class="wpcf7-form-control-wrap your-email">
            <input type="email" 
            name="email"
            id="contact-email"
            value="" size="40" 
            class="wpcf7-form-control wpcf7-text wpcf7-email wpcf7-validates-as-required wpcf7-validates-as-email" 
            aria-required="true" 
            aria-invalid="false">
        </span> 
    </p>

    <p>Amount  (required<br>
        <span class="wpcf7-form-control-wrap text-981">
            <input type="text" 
            name="amount" 
            value="" 
            id="contact-amount"
            size="40" 
            class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required" 
            aria-required="true" 
            aria-invalid="false">
        </span>
    </p>

    <p>Comment <br>
    <span class="wpcf7-form-control-wrap textarea-520">
            <textarea name="comment" 
            cols="40" 
            rows="10" 
            id="contact-comment"
            class="wpcf7-form-control wpcf7-textarea" 
            aria-invalid="false"></textarea>
        </span>
    </p>

    <p><input type="submit" value="Send" class="confirmation-btn submit"></p>

    <p style="color:red;font-weight:bold;">Note : * - required fields</p>

    <p> When you proceed you will be forwarded to payments.paysimple.com secure payment site. You will need your card number, expiration, and you will need to enter your name. The other fields are optional. It is our preference that you reference the invoice you are paying as well.</p>
    </form>';


    echo '<div class="confirmation" style="display:hidden;">';
    echo '<form action="' . esc_url( $_SERVER['REQUEST_URI'] ) . '" method="post" class="custom-contact-submit-form">';
    echo '<p><strong>Your Name</strong><br><span class="confirm-name"></span></p>';
    echo '<p><strong>Your Email</strong><br><span class="confirm-email"></span></p>';
    echo '<p><strong>Your Amount</strong><br><span class="confirm-amount"></span></p>';
    echo '<p><strong>Your Comment</strong><br><span class="confirm-comment"></span></p>';

    echo '<input type="hidden" name="hname" value="!">';
    echo '<input type="hidden" name="hemail" value="!">';
    echo '<input type="hidden" name="hamount" value="!">';
    echo '<input type="hidden" name="hcomment" value="!">';

    echo '<p><input type="submit" name="submit-form" value="Proceed to Checkout" class="submit-btn"></p>';

    echo '</form>';
    echo '</div>';

    // echo '<form action="https://api.paysimple.com/v4/payment" method="POST">
    //     <input type="text" name="AccountId">
    //     <input type="text" name="Amount">
    //     <input type="submit" name="submit">
    // </form>';

}


function deliver_mail() {
     // custom-contact-form
    // if the submit button is clicked, send the email
    if (isset($_POST['submit-form'])) {

        // sanitize form values
        $name    = sanitize_text_field( $_POST['hname'] );
        $comment = sanitize_text_field( $_POST['hcomment'] );
        $amount  = sanitize_text_field( $_POST['hamount'] );
        $email   = sanitize_email( $_POST['hemail'] );
        $subject = 'New Payment! Pay Our Fees';

        $message = '
        From: '.$name.' <'. $email .'>
        Comment :'.esc_textarea($comment).'
        Amount: '.sanitize_text_field($amount).'
        --
        This e-mail was sent from a contact form on James D Miller CPA and Associates (http://jdma.biz/temp)';enter code here

        // get the blog administrator's email address
        // $to = get_option( 'admin_email' );
        $to = 'I WILL INSERT MY EMAIL HERE';

        $headers = "From: $name <$email>" . "\r\n";

        // If email has been process for sending, display a success message
        if ( wp_mail( $to, $subject, $message, $headers ) ) {
            echo '<div>';
            echo '<p>Thanks for contacting me, expect a response soon.</p>';
            echo '</div>';
        } else {
            echo 'An unexpected error occurred';
        }

    }
}

function paySimple() {

    if ( isset( $_POST['submit-form'] ) ) {

    // $userName = "<MYUSERNAME>";
    // $superSecretCode = "<CODE HERE>";
    // $timestamp = gmdate("c");
    // $hmac = hash_hmac("sha256", $timestamp, $superSecretCode, true); //note the raw output parameter
    // $hmac = base64_encode($hmac);                                                                                                                                                                                                                            
    // $auth = "Authorization: PSSERVER AccessId = $userName; Timestamp = $timestamp; Signature = $hmac";
    $url = "https://api.paysimple.com/v4/payment";

    $post_args      = json_encode(array('AccountId'  => 37706,'Amount' => $_POST['hamount']));

    $curl = curl_init();
    curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_args);
    // curl_setopt($curl, CURLOPT_HTTPHEADER, array($auth));

    $result = curl_exec($curl);

    var_dump(curl_exec($curl));
    $responseCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
    curl_close($curl);
    echo "<br>response: $responseCode <br><br>";
    die();
    }

}


function cf_shortcode() {
    ob_start();
    html_form_code();
    deliver_mail();
    paySimple();

    return ob_get_clean();
}

add_shortcode( 'contact_form', 'cf_shortcode' );

?>

答え

paySimple

メソッドの問題だと思います

お支払いプロバイダーは、サーバーに送信する前にデータを暗号化する必要がある方法を提供します。この場合彼らは

hmac

を使用して

base64

の暗号化が必要です。これは、解析ツールのドキュメントでは ここ です

あなたの例で、次のコードを見つけた:

// $userName = "jdmcpa4u";
// $superSecretCode = "<CODE HERE>";
// $timestamp = gmdate("c");
// $hmac = hash_hmac("sha256", $timestamp, $superSecretCode, true); //note the raw output parameter
// $hmac = base64_encode($hmac);                                                                                                                                                                                                                            
// $auth = "Authorization: PSSERVER AccessId = $userName; Timestamp = $timestamp; Signature = $hmac";
$url = "https://api.paysimple.com/v4/payment";

$post_args      = json_encode(array('AccountId'  => 37706,'Amount' => $_POST['hamount']));

$curl = curl_init();
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_args);
// curl_setopt($curl, CURLOPT_HTTPHEADER, array($auth));

私は信じるそれらの行をコメントから外すし、もう一度やり直してくださいする必要があります

PaySimple 含まれていますあなたの秘密鍵と要求のコンピューター署名要求ごとに送信する必要があります

その指示に従う場合正しく要求から署名の計算し、も送信している署名と比較します。彼らは誰もを確保することができますこの方法が要求データを改ざんします。これはなぜそれが本当に決してあなたの秘密鍵を公開することが重要です

http://stackoverflow.com/questions/29126976/integrating-paysimple-api-please-check-whats-wrong

スポンサーリンク

Leave a Reply