This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Full source code is available at https://github.com/saranyan/PayPal-Code-Examples | |
//--------------------------------------------------------------------- | |
//Step 1 - Initialize. | |
//Do this before anything else. | |
public void initLibrary() { | |
PayPal pp = PayPal.getInstance(); | |
if (pp == null) { | |
// This is the main initialization call that takes in your Context, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@namespace("com.x.service.catalog") | |
/** | |
* Protocol for the Catalog Service | |
* ================================ | |
*/ | |
protocol CatalogService { | |
//----------------------------------------------------------------------------------------------------- | |
// Request & Response: Product Types |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
java -jar avro-tools-1.5.4.jar idl catalog.avdl /tmp/catalog.avpr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"protocol" : "CatalogService", | |
"namespace" : "com.x.service.catalog", | |
"types" : [ { | |
"type" : "record", | |
"name" : "GetProductTypesMessage", | |
"fields" : [ { | |
"name" : "locale", | |
"type" : [ "null", "string" ] | |
} ], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CONTRACT_PROTOCOL_JSON = <<-EOS | |
{ | |
"protocol" : "CatalogService", | |
"namespace" : "com.x.service.catalog", | |
"types" : [ { | |
"type" : "record", | |
"name" : "GetProductTypesMessage", | |
"fields" : [ { | |
"name" : "locale", | |
"type" : [ "null", "string" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if Rails.env.production? | |
PAYPAL_ACCOUNT = 'production@gmail.com' | |
else | |
PAYPAL_ACCOUNT = 'development@gmail.com' | |
ActiveMerchant::Billing::Base.mode = :test | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#from http://www.ruby-forum.com/topic/163331#817338 | |
#this code will also work if you are not using active merchant. | |
if request.post? | |
#new | |
@params = params | |
@params[:cmd] = "_notify-validate" | |
@params.delete(:action) | |
@params.delete(:controller) | |
url = URI.parse("https://www.paypal.com/cgi-bin/webscr") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "mylibrary.h" | |
#include <stdio.h> | |
double calculate_something(int a, float b) | |
{ | |
return a+b; | |
} | |
const char* test_function_1(const char *w) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# mylibrary.rb | |
TESTVAR = 2 | |
module MyLibrary | |
extend FFI::Library | |
ffi_lib "mylibrary.so" | |
attach_function :calculate_something, [:int, :float], :double | |
attach_function :test_function_1, [:string], :string | |
attach_function :test_function_2, [:double, :pointer, :string], :int | |
attach_function :test_function_3, [], :void | |
attach_function :test_function_4, [:pointer], :void |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include "mylibrary.h" | |
int main(){ | |
char x[10]; | |
double d = 10.0; | |
double *dp = &d; | |
double dd[3]; | |
printf("tf0 - %lf\n",calculate_something(1,2.33)); |
OlderNewer