Jump to content

nodirtyrockstar

Members
  • Posts

    108
  • Joined

  • Last visited

nodirtyrockstar's Achievements

Member

Member (2/5)

1

Reputation

  1. Just in case you still need further clarification, Ch0cu3r is right that you don't need both. You can write HTML to the screen with PHP, most commonly like so: echo "<h1>HTML</h1>";
  2. It looks like your link is wrong. You said your directory for the second file is here: /htdocs/tables/php/projects.php, but you're including a file at php/projects.php. You need to send it to the tables directory first, then into the php directory, and finally to your document. Oh, my bad...I looked more closely at it. I think your link is right. Sorry.
  3. I think you are making a lot of assumptions about what classes I have and what they are doing. My input class only does one thing. It handles input. The way I handle the user's order is not something I really went into on here, but suffice it to say, it is separate from the Input class.
  4. I agree with previous commenters that it would help to know what your link does when you click on it. PLEASE don't use JavaScript. That is a hack. Try putting the type="submit" attribute on the input. The name attribute gives the element a name, and the value is the actual data you are passing. You should consider reading the API. MDN is better than w3schools.com. They're notoriously wrong. Here ya go: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input If this works, please don't forget to mark my answer as the solution. (please)
  5. The image should not affect your ability to submit. It is just a cosmetic feature. Looking into it now. Found a red herring and edited this post.
  6. Alright, thanks for reading. I am going with putting it into the Input class.
  7. Requested quantity can't be the key in an array, because it isn't necessarily unique.
  8. I'm writing some classes right now for a website with a shopping cart. There are all kinds of classes, Blog, Cart, Product, Database, etc. I am trying to make a design choice about where to store the requested quantity for a particular product. I feel like it should NOT go into the Product class, because the requested quantity does not semantically relate to any of the standard product detail. I was considering maybe setting the quantity property of the product instance, to the requested quantity, once it is put into the cart. For some reason my instinct says no, that it should be abstracted out, perhaps into the Cart class. If that is the case, how do you couple the requested quantity with the requested object? As array key/value pair? Is there another class it could go into? Does anyone have practical experience to shed some light on this?
  9. Okay, I found that using the var keyword automatically declares it as public. Does that mean it is still possible to modify privacy with private or protected here?
  10. Is it considered incorrect practice to declare privacy modifiers on variable/properties of subclasses? for example: class SubClass { var $property = 'notice there is no private, public, or protected keyword here'; }
  11. Basically what I can see is that I am failing to create the apiContext object. Can anyone see where the error is? Please tell me how I can improve the question. Here is the error: Fatal error: Uncaught exception 'PayPal\Exception\PPConnectionException' with message 'Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment.' in /vendor/paypal/sdk-core-php/lib/PayPal/Core/PPHttpConnection.php:104 Stack trace: #0 /vendor/paypal/sdk-core-php/lib/PayPal/Transport/PPRestCall.php(44): PayPal\Core\PPHttpConnection->execute('{"intent":"sale...') #1 /vendor/paypal/rest-api-sdk-php/lib/PayPal/Api/Payment.php(246): PayPal\Transport\PPRestCall->execute(Array, '/v1/payments/pa...', 'POST', '{"intent":"sale...') #2 /pymt.php(38): PayPal\Api\Payment->create(Object(PayPal\Rest\ApiContext)) #3 {main} thrown in /vendor/paypal/sdk-core-php/lib/PayPal/Core/PPHttpConnection.php on line 104 This is the PHP sample I'm using. I am trying to run it off my server. If a customer clicks the pay with paypal button, it runs the following sample script: <?php require __DIR__ . '/../bootstrap.php'; use PayPal\Api\Address; use PayPal\Api\Amount; use PayPal\Api\Payer; use PayPal\Api\Payment; use PayPal\Api\FundingInstrument; use PayPal\Api\RedirectUrls; use PayPal\Api\Transaction; session_start(); $payer = new Payer(); $payer->setPayment_method('paypal'); $amount = new Amount(); $amount->setCurrency('USD'); $amount->setTotal('1.00'); $transaction = new Transaction(); $transaction->setAmount($amount); $transaction->setDescription('This is the payment description.'); $baseUrl = getBaseUrl(); $redirectUrls = new RedirectUrls(); $redirectUrls->setReturn_url('baseUrl/sale.php'); $redirectUrls->setCancel_url('baseUrl/saleFail.php'); $payment = new Payment(); $payment->setIntent('sale'); $payment->setPayer($payer); $payment->setRedirect_urls($redirectUrls); $payment->setTransactions(array($transaction)); try { $payment->create($apiContext); } catch (\PPConnectionException $ex) { echo 'Exception: ' . $ex->getMessage() . PHP_EOL; var_dump($ex->getData()); exit(1); } foreach ($payment->getLinks() as $link) { if ($link->getRel() == 'approval_url') { $redirectUrl = $link->getHref(); } } $_SESSION['paymentId'] = $payment->getId(); if(isset($redirectUrl)) { header('Location: $redirectUrl'); exit; } ?> Here's the redacted bootstrap.php: <?php /* * Sample bootstrap file. */ // Include the composer autoloader if(!file_exists(__DIR__ .'/vendor/autoload.php')) { echo "The 'vendor' folder is missing. You must run 'composer update --no-dev' to resolve application dependencies.\nPlease see the README for more information.\n"; exit(1); } require __DIR__ . '/vendor/autoload.php'; require __DIR__ . '/common.php'; use PayPal\Rest\ApiContext; use PayPal\Auth\OAuthTokenCredential; $apiContext = getApiContext(); /** Helper method for getting an APIContext for all calls * * @return PayPal\Rest\ApiContext */ function getApiContext() { // ### Api context // Use an ApiContext object to authenticate // API calls. The clientId and clientSecret for the // OAuthTokenCredential class can be retrieved from // developer.paypal.com $apiContext = new ApiContext( new OAuthTokenCredential( 'MY CLIENT ID', 'MY SECRET' ) ); // Register the sdk_config.ini file in current directory // as the configuration source. if(!defined("PP_CONFIG_PATH")) { define("PP_CONFIG_PATH", __DIR__); } return $apiContext; } ?> Can anyone help? Let me know if you need more info. Thanks up front.
  12. I am sure you're right. I'll see if I can get this working. Can anyone answer this for me: what is the issue with fetch_all()?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.