Angular does not have any abstractions over PaymentRequest API . This library provides you two ways to use this API with Angular of 6+ version.
As an Angular service:
import {PaymentRequestService} from '@ng-web-apis/payment-request';
// ...
constructor(private readonly paymentRequest: PaymentRequestService) {}
pay(details: PaymentDetailsInit) {
this.paymentRequest.request(details).then(
response => {
response.complete();
},
error => {},
);
}
As a set of directives:
Click to add some items to a shopping cart:
50 ₽
100 ₽
70 ₽
70 ₽
10 ₽
1000 ₽
Shopping Cart
Nothing addedTotal: 0 ₽
How it works:
waPayment directive defines a scope for a new payment and needs PaymentItem object with information about a label and a total sum of the payment
Each item of the shipping cart is a waPaymentItem directive. It is a declarative PaymentItem for your Payment
Click on the button starts a PaymentRequest modal in your browser that returns PaymentResponse or an error. It works due a waPaymentSubmit directive.