Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //1.client method to retrieve payment ID
- const makePayment = this.cfns.httpsCallable('payPalPay');
- const paymentIdResult = makePayment({price: 9});
- paymentIdResult.subscribe(val => {
- //val is empty regardless of what I do on the server-side
- return val.paymentId;
- });
- //2. server endpoint being called
- exports.payPalPay = functions.https.onCall((data, context) => {
- return pay(data, context)
- });
- //3. actual server-side logic
- export function pay(data, context): Observable<string> {
- var subject = new Subject();
- const payReq = ...
- paypal.payment.create(payReq, (error, payment) => {
- if (payment.state === 'created') {
- subject.next({paymentId: payment.id});
- subject.complete();
- }
- });
- return subject;
- // tried returning string instead of Observable<string>. No luck
- // subject.subscribe(val =>{
- // return val;
- // });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement