
Paypalサブスクリプション-Paypal自動支払い-デモ付きのPHPの例を使用したPaypal定期支払い
ペイパルサブスクリプション–すべての開発者が簡単PayPalサブスクリプションボタンを使用して、製品の購入者からペイパルの自動支払いを取得し、メンバーシップ取得のすべての支払いを継続的に請求します。 ペイパルの定期支払いを使用して、購入者は製品または一部のダウンロード可能な製品サービスを毎日、7日ごと、30日ごと、および365日ごとに取得します。
PHPを使用したPayPalサブスクリプション
頑張って 定期支払いペイパル 記事、私はペイパルの定期支払いを設定しています。ショッピングカート、ペイパルサブスクリプションの管理、一括支払い、自動支払いペイパル、ペイパル自動請求、デジタル商品などのさまざまなモードでPayPal支払いを使用する方法を教えてください。
PayPal Webサイトのツールを使用して、オンラインeコマースWebサイトに追加する簡単なステップバイステップの[購読]ボタンを作成するか、Stripe Checkout withBillingを使用して定期支払いを統合するためのHTMLソースコードを作成できます。
これで ペイパルサブスクリプション 記事では、ペイパルを使用して定期支払いを管理する方法、または定期請求ペイパルのPHPおよびHTMLソースコードを使用してPayPalサブスクライブボタンをカスタマイズし、支払いを自動的に取得する方法について説明します。
製品の購入者が、毎日、7日ごと、30日ごと、または365日ごとに請求されるプランを選択できる場合。
IMP注:PayPalは、開発とテストの目的でサンドボックスアカウントを提供しています。 ここでは、テストにサンドボックスを使用しています。そのため、単純なテストバージョンのデモを行う場合は、更新されたPayPalサンドボックスのクレデンシャルを使用できます。
スクリプトの背後にある概念
前回のペイパルサブスクリプションの記事では、PayPalの[今すぐ購入]ボタン、サブスクリプションのペイパル、およびPayPalの[カートに追加]ボタンを教えました。 ペイパル定期支払い ここで、デモで意味のある例を示すためにボタンをカスタマイズしました。
この記事では、PHPのPayPal購読ボタンを使用して、製品アイテムの購読ベースのWebサイトの例を示しました。ここでは、購読者がプランと定期的な期間を選択できます。
ここでは、加入者は毎日、7日ごと、30日ごと、365日ごとなどの製品またはサービスプランを選択できます。また、「何サイクル後に請求が停止するか」という請求サイクル手段も選択できます。

