Skip to content

Latest commit

 

History

History
76 lines (56 loc) · 1.9 KB

README.md

File metadata and controls

76 lines (56 loc) · 1.9 KB

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)
}