Socket
Socket
Sign inDemoInstall

github.com/mythrnr/paypayopa-sdk-go

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/mythrnr/paypayopa-sdk-go


Version published
Created
Source

paypayopa-sdk-go

日本語

  • ⚠️ This SDK is Unofficial. ⚠️
  • Package paypayopa provides SDK to use PayPay API for Go.
  • Official: https://developer.paypay.ne.jp

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.

IntegrationDocument
Web Paymenthttps://developer.paypay.ne.jp/products/docs/webpayment
Native Paymenthttps://developer.paypay.ne.jp/products/docs/nativepayment
Dynamic QRhttps://developer.paypay.ne.jp/products/docs/qrcode
App Invokehttps://developer.paypay.ne.jp/products/docs/appinvoke
Continuous Paymenthttps://developer.paypay.ne.jp/products/docs/continuouspayment
PreAuth & Capturehttps://developer.paypay.ne.jp/products/docs/preauthcapture
Request Moneyhttps://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)
    }
}

FAQs

Package last updated on 09 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc