Paypal
This library was generated with Angular CLI version 17.2.0.
Code scaffolding
Run ng generate component component-name --project paypal
to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module --project paypal
.
Note: Don't forget to add --project paypal
or else it will be added to the default project in your angular.json
file.
Build
Run ng build paypal
to build the project. The build artifacts will be stored in the dist/
directory.
PayPal Developer link
Integrating PaypalModule into AppModule
To use the PaypalModule
in your Angular application, follow these steps:
-
Import PaypalModule into AppModule:
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { PaypalModule } from '@angular_faruk/paypal';
import { IS_TESTING_MODE } from '@angular_faruk/paypal';
import { PaypalComponent } from '@angular_faruk/paypal';
@NgModule({
declarations: [
AppComponent
],
imports: [
PaypalModule
],
bootstrap: [AppComponent],
providers: [PaypalComponent,
{ provide: IS_TESTING_MODE, useValue: true }
]
})
export class AppModule {}
Configuration
-
Option 2: You can import in any componet.
Example:
import { IS_TESTING_MODE, PaypalComponent } from '@angular_faruk/paypal';
import{PaypalService}from '@angular_faruk/paypal'
import { Component, Inject } from '@angular/core';
@Component({
selector: 'app-demo',
templateUrl: './demo.component.html',
styleUrls: ['./demo.component.css']
})
export class LandingPageCoffeeComponent {
constructor( private PaypalComponent:PaypalComponent , private paypalService: PaypalService,@Inject(IS_TESTING_MODE) private isTestingMode: boolean ) {
}
}
example
get_Access_token(ClientID:string,Secret_id:string) {
this.PaypalComponent.Access_token(ClientID,Secret_id).then((response) => {
}).catch((error) => {
});
}
let OrderformData:any= {
name: string;
description: string;
quantity: number;
currency_code: string;
value: number;
return_url: string;
cancel_url: string;
}
const intent = 'CAPTURE';
let OrderformData:any= {
name: string;
description: string;
quantity: number;
currency_code: string;
value: number;
return_url: string;
cancel_url: string;
items: Array<{
name: string;
description: string;
quantity: number;
unit_amount: {
currency_code: string;
value: number;
};
}>;
}
const intent = 'CAPTURE';
this.PaypalComponent.create_order(OrderformData).then((response) => {
}).catch((error) => {
});
this.PaypalComponent.order_details(order_id).then((response) => {
}).catch((error) => {
});
this.PaypalComponent.capturePayment(order_id).then((response) => {
}).catch((error) => {
});
Example
Running unit tests
Run ng test paypal
to execute the unit tests via Karma.
Further help
To get more help on the Angular CLI use ng help
or go check out the Angular CLI Overview and Command Reference page.