@agilo/medusa-payment-reepay

Reepay payment provider for Medusa


Keywords
medusa, medusa-plugin, medusa-plugin-payment, medusa-reepay
License
MIT
Install
npm install @agilo/medusa-payment-reepay@1.0.1

Documentation

Medusa Hackathon 2022

About

Participants

@anteprimorac
@josipmatichr
@marijapolovic

Description

Adds Reepay payment provider for Medusa Commerce.

Set up Project

Install:

npm i @agilo/medusa-payment-reepay

Add to medusa-config.js

{
  resolve: `@agilo/medusa-payment-reepay`,
  options: {
    api_key: REEPAY_API_KEY,
    payment_methods: ["mobilepay"],
    webhook_secret: WEBOOK_SECRET,
    accept_url: "www.some-webshop.com/checkout/payment",
    cancel_url: "www.some-webshop.com/checkout",
  },
}

Enable reepay as a payment provider in Medusa admin settings

Creating Payment Session

Use Medusa API to create Payment Sessions for the available payment providers.

This will create a Reepay charge session.

Request

{
  settle: false,
  order: {
    handle: CART_ID,
    amount: TOTAL,
    currency: CURRENCY_CODE,
    customer: {
      email: CART_EMAIL,
    },
  },
  payment_methods: this.options_.payment_methods,
  accept_url: this.options_.accept_url,
  cancel_url: this.options_.cancel_url,
}

Response

{
  id: "string",
  url: "string"
}

Authorize Payment

Use Medusa API to complete cart, this will result in an attempt to authorize payment.

To authorize payment using Reepay checkout you can use cart.payment_session.data.action.url to redirect user to the checkout page.

After completion user is redirected to the options.accept_url, where you can complete a cart.

If you're using webhooks you should make sure to check that the cart is not already completed to avoid conflict. In this case you should retrieve an order before trying to complete the cart.

Capture Payment

Capturing payment will result in an attempt to settle a payment

Cancel Payment

Canceling an order will result in an attempt to cancel a charge

Refund Payment

Creating a refund will result in an attempt to create a refund

Webhooks

Currently, the only supported webhook is for invoice_authorized.

Once this webhook is fired, this will result in an attempt to complete a cart.

MobilePay

To enable MobilePay payment method you should add a MobilePay acquirer in the Reepay acquiring configuration. After that you should add "mobilepay" as a payment method in the medusa-payment-reepay options.

Resources

Medusa Docs
https://docs.medusajs.com/

Reepay Docs
https://reference.reepay.com/api/

MobilePay Docs
https://developer.mobilepay.dk/products/online/test