Skip to content

Instantly share code, notes, and snippets.

@jaypatel512
Last active January 12, 2017 16:44
Show Gist options
  • Save jaypatel512/9ea50bf5a8a39cb35bd1df9511f350a7 to your computer and use it in GitHub Desktop.
Save jaypatel512/9ea50bf5a8a39cb35bd1df9511f350a7 to your computer and use it in GitHub Desktop.
import com.paypal.api.payments.CreditCard;
import com.paypal.base.rest.APIContext;
import com.paypal.base.rest.PayPalRESTException;
public class JavaSampleOne {
public static void main(String[] args) {
// Replace these values with your clientId and secret. You can use these to get started right now.
String clientId = "AYSq3RDGsmBLJE-otTkBtM-jBRd1TCQwFf9RGfwddNXWz0uFU9ztymylOhRS";
String clientSecret = "EGnHDxD_qRPdaLdZz8iCr8N7_MzF-YHPTkjs6NKYQvQSBngp4PTTVWkPZRbL";
// Create a Credit Card
CreditCard card = new CreditCard()
.setType("visa")
.setNumber("4417119669820331")
.setExpireMonth(11)
.setExpireYear(2019)
.setCvv2(012)
.setFirstName("Joe")
.setLastName("Shopper");
try {
APIContext context = new APIContext(clientId, clientSecret, "sandbox");
card.create(context);
System.out.println(card);
} catch (PayPalRESTException e) {
System.err.println(e.getDetails());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment