Skip to content

Latest commit

 

History

History
120 lines (88 loc) · 3.07 KB

README.md

File metadata and controls

120 lines (88 loc) · 3.07 KB

paypayopa-sdk-go

日本語

Status

Check codes

Scan Vulnerabilities

Requirements

  • Go 1.20 or above.
  • Docker (for Development)

For development

Install

Get it with go get.

go get github.com/mythrnr/paypayopa-sdk-go

Feature

Integration based SDK

The official paypay/paypayopa-sdk-* will obviously do the job. But, to focus to integrate SDK to your system, mythrnr/paypayopa-sdk-go provides clients each integration such as Web Payment or Native Payment, not based REST API.

Usage

Available integration here.

Integration Document
Web Payment https://developer.paypay.ne.jp/products/docs/webpayment
Native Payment https://developer.paypay.ne.jp/products/docs/nativepayment
Dynamic QR https://developer.paypay.ne.jp/products/docs/qrcode
App Invoke https://developer.paypay.ne.jp/products/docs/appinvoke
Continuous Payment https://developer.paypay.ne.jp/products/docs/continuouspayment
PreAuth & Capture https://developer.paypay.ne.jp/products/docs/preauthcapture
Request Money https://developer.paypay.ne.jp/products/docs/pendingpayment

Create Credentials

  • Use paypayopa.NewCredentials , and set the API key generated on the developer page.
  • Use paypayopa.Env*** to switch the connection destination.
creds := paypayopa.NewCredentials(
    paypayopa.EnvSandbox,
    "YOUR_API_KEY",
    "YOUR_API_KEY_SECRET",
    "YOUR_MERCHANT_ID",
)

Example to create and delete QR code using Web Payment

package main

import (
    "context"
    "encoding/json"
    "log"

    "github.com/google/uuid"
    "github.com/mythrnr/paypayopa-sdk-go"
)

func main() {
    creds := paypayopa.NewCredentials(
        paypayopa.EnvSandbox,
        "YOUR_API_KEY",
        "YOUR_API_KEY_SECRET",
        "YOUR_MERCHANT_ID",
    )

    wp := paypayopa.NewWebPayment(creds)
    ctx := context.Background()

    res, info, err := wp.CreateCode(ctx, &paypayopa.CreateQrCodePayload{
        MerchantPaymentID: uuid.NewString(),
        Amount: &paypayopa.MoneyAmount{
            Amount:   1000,
            Currency: paypayopa.CurrencyJPY,
        },
        CodeType:     paypayopa.CodeTypeOrderQR,
        RedirectURL:  "https://localhost",
        RedirectType: paypayopa.RedirectTypeWebLink,
    })

    if err != nil {
        log.Fatalf("%+v", err)
    }

    if !info.Success() {
        log.Fatalf("%+v", info)
    }

    info, err = wp.DeleteCode(ctx, res.CodeID)
    if err != nil {
        log.Fatalf("%+v", err)
    }
}