pandudpn / mobile-pulsa-go

(Unofficial) Mobile Pulsa REST API for Go.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MobilePulsa API Go Client

GoDoc Coverage Status Go Report Card

This is Unofficial Project for Prepaid or Postpaid Product in Indonesia. This is created by pandudpn.

Documentation

For the API Documentation, check IAK Documentation

Installation

Install with :

go get -u github.com/pandudpn/mobile-pulsa-go

Then, import it using:

import "github.com/pandudpn/mobile-pulsa-go"

Usage

package main

import (
    "log"

    "github.com/pandudpn/mobile-pulsa-go"
    "github.com/pandudpn/mobile-pulsa-go/topup"
)

func main() {
    apiKey := "api-key"
    userName := "username"
    appEnv := "development"

    opts := mobilepulsa.NewOption()
    opts.SetAPIKey(apiKey)
    opts.SetUsername(username)
    // set the environment
    if appEnv == "development" {
        opts.SetDevelopment()
    } else {
        opts.SetProduction()
    }

    // for an example, you want to buy pulse `Telkomsel` with nominal 1.000
    productCode := "htelkomsel1000"

    data := &topup.TopUpParam{
        RefID: "uuid-123",
        ProductCode: productCode,
        CustomerID: "target_phone_number",
    }

    topup, err := topup.CreatePayment(data, opts)
    if err != nil {
        // do something here
        log.Println("error create payment prepaid product", err)
        return
    }

    log.Println(topup.Message)
}

About

(Unofficial) Mobile Pulsa REST API for Go.

License:MIT License


Languages

Language:Go 99.6%Language:Makefile 0.3%Language:Shell 0.1%