def creat_qr(): req = request.json print(req) client = paypayopa.Client(auth=(API_KEY, API_SECRET)) merchant_payment_id = uuid.uuid4().hex payment_details = { "merchantPaymentId": merchant_payment_id, "codeType": "ORDER_QR", "orderItems": req["orderItems"], "amount": req["amount"], "redirectUrl": "{}/{}".format(FRONTEND_PATH, merchant_payment_id), "redirectType": "WEB_LINK", } resp = client.code.create_qr_code(data=payment_details) return json.dumps(resp)
def __init__(self): # Read base information json_file = open('./baseinfo.json', 'r') base_json = json.load(json_file) API_KEY = base_json['apiKey'] API_SECRET = base_json['apiKeySecret'] MERCHANT_ID = base_json['mid'] #Set True for Production Environment. By Default this is set False for Sandbox Environment. client = paypayopa.Client(auth=(API_KEY, API_SECRET), production_mode=False) client.set_assume_merchant(MERCHANT_ID) self.client = client self.redirectUrl = base_json['redirectUrl'] self.merchantPaymentIdPrefix = base_json['merchantPaymentIdPrefix']
import os import json _DEBUG = os.environ.get("_DEBUG", default=True) API_KEY = os.environ.get("API_KEY") API_SECRET = os.environ.get("API_SECRET") FRONTEND_PATH = os.environ.get("REDIRECT_PATH", default="http://localhost:8080/orderpayment") if not API_KEY: raise ValueError("No API_KEY set for Flask application") if not API_SECRET: raise ValueError("No API_SECRET set for Flask application") client = paypayopa.Client( auth=(API_KEY, API_SECRET), production_mode=False ) # Set True for Production Environment. By Default this is set False for Sandbox Environment client.set_assume_merchant("MUNE_CAKE_SHOP") app = Flask(__name__) cors = CORS(app) app.config['CORS_HEADERS'] = 'Content-Type' CAKES = [ { "title": "cake_shop.mississippi", "id": 1, "price": 120, "image": "darkforest.png" },
def setUp(self): self.base_url = 'https://stg-api.sandbox.paypay.ne.jp/v2' self.payment_id = 'fake_payment_id' self.refund_id = 'fake_refund_id' self.merchant_id = 'fake_merchant_id' self.client = paypayopa.Client(auth=('key_id', 'key_secret'))
import paypayopa # 環境変数 LOGGER_LEVEL = os.environ.get("LOGGER_LEVEL") # PayPay API PAY_PAY_API_KEY = os.environ.get("PAY_PAY_API_KEY") PAY_PAY_API_SECRET = os.environ.get("PAY_PAY_API_SECRET") PAY_PAY_API_MERCHANT_ID = os.environ.get("PAY_PAY_API_MERCHANT_ID") if (os.environ.get("PAY_PAY_IS_PROD") == 'True' or os.environ.get("PAY_PAY_IS_PROD") == 'true'): PAY_PAY_IS_PROD = True else: PAY_PAY_IS_PROD = False client = paypayopa.Client(auth=(PAY_PAY_API_KEY, PAY_PAY_API_SECRET), production_mode=PAY_PAY_IS_PROD) client.set_assume_merchant(PAY_PAY_API_MERCHANT_ID) # ログ出力の設定 logger = logging.getLogger() if LOGGER_LEVEL == 'DEBUG': logger.setLevel(logging.DEBUG) else: logger.setLevel(logging.INFO) # テーブル操作クラスの初期化 payment_order_table_controller = TableOrderPaymentOrderInfo() channel_access_token_controller = ChannelAccessToken() # LINE BOTリソースの宣言 CHANNEL_ID = os.getenv('LINE_CHANNEL_ID', None) if CHANNEL_ID is None: logger.error('Specify CHANNEL_ID as environment variable.')
import paypayopa import time API_KEY = 'a_K86OGgHiIW_kX6a' API_SECRET = 'BErO7ESgBqWz7nSeSO+FqZIp/pUMXdeJfY2E2pUG' client = paypayopa.Client(auth=(API_KEY, API_SECRET), production_mode=False) client.set_assume_merchant("302793184549576704") request = { "merchantPaymentId": round(time.time()), "codeType": "ORDER_QR", "redirectUrl": "http://foobar.com", "redirectType": "WEB_LINK", "orderDescription": "Example - Mune Cake shop", "orderItems": [{ "name": "Moon cake", "category": "pasteries", "quantity": 1, "productId": "67678", "unitPrice": { "amount": 1, "currency": "JPY" } }], "amount": { "amount": 1,