augustin-wien / augustina-backend

An open-source web shop designed for selling magazines on the street.
GNU Affero General Public License v3.0
7 stars 0 forks source link

Vivawallet MVP #27

Closed lebe1 closed 1 year ago

lebe1 commented 1 year ago

Type of change

Notes

IMPORTANT

So far this is only for development stage and not any production code yet. For production code there should not be any amount sent, which could be manipulated. Also we are connected to a developer demo account not a production account.

TO BE DONE for the next PR:

  1. Simplify functions in vivawallet.go since there is a lot of repeating code
  2. Generate customer and paymentOrder from database or frontend information instead of sample as it is right now
  3. For the first POST request, only accept items to be sent and calculate amount in the backend instead of sending amount of money via POST request
  4. Create tests for whole process !!
  5. Create a good solution to switch between PaymentProviders (also for accounting purposes)

Description

This PR covers the MVP (minimal viable product) of the VIvaWallet checkout process. Each process step is described below:

  1. Create payment order via new endpoint

    • URL: http://localhost:3000/api/transaction/
    • POST Request
    • Sample cURL call
      curl --header "Content-Type: application/json" \
      --request POST \
      --data '{"amount":2500}' \
      http://localhost:3000/api/transaction/
    • Here the amount is in cents, so this call requests to charge 2500 cents which is 25€
    • If successful, response is: {"SmartCheckoutURL":"https://demo.vivapayments.com/web/checkout?ref=8958019584072636"}
    • VivaWallet checkout URL (Sample link in demo version: https://demo.vivapayments.com/web/checkout?ref=9699361263129530) like
  2. After being redirected to the VivaWallet checkout URL, you need VivaWallet Test Cards to have a successful process.

    • NOTE: First option with Visa card did not work for me but third card option for Mastercard did.
  3. After a successful transaction the user is being redirected to a success page, which is right now https://local.com/success and will be changed towards production.

    • NOTE: The whole sample URL, looks something like this https://local.com/success?t=d87ea0e6-91da-4312-abdf-67ebb84ee981&s=5857961245421135&lang=en-GB&eventId=0&eci=1
    • Here the frontend (or developer for testing purposes) has to extract the transactionID, which is t or in this sample URL above d87ea0e6-91da-4312-abdf-67ebb84ee981
  4. It is the frontends task to extract the transactionID from the URL to verify the transaction via new endpoint

    • URL: http://localhost:3000/api/verification/
    • POST Request
    • Sample cURL call
      curl --header "Content-Type: application/json" \
      --request POST \
      --data '{"transactionid":"0a384178-d329-4d54-9474-75c4adff51c0"}' \
      http://localhost:3000/api/verification/
    • If successful, response is: {"Verification":true}

      Checklist: