• Resolved believelody

    (@believelody)


    Hi, I’m using WordPress as backend. I want to build a REST route for handling payment using your plugin. Can you tell me please a step by step process to achieve this functionality ?
    For example, in frontent, user clicks on “buy” which trigger a POST request (capture charge for stripe) to wordpress.
    In my function on server, how can I handle payment request ?
    – Use WC_Stripe_Payment_Intent ?
    – Use WC_Stripe_Payment_Charge ?
    – Use an action hooks ? Which ones ?
    – What else before trigger a process_payment methods ?
    – Which informations I need to perform a basic payment ? Token_id, payment_intent_id, payment_method_id, order_id ?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Clayton R

    (@mrclayton)

    Hi @believelody,

    You will find most of the information you need by reviewing our API docs where all of the code is documented.

    API Docs

    The class you should look at is WC_Stripe_Controller_Checkout. The route is wp-json/wc-stripe/v1/checkout and it follows the WP semantics for REST url’s. The process_checkout method acts as a wrapper for the WC_Checkout::process_checkout method.

    If you look here you will see that all payment methods are submitted to the server in the format ${gateway_id}_token_key so stripe_cc_token_key for the credit card gateway.

    All other fields like billing and shipping info is submitted in the format that WC expects.

    Kind Regards,

    Thread Starter believelody

    (@believelody)

    Hello, thank you very much for all this information. I will give it a try.
    Just another question about the format. Does that mean that those following properties: save_method_key, save_source_key, payment_type_key and payment_intent_key in WC_Payment_Gateway_Stripe will begin by “gateway_id” which is “stripe_cc” ? I read in stripe docs that it needs a source or a token or a payment_method id string from client side. I’m a bit confuse in this part.

    Sincerelly

    Plugin Author Clayton R

    (@mrclayton)

    Hi @believelody,

    Yes all of those properties begin with the gateway’s ID.

    When submitting the Stripe payment method to your server, it should be in the format ${gateway_id}_token_key. So for the credit card gateway it would be stripe_cc_token_key.

    Here is what each property is used for:

    $token_key: Used for the one time payment
    $saved_method_key: Used when a customer pays with a saved payment method
    $save_source_key: Indicator that is set when customer want’s to save their payment method
    $payment_type_key: Indicator that tells the plugin if the customer is paying with a new or saved payment method.

    Kind Regards,

    Thread Starter believelody

    (@believelody)

    Hi @mrclayton, thank you very much, I will go with that.

    Kind Regards

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Make a API route using this plugin for Single Page Application’ is closed to new replies.