Categorygithub.com/mythrnr/paypayopa-sdk-go
modulepackage
0.5.1
Repository: https://github.com/mythrnr/paypayopa-sdk-go.git
Documentation: pkg.go.dev

# README

paypayopa-sdk-go

English

  • ⚠️ この SDK は 非公式 . ⚠️
  • paypayopa は PayPay API を Go で使うための SDK を提供する.
  • 公式サイト: https://developer.paypay.ne.jp

Status

Check codes

Scan Vulnerabilities

Requirements

  • Go 1.20 以上.
  • Docker (開発時)

開発に必要

Install

go get で取得する.

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

Feature

インテグレーションベースの SDK

公式の paypay/paypayopa-sdk-* も当然ながら十分に役割を果たすが, mythrnr/paypayopa-sdk-go は SDK の統合に更に集中するために Web Payment や Native Payment などのインテグレーションごとに クライアントを生成して利用する.

Usage

使用可能なインテグレーションは下記の通り.

インテグレーションドキュメント
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

資格情報の生成

  • paypayopa.NewCredentials を使い, 開発者ページで生成した API キーなどを設定する.
  • paypayopa.Env*** を指定し, 接続先を切り替える.
creds := paypayopa.NewCredentials(
    paypayopa.EnvSandbox,
    "YOUR_API_KEY",
    "YOUR_API_KEY_SECRET",
    "YOUR_MERCHANT_ID",
)

Web Payment を用いた QR コードの作成と削除の例

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

# Functions

NewAppInvoke returns a client for App Invoke.
NewAppInvokeWithHTTPClient returns a App Invoke client that performs with a pre-configured *http.Client.
NewContinuousPayment returns a client for Continuous Payment.
NewContinuousPaymentWithHTTPClient returns a Continuous Payment client that performs with a pre-configured *http.Client.
NewCredentials creates a structure to hold the credentials.
NewDynamicQR returns a client for Dynamic QR.
NewDynamicQRWithHTTPClient returns a Dynamic QR client that performs with a pre-configured *http.Client.
NewNativePayment returns a client for Native Payment.
NewNativePaymentWithHTTPClient returns a Native Payment client that performs with a pre-configured *http.Client.
NewPreAuthCapture returns a client for PreAuth & Capture.
NewPreAuthCaptureWithHTTPClient returns a PreAuth & Capture client that performs with a pre-configured *http.Client.
NewRequestMoney returns a client for Request Money.
NewRequestMoneyWithHTTPClient returns a Request Money client that performs with a pre-configured *http.Client.
NewWebPayment returns a client for Web Payment.
NewWebPaymentWithHTTPClient returns a Web Payment client that performs with a pre-configured *http.Client.

# Constants

CodeTypeOrderQR is a fixed value that needs to be entered when sending a QR Code creation request.
CodeTypeTopupQR is a fixed value that needs to be entered when sending a request to create a QR code for top-up.
CurrencyJPY is the currency unit for the Japanese yen.
EnvProduction is a value that specifies that the request should be sent to the production environment.
EnvSandbox is a value that specifies that the request should be sent to the sandbox environment.
EnvStaging is a value that specifies that the request should be sent to the staging environment.
LangEN is a value to set the language of the cashback message text to English.
LangJA is a value to set the language of the cashback message text to Japanese.
ProductTypePayLaterRepayment is a type of product type.
ProductTypeRealInvestment is a type of product type.
ProductTypeVirtualBonusInvestment is a type of product type.
RedirectTypeDeepLink is specified when the payment is occurring in the app.
RedirectTypeWebLink is specified when the payment is occurring in a web browser.
ScopeBankRegistration represents the scope bank_registration of the user authorization.
ScopeCashback represents the scope cashback of the user authorization.
ScopeContinuousPayments represents the scope continuous_payments of the user authorization.
ScopeDirectDebit represents the scope direct_debit of the user authorization.
ScopeGetBalance represents the scope get_balance of the user authorization.
ScopeMerchantTopup represents the scope merchant_topup of the user authorization.
ScopeNotificationCenterAb represents the scope notification_center_ab of the user authorization.
ScopeNotificationCenterOg represents the scope notification_center_og of the user authorization.
ScopeNotificationCenterTl represents the scope notification_center_tl of the user authorization.
ScopePendingPayments represents the scope pending_payments of the user authorization.
ScopePreauthCaptureNative represents the scope preauth_capture_native of the user authorization.
ScopePreauthCaptureTransaction represents the scope preauth_capture_transaction of the user authorization.
ScopePushNotification represents the scope push_notification of the user authorization.
ScopeQuickPay represents the scope quick_pay of the user authorization.
ScopeUserNotification represents the scope user_notification of the user authorization.
ScopeUserProfile represents the scope user_profile of the user authorization.
ScopeUserTopup represents the scope user_topup of the user authorization.
UserAuthorizeResultBadRequest is the value when it fails due to other factors.
UserAuthorizeResultDeclined is the value when the authorization could not be obtained.
UserAuthorizeResultSucceeded is the value when the authorization was obtained.

# Variables

No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ContinuousPayment provides an API for PayPay's Continuous Payment functionality.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Credentials is a structure that holds credentials.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NativePayment provides an API for PayPay's Native Payment functionality.
No description provided by the author
No description provided by the author
PreAuthCapture provides an API for PayPay's PreAuth & Capture functionality.
No description provided by the author
No description provided by the author
No description provided by the author
RequestMoney provides an API for PayPay's payment request functionality.
ResultInfo is the result object of the PayPay API processing.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
WebPayment provides an API for PayPay's web payment functionality.

# Type aliases

AppInvoke provides an API for PayPay's App Invoke functionality.
CodeType is the code type required for QR Code creation requests.
Currency is the type of currency.
DynamicQR provides an API for PayPay's Dynamic QR functionality.
Environment is a type used to specify the destination of the request.
Lang is a value specified in the lang header to set the language of the cashback message text.
ProductType is the product type of the PayPay system.
RedirectType is the type of redirection to specify when sending a QR Code creation request.
Scope is the scope of the user authorization.
UserAuthorizeResult is the result of user authorization.