ペイパルサブスクリプションチュートリアルスクリプトの詳細
以下は、このチュートリアルで使用される完全なHTMLおよびPHPソースコードの詳細と、定期支払いペイパルの設定に関する適切な説明です。
index.php
このページには、サブスクリプションプランおよびプランのサイクルとともに製品アイテムサブスクリプション情報を表示するためのソースコードが含まれています。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
<html> <head> <title>PayPal Subscription Button for Recurring Payments</title> <link rel="stylesheet" type="text/css" href="css/main.css"> </head> <body> <div id="main"> <center><h2>PayPal Subscription Button for Recurring Payments</h2></center> <div id="paypal_subscriptions"> <h2>Products paper Subscription</h2> <hr/> <div id="product_paypal_subscriptions"> <center> <h3>Brand Products</h3></center> <img src="images/9.jpg" id="product_img" /> <hr class="type_1"> <form action="process.php" method="POST"> <div class="fgrow"> <span>Select a Plan :-</span> <select id="choose_plan_name" name="choose_plan_name"> <option value="every-day">Every Day </option> <option value="seven-day">every seven-day </option> <option value="thirty-day">30 days </option> <option value="full-year">365 Days </option> </select> </div> <div class="fgrow"> <span>After How Many Cycles Should Billing Stop ?</span> <select id="select_cycles" name="select_cycles"> <option value="">Never </option> <?php for ($i = 2; $i <= 30; $i++) { ?> <option value="<?php echo $i; ?>"><?php echo $i; ?> </option> <?php } ?> </select> </div> <input type="submit" value="Subscrive ($5/Day)" name="submit" id="subscribe"> </form> </div> <div id="product_paypal_subscriptions"> <center> <h3>Brand Products Item Subscription Details</h3></center> <hr class="type_1"> <ul> <li><b>Every Day</b></li> <P class="live-product-item">If you pay everyday,<br>Then Item Price is <b>$5/Day.</b></P> <li><b>every seven-day</b></li> <P class="live-product-item">If you pay every seven-day,<br>Then Item Price is <b>$30/Week.</b></P> <li><b>30 days</b></li> <P class="live-product-item">If you pay 30 days,<br>Then Item Price is <b>$120/Month.</b></P> <li><b>365 Days</b></li> <P class="live-product-item">If you pay 365 Days,<br>Then Item Price is <b>$1852/Year.</b></P> </ul> <br> <i> Note : Amount will take 1st day of every Month/Year/Week</i> </div> </div> <img id="paypal_logo" style="margin-top: -30;" src="images/secure-paypal-logo.jpg"> </div> <script src="js/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#choose_plan_name').on('change', function() { if (this.value === 'every-day') { $('input#subscribe').val('Subscrive ($5/Day)'); } else if (this.value === 'seven-day') { $('input#subscribe').val('Subscrive ($30/Week)'); } else if (this.value === 'thirty-day') { $('input#subscribe').val('Subscrive ($120/Month)'); } else if (this.value === 'full-year') { $('input#subscribe').val('Subscrive ($1852/Year)'); } }); }); </script> </body> </html> |
Process.php
このファイルには、PayPalへのサブスクリプション金額を処理するためのコードが含まれています。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
<?php if (isset($_POST['submit'])) { $range_data = $_POST['select_cycles']; $product_name = 'Brand Products'; $product_currency = 'USD'; if ($_POST['choose_plan_name'] == 'every-day') { $charge_price = 5; $cycle = 'D'; } else if ($_POST['choose_plan_name'] == 'seven-day') { $charge_price = 29; $cycle = 'W'; } else if ($_POST['choose_plan_name'] == 'thirty-day') { $charge_price = 999; $cycle = 'M'; } else if ($_POST['choose_plan_name'] == 'full-year') { $charge_price = 1852; $cycle = 'Y'; } $paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; $merchant_email = 'merchants email id'; $cancel_return = "https://www.pakainfo.com/tutorial/paypal-subscription/index.php"; $success_return = "https://www.pakainfo.com/tutorial/paypal-subscription/success.php"; ?> <div style="margin-left: 38%"><img src="images/ajax-loader.gif"/><img src="images/loading.gif"/></div> <form name = "myform" action = "<?php echo $paypal_url; ?>" method = "post" target = "_top"> <input type="hidden" name="cmd" value="_xclick-subscriptions"> <input type = "hidden" name = "business" value = "<?php echo $merchant_email; ?>"> <input type="hidden" name="lc" value="IN"> <input type = "hidden" name = "item_name" value = "<?php echo $product_name; ?>"> <input type="hidden" name="no_note" value="1"> <input type="hidden" name="src" value="1"> <?php if (!empty($range_data)) { ?> <input type="hidden" name="srt" value="<?php echo $range_data; ?>"> <?php } ?> <input type="hidden" name="a3" value="<?php echo $charge_price; ?>"> <input type="hidden" name="p3" value="1"> <input type="hidden" name="t3" value="<?php echo $cycle; ?>"> <input type="hidden" name="currency_code" value="<?php echo $product_currency; ?>"> <input type = "hidden" name = "cancel_return" value = "<?php echo $cancel_return ?>"> <input type = "hidden" name = "return" value = "<?php echo $success_return; ?>"> <input type="hidden" name="bn" value="PP-SubscriptionsBF:btn_subscribeCC_LG.gif:NonHostedGuest"> </form> <script type="text/javascript"> document.myform.submit(); </script> <?php } ?> |
Success.php
ペイパルサブスクリプション:PayPalはこれを呼び出します Success.php ペイパルの自動サブスクリプション支払いが正常に行われたときにファイルし、すべてのトランザクション情報を含む$ _REQUEST配列を提供し、フロントエンドのdsiplayに表示します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
<html> <head> <title>PayPal Subscription Button for Recurring Payments</title> <link rel="stylesheet" type="text/css" href="css/main.css"> </head> <body> <?php if (!empty($_REQUEST)) { $product_no = $_REQUEST['item_number']; // Product ID $product_transaction = $_REQUEST['tx']; // transaction ID $product_price = $_REQUEST['amt']; // received amount value $product_currency = $_REQUEST['cc']; // received currency type $product_status = $_REQUEST['st']; // product status } ?> <div id="main"> <h2 style="margin-left: -6%;">PayPal Subscription Button for Recurring Payments</h2> <div id="main-card"> <h2>Products paper Subscription</h2> <hr/> <?php //confirm the product price and currency details if ($_REQUEST['st'] == 'Completed') { echo "<h3 id='success'>Payment SuccessFul</h3>"; echo "<P>Transaction Status - " . $product_status . "</P>"; echo "<P>Transaction Id - " . $product_transaction . "</P>"; echo "<div class='back_btn'><a href='index.php' id= 'btn'><< Back</a></div>"; } else { echo "<h3 id='fail'>Payment Failed</h3>"; echo "<P>Transaction Status - Unompleted</P>"; echo "<P>Transaction Id - " . $product_transaction . "</P>"; echo "<div class='back_btn'><a href='index.php' id= 'btn'><< Back</a></div>"; } ?> </div> <div id="pakainfo"> <a href=https://www.pakainfo.com/app><img src="images/pakainfo.jpg" alt="Online Form Builder"/></a> </div> </div> </body> </html> |
main.css
HTML要素の必要なすべての単純なスタイルが含まれています。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
@import url(http://fonts.googleapis.com/css?family=Raleway); #main{ width:960px; margin:50px auto; font-family:raleway; } h2{ background-color: #FEFFED; text-align:center; border-radius: 10px 10px 0 0; margin: -10px -40px; padding: 16px; } hr{ border:0; border-bottom:1px solid #ccc; margin: 10px -40px; margin-bottom: 30px; } #paypal_subscriptions{ width: 88%; float: left; border-radius: 10px; font-family:raleway; border: 2px solid #ccc; padding: 10px 40px 26px; margin: 0 40px 40px 0; } select{ width:99.5%; padding: 10px; margin-top: 8px; border: 1px solid #ccc; padding-left: 6px; font-size: 16px; font-family:raleway; } input[type=submit]{ width: 100%; background-color:#FFBC00; color: white; border: 2px solid #FFCB00; padding: 10px; font-size:20px; cursor:pointer; border-radius: 6px; margin: 16px 0px; } input[type=submit]:hover{ transform: scale(1.05); } #profile{ padding:50px; border:1px dashed grey; font-size:20px; background-color:#DCE6F7; } #logout{ float:right; padding:6px; border:dashed 1px gray; } a{ text-decoration:none; color: cornflowerblue; } i{ color: rgb(155, 155, 155); } #pakainfo{ float:right; } #product_paypal_subscriptions{ width: 331px; height: 558px; float: left; margin: 9px 24px; padding: 20px; box-shadow: 0px 6px 17px 1px #99A3AD, 0px 0px 40px #EEEEEE; } hr.type_1 { border: 0; height: 56px; background-image: url(../images/type_1.png); background-repeat: no-repeat; margin: 10px 67px; } #product_img{ margin: 2px 61px; width: 200px; } img#paypal_logo { float: right; margin-right: 27px; margin-top: 1%; padding-bottom: 16px; } .fgrow{ margin-bottom: 16px; } #main-card { width: 492px; height: 350px; float: left; border-radius: 10px; font-family: raleway; border: 2px solid #ccc; padding: 10px 40px 11px; margin: 16PX; } #main-card h3#success { text-align: center; font-size: 24px; margin-top: 50px; color: green; } #main-card P { margin-left: 122px; } #main-card .back_btn { margin-top: 51px; text-align: center; } #btn { width: 100%; background-color: #FFBC00; color: white; border: 2px solid #FFCB00; padding: 10px 70px; font-size: 20px; cursor: pointer; border-radius: 6px; margin-bottom: 16px; } a{ text-decoration:none; color: cornflowerblue; } #pakainfo{ float: right; } #main-card h3#fail{ text-align: center; font-size: 24px; margin-top: 50px; color: red; } .live-product-item{ margin-top: 6px; margin-bottom: 16px; line-height: 26px; } |
私はあなたがについてのアイデアを得ることを願っています ペイパルサブスクリプション。
フィードバックをお願いします infinityknow.com。
この記事に関する貴重なフィードバック、質問、コメントはいつでも歓迎します。
この投稿を楽しんで気に入った場合は、共有することを忘れないでください。
参考資料 : www.pakainfo.com