会員サイトをリニューアルしました! 新サイトはこちら

Paypal決済ボタンについて < SWELLに関する質問

フォーラムをリニューアルしました!
今後は、新フォーラムをご利用ください。

Paypal決済ボタンについて
 
通知
すべてクリア

[解決済] Paypal決済ボタンについて

5 投稿
2 ユーザー
0 Likes
1,144 表示
P-one
(@p-one)
Active Member
Topic starter
 

はじめまして。SWELLを使い始めた初心者です。

投稿ページ、固定ページに、「J-振り」ボタン、Paypalボタン、を設置できますか?

J-振りは、ボタン画像にリンクを貼る

Paypalは、コード画面で、HTMLとScriptなど、Paypalで自動生成されたものをコピペする

ような仕様です。

Paypalボタンがうまく貼れません。

よろしくお願いします。

 
投稿済 : 21/01/2021 6:48 am
了(開発者)
(@ryo)
Illustrious Member Admin
 

すみません、僕は分からないですが、Paypalのドキュメント読んでその通りにすればいけると思います!

 
投稿済 : 21/01/2021 7:19 am
P-one
(@p-one)
Active Member
Topic starter
 

@ryo Paypalの説明では、以下のコードをwebページに貼り付ける、と指示されます。

<div id="smart-button-container">
<div style="text-align: center;">
<div style="margin-bottom: 1.25rem;">
<p>ご購入商品</p>
<select id="item-options"><option value="オンデマンド1" price="2200">オンデマンド1 - 2200 JPY</option><option value="オンデマンド2" price="2200">オンデマンド2 - 2200 JPY</option></select>
<select style="visibility: hidden" id="quantitySelect"></select>
</div>
<div id="paypal-button-container"></div>
</div>
</div>
<script src="https://www.paypal.com/sdk/js?client-id=sb&currency=JPY" data-sdk-integration-source="button-factory"></script>
<script>
function initPayPalButton() {
var shipping = 0;
var itemOptions = document.querySelector("#smart-button-container #item-options");
var quantity = parseInt();
var quantitySelect = document.querySelector("#smart-button-container #quantitySelect");
if (!isNaN(quantity)) {
quantitySelect.style.visibility = "visible";
}
var orderDescription = 'ご購入商品';
if(orderDescription === '') {
orderDescription = 'Item';
}
paypal.Buttons({
style: {
shape: 'rect',
color: 'gold',
layout: 'vertical',
label: 'pay',

},
createOrder: function(data, actions) {
var selectedItemDescription = itemOptions.options[itemOptions.selectedIndex].value;
var selectedItemPrice = parseFloat(itemOptions.options[itemOptions.selectedIndex].getAttribute("price"));
var tax = (0 === 0) ? 0 : (selectedItemPrice * (parseFloat(0)/100));
if(quantitySelect.options.length > 0) {
quantity = parseInt(quantitySelect.options[quantitySelect.selectedIndex].value);
} else {
quantity = 1;
}

tax *= quantity;
tax = Math.round(tax * 100) / 100;
var priceTotal = quantity * selectedItemPrice + parseFloat(shipping) + tax;
priceTotal = Math.round(priceTotal * 100) / 100;
var itemTotalValue = Math.round((selectedItemPrice * quantity) * 100) / 100;

return actions.order.create({
purchase_units: [{
description: orderDescription,
amount: {
currency_code: 'JPY',
value: priceTotal,
breakdown: {
item_total: {
currency_code: 'JPY',
value: itemTotalValue,
},
shipping: {
currency_code: 'JPY',
value: shipping,
},
tax_total: {
currency_code: 'JPY',
value: tax,
}
}
},
items: [{
name: selectedItemDescription,
unit_amount: {
currency_code: 'JPY',
value: selectedItemPrice,
},
quantity: quantity
}]
}]
});
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
alert('Transaction completed by ' + details.payer.name.given_name + '!');
});
},
onError: function(err) {
console.log(err);
},
}).render('#paypal-button-container');
}
initPayPalButton();
</script>

 
投稿済 : 21/01/2021 2:31 pm
了(開発者)
(@ryo)
Illustrious Member Admin
 

申し訳ないですが、こういうテーマ機能を超えたサイトごとの個別なカスタマイズに関してはサポート外となっております。

僕からは自力で頑張ってくださいとしか言いようがないです!

コードで実装するのが難しければ、プラグインとかも色々あると思いますよ。

 
投稿済 : 21/01/2021 2:50 pm
P-one
(@p-one)
Active Member
Topic starter
 

ありがとうございます。サポート外の質問で、申し訳ありませんでした。

頑張ってみます。

 
投稿済 : 25/01/2021 3:03 am
共有: