Stripe API implementation error/exception handling

Stripe error handling

Stripe error handling

Stripe API libraries raise exceptions for many reasons, such as a failed charge, invalid parameters, authentication errors, and network unavailability. The Stripe recommends for writing code that gracefully handles all possible API exceptions.

Below Error Handling code is compatible with latest stripe API version

 

For old stripe versions i.e Stripe API v1.18.0 use below Error Handling code

For more details please check .

 

What is different between abstract class and interface in PHP?

1) – For abstract class a method must be declared as abstract. Abstract methods doesn’t have any implementation.
– For interface all the methods by default are abstract methods only. So one cannot declare variables or concrete methods in interfaces.

2) – The Abstract methods can declare with Access modifiers like public, internal, protected. When implementing in subclass these methods must be defined with the same (or a less restricted) visibility.
– All methods declared in an interface must be public.

3) – Abstract class can contain variables and concrete methods.
– Interfaces cannot contain variables and concrete methods except constants.

4) – A class can Inherit only one Abstract class and Multiple inheritance is not possible for Abstract class.
– A class can implement many interfaces and Multiple interface inheritance is possible.

5) – Abstract class can contains constructor
– Interfaces cannot contain constructor

6) – Only complete member of abstact class can be static
– Member of interface can not be static

How to Copy directory/files from windows command line/prompt

COPY – It will allow you to quickly copy files from one location to another location.

Syntex > copy source_file_name destination_file_name

XCOPY – The xcopy command allows you to copy files and directories from one location to another location. This makes it much more suitable for copying folders. xcopy also has many modifiers which gives advanced users more control over the copying process.

Syntex > xcopy /E /I source_dir_name destination_die_name

Reference of /E and /I
/E – This option makes sure that empty subfolders are copied to the destination.
/I – Avoids prompting if the destination is a folder or file.

How can I offer a gzipped csv file for download using PHP?

Question:

I have a PHP script that creates  csv file from the db. I would like to have the script to create the csv data and immediately make a .gzip file available for download. Can you please give me some ideas?

Answer:

You can easily apply gzip compression with the gzencode function.

 

Stripe Payment gateway integration in PHP with DEMO Examples

Stripe payment gateway integration

Stripe payment gateway integration

Stripe payment gateway offers 2 ways of integration in PHP –

  • Stripe checkout integration
  • Stripe custom integration (Stripe.js)

Strip checkout integration:

The easiest way to integrate Stripe is via Checkout, an embedded tool that takes care of building an HTML form, validating user input, and securing your customers’ card data. Using Checkout, sensitive credit card information is sent directly to Stripe, and does not touch your server. Stripe returns to your site a token representation of the card, and this token can then be used in a charge request.

Embedding Checkout in your site

To get started, add the following code to your payment page:

Stripe Checkout Demo

Reference link : https://stripe.com/docs/checkout/tutorial

Stripe custom integration (Stripe.js):

For a more custom approach, you can instead use Stripe with your own payment form via Stripe.js.

Processing payments with Custom Stripe integration has two components:

Below code example show you demonstrate you the custom stripe integration with stripe.js.

Demo Link

You can download all above demos from below link :
Download Source Code

Or

Browse source code in github : https://github.com/sagarsdeshmukh/Stripe_gateway_integration_demo_with_PHP

If you have any additional questions Or queries, don’t hesitate to let me know!, Just put comment below or contact @ my mail id sagarsdeshmukh@gmail.com

Hope you enjoy my post :)

Bootstrap – Accordion Inside Accordion Example

Bootstrap-Accordion-Inside-Accordion_nested-Accordion_demo

Bootstrap-Accordion-Inside-Accordion_nested-Accordion_demo

Demo

Braintree Hosted Fields integration with Custom Stylesheet(css) and validation

Braintree-Hosted-Fields-custom-css-validation-Demo

Braintree hosted field integration offer great flexibility in customization of payment form design with custom style sheet (css) and validation error handling. You can change complete look and feel of your payment form as per site theme with hosted fields solution and it being so easy to do.

We will have example of custom design of payment form below in that we added auto payment method detection logic with braintree on the basis of card number as well as added error handing style on form fields.

With this script you can handle/ Manage full form validation with braintree internal card validation too.

Custom design mock-up :

Braintree-Hosted-Fields-custom-css-validation-Demo

Validation error handling :

Braintree-Hosted-Fields-Demo-custom-validation-style

You can edit the all style content in below script as per your requirement-

 

hosted_field_style.css

 

hosted_field_style.js

 

You can download full script from here.

For any queries regarding above script put comments below or reach me vie mail  – sagarsdeshmukh91@gmail.com

Braintree (PayPal) Payment gateway integration with 3D secure option in PHP

ilovephp.net

ilovephp.net

By using 3D secure, we provide an additional layer of verification to cardholders and merchants. In checkout process, braintree verify the card details to check does the card has enabled for 3D secure verification OR not. If the card is enabled for authenticate using 3D Secure, the Braintree SDK will display a web page which is provided by the card issuer. The 3D secure authentication page will verify the cardholder’s identity, which is usually done by entering a password.

Note : Before proceed with Braintree 3D secure integration, the braintree Sandbox Account is need to enabled for 3D secure. To enroll in 3D Secure, please contact the Braintree support team at support@braintreepayments.com

If want to make 3D secure transaction with specific payment method just checkout below script.

 

Braintree Payment Gateway integration with 3D secure in Drop in-UI Example (Demo) :

 

Braintree – Payment Gateway integration with 3D secure (Hosted Fields) example

You can download all above demos from below link :
Download Source Code

Or

Browse source code in github : https://github.com/sagarsdeshmukh/Braintree_gateway_integration_demo_with_PHP

If you have any additional questions Or queries, don’t hesitate to let me know!, Just put comment below or contact @ my mail id sagarsdeshmukh@gmail.com

Happy coding!

Ref. Link : https://developers.braintreepayments.com/guides/3d-secure/overview
Test card details : https://developers.braintreepayments.com/guides/3d-secure/testing-go-live/php

Simple RESTful API webservice demo in PHP

API URL :  http://domain_name/api.php

Input param :

API Call Request :

Successfull Output :

Error Output :

API Script (api.php) :