2016-10-07 5 views
1

なぜIonic2アプリをPaypalと統合できないのか分かりません。Paypalとionic 2がうまく動作せず、JSONエラーが発生する

私はPayPal cordova mobile sdkにIonicネイティブラッパーを使用しています。

私はPaypal.initのための成功を得るが、私はイオン2 RC0を使用していますrenderSinglePaymentUI

import { Injectable } from '@angular/core'; 
//import { Paypal, PaypalPayments } from 'ionic-native'; 

import {PayPal, PayPalPayment, PayPalPaymentDetails, PayPalConfiguration, PayPalConfigurationOptions} from 'ionic-native'; 
//import {PayPal} from 'ionic-native'; 

@Injectable() 
export class Payments { 

paymentdata : PayPalPayment; 
paymentdetails: PayPalPaymentDetails; 
paypalConfig: PayPalConfiguration; 
paypalConfigOptions: PayPalConfigurationOptions; 

constructor() { 
this.initiatePaypal(); 
} 

initiatePaypal(){ 
    // this.paypalConfig = new PayPalConfiguration("[email protected]","+65", "85256592", "MMS", "mmssingapore.org","mmssingapore.org",YES,0,YES,"en",YES,NO,YES,"[email protected]", "testing123"); 

PayPal.init({ 
     "PayPalEnvironmentProduction": "YOUR_PRODUCTION_CLIENT_ID", 
     "PayPalEnvironmentSandbox": "AYghcu8pISVBO03yX58CVC7vccATg5jraW-k52jPw9V63RQkuIaS2H8moi2OnWln97FPvP-gDEMbMlHj" 
     }) 
    .then(onSuccess => { 
     console.log("init success"); 
     alert("init success" + JSON.stringify(onSuccess)); 
    }) 
    .catch(onError => { 
     console.log("init failed", Error); 
     alert("init failed" + JSON.stringify(onError)); 
    }); 
} 


initiatePayment(){ 

    this.paymentdetails = new PayPalPaymentDetails("10.00", "0", "hello"); 
    this.paymentdata = new PayPalPayment("10.00","USD", "MMS tickets", "sale"); 


    PayPal.renderSinglePaymentUI(this.paymentdata) 
    .then(onSuccess => { 
     console.log('OnSuccess Render: ' + JSON.stringify(onSuccess)); 
     alert('OnSuccess Render: ' + JSON.stringify(onSuccess)); 
     }) 
    .catch(onError=> { 
     console.log('onError Render: ' + JSON.stringify(onError)); 
     alert('onError Render: ' + JSON.stringify(onError)); 
     }); 
} 



} 

のためのJSONのエラーを取得。

お使いのシステム情報:

コルドバCLI:6.3.1 イオンFrameworkのバージョン:2.0.0-rc.0 イオンCLIバージョン:2.1.0 イオンのApp Libのバージョン:2.1.0- beta1 OS: ノードバージョン:v6.7.0

+0

、あなたはどのようなエラーを取得しています –

答えて

0

今日はIonic 2とPayPalを併用してみました。私はhttp://ionicframework.com/docs/native/paypalの指示に従いましたが、ほとんどすべてが機能しましたが、例外はありませんでした。ここではうまく働いたシンプルなプロバイダがあります。それが役に立てば幸い! 'preload'はと呼ばれる前にが支払われますが、もちろんサンプルコードです。

import { Injectable } from '@angular/core'; 
import { PayPal, PayPalPayment, PayPalConfiguration } from '@ionic-native/paypal'; 

@Injectable() 
export class PaypalProvider {  
    private paypal: PayPal; 

    constructor() { } 

    public preload() { 
     this.paypal = new PayPal(); 

     this.paypal.init({ 
      PayPalEnvironmentProduction: "YOUR_PRODUCTION_CLIENT_ID", 
      PayPalEnvironmentSandbox: "YOUR_SANDBOX_CLIENT_ID" 
     }).then(value => { 
      console.log('[???] init:', value); 
      this.paypal.prepareToRender('PayPalEnvironmentSandbox', new PayPalConfiguration({ 
       presentingInPopover: true, 
      })).then(value => { 
       console.log('[???] prepared:', value); 
      }).catch(error => { 
       console.log('[???] Error:', error); 
      }); 
     }).catch(error => { 
      console.log('[???] Error:', error); 
     }); 
    } 

    public fooPayment() { 
     let payment = new PayPalPayment('10.00', 'BRL', 'Some Product', 'Assinatura'); 
     this.paypal.renderSinglePaymentUI(payment).then(value => { 
      console.log('[???] Payment:', value); 
     }).catch(error => { 
      console.log('[???] Payment Error', error); 
     }); 
    }  
} // - - - 

私のシステム:エラーを言及していない

Cordova CLI: 6.5.0 
Ionic Framework Version: 2.3.0 
Ionic CLI Version: 2.2.1 
Ionic App Lib Version: 2.2.0 
Ionic App Scripts Version: 1.1.4 
OS: Windows 8.1 
Node Version: v6.9.1 
関連する問題