PayPal
PayPal Credit
PayPal Credit is an instant, reusable credit line your customers can use at checkout. It appears as an additional button in your checkout form and offers all available financing options to customers automatically through a PayPal UI – including Easy Payments in the US and Instalments in the UK, if those have been enabled for your PayPal account.
Before you get started
- See our PayPal Credit support article for full details on the availability and benefits of this feature
- Complete your PayPal client-side integration
- Integrate PayPal with the Vault flow or Checkout flow
Integration
Offering PayPal Credit is similar to offering regular PayPal payments.
- Add a PayPal Credit button
- Download the paypal-credit-android assets
- Add them to your project's
res
folder - Display the PayPal Credit button in an
ImageButton
or similar element in your view:
- XML
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/paypal_credit_button"
android:background="@android:color/transparent" />
- Tokenize using PayPal Credit
- On the
PayPalRequest
object, set theofferCredit
option totrue
- On the
- Submit the resulting payment method nonce to your server to create a transaction
Examples
PayPal and PayPal Credit with the Vault flow
Here is an example of a Vault flow integration with both PayPal and PayPal Credit buttons:
- Java
//-- PayPal Button --
paypalButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
PayPalRequest request = new PayPalRequest()
.currencyCode("USD")
PayPal.requestBillingAgreement(mBraintreeFragment, request);
}
}
//-- PayPal Credit Button --
paypalCreditButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
PayPalRequest request = new PayPalRequest()
.currencyCode("USD")
.offerCredit(true); // Offer PayPal Credit
PayPal.requestBillingAgreement(mBraintreeFragment, request);
}
}
When you receive a callback in onPaymentMethodNonceCreated
, you can query the PayPalAccountNonce
object you get back for specific customer information.
- Java
public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
if (paymentMethodNonce instanceof PayPalAccountNonce) {
PayPalAccountNonce paypalAccountNonce = (PayPalAccountNonce) paymentMethodNonce;
PayPalCreditFinancing creditFinancing = paypalAccountNonce.getCreditFinancing();
if (creditFinancing != null) {
// PayPal Credit was accepted
}
// Access additional information
String email = paypalAccountNonce.getEmail();
String firstName = paypalAccountNonce.getFirstName();
String lastName = paypalAccountNonce.getLastName();
String phone = paypalAccountNonce.getPhone();
// See PostalAddress.java for details
PostalAddress billingAddress = paypalAccountNonce.getBillingAddress();
PostalAddress shippingAddress = paypalAccountNonce.getShippingAddress();
}
// Send nonce to server
String nonce = paymentMethodNonce.getNonce();
}
PayPal and PayPal Credit with the Checkout flow
Here is an example of a Checkout flow integration with both PayPal and PayPal Credit buttons:
- Java
//-- PayPal Button --
paypalButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
PayPalRequest request = new PayPalRequest("10.00")
.currencyCode("USD")
PayPal.requestOneTimePayment(mBraintreeFragment, request);
}
}
//-- PayPal Credit Button --
paypalCreditButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
PayPalRequest request = new PayPalRequest("10.00")
.currencyCode("USD")
.offerCredit(true); // Offer PayPal Credit
PayPal.requestOneTimePayment(mBraintreeFragment, request);
}
}
When you receive a callback in onPaymentMethodNonceCreated
, you can query the PayPalAccountNonce
object you get back for specific customer information.
- Java
public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
if (paymentMethodNonce instanceof PayPalAccountNonce) {
PayPalAccountNonce paypalAccountNonce = (PayPalAccountNonce) paymentMethodNonce;
PayPalCreditFinancing creditFinancing = paypalAccountNonce.getCreditFinancing();
if (creditFinancing != null) {
// PayPal Credit was accepted
}
// Access additional information
String email = paypalAccountNonce.getEmail();
String firstName = paypalAccountNonce.getFirstName();
String lastName = paypalAccountNonce.getLastName();
String phone = paypalAccountNonce.getPhone();
// See PostalAddress.java for details
PostalAddress billingAddress = paypalAccountNonce.getBillingAddress();
PostalAddress shippingAddress = paypalAccountNonce.getShippingAddress();
}
// Send nonce to server
String nonce = paymentMethodNonce.getNonce();
}
See also
- Android SDK reference for PayPal tokenization
- PayPal Vault integration
- PayPal Checkout integration
- PayPal Credit support article
Next Page: Server-side →