generated from mythrnr/template-lib-golang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc.go
69 lines (53 loc) · 1.5 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
Package paypayopa provides SDK to use PayPay Open Payment API.
Package paypayopa は, PayPay Open Payment API を使用するための SDK を提供する.
See: https://developer.paypay.ne.jp
# Example to create and delete QR code using Web Payment
- For more example, see https://github.com/mythrnr/paypay-sample-ecommerce-backend-go
package main
import (
"context"
"encoding/json"
"log"
"os"
"github.com/google/uuid"
"github.com/mythrnr/paypayopa-sdk-go"
)
func main() {
creds := paypayopa.NewCredentials(
paypayopa.EnvSandbox,
os.Getenv("PAYPAYOPA_API_KEY"),
os.Getenv("PAYPAYOPA_API_KEY_SECRET"),
os.Getenv("PAYPAYOPA_MERCHANT_ID"),
)
wp := paypayopa.NewWebPayment(creds)
ctx := context.Background()
res, info, err := wp.CreateQRCode(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)
}
b, _ := json.MarshalIndent(info, "", " ")
log.Println(string(b))
if !info.Success() {
log.Fatalf("%+v", info)
}
b, _ = json.MarshalIndent(res, "", " ")
log.Println(string(b))
info, err = wp.DeleteQRCode(ctx, res.CodeID)
if err != nil {
log.Fatalf("%+v", err)
}
b, _ = json.MarshalIndent(info, "", " ")
log.Println(string(b))
}
*/
package paypayopa