Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Notifications

somentelucas edited this page Sep 3, 2018 · 11 revisions

Introduction

It's the best way to sync status from Moip with your system. Do you want to know what's happening with your business and be notified when an order is created, when a payment is authorized or canceled or when other things happen in your account? So, this page may help you! 🙌📢

Dependencies

import static br.com.moip.helpers.PayloadFactory.payloadFactory;
import static br.com.moip.helpers.PayloadFactory.value;

Features

Index

Create notification preference

Authorization able
Basic Auth
OAuth
List events = new ArrayList();
events.add("ORDER.*");
events.add("PAYMENT.AUTHORIZED");
events.add("PAYMENT.CANCELLED");

Map<String, Object> body = payloadFactory(
    value("events", events),
    value("target", "https://my.site.com/test/receive_notifications"),
    value("media", "WEBHOOK")
);

Map<String, Object> newPreference = Moip.API.notificationPreferences().create(body, setup);

Get notification preference

Authorization able
Basic Auth
OAuth
Map<String, Object> getResponse = Moip.API.notificationPreferences().get("notification_preference_id", setup);

List notification preferences

Authorization able
Basic Auth
OAuth
List<Map<String, Object>> listResponse = Moip.API.notificationPreferences().list(setup);

Remove notification preference

Authorization able
Basic Auth
OAuth
Map<String, Object> response = Moip.API.notificationPreferences().remove("notification_preference_id", setup);

Get webhook

Authorization able
Basic Auth
OAuth

You should send the ID of the resource that you want to check (order, payment, refund, etc).

Map<String, Object> response = Moip.API.webhooks().get("resource_id", setup);

List webhooks

Authorization able
Basic Auth
OAuth
Map<String, Object> response = Moip.API.webhooks().list(setup);