2017-12-31 20 views
0

Ich benutze PayPal Android SDK 2.15.3 in einer Anwendung, aber ich bekomme sate Created statt genehmigen. HierStatus "Erstellt" in PayPal Android SDK 2.15.3

ist die Antwort, die ich immer bin in ActivityResult

{ 
"client": { 
    "environment": "sandbox", 
    "paypal_sdk_version": "2.15.3", 
    "platform": "Android", 
    "product_name": "PayPal-Android-SDK" 
}, 
"response": { 
    "create_time": "2017-12-31T04:51:58Z", 
    "id": "PAY-4XV16532X6313912DLJEGZ3Q", 
    "intent": "sale", 
    "state": "created" 
}, 
"response_type": "payment" 

}

Wie kann ich Zustand erhalten genehmigen?

Antwort

0

Ich verwende diese SDK-Version auch. Es hat mit mir funktioniert. Versuchen Sie diesen Weg:

Überprüfen Sie zuerst Ihre Anmeldeinformationen.

String CONFIG_ENVIRONMENT = PayPalConfiguration.ENVIRONMENT_SANDBOX; 
String CONFIG_CLIENT_ID = "..."; 
int REQUEST_CODE_PAYMENT = 1; 

Einstellung Konfigurations PayPal

private static PayPalConfiguration config = new PayPalConfiguration() 
     .environment(CONFIG_ENVIRONMENT) 
     .clientId(CONFIG_CLIENT_ID) 
     .merchantName("Payment Test") 
     .merchantPrivacyPolicyUri(Uri.parse("https://www.example.com/privacy")) 
     .merchantUserAgreementUri(Uri.parse("https://www.example.com/legal")); 


@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 

    Intent intent = new Intent(this, PayPalService.class); 
    intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, config); 
    startService(intent); 
} 

die Schaltfläche

public void onBuyPressed(View pressed) { 
    PayPalPayment thingToBuy = getThingToBuy(PayPalPayment.PAYMENT_INTENT_SALE); 
    Intent intent = new Intent(SampleActivity.this, PaymentActivity.class); 
    intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, config); 
    intent.putExtra(PaymentActivity.EXTRA_PAYMENT, thingToBuy); 
    startActivityForResult(intent, REQUEST_CODE_PAYMENT); 
} 

private PayPalPayment getThingToBuy(String paymentIntent) { 
    //Brazilian real 
    return new PayPalPayment(new BigDecimal("10.00"), "BRL", "Test", 
      paymentIntent); 
} 

Und die ActivityResult Seting

@Override 
protected void onActivityResult(int requestCode, int resultCode, Intent data) { 

    if (requestCode == REQUEST_CODE_PAYMENT) { 
     if (resultCode == Activity.RESULT_OK) { 
      PaymentConfirmation confirm = 
        data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION); 
      if (confirm != null) { 
       try { 
        Log.i(TAG, confirm.toJSONObject().toString(4)); 
        Log.i(TAG, confirm.getPayment().toJSONObject().toString(4)); 

       } catch (JSONException e) { 
        ... 
       } 
      } 
     } else if (resultCode == Activity.RESULT_CANCELED) { 
      ... 
     } else if (resultCode == PaymentActivity.RESULT_EXTRAS_INVALID) { 
      ... 
     } 
     } 
}