Skip to content

Instantly share code, notes, and snippets.

View SeraphimSerapis's full-sized avatar

Tim Messerschmidt SeraphimSerapis

View GitHub Profile
@SeraphimSerapis
SeraphimSerapis / Untitled 1.txt
Created November 19, 2012 15:51
Initializes a parallel payment
private void initParallelPayment() {
PayPalReceiverDetails receiver0 = new PayPalReceiverDetails();
PayPalReceiverDetails receiver1 = new PayPalReceiverDetails();
// Setup additional information
PayPalAdvancedPayment payment = new PayPalAdvancedPayment();
payment.setCurrencyType("EUR");
payment.getReceivers().add(receiver0);
payment.getReceivers().add(receiver1);
@SeraphimSerapis
SeraphimSerapis / Untitled 1.txt
Created November 19, 2012 15:52
Initializes a chained payment
private void initChainedPayment() {
PayPalReceiverDetails receiver0 = new PayPalReceiverDetails();
PayPalReceiverDetails receiver1 = new PayPalReceiverDetails();
PayPalReceiverDetails receiver2 = new PayPalReceiverDetails();
receiver0.setIsPrimary(true);
// Setup additional information
PayPalAdvancedPayment payment = new PayPalAdvancedPayment();
payment.setCurrencyType("EUR");
payment.getReceivers().add(receiver0);
@SeraphimSerapis
SeraphimSerapis / Untitled 1.txt
Created November 19, 2012 15:54
Initializes the PayPal MPL
private void initLibrary() {
new Thread() {
@Override
public void run() {
pp = PayPal.getInstance();
if (pp == null) {
pp = PayPal.initWithAppID(context, "APP-80W284485P519543T",
PayPal.ENV_SANDBOX);
}
final CheckoutButton button = pp.getCheckoutButton(context,
@SeraphimSerapis
SeraphimSerapis / Untitled 1.txt
Created November 19, 2012 15:56
Activity result after payment
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_PAY) {
switch (resultCode) {
case RESULT_OK:
String payKey = data
.getStringExtra(PayPalActivity.EXTRA_PAY_KEY);
showToast("Payment succeeded - Key: " + payKey);
break;
case RESULT_CANCELED:
showToast("Payment got canceled");
<!DOCTYPE html>
<html>
<head>
<title>Adaptive Payments</title>
</head>
<body>
<p>This example uses parallel payments:</p>
<?php
// Include the needed files
<?php
/****************************************************
web_constants.php
Define constants used by web pages in this file
****************************************************/
/* Define the PayPal URL. This is the URL that the buyer is
first sent to to authorize payment with their paypal account
change the URL depending if you are testing on the sandbox
or going to the live PayPal site
paypalhere://takePayment?
acceped=cash,card,paypal // optional
&returnUrl=your app’s callback
&as=b64 // optional
&step=choosePayment
&payerPhone=the payer’s phone number // optional
&invoice=your invoice as JSON (encoded)
yourScheme://yourHost/?{result}
?Type={Type}
&InvoiceId={InvoiceId}
&Tip={Tip}
&Email={Email}
&TxId={TxId}
{
"merchantEmail": "[email protected]",
"itemList": {
"item": [
{
"name": "Name",
"description": "An item",
"quantity": "2.0",
"unitPrice": "10.0",
"taxName": "Tax",
@SeraphimSerapis
SeraphimSerapis / Verify payment
Created May 13, 2013 13:50
Verifies a payment that is being generated with PayPal's Mobile SDKs.
require 'paypal-sdk-rest'
require 'sinatra'
include PayPal::SDK::REST
get '/verify/:payment_id/:total/:currency' do
payment_id = params[:payment_id]
total = params[:total]
currency = params[:currency]