2017-10-12 231 views
1

後我的角度4個project.I要打API調用支付寶付款,獲得成功之後,但actions.payment.execute().then不允許訪問任何外部對象的API調用。PayPal支付:讓我使用PayPal支付付款成功

我可以得到任何成功的事件嗎? PayPal上BUTTOM

document.querySelector('#paypal-button').dispatchEvent(new CustomEvent('onPaymentCompleted', { detail: {payment: JSON.stringify(payment)},bubbles: true })); 


onAuthorize: function (data, actions) { 

    return actions.payment.execute().then(function() { 
     //want to make an api call 
        }); 
       } 
     }, '#paypal-button-container'); 

回答

0

基於這裏的答案Processing Paypal onAuthorize callback in Angular 4,您可以發送自定義事件

<div id="paypal-button" (onPaymentCompleted)="addNewContract($event)"></div> 

,然後你又要原始上下文的訪問:

addNewContract(event) { 
    console.log(event.detail.payment); 
    }