Manual capture
Separate authorization and capture to create an order now, but capture funds later.
Reserve funds now, but capture them only after you complete a service. For example, a hotel may authorize a payment in full prior to a guest’s arrival, then move the money when the guest checks out.
Smartpay by default captures the full order automatically as soon as the order is authorized. If you would like to manually capture the order, for example after the stock is confirmed and the items are ready to ship, please use the manual capture flow described below.
When an order is authorized, Smartpay guarantees the amount and holds it on the customer’s account for up to 7 days. Failure to capture the order by this time cancels the authorization and releases the funds. When this happens, the order status transitions to canceled.
1. Tell Smartpay to authorize only
When you create the checkout session for the shopper's order specify manual
in the captureMethod
field for the Create a checkout session API call.
curl --request POST \
--url https://api.smartpay.co/v1/checkout-sessions \
--header 'Accept: application/json' \
--header 'Authorization: Basic sk_test_abcdef12345678' \
--header 'Content-Type: application/json' \
--data '
{
"amount": 1500,
"cancelUrl": "https://mystore.jp/cancel",
"captureMethod": "manual",
"currency": "JPY",
"customerInfo": {
"accountAge": 30,
"address": {
"line1": "虎ノ門1-17-1",
"line2": "虎ノ門ヒルズビジネスタワー 15階",
"locality": "港区",
"administrativeArea": "東京都",
"postalCode": "105-6415",
"country": "JP"
},
"dateOfBirth": "2019-08-24",
"emailAddress": "[email protected]",
"firstName": "John",
"firstNameKana": "ドエ",
"lastName": "Doe",
"lastNameKana": "ドエ",
"legalGender": "male",
"phoneNumber": "+818000000000",
"reference": "string"
},
"description": "string",
"items": [
{
"amount": 1000,
"brand": "FARVALUE",
"currency": "JPY",
"description": "ニット セーター",
"gtin": "682141169930",
"images": [
"https://mystore.jp/images/image.png"
],
"label": null,
"metadata": {},
"name": "セーター",
"priceDescription": null,
"priceMetadata": {},
"productDescription": null,
"productMetadata": {},
"quantity": 1,
"reference": "my_merchant_product_reference",
"url": "https://mystore.jp/my-product/"
}
],
"locale": "ja",
"reference": "my_merchant_order_reference",
"shippingInfo": {
"address": {
"line1": "虎ノ門1-17-1",
"line2": "虎ノ門ヒルズビジネスタワー 15階",
"locality": "港区",
"administrativeArea": "東京都",
"postalCode": "105-6415",
"country": "JP"
},
"addressType": "home",
"carrierName": "yamato",
"reference": "1234-5678-9123",
"feeAmount": 500,
"feeCurrency": "JPY"
},
"successUrl": "https://mystore.jp/success"
}
'
$api = new \Smartpay\Api(getenv('SECRET_KEY'), getenv('PUBLIC_KEY'));
$checkoutSession = $api->checkoutSession([
'amount' => 1500,
'cancelUrl' => 'https://mystore.jp/cancel',
'captureMethod' => 'manual',
'currency' => 'JPY',
'customerInfo' => [
'accountAge' => 30,
'address' => [
'line1' => '虎ノ門1-17-1',
'line2' => '虎ノ門ヒルズビジネスタワー 15階',
'locality' => '港区',
'administrativeArea' => '東京都',
'postalCode' => '105-6415',
'country' => 'JP'
],
'dateOfBirth' => '2019-08-24',
'emailAddress' => '[email protected]',
'firstName' => 'John',
'firstNameKana' => 'ドエ',
'lastName' => 'Doe',
'lastNameKana' => 'ドエ',
'legalGender' => 'male',
'phoneNumber' => '+818000000000',
'reference' => 'string'
],
'description' => 'My Smartpay order',
'items' => [
[
'amount' => 1000,
'brand' => 'FARVALUE',
'currency' => 'JPY',
'description' => 'ニット セーター',
'gtin' => '682141169930',
'images' => [
'https://mystore.jp/images/image.png'
],
'name' => 'セーター',
'quantity' => 1,
'reference' => 'my_merchant_product_reference',
'url' => 'https://mystore.jp/my-product/'
]
],
'locale' => 'ja',
'reference' => 'my_merchant_order_reference',
'shippingInfo' => [
'address' => [
'line1' => '虎ノ門1-17-1',
'line2' => '虎ノ門ヒルズビジネスタワー 15階',
'locality' => '港区',
'administrativeArea' => '東京都',
'postalCode' => '105-6415',
'country' => 'JP',
],
'feeAmount' => 500,
'feeCurrency' => 'JPY',
],
'successUrl' => 'https://mystore.jp/success'
]);
Smartpay.configure do |config|
config.public_key = ENV['PUBLIC_KEY']
config.secret_key = ENV['SECRET_KEY']
end
session = Smartpay::Api.create_checkout_session({
amount: 1500,
cancelUrl: 'https://mystore.jp/cancel',
captureMethod: 'manual',
currency: 'JPY',
customerInfo: {
accountAge: 30,
address: {
line1: '虎ノ門1-17-1',
line2: '虎ノ門ヒルズビジネスタワー 15階',
locality: '港区',
administrativeArea: '東京都',
postalCode: '105-6415',
country: 'JP',
},
dateOfBirth: '1985-06-30',
email: '[email protected]',
firstName: '田中',
lastName: '太郎',
firstNameKana: 'たなか',
lastNameKana: 'たろう',
legalGender: 'male',
phoneNumber: '+818000000000',
reference: 'my_merchant_consumer_reference',
},
description: 'My Smartpay order',
items: [
{
amount: 1000,
brand: 'FARVALUE',
currency: 'JPY',
description: 'ニット セーター',
gtin: '682141169930',
images: [
'https://mystore.jp/images/image.png'
],
label: null,
metadata: {},
name: 'セーター',
priceDescription: null,
priceMetadata: {},
productDescription: null,
productMetadata: {},
quantity: 1,
reference: 'my_merchant_product_reference',
url: 'https://mystore.jp/my-product/'
}
],
reference: 'my_merchant_order_reference',
shippingInfo: {
address: {
line1: '虎ノ門1-17-1',
line2: '虎ノ門ヒルズビジネスタワー 15階',
locality: '港区',
administrativeArea: '東京都',
postalCode: '105-6415',
country: 'JP',
},
feeAmount: 500,
feeCurrency: 'JPY',
},
successUrl: 'https://mystore.jp/success',
})
SECRET_KEY = os.environ.get('SECRET_KEY', '<YOUR_SECRET_KEY>')
PUBLIC_KEY = os.environ.get('PUBLIC_KEY', '<YOUR_PUBLIC_KEY>')
smartpay = Smartpay(SECRET_KEY, public_key=PUBLIC_KEY)
session = smartpay.create_checkout_session({
"amount": 1500,
"cancelUrl": "https://mystore.jp/cancel",
"captureMethod": "manual",
"currency": "JPY",
"customerInfo": {
"accountAge": 30,
"address": {
"line1": "虎ノ門1-17-1",
"line2": "虎ノ門ヒルズビジネスタワー 15階",
"locality": "港区",
"administrativeArea": "東京都",
"postalCode": "105-6415",
"country": "JP",
},
"dateOfBirth": "1985-06-30",
"email": "[email protected]",
"firstName": "田中",
"lastName": "太郎",
"firstNameKana": "たなか",
"lastNameKana": "たろう",
"legalGender": "male",
"phoneNumber": "+818000000000",
"reference": "my_merchant_consumer_reference",
},
"items": [
{
"amount": 1000,
"brand": "FARVALUE",
"currency": "JPY",
"description": "ニット セーター",
"gtin": "682141169930",
"images": [
"https://mystore.jp/images/image.png"
],
"label": null,
"metadata": {},
"name": "セーター",
"priceDescription": null,
"priceMetadata": {},
"productDescription": null,
"productMetadata": {},
"quantity": 1,
"reference": "my_merchant_product_reference",
"url": "https://mystore.jp/my-product/"
}
],
"reference": "my_merchant_order_reference",
"shippingInfo": {
"address": {
"line1": "虎ノ門1-17-1",
"line2": "虎ノ門ヒルズビジネスタワー 15階",
"locality": "港区",
"administrativeArea": "東京都",
"postalCode": "105-6415",
"country": "JP",
},
"feeAmount": 500,
"feeCurrency": "JPY",
},
"successUrl": "https://mystore.jp/success",
})
2. Redirect the shopper to Smartpay checkout
Redirect the shopper to Smartpay checkout using the url
returned by the create checkout session API call. Once the shopper successfully completes the checkout, your order status be requires_capture
.
Please note that the order is only valid for 7 days and needs to be captured within that time. If you do not capture it within 7 days, the order will be canceled automatically.
3. Create a payment (Capture the order)
Create a payment (capture the order) by following our capture an order guide
Cancelling an order
If the shopper cancels the order before it is captured you can cancel the Smartpay order by following our cancel an order guide.
Updated 6 months ago