|
| 1 | +// |
| 2 | +// PayPal.h |
| 3 | +// |
| 4 | +// MPL Library - Developer Interface |
| 5 | +// |
| 6 | +// Created by Paypal 2010 |
| 7 | +// Modified by: |
| 8 | +// DiZoglio, James(jdizoglio) on 5/10/11. |
| 9 | +// |
| 10 | +// Copyright 2011 Paypal. All rights reserved. |
| 11 | +// |
| 12 | +// |
| 13 | + |
| 14 | +#import <UIKit/UIKit.h> |
| 15 | + |
| 16 | +@class PPMEPRootViewController; |
| 17 | +@class PayPalContext; |
| 18 | +@class PayPalAmounts; |
| 19 | +@class PayPalAddress; |
| 20 | + |
| 21 | +@class PayPalPayment; |
| 22 | +@class PayPalAdvancedPayment; |
| 23 | + |
| 24 | +@class PayPalPreapprovalDetails; |
| 25 | + |
| 26 | +typedef enum PayPalPaymentStatus { |
| 27 | + STATUS_COMPLETED, |
| 28 | + STATUS_CREATED, |
| 29 | + STATUS_OTHER, |
| 30 | +} PayPalPaymentStatus; |
| 31 | + |
| 32 | +typedef enum PayPalEnvironment { |
| 33 | + ENV_LIVE, |
| 34 | + ENV_SANDBOX, |
| 35 | + ENV_NONE, |
| 36 | +} PayPalEnvironment; |
| 37 | + |
| 38 | +typedef enum PayPalButtonType { |
| 39 | + BUTTON_152x33, |
| 40 | + BUTTON_194x37, |
| 41 | + BUTTON_278x43, |
| 42 | + BUTTON_294x43, |
| 43 | + BUTTON_TYPE_COUNT, |
| 44 | +} PayPalButtonType; |
| 45 | + |
| 46 | +typedef enum PayPalButtonText { |
| 47 | + BUTTON_TEXT_PAY, //default |
| 48 | + BUTTON_TEXT_DONATE, |
| 49 | +} PayPalButtonText; |
| 50 | + |
| 51 | +typedef enum PayPalFeePayer { |
| 52 | + FEEPAYER_SENDER, |
| 53 | + FEEPAYER_PRIMARYRECEIVER, |
| 54 | + FEEPAYER_EACHRECEIVER, |
| 55 | + FEEPAYER_SECONDARYONLY, |
| 56 | +} PayPalFeePayer; |
| 57 | + |
| 58 | +typedef enum PayPalFailureType { |
| 59 | + SYSTEM_ERROR, |
| 60 | + RECIPIENT_ERROR, |
| 61 | + APPLICATION_ERROR, |
| 62 | + CONSUMER_ERROR, |
| 63 | +} PayPalFailureType; |
| 64 | + |
| 65 | +typedef enum PayPalPaymentType { |
| 66 | + TYPE_NOT_SET = -1, |
| 67 | + TYPE_GOODS, |
| 68 | + TYPE_SERVICE, |
| 69 | + TYPE_PERSONAL, |
| 70 | +} PayPalPaymentType; |
| 71 | + |
| 72 | +typedef enum PayPalPaymentSubType { |
| 73 | + SUBTYPE_NOT_SET = -1, |
| 74 | + SUBTYPE_AFFILIATE_PAYMENTS, |
| 75 | + SUBTYPE_B2B, |
| 76 | + SUBTYPE_PAYROLL, |
| 77 | + SUBTYPE_REBATES, |
| 78 | + SUBTYPE_REFUNDS, |
| 79 | + SUBTYPE_REIMBURSEMENTS, |
| 80 | + SUBTYPE_DONATIONS, |
| 81 | + SUBTYPE_UTILITIES, |
| 82 | + SUBTYPE_TUITION, |
| 83 | + SUBTYPE_GOVERNMENT, |
| 84 | + SUBTYPE_INSURANCE, |
| 85 | + SUBTYPE_REMITTANCES, |
| 86 | + SUBTYPE_RENT, |
| 87 | + SUBTYPE_MORTGAGE, |
| 88 | + SUBTYPE_MEDICAL, |
| 89 | + SUBTYPE_CHILD_CARE, |
| 90 | + SUBTYPE_EVENT_PLANNING, |
| 91 | + SUBTYPE_GENERAL_CONTRACTORS, |
| 92 | + SUBTYPE_ENTERTAINMENT, |
| 93 | + SUBTYPE_TOURISM, |
| 94 | + SUBTYPE_INVOICE, |
| 95 | + SUBTYPE_TRANSFER, |
| 96 | +} PayPalPaymentSubType; |
| 97 | + |
| 98 | +typedef enum PayPalAmountErrorCode { |
| 99 | + AMOUNT_ERROR_NONE, |
| 100 | + AMOUNT_ERROR_SERVER, |
| 101 | + AMOUNT_ERROR_OTHER, |
| 102 | + AMOUNT_CANCEL_TXN, |
| 103 | +} PayPalAmountErrorCode; |
| 104 | + |
| 105 | +typedef enum PayPalInitializationStatus { |
| 106 | + STATUS_NOT_STARTED, |
| 107 | + STATUS_COMPLETED_SUCCESS, |
| 108 | + STATUS_COMPLETED_ERROR, |
| 109 | + STATUS_INPROGRESS, |
| 110 | +} PayPalInitializationStatus; |
| 111 | + |
| 112 | +@protocol PayPalPaymentDelegate |
| 113 | +@required |
| 114 | +- (void)paymentSuccessWithKey:(NSString *)payKey andStatus:(PayPalPaymentStatus)paymentStatus; |
| 115 | +- (void)paymentFailedWithCorrelationID:(NSString *)correlationID; |
| 116 | +- (void)paymentCanceled; |
| 117 | +- (void)paymentLibraryExit; |
| 118 | + |
| 119 | +/* |
| 120 | + Example: To parse the responseMessage containing the following key fields. You can check the responseMessage |
| 121 | + from couldNotFetchDeviceReferenceToken or receivedDeviceReferenceToken. You can create a local application log |
| 122 | + to capture this output. The errors captured are both Network(Request) and Application catagory errors. |
| 123 | + |
| 124 | + NSString *severity = [[PayPal getPayPalInst].responseMessage objectForKey:@"severity"]; |
| 125 | + NSString *category = [[PayPal getPayPalInst].responseMessage objectForKey:@"category"]; |
| 126 | + NSString *errorId = [[PayPal getPayPalInst].responseMessage objectForKey:@"errorId"]; |
| 127 | + NSString *message = [[PayPal getPayPalInst].responseMessage objectForKey:@"message"]; |
| 128 | + */ |
| 129 | + |
| 130 | +@optional |
| 131 | +- (PayPalAmounts *)adjustAmountsForAddress:(PayPalAddress const *)inAddress andCurrency:(NSString const *)inCurrency andAmount:(NSDecimalNumber const *)inAmount andTax:(NSDecimalNumber const *)inTax andShipping:(NSDecimalNumber const *)inShipping andErrorCode:(PayPalAmountErrorCode *)outErrorCode; |
| 132 | +- (NSMutableArray *)adjustAmountsAdvancedForAddress:(PayPalAddress const *)inAddress andCurrency:(NSString const *)inCurrency andReceiverAmounts:(NSMutableArray *)receiverAmounts andErrorCode:(PayPalAmountErrorCode *)outErrorCode; |
| 133 | + |
| 134 | +- (PayPalAmounts *)adjustAmountsForAddress:(PayPalAddress const *)inAddress andCurrency:(NSString const *)inCurrency andAmount:(NSDecimalNumber const *)inAmount andTax:(NSDecimalNumber const *)inTax andShipping:(NSDecimalNumber const *)inShipping __attribute__((deprecated)); |
| 135 | +- (NSMutableArray *)adjustAmountsAdvancedForAddress:(PayPalAddress const *)inAddress andCurrency:(NSString const *)inCurrency andReceiverAmounts:(NSMutableArray *)receiverAmounts __attribute__((deprecated)); |
| 136 | +@end |
| 137 | + |
| 138 | +@interface PayPal : NSObject <UIWebViewDelegate> { |
| 139 | + @private |
| 140 | + id<PayPalPaymentDelegate> delegate; |
| 141 | + BOOL paymentsEnabled; //readonly, TRUE if the device is allowed to make payments |
| 142 | + BOOL shippingEnabled; |
| 143 | + BOOL dynamicAmountUpdateEnabled; |
| 144 | + |
| 145 | + NSString *appID; |
| 146 | + NSString *lang; |
| 147 | + |
| 148 | + PayPalEnvironment environment; |
| 149 | + PayPalButtonText buttonText; |
| 150 | + PayPalFeePayer feePayer; |
| 151 | + |
| 152 | + PayPalAdvancedPayment *payment; |
| 153 | + PayPalPreapprovalDetails *preapprovalDetails; |
| 154 | + |
| 155 | + NSMutableArray *payButtons; |
| 156 | + NSMutableDictionary *responseMessage; |
| 157 | + |
| 158 | + PPMEPRootViewController *rootvc; |
| 159 | +} |
| 160 | + |
| 161 | +@property (nonatomic, retain) id delegate; |
| 162 | +@property (nonatomic, readonly) BOOL paymentsEnabled; |
| 163 | +@property (nonatomic, assign) BOOL shippingEnabled; |
| 164 | +@property (nonatomic, assign) BOOL dynamicAmountUpdateEnabled; |
| 165 | + |
| 166 | +@property (nonatomic, retain, readonly) NSString *appID; |
| 167 | +@property (nonatomic, retain) NSString *lang; |
| 168 | + |
| 169 | +@property (nonatomic, readonly) PayPalEnvironment environment; |
| 170 | +@property (nonatomic, readonly) PayPalButtonText buttonText; |
| 171 | +@property (nonatomic, assign) PayPalFeePayer feePayer; |
| 172 | + |
| 173 | +@property (nonatomic, retain, readonly) PayPalAdvancedPayment *payment; |
| 174 | +@property (nonatomic, retain, readonly) PayPalPreapprovalDetails *preapprovalDetails; |
| 175 | + |
| 176 | +@property (nonatomic, retain) NSMutableArray *payButtons; |
| 177 | +@property (nonatomic, retain) NSMutableDictionary *responseMessage; |
| 178 | + |
| 179 | ++(PayPal*)getPayPalInst; |
| 180 | ++(PayPal*)initializeWithAppID:(NSString const *)inAppID; |
| 181 | ++(PayPal*)initializeWithAppID:(NSString const *)inAppID forEnvironment:(PayPalEnvironment)env; |
| 182 | ++(PayPalInitializationStatus)initializationStatus; |
| 183 | ++(NSString *)buildVersion; |
| 184 | + |
| 185 | +-(UIButton *)getPayButtonWithTarget:(const id<PayPalPaymentDelegate>)target andAction:(SEL)action andButtonType:(PayPalButtonType)theButtonType andButtonText:(PayPalButtonText)theButtonText; |
| 186 | +//calls getPayButton with text PAY |
| 187 | +-(UIButton *)getPayButtonWithTarget:(const id<PayPalPaymentDelegate>)target andAction:(SEL)action andButtonType:(PayPalButtonType)theButtonType; |
| 188 | + |
| 189 | +-(void)checkoutWithPayment:(PayPalPayment *)inPayment; |
| 190 | +-(void)advancedCheckoutWithPayment:(PayPalAdvancedPayment *)inPayment; |
| 191 | +-(void)preapprovalWithKey:(NSString *)preapprovalKey andMerchantName:(NSString *)merchantName; |
| 192 | + |
| 193 | +@end |
0 commit comments