class_gw_paypal.php
来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 580 行 · 第 1/2 页
PHP
580 行
<?php/*+--------------------------------------------------------------------------| Invision Power Board v2.1.5| ========================================| by Matthew Mecham| (c) 2001 - 2005 Invision Power Services| | ========================================| Web: | Time: Wed, 01 Mar 2006 19:11:28 GMT| Release: | Email: +---------------------------------------------------------------------------|| > Payment Gateway API: PAYPAL| > Module written by Matt Mecham| > Date started: 31st March 2005 (14:45)||+--------------------------------------------------------------------------*/ if ( ! defined( 'GW_CORE_INIT' ) ){ print "You cannot access this module in this manner"; exit();}//--------------------------------------------------------------------------// DEFINITIONS EXPECTED AT THIS POINT//--------------------------------------------------------------------------// GW_URL_VALIDATE : The url for validating payment// GW_URL_PAYDONE : The url that the gatways returns the viewer to after// : payment processed successfully// GW_URL_PAYCANCEL: The url that the gatways returns the viewer to after// : payment processed unsuccessfully or when cancelled//--------------------------------------------------------------------------// ITEM ARRAY//--------------------------------------------------------------------------// 'currency_code' => Currency code,// 'member_unique_id' => member's ID,// 'member_name' => member's NAME,// 'member_email' => member's EMAIL,// 'package_cost' => Requested package cost// 'package_id' => Requested package ID// 'package_title' => Requested package title// 'duration_int' => Requested package duration int (ie: 12)// 'duration_unit' => Requested package duration unit (ie: m,d,y,w) [ month, day, year, week ]// 'company_email' => Company's email address// 'ttr_int' => Time to run (Time left on current package) integar (ie 3)// 'ttr_unit' => Time to run (Time left on current package) unit (ie w)// 'ttr_balance' => Time to run (Balance left on current package)// 'ttr_package_id' => Current package id (used for upgrading)// 'vendor_id' => The ID of the vendor (not used in all gateways)// 'product_id' => The gateway ID of the product (not used in all gateways)// 'extra_1' thru 5 => Gateway extras ( from DB / tied in method_vars )//--------------------------------------------------------------------------class class_gw_module EXTENDS class_gateway{ # Global var $ipsclass; # Identify var $i_am = 'PayPal'; var $can_do_recurring_billing = 1; var $can_do_upgrades = 1; /*-------------------------------------------------------------------------*/ // INIT /*-------------------------------------------------------------------------*/ function main_init() { } /*-------------------------------------------------------------------------*/ // Generate hidden fields [ Recurring, normal screen ] /*-------------------------------------------------------------------------*/ function gw_generate_hidden_fields_normal_recurring( $items=array() ) { $this->core_add_hidden_field( "cmd" , "_xclick-subscriptions" ); $this->core_add_hidden_field( "currency_code", $items['currency_code'] ); $this->core_add_hidden_field( "custom" , $items['member_unique_id'] ); $this->core_add_hidden_field( "item_number" , $items['package_id'] ); $this->core_add_hidden_field( "t3" , strtoupper($items['duration_unit'] )); $this->core_add_hidden_field( "p3" , $items['duration_int'] ); $this->core_add_hidden_field( "a3" , $items['package_cost'] ); $this->core_add_hidden_field( "business" , $items['company_email'] ); $this->core_add_hidden_field( "item_name" , $items['package_title'] ); $this->core_add_hidden_field( "no_shipping" , 1 ); $this->core_add_hidden_field( "src" , 1 ); $this->core_add_hidden_field( "rm" , 2 ); $this->core_add_hidden_field( "no_note" , 1 ); $this->core_add_hidden_field( "notify_url" , GW_URL_VALIDATE ); $this->core_add_hidden_field( "return" , GW_URL_PAYDONE ); $this->core_add_hidden_field( "cancel_return", GW_URL_PAYCANCEL ); return $this->core_compile_hidden_fields(); } /*-------------------------------------------------------------------------*/ // Generate hidden fields [ Recurring, upgrade screen ] /*-------------------------------------------------------------------------*/ function gw_generate_hidden_fields_upgrade_recurring( $items=array() ) { $this->core_add_hidden_field( "cmd" , "_xclick-subscriptions" ); $this->core_add_hidden_field( "currency_code", $items['currency_code'] ); $this->core_add_hidden_field( "custom" , $items['member_unique_id'] ); $this->core_add_hidden_field( "item_number" , $items['package_id'] ); $this->core_add_hidden_field( "t3" , strtoupper($items['duration_unit']) ); $this->core_add_hidden_field( "p3" , $items['duration_int'] ); $this->core_add_hidden_field( "a3" , $items['package_cost'] ); $this->core_add_hidden_field( "a1" , $items['ttr_balance'] ); $this->core_add_hidden_field( "p1" , $items['ttr_int'] ); $this->core_add_hidden_field( "t1" , strtoupper($items['ttr_unit'] )); $this->core_add_hidden_field( "memo" , "upgrade" ); $this->core_add_hidden_field( "invoice" , $items['ttr_package_id'].'x'.$items['package_id'].'x'.$items['member_unique_id'] ); $this->core_add_hidden_field( "business" , $items['company_email'] ); $this->core_add_hidden_field( "item_name" , $items['package_title'] ); $this->core_add_hidden_field( "no_shipping" , 1 ); $this->core_add_hidden_field( "src" , 1 ); $this->core_add_hidden_field( "no_note" , 1 ); $this->core_add_hidden_field( "rm" , 2 ); $this->core_add_hidden_field( "notify_url" , GW_URL_VALIDATE ); $this->core_add_hidden_field( "return" , GW_URL_PAYDONE ); $this->core_add_hidden_field( "cancel_return", GW_URL_PAYCANCEL ); return $this->core_compile_hidden_fields(); } /*-------------------------------------------------------------------------*/ // Generate hidden fields [ normal screen ] /*-------------------------------------------------------------------------*/ function gw_generate_hidden_fields_normal( $items=array() ) { $this->core_add_hidden_field( "cmd" , "_xclick" ); $this->core_add_hidden_field( "currency_code", $items['currency_code'] ); $this->core_add_hidden_field( "custom" , $items['member_unique_id'] ); $this->core_add_hidden_field( "item_number" , $items['package_id'] ); $this->core_add_hidden_field( "item_name" , $items['package_title'] ); $this->core_add_hidden_field( "amount" , $items['package_cost'] ); $this->core_add_hidden_field( "business" , $items['company_email'] ); $this->core_add_hidden_field( "no_shipping" , 1 ); $this->core_add_hidden_field( "src" , 1 ); $this->core_add_hidden_field( "notify_url" , GW_URL_VALIDATE ); $this->core_add_hidden_field( "return" , GW_URL_PAYDONE ); $this->core_add_hidden_field( "cancel_return", GW_URL_PAYCANCEL ); return $this->core_compile_hidden_fields(); } /*-------------------------------------------------------------------------*/ // Generate hidden fields [ upgrade screen ] /*-------------------------------------------------------------------------*/ function gw_generate_hidden_fields_upgrade( $items=array() ) { $this->core_add_hidden_field( "cmd" , "_xclick" ); $this->core_add_hidden_field( "currency_code", $items['currency_code'] ); $this->core_add_hidden_field( "custom" , $items['member_unique_id'] ); $this->core_add_hidden_field( "item_number" , $items['package_id'] ); $this->core_add_hidden_field( "business" , $items['company_email'] ); $this->core_add_hidden_field( "item_name" , $items['package_title'] ); $this->core_add_hidden_field( "invoice" , $items['ttr_package_id'].'x'.$items['package_id'].'x'.$items['member_unique_id'] ); $this->core_add_hidden_field( "amount" , $items['ttr_balance'] ); $this->core_add_hidden_field( "no_shipping" , 1 ); $this->core_add_hidden_field( "src" , 1 ); $this->core_add_hidden_field( "notify_url" , GW_URL_VALIDATE ); $this->core_add_hidden_field( "return" , GW_URL_PAYDONE ); $this->core_add_hidden_field( "cancel_return", GW_URL_PAYCANCEL ); return $this->core_compile_hidden_fields(); } /*-------------------------------------------------------------------------*/ // Generate Purchase button /*-------------------------------------------------------------------------*/ function gw_generate_purchase_button() { return '<input type="image" src="https://www.paypal.com/images/x-click-but6.gif" name="submit" alt="'.$this->ipsclass->lang['paywith_paypal'].'" />'; } /*-------------------------------------------------------------------------*/ // Generate Form action [normal] /*-------------------------------------------------------------------------*/ function gw_generate_normal_form_action() { return "https://www.paypal.com/cgi-bin/webscr"; } /*-------------------------------------------------------------------------*/ // Generate Form action [upgrade] /*-------------------------------------------------------------------------*/ function gw_generate_upgrade_form_action() { return $this->gw_generate_normal_form_action(); } /*-------------------------------------------------------------------------*/ // Generate Form action [normal, recurring] /*-------------------------------------------------------------------------*/ function gw_generate_normal_recurring_form_action() { return $this->gw_generate_normal_form_action(); } /*-------------------------------------------------------------------------*/ // Generate Form action [upgrade, recurring] /*-------------------------------------------------------------------------*/ function gw_generate_upgrade_recurring_form_action() { return $this->gw_generate_normal_form_action(); } /*-------------------------------------------------------------------------*/ // Validate Payment // What we need to return: // 'currency_code' => Currency code, // 'payment_amount' => Amount paid, // 'payment_status' => REFUND, ONEOFF, RECURRING // 'member_unique_id' => member's ID, // 'purchase_package_id'=> Purchased package ID // 'current_package_id' => Current package ID (used for upgrading) // 'verified' => TRUE , FALSE (Gateway verifies info as correct) // 'subscription_id' => (Used for recurring payments) // 'transaction_id' => Gateway transaction ID /*-------------------------------------------------------------------------*/ function gw_validate_payment() { //-------------------------------------- // INIT //-------------------------------------- //-------------------------------------- // Debug... //-------------------------------------- if ( GW_TEST_MODE_ON ) { if ( ! is_array( $_POST ) or ! count( $_POST ) ) { $_POST = $_GET; } } $post_back[] = 'cmd=_notify-validate'; foreach ($_POST as $key => $val) { $post_back[] = $key . '=' . urlencode ($val); } $post_back_str = implode('&', $post_back); //-------------------------------------- // URLS //-------------------------------------- $urls = array( 'curl_full' => 'http://www.paypal.com/cgi-bin/webscr', 'sock_url' => 'www.paypal.com', 'sock_path' => '/cgi-bin/webscr' ); //-------------------------------------- // Throw back to PayPal to verify //-------------------------------------- $state = $this->core_post_back( $urls, $post_back_str, 80 ); //-------------------------------------- // Check... //-------------------------------------- $state = ( stristr($state, 'VERIFIED') ) ? 'VERIFIED' : 'INVALID'; if ( $state != 'VERIFIED' ) {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?