質問編集履歴
1
data追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -41,4 +41,103 @@
|
|
41
41
|
|
42
42
|
最初customerが共有できていないのかなと思ったのですがstripeにきいたところ、ディスティネーション支払いはプラットフォームなのでcustomerの共有は不要とのことでした。管理画面に上記のcustomerIDはあるのでなぜないと出てしまうのかわからない状態です。
|
43
43
|
|
44
|
-
このエラーの対処方法わかる方いるでしょうか?
|
44
|
+
このエラーの対処方法わかる方いるでしょうか?
|
45
|
+
|
46
|
+
dataの送り方は下記でviewからjsで送っています。
|
47
|
+
|
48
|
+
```
|
49
|
+
<script>
|
50
|
+
var stripe = Stripe('pk_test_');
|
51
|
+
var csrf_token = document.querySelector('meta[name="csrf-token"]').content;
|
52
|
+
var createCheckoutSession = function(priceId,customerId,accountId) {
|
53
|
+
return fetch("/create-checkout-session", {
|
54
|
+
method: "POST",
|
55
|
+
headers: {
|
56
|
+
"Content-Type": "application/json",
|
57
|
+
'X-CSRF-Token': csrf_token
|
58
|
+
},
|
59
|
+
body: JSON.stringify({
|
60
|
+
priceId: priceId,
|
61
|
+
customerId: customerId,
|
62
|
+
accountId: accountId,
|
63
|
+
})
|
64
|
+
}).then(function(result) {
|
65
|
+
return result.json();
|
66
|
+
});
|
67
|
+
};
|
68
|
+
document
|
69
|
+
.getElementById("checkout")
|
70
|
+
.addEventListener("click", function(evt) {
|
71
|
+
createCheckoutSession("<%= @plan.stripe_price_id %>","<%= current_user.stripe_customer_id %>","<%= @plan_user.stripe_account_id %>").then(function(data) {
|
72
|
+
stripe
|
73
|
+
.redirectToCheckout({
|
74
|
+
sessionId: data.id
|
75
|
+
})
|
76
|
+
.then(handleResult);
|
77
|
+
});
|
78
|
+
});
|
79
|
+
</script>
|
80
|
+
|
81
|
+
```
|
82
|
+
|
83
|
+
dataは下記になります
|
84
|
+
|
85
|
+
```
|
86
|
+
{
|
87
|
+
"id": "evt_",
|
88
|
+
"object": "event",
|
89
|
+
"api_version": "",
|
90
|
+
"created": ,
|
91
|
+
"data": {
|
92
|
+
"object": {
|
93
|
+
"id": "cs_test_",
|
94
|
+
"object": "checkout.session",
|
95
|
+
"allow_promotion_codes": null,
|
96
|
+
"amount_subtotal": 3000,
|
97
|
+
"amount_total": 3000,
|
98
|
+
"billing_address_collection": null,
|
99
|
+
"cancel_url": "",
|
100
|
+
"client_reference_id": null,
|
101
|
+
"currency": "usd",
|
102
|
+
"customer": "cus_",
|
103
|
+
"customer_details": {
|
104
|
+
"email": "",
|
105
|
+
"tax_exempt": "none",
|
106
|
+
"tax_ids": [
|
107
|
+
]
|
108
|
+
},
|
109
|
+
"customer_email": null,
|
110
|
+
"livemode": false,
|
111
|
+
"locale": null,
|
112
|
+
"metadata": {
|
113
|
+
},
|
114
|
+
"mode": "payment",
|
115
|
+
"payment_intent": "pi_",
|
116
|
+
"payment_method_options": {
|
117
|
+
},
|
118
|
+
"payment_method_types": [
|
119
|
+
"card"
|
120
|
+
],
|
121
|
+
"payment_status": "paid",
|
122
|
+
"setup_intent": null,
|
123
|
+
"shipping": null,
|
124
|
+
"shipping_address_collection": null,
|
125
|
+
"submit_type": null,
|
126
|
+
"subscription": null,
|
127
|
+
"success_url": "",
|
128
|
+
"total_details": {
|
129
|
+
"amount_discount": 0,
|
130
|
+
"amount_shipping": 0,
|
131
|
+
"amount_tax": 0
|
132
|
+
}
|
133
|
+
}
|
134
|
+
},
|
135
|
+
"livemode": false,
|
136
|
+
"pending_webhooks": 3,
|
137
|
+
"request": {
|
138
|
+
"id": null,
|
139
|
+
"idempotency_key": null
|
140
|
+
},
|
141
|
+
"type": "checkout.session.completed"
|
142
|
+
}
|
143
|
+
```
|