首页 > 解决方案 > 离子贝宝ID交易

问题描述

早上好,我正在研究很多,但我仍然没有得到我想要的,我对这一切都很陌生。我想知道通过 PayPal 付款时如何获取交易 ID。我在https://ionicframework.com/docs/native/paypal/上没有找到任何东西, 有人可以帮我解决付款后如何获取交易 ID 吗?我的想法是在付款后根据交易数据生成一个二维码。先感谢您!

这是我的代码:

this.payPal.init({
  PayPalEnvironmentProduction: ''
  PayPalEnvironmentSandbox: 'mySandbox',
}).then(() => {
  this.payPal.prepareToRender('PayPalEnvironmentSandbox', new PayPalConfiguration({
    acceptCreditCards: false,
    languageOrLocale: 'pt-BR',
    merchantName: (this.produto.nom_produto),
    merchantPrivacyPolicyURL: '',
    merchantUserAgreementURL: ''
  })).then(() => {
    let detail = new PayPalPaymentDetails('1.00', '0.00', '0.00');
    let payment = new PayPalPayment('1.00', 'BRL', 'Produto', 'Sale', detail);
    this.payPal.renderSinglePaymentUI(payment).then((response) => {
      console.log('pagamento efetuado');
      this.createCode();
      let toast = this.toastCtrl.create({ duration: 3000, position: 'bottom' });
      toast.setMessage('Pagamento efetuado com sucesso');
      toast.present();
    }, () => {
      console.log('erro ao renderizar o pagamento do paypal');
    })
  })
})

}

标签: cordovaionic-frameworkpaypal

解决方案


支付成功。您可以在下面找到交易的 id

this.payPal.init({
      PayPalEnvironmentProduction: ''
      PayPalEnvironmentSandbox: 'mySandbox',
    }).then(() => {
      this.payPal.prepareToRender('PayPalEnvironmentSandbox', new PayPalConfiguration({
        acceptCreditCards: false,
        languageOrLocale: 'pt-BR',
        merchantName: (this.produto.nom_produto),
        merchantPrivacyPolicyURL: '',
        merchantUserAgreementURL: ''
      })).then(() => {
        let detail = new PayPalPaymentDetails('1.00', '0.00', '0.00');
        let payment = new PayPalPayment('1.00', 'BRL', 'Produto', 'Sale', detail);
        this.payPal.renderSinglePaymentUI(payment).then((response) => {
          console.log('pagamento efetuado');
          let transactionId = response.response.id;
          console.log('Your transaction id is ', transactionId);
          this.createCode();
          let toast = this.toastCtrl.create({ duration: 3000, position: 'bottom' });
          toast.setMessage('Pagamento efetuado com sucesso');
          toast.present();
        }, () => {
          console.log('erro ao renderizar o pagamento do paypal');
        });
      });
    });

推荐阅读