Skip to content

Commit

Permalink
charge-updating quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
craig committed Jan 9, 2013
1 parent 258993f commit 01b4bbf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions lib/Twocheckout.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ abstract class Twocheckout
public static $format = "json";
public static $apiBaseUrl = "https://www.2checkout.com/api/";
public static $error;
const VERSION = '0.1.0';
const VERSION = '0.1.1';

static function setCredentials($user, $pass)
{
Expand All @@ -28,4 +28,4 @@ static function setCredentials($user, $pass)
require(dirname(__FILE__) . '/Twocheckout/TwocheckoutReturn.php');
require(dirname(__FILE__) . '/Twocheckout/TwocheckoutNotification.php');
require(dirname(__FILE__) . '/Twocheckout/TwocheckoutCharge.php');
require(dirname(__FILE__) . '/Twocheckout/TwocheckoutMessage.php');
require(dirname(__FILE__) . '/Twocheckout/TwocheckoutMessage.php');
22 changes: 11 additions & 11 deletions lib/Twocheckout/TwocheckoutCharge.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@
class Twocheckout_Charge extends Twocheckout
{

public static function form($params, $type="Checkout")
public static function form($params, $type='Checkout')
{
echo "<form id=\"2checkout\" action=\"https://www.2checkout.com/checkout/spurchase\" method=\"post\">\n";
echo '<form id="2checkout" action="https://www.2checkout.com/checkout/purchase" method="post">';

foreach ($params as $key => $value)
{
echo "<input type=\"hidden\" name=\"$key\" value=\"$value\"/>\n";
echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>';
}
if ($type == "auto") {
echo "<input type=\"submit\" value=\"Click here if you are not redirected automatically\" /></form>\n";
echo "<script type=\"text/javascript\">document.getElementById('2checkout').submit();</script>";
if ($type == 'auto') {
echo '<input type="submit" value="Click here if you are not redirected automatically" /></form>';
echo '<script type="text/javascript">document.getElementById("2checkout").submit();</script>';
} else {
echo "<input type=\"submit\" value=\"$type\" />\n";
echo "</form>";
echo '<input type="submit" value="'.$type.'" />';
echo '</form>';
}
}

public static function link($params)
{
$url = "https://www.2checkout.com/checkout/spurchase?".http_build_query($params, '', '&amp;');
$url = 'https://www.2checkout.com/checkout/purchase?'.http_build_query($params, '', '&amp;');
return $url;
}

public static function redirect($params)
{
$url = "https://www.2checkout.com/checkout/spurchase?".http_build_query($params, '', '&amp;');
$url = 'https://www.2checkout.com/checkout/purchase?'.http_build_query($params, '', '&amp;');
header("Location: $url");
}

}
}
8 changes: 4 additions & 4 deletions test/ChargeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function testChargeForm()
'li_0_name' => 'Test Product',
'li_0_price' => '0.01'
);
$test = '<form id="2checkout" action="https://www.2checkout.com/checkout/spurchase" method="post">' +
$test = '<form id="2checkout" action="https://www.2checkout.com/checkout/purchase" method="post">' +
'<input type="hidden" name="sid" value="1817037"/>' +
'<input type="hidden" name="mode" value="2CO"/>' +
'<input type="hidden" name="li_0_name" value="Test Product"/>' +
Expand All @@ -32,7 +32,7 @@ public function testChargeFormAuto()
'li_0_name' => 'Test Product',
'li_0_price' => '0.01'
);
$test = '<form id="2checkout" action="https://www.2checkout.com/checkout/spurchase" method="post">' +
$test = '<form id="2checkout" action="https://www.2checkout.com/checkout/purchase" method="post">' +
'<input type="hidden" name="sid" value="1817037"/>' +
'<input type="hidden" name="mode" value="2CO"/>' +
'<input type="hidden" name="li_0_name" value="Test Product"/>' +
Expand All @@ -51,9 +51,9 @@ public function testChargeLink()
'li_0_name' => 'Test Product',
'li_0_price' => '0.01'
);
$test = 'https://www.2checkout.com/checkout/spurchase?sid=1817037&amp;mode=2CO&amp;li_0_name=Test+Product&amp;li_0_price=0.01';
$test = 'https://www.2checkout.com/checkout/purchase?sid=1817037&amp;mode=2CO&amp;li_0_name=Test+Product&amp;li_0_price=0.01';
$result = Twocheckout_Charge::link($params);
$this->assertEquals($test, $result);
}

}
}

0 comments on commit 01b4bbf

Please sign in to comment.