Posts

Showing posts with the label Stripe Payments

Catching Stripe Errors With Try/Catch PHP Method

Answer : If you're using the Stripe PHP libraries and they have been namespaced (such as when they're installed via Composer) you can catch all Stripe exceptions with: <?php try { // Use a Stripe PHP library method that may throw an exception.... \Stripe\Customer::create($args); } catch (\Stripe\Error\Base $e) { // Code to do something with the $e exception object when an error occurs echo($e->getMessage()); } catch (Exception $e) { // Catch any other non-Stripe exceptions } I think there is more than these exceptions ( Stripe_InvalidRequestError and Stripe_Error ) to catch. The code below is from Stripe's web site. Probably, these additional exceptions, which you didn't consider, occurs and your code fails sometimes . try { // Use Stripe's bindings... } catch(Stripe_CardError $e) { // Since it's a decline, Stripe_CardError will be caught $body = $e->getJsonBody(); $err = $body['error']; print('Status is:...

Angular 7 & Stripe Error TS2304: Cannot Find Name 'Stripe'

Answer : The issue is resolved by including a reference to the @types/stripe-v3 package in the compilerOptions.types array of your tsconfig.app.json file in the src directory of your Angular project. { "extends": "../tsconfig.json", "compilerOptions": { "outDir": "../out-tsc/app", "types": [ "stripe-v3" ] }, "exclude": [ "test.ts", "**/*.spec.ts" ] } This solution was posted by bjornharvold in this thread. Angular imports types based on values of compilerOptions.types and compilerOptions.typeRoots from the typescript configuration file. TS compilerOptions docs reference By default Angular projects created using angular cli will have two typescript configuration files. tsconfig.json in the root of the project tsconfig.app.json in /src directory If both types and typeRoots are undefined angular will import all the typings from...