Code Monkey home page Code Monkey logo

woocommerce-create-payment's Introduction

Create a Payment with WooCommerce - INTERNAL HACKATHON WINNER

This is an example project that shows how to use Rapyd's plugins service to create a seamless payment.

The project purpose is to show how to create a secure PCI compliant payment using a credit card, then save the tokens of the card and create a payment using this tokens.

Running the project:

  1. npm i

  2. set const my_base_url to your domain in index.js file (will not work localhost)

  3. activate your woocommerce plugin and set your woocommerce access key and secret key in api.js file. (please see more details here: https://docs.rapyd.net/works-with/docs/plugins-for-rapyd-payments)

  4. run node index.js

  5. create a post request my_base_url/createCheckoutUrl url: http://localhost:3001/createCheckoutUrl example request body:

          {
                  "currency_code":"EUR",
                  "country_code":"AT",
                  "amount":10,
                  "order_id":"my_unique_order_id_124"
          }

    example response: https://sandboxcheckout.rapyd.net?token=checkout_20e546a5f1885643e81baebf118ff035

  6. browse to the url that is returned. create a payment using credit card.

  7. create a get request to get payment details from example db using the following route: http://localhost:3001/paymentDetailsByOrderId?order_id=my_unique_order_id_123 example response:

      {
           "payment_token": "payment_9a313b40defe1c4b0fb681e936ea4ec3",
           "payment_method": "card_08618e95292467d55a7d3d5a445944e9",
           "woo_status": "processing"
      }
  8. create a post request to my_base_url/createSubscriptionPayment example request body:

       {
            "payment_token": "payment_9a313b40defe1c4b0fb681e936ea4ec3",
            "payment_method": "card_08618e95292467d55a7d3d5a445944e9",
            "amount":12,
            "order_id":"my_unique_order_id_124",
            "currency_code":"EUR"
       }

    example response:

    {
    "statusCode": 200,
        "body": {
            "woo_status": "processing",
            "woo_order_note": "Rapyd payment success"
        },
        "headers": {
            "date": "Tue, 02 Nov 2021 14:46:02 GMT",
            "content-type": "application/json; charset=utf-8",
            "content-length": "68",
            "connection": "close",
            "etag": "W/\"44-tdNQMsSTZSeNxYpbcnrZ0Q\""
        }
    }

Get Support

woocommerce-create-payment's People

Contributors

uxdrew avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

6638112

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.