WooshPay 결제

개요 #

There are four steps to creating a complete checkout:

  1. 제품 만들기
  2. Create a Price
  3. Create a Checkout
  4. Jump to the cashier to complete the payment

제품 만들기 #

Products and prices are core resources for many WooshPay integrations. Products define what your business offers, whether that’s goods or services.

요청

{
    "name":"example product",
    "active":true,
    "description":"some description",
    "metadata":{
        "key1":"value1",
        "key3":"value3"
    },
    "url":"www.example.com"
}

응답

{
    "id": "prod_1554351292598452224",
    "object": "product",
    "created": 1665642282000,
    "active": true,
    "description": "some description",
    "metadata": {
        "key1": "value1",
        "key2": "value2"
    },
    "name": "example product",
    "livemode": false,
    "url": "www.example.com",
    "updated": 1665642282000,
    "images": null
}

Create a Price #

Prices define how much and how often to charge for products. You can create single or multiple prices for a product.

Request 1:Directly bind the exsisted product

{
    "currency":"GBP",
    "product":"prod_1554351292598452224",
    "unit_amount":5,
    "active":true,
    "metadata":{
        "key1":"value1",
        "key2":"value2"
    },
    "nickname":"some nickname",
    "product_data":null,
    "lookup_key":"test_lookup_key"
}

Request 2:Create a new product while create a price

{
    "currency":"GBP",
    "product":null,
    "unit_amount":5,
    "active":true,
    "metadata":{
        "key1":"value1",
        "key2":"value2"
    },
    "nickname":"fengli",
    "product_data":{
        "id":null,
        "name":"example product",
        "active":true,
        "description":"very delicious",
        "metadata":{
            "key1":"value1",
            "key2":"value2"
        },
        "url":"www.example.com"
    },
    "billing_scheme":"testscheme",
    "lookup_key":"test_lookup_key"
}

응답

{
    "id":"price_1554384814788837376",
    "object":"price",
    "created":1659429194000,
    "active":true,
    "currency":"GBP",
    "metadata":{
        "key1":"value1",
        "key2":"value2"
    },
    "nickname":"some nickname",
    "product":{
        "id":"prod_1554351292598452224",
        "object":"product",
        "created":1659421201000,
        "active":true,
        "description":"very delicious",
        "metadata":{
            "key1":"value1",
            "key3":"value3"
        },
        "name":"taiwan fengli",
        "livemode":false,
        "url":"www.example.com",
        "updated":1659422039000
    },
    "type":"one_time",
    "livemode":false,
    "unit_amount":5,
    "billing_scheme":"per_unit",
    "lookup_key":"test_lookup_key"
}

Create Checkout #

A Checkout Session is the programmatic representation of what your customer sees when they’re redirected to the payment form. You can configure it with options such as:

  • 라인 항목 to charge
  • currencies to use

You also need to specify:

  • A success_url, a page on your website to redirect your customer after they complete the payment.
  • A cancel_url, a page on your website to redirect your customer if they click on your logo in Checkout.

Note: Checkout Sessions expire 24 hours after creation.

요청

{
    "cancel_url":"www.example.com",
    "mode":"payment",
    "success_url":"www.wooshpay.com",
    "line_items":[
        {
            "price_data":{
                "currency":"GBP",
                "product":null,
                "unit_amount":5,
                "active":true,
                "metadata":{
                    "key1":"value1",
                    "key2":"value2"
                },
                "nickname":"fengli",
                "product_data":{
                    "id":null,
                    "name":"example product",
                    "active":true,
                    "description":"very delicious",
                    "metadata":{
                        "key1":"value1",
                        "key2":"value2"
                    },
                    "url":"www.example.com"
                },
                "billing_scheme":"testscheme",
                "lookup_key":"test_lookup_key"
            },
            "quantity":1
        }
    ]
}

응답

{
    "id":"cs_1580071142008291328",
    "object":"checkout.session",
    "created":1665553291000,
    "currency":"GBP",
    "customer":"",
    "mode":"payment",
    "livemode":false,
    "shipping":null,
    "status":"open",
  "url":"https://checkouttest.wooshpay.com/pay/cs_test_1580071142008291328?key=pk_test_dGVzdDpXWUg1eUF4OXZpUUF4UHNoYmdRRjVTTTE=",
    "cancel_url":"www.baidu.com",
    "client_reference_id":null,
    "customer_email":null,
    "line_items":{
        "object":"list",
        "data":[
            {
                "id":"li_1580071142847152128",
                "object":"item",
                "currency":"GBP",
                "description":"example product",
                "price":{
                    "id":"price_1580071142859735040",
                    "object":"price",
                    "created":1665553291000,
                    "active":true,
                    "currency":"GBP",
                    "metadata":{
                        "key1":"value1",
                        "key2":"value2"
                    },
                    "nickname":"fengli",
                    "product":{
                        "id":"prod_1580071142880706560",
                        "object":"product",
                        "created":1665553291000,
                        "active":true,
                        "description":"some description",
                        "metadata":{
                            "key1":"value1",
                            "key2":"value2"
                        },
                        "name":"example product",
                        "livemode":false,
                        "url":"www.example.com",
                        "updated":1665553291000,
                        "images":null
                    },
                    "type":"one_time",
                    "livemode":false,
                    "unit_amount":5,
                    "billing_scheme":"per_unit",
                    "lookup_key":"test_lookup_key"
                },
                "quantity":1,
                "amount_subtotal":5,
                "amount_total":5
            }
        ],
        "url":null,
        "has_more":null
    },
    "payment_intent":"pi_1580071150141046784",
    "payment_method_types":null,
    "payment_status":"unpaid",
    "success_url":"www.wooshpay.com",
    "amount_subtotal":5,
    "amount_total":5,
    "billing_address_collection":"auto",
    "expires_at":1665639691214,
    "payment_link":"",
    "payment_method_options":null,
    "phone_number_collection":null,
    "shipping_address_collection":null,
    "client_secret":"pi_1580071150141046784_secret_bsOGcAMewpe6orzCbZHMlomu"
}

Redirect the URL #

After creating a Checkout Session, redirect your customer to the URL returned in the response.

What are your feelings
Updated on 8월 9, 2